mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
or1k: Add hard float support
This patch adds hardware floating point support to OpenRISC. Hardware floating point toolchain builds are enabled by passing the machine specific argument -mhard-float to gcc via CFLAGS. With this enabled GCC generates floating point instructions for single-precision operations and exports __or1k_hard_float__. There are 2 main parts to this patch. - Implement fenv functions to update the FPCSR flags keeping it in sync with sfp (software floating point). - Update machine context functions to store and restore the FPCSR state. *On mcontext_t ABI* This patch adds __fpcsr to mcontext_t. This is an ABI change, but also an ABI fix. The Linux kernel has always defined padding in mcontext_t that space was missing from the glibc ABI. In Linux this unused space has now been re-purposed for storing the FPCSR. This patch brings OpenRISC glibc in line with the Linux kernel and other libc implementation (musl). Compatibility getcontext, setcontext, etc symbols have been added to allow for binaries expecting the old ABI to continue to work. *Hard float ABI* The calling conventions and types do not change with OpenRISC hard-float so glibc hard-float builds continue to use dynamic linker /lib/ld-linux-or1k.so.1. *Testing* I have tested this patch both with hard-float and soft-float builds and the test results look fine to me. Results are as follows: Hard Float # failures FAIL: elf/tst-sprof-basic (Haven't figured out yet, not related to hard-float) FAIL: gmon/tst-gmon-pie (PIE bug in or1k toolchain) FAIL: gmon/tst-gmon-pie-gprof (PIE bug in or1k toolchain) FAIL: iconvdata/iconv-test (timeout, passed when run manually) FAIL: nptl/tst-cond24 (Timeout) FAIL: nptl/tst-mutex10 (Timeout) # summary 6 FAIL 4289 PASS 86 UNSUPPORTED 16 XFAIL 2 XPASS # versions Toolchain: or1k-smhfpu-linux-gnu Compiler: gcc version 14.0.1 20240324 (experimental) [master r14-9649-gbb04a11418f] (GCC) Binutils: GNU assembler version 2.42.0 (or1k-smhfpu-linux-gnu) using BFD version (GNU Binutils) 2.42.0.20240324 Linux: Linux buildroot 6.9.0-rc1-00008-g4dc70e1aadfa #112 SMP Sat Apr 27 06:43:11 BST 2024 openrisc GNU/Linux Tester: shorne Glibc: 2024-04-25b62928f907
Florian Weimer x86: In ld.so, diagnose missing APX support in APX-only builds (origin/master, origin/HEAD) Soft Float # failures FAIL: elf/tst-sprof-basic FAIL: gmon/tst-gmon-pie FAIL: gmon/tst-gmon-pie-gprof FAIL: nptl/tst-cond24 FAIL: nptl/tst-mutex10 # summary 5 FAIL 4295 PASS 81 UNSUPPORTED 16 XFAIL 2 XPASS # versions Toolchain: or1k-smh-linux-gnu Compiler: gcc version 14.0.1 20240324 (experimental) [master r14-9649-gbb04a11418f] (GCC) Binutils: GNU assembler version 2.42.0 (or1k-smh-linux-gnu) using BFD version (GNU Binutils) 2.42.0.20240324 Linux: Linux buildroot 6.9.0-rc1-00008-g4dc70e1aadfa #112 SMP Sat Apr 27 06:43:11 BST 2024 openrisc GNU/Linux Tester: shorne Glibc: 2024-04-25b62928f907
Florian Weimer x86: In ld.so, diagnose missing APX support in APX-only builds (origin/master, origin/HEAD) Documentation: https://raw.githubusercontent.com/openrisc/doc/master/openrisc-arch-1.4-rev0.pdf Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
This commit is contained in:
@ -17,56 +17,35 @@
|
||||
<https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <sysdep.h>
|
||||
#include <shlib-compat.h>
|
||||
#include "ucontext_i.h"
|
||||
|
||||
/* int getcontext (ucontext_t *ucp)
|
||||
#define __CONTEXT_FUNC_NAME __getcontext
|
||||
#define __CONTEXT_ENABLE_FPCSR 1
|
||||
#define __CONTEXT_SIGMASK_OFFSET UCONTEXT_SIGMASK
|
||||
|
||||
Returns 0 on success -1 and errno on failure.
|
||||
*/
|
||||
.text
|
||||
ENTRY(__getcontext)
|
||||
/* Store r1, the stack pointer. */
|
||||
l.sw (UCONTEXT_MCONTEXT + 1*4)(r3), r1
|
||||
/* Store r2, the frame pointer. */
|
||||
l.sw (UCONTEXT_MCONTEXT + 2*4)(r3), r2
|
||||
/* Store r9, the link register. */
|
||||
l.sw (UCONTEXT_MCONTEXT + 9*4)(r3), r9
|
||||
/* Store r9 to reg[11] too, as we need two links for makecontext. */
|
||||
l.sw (UCONTEXT_MCONTEXT + 11*4)(r3), r9
|
||||
/* Store r10, the TLS register. */
|
||||
l.sw (UCONTEXT_MCONTEXT + 10*4)(r3), r10
|
||||
/* Store r14-r30 even, callee saved registers. */
|
||||
l.sw (UCONTEXT_MCONTEXT + 14*4)(r3), r14
|
||||
l.sw (UCONTEXT_MCONTEXT + 16*4)(r3), r16
|
||||
l.sw (UCONTEXT_MCONTEXT + 18*4)(r3), r18
|
||||
l.sw (UCONTEXT_MCONTEXT + 20*4)(r3), r20
|
||||
l.sw (UCONTEXT_MCONTEXT + 22*4)(r3), r22
|
||||
l.sw (UCONTEXT_MCONTEXT + 24*4)(r3), r24
|
||||
l.sw (UCONTEXT_MCONTEXT + 26*4)(r3), r26
|
||||
l.sw (UCONTEXT_MCONTEXT + 28*4)(r3), r28
|
||||
l.sw (UCONTEXT_MCONTEXT + 30*4)(r3), r30
|
||||
#include "getcontext-common.S"
|
||||
|
||||
/* Get signal mask. */
|
||||
/* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */
|
||||
l.ori r6, r0, _NSIG8
|
||||
l.addi r5, r3, UCONTEXT_SIGMASK
|
||||
l.ori r4, r0, 0
|
||||
l.ori r3, r0, SIG_BLOCK
|
||||
l.ori r11, r0, SYS_ify (rt_sigprocmask)
|
||||
/* Do the syscall. */
|
||||
l.sys 1
|
||||
l.nop
|
||||
versioned_symbol (libc, __getcontext, getcontext, GLIBC_2_40)
|
||||
|
||||
/* if -4096 < ret < 0 holds, it's an error */
|
||||
l.sfgeui r11, 0xf001
|
||||
l.bf 1f
|
||||
l.nop
|
||||
#if SHLIB_COMPAT (libc, GLIBC_2_35, GLIBC_2_40)
|
||||
|
||||
l.jr r9
|
||||
l.ori r11, r0, 0
|
||||
/* Define a compat version of getcontext for glibc's before the fpcsr
|
||||
field was added to mcontext_t. The offset sigmask changed with this
|
||||
introduction, the change was done because glibc's definition of
|
||||
ucontext_t was initially defined incompatible with the Linux
|
||||
definition of ucontext_t. We keep the compatability definition to
|
||||
allow getcontext, setcontext and swapcontext to work in older
|
||||
binaries. */
|
||||
|
||||
1: l.j __syscall_error
|
||||
l.ori r3, r11, 0
|
||||
# undef __CONTEXT_FUNC_NAME
|
||||
# undef __CONTEXT_ENABLE_FPCSR
|
||||
# undef __CONTEXT_SIGMASK_OFFSET
|
||||
# define __CONTEXT_FUNC_NAME __getcontext_nofpcsr
|
||||
# define __CONTEXT_SIGMASK_OFFSET (UCONTEXT_SIGMASK - 4)
|
||||
|
||||
END(__getcontext)
|
||||
weak_alias(__getcontext, getcontext)
|
||||
# include "getcontext-common.S"
|
||||
|
||||
compat_symbol (libc, __getcontext_nofpcsr, getcontext, GLIBC_2_35)
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user