Skip to content

Commit

Permalink
uclibc: fix definition of __UCLIBC_HAS_SOFT_FLOAT__
Browse files Browse the repository at this point in the history
`__UCLIBC_HAS_SOFT_FLOAT__` can only be defined if `UCLIBC_HAS_FLOATS`
is enabled and `UCLIBC_HAS_FPU` is disabled.

This definition is used in the implementation of setjmp()/longjmp() and
setcontext()/getcontext(): If __UCLIBC_HAS_SOFT_FLOAT__ is defined, the
FP registers are _not_ saved/restored.

We need to forbid touching the FP registers if BID_VARIANT_FLAG_NOFPU is
defined.

Also explicitly define __UCLIBC_HAS_FPU__ because on certain platforms
the layout of _jmp_buf may depend on this setting and all supported
platforms actually support the FPU.

Change-Id: I835c4c6317ff8b1dd166b3a970e1bee013f75540
  • Loading branch information
Frank Mehnert authored and kk-infra committed May 7, 2024
1 parent 876fdf2 commit 4702a08
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ __longjmp:
ldp x25, x26, [x0, #JB_X25<<3]
ldp x27, x28, [x0, #JB_X27<<3]
ldp x29, x30, [x0, #JB_X29<<3]
#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__
#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__ && ! defined BID_VARIANT_FLAG_NOFPU
ldp d8, d9, [x0, #JB_D8<<3]
ldp d10, d11, [x0, #JB_D10<<3]
ldp d12, d13, [x0, #JB_D12<<3]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ __sigsetjmp:
stp x25, x26, [x0, #JB_X25<<3]
stp x27, x28, [x0, #JB_X27<<3]
stp x29, x30, [x0, #JB_X29<<3]
#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__
#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__ && ! defined BID_VARIANT_FLAG_NOFPU
stp d8, d9, [x0, #JB_D8<<3]
stp d10, d11, [x0, #JB_D10<<3]
stp d12, d13, [x0, #JB_D12<<3]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ __longjmp:
ldmia ip!, {v1-v6, sl, fp, sp, lr}
#endif

#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__
#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__ && ! defined BID_VARIANT_FLAG_NOFPU
#ifdef __VFP_FP__
/* Restore the VFP registers. */
/* Following instruction is fldmiax ip!, {d8-d15}. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ ENTRY(__getcontext)
add r2, r4, #UCONTEXT_SIGMASK
bl PLTJMP(sigprocmask)

#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__
#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__ && ! defined BID_VARIANT_FLAG_NOFPU
# ifdef __VFP_FP__
/* Store the VFP registers. */
/* Following instruction is fstmiax ip!, {d8-d15}. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
ENTRY(__setcontext)
mov r4, r0

#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__
#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__ && ! defined BID_VARIANT_FLAG_NOFPU
# ifdef __VFP_FP__
/* Following instruction is vldmia r0!, {d8-d15}. */
ldc p11, cr8, [r0], #64
Expand Down
2 changes: 1 addition & 1 deletion uclibc/lib/contrib/uclibc/libc/sysdeps/linux/arm/setjmp.S
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ __sigsetjmp:
/* Save registers */
stmia ip!, {v1-v6, sl, fp, sp, lr}
#endif
#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__
#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__ && ! defined BID_VARIANT_FLAG_NOFPU
# ifdef __VFP_FP__
/* Store the VFP registers. */
/* Following instruction is fstmiax ip!, {d8-d15}. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void __longjmp (__jmp_buf env, int val_arg)
register int val __asm__ ("a1");

/* Pull back the floating point callee-saved registers. */
#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__
#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__ && ! defined BID_VARIANT_FLAG_NOFPU
#if _MIPS_SIM == _MIPS_SIM_ABI64
__asm__ __volatile__ ("l.d $f24, %0" : : "m" (env[0].__fpregs[0]));
__asm__ __volatile__ ("l.d $f25, %0" : : "m" (env[0].__fpregs[1]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ __sigsetjmp_aux (jmp_buf env, int savemask, long long sp, long long fp, long lon
__sigsetjmp_aux (jmp_buf env, int savemask, int sp, int fp)
#endif /* O32 || N32 */
{
#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__
#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__ && ! defined BID_VARIANT_FLAG_NOFPU
/* Store the floating point callee-saved registers... */
#if _MIPS_SIM == _MIPS_SIM_ABI64
__asm__ __volatile__ ("s.d $f24, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[0]));
Expand Down
4 changes: 2 additions & 2 deletions uclibc/lib/uclibc/ARCH-amd64/include/bits/uClibc_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@
#define __ARCH_USE_MMU__ 1
#ifndef BID_VARIANT_FLAG_NOFPU
#define __UCLIBC_HAS_FLOATS__ 1
#define __UCLIBC_HAS_FPU__ 1
#endif
/* FM3: For arm. Does not influence x86. */
#define __UCLIBC_HAS_SOFT_FLOAT__ 1
#undef __UCLIBC_HAS_SOFT_FLOAT__
#define __HAS_FPU__ 1
#define __DO_C99_MATH__ 1
#define __UCLIBC_HAS_LONG_DOUBLE_MATH__ 1
Expand Down
3 changes: 2 additions & 1 deletion uclibc/lib/uclibc/ARCH-arm/include/bits/uClibc_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@
#define __ARCH_USE_MMU__ 1
#ifndef BID_VARIANT_FLAG_NOFPU
#define __UCLIBC_HAS_FLOATS__ 1
#define __UCLIBC_HAS_FPU__ 1
#endif
#define __UCLIBC_HAS_SOFT_FLOAT__ 1
#undef __UCLIBC_HAS_SOFT_FLOAT__
#define __HAS_FPU__ 1
#define __DO_C99_MATH__ 1
#define __UCLIBC_HAS_LONG_DOUBLE_MATH__ 1
Expand Down
3 changes: 2 additions & 1 deletion uclibc/lib/uclibc/ARCH-arm64/include/bits/uClibc_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@
#define __ARCH_USE_MMU__ 1
#ifndef BID_VARIANT_FLAG_NOFPU
#define __UCLIBC_HAS_FLOATS__ 1
#define __UCLIBC_HAS_FPU__ 1
#endif
#define __UCLIBC_HAS_SOFT_FLOAT__ 1
#undef __UCLIBC_HAS_SOFT_FLOAT__
#define __HAS_FPU__ 1
#define __DO_C99_MATH__ 1
#define __UCLIBC_HAS_LONG_DOUBLE_MATH__ 1
Expand Down
3 changes: 2 additions & 1 deletion uclibc/lib/uclibc/ARCH-mips/include/bits/uClibc_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@
#define __ARCH_USE_MMU__ 1
#ifndef BID_VARIANT_FLAG_NOFPU
#define __UCLIBC_HAS_FLOATS__ 1
#define __UCLIBC_HAS_FPU__ 1
#endif
#define __UCLIBC_HAS_SOFT_FLOAT__ 1
#undef __UCLIBC_HAS_SOFT_FLOAT__
#define __HAS_FPU__ 1
#define __DO_C99_MATH__ 1
#define __UCLIBC_HAS_LONG_DOUBLE_MATH__ 1
Expand Down
3 changes: 2 additions & 1 deletion uclibc/lib/uclibc/ARCH-riscv/include/bits/uClibc_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@
#define __ARCH_USE_MMU__ 1
#ifndef BID_VARIANT_FLAG_NOFPU
#define __UCLIBC_HAS_FLOATS__ 1
#define __UCLIBC_HAS_FPU__ 1
#endif
#define __UCLIBC_HAS_SOFT_FLOAT__ 1
#undef __UCLIBC_HAS_SOFT_FLOAT__
#define __HAS_FPU__ 1
#define __DO_C99_MATH__ 1
#define __UCLIBC_HAS_LONG_DOUBLE_MATH__ 1
Expand Down
4 changes: 2 additions & 2 deletions uclibc/lib/uclibc/ARCH-x86/include/bits/uClibc_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@
#define __ARCH_USE_MMU__ 1
#ifndef BID_VARIANT_FLAG_NOFPU
#define __UCLIBC_HAS_FLOATS__ 1
#define __UCLIBC_HAS_FPU__ 1
#endif
/* FM3: For arm. Does not influence x86. */
#define __UCLIBC_HAS_SOFT_FLOAT__ 1
#undef __UCLIBC_HAS_SOFT_FLOAT__
#define __HAS_FPU__ 1
#define __DO_C99_MATH__ 1
#define __UCLIBC_HAS_LONG_DOUBLE_MATH__ 1
Expand Down

0 comments on commit 4702a08

Please sign in to comment.