diff options
author | Andrew Waterman <waterman@cs.berkeley.edu> | 2015-02-08 18:47:58 -0800 |
---|---|---|
committer | Andrew Waterman <waterman@cs.berkeley.edu> | 2015-02-23 15:58:33 -0800 |
commit | 03805f499abf4571281fd3311f434ff9e5e10453 (patch) | |
tree | cd683ff0c86346d9afd569faba63b0dea45e9da3 /glibc | |
parent | af448f0743ad9eb037f94ec404b04b843823837a (diff) | |
download | riscv-gnu-toolchain-03805f499abf4571281fd3311f434ff9e5e10453.zip riscv-gnu-toolchain-03805f499abf4571281fd3311f434ff9e5e10453.tar.gz riscv-gnu-toolchain-03805f499abf4571281fd3311f434ff9e5e10453.tar.bz2 |
Upgrade to glibc 2.21
Diffstat (limited to 'glibc')
21 files changed, 256 insertions, 315 deletions
diff --git a/glibc/sysdeps/riscv/bits/atomic.h b/glibc/sysdeps/riscv/bits/atomic.h index 56c2aa3..a858820 100644 --- a/glibc/sysdeps/riscv/bits/atomic.h +++ b/glibc/sysdeps/riscv/bits/atomic.h @@ -42,6 +42,12 @@ typedef uintmax_t uatomic_max_t; #ifdef __riscv_atomic +#ifdef __riscv64 +# define __HAVE_64B_ATOMICS 1 +#endif + +#define USE_ATOMIC_COMPILER_BUILTINS 1 + #define asm_amo(which, ordering, mem, value) ({ \ typeof(*mem) __tmp; \ if (sizeof(__tmp) == 4) \ @@ -110,6 +116,11 @@ typedef uintmax_t uatomic_max_t; atomic_exchange_and_add(mem, value) #define catomic_max(mem, value) atomic_max(mem, value) -#endif /* __riscv_atomic */ +#else /* __riscv_atomic */ + +#define __HAVE_64B_ATOMICS 0 +#define USE_ATOMIC_COMPILER_BUILTINS 0 + +#endif /* !__riscv_atomic */ #endif /* bits/atomic.h */ diff --git a/glibc/sysdeps/riscv/bits/link.h b/glibc/sysdeps/riscv/bits/link.h index f84fe10..6d04749 100644 --- a/glibc/sysdeps/riscv/bits/link.h +++ b/glibc/sysdeps/riscv/bits/link.h @@ -28,7 +28,7 @@ typedef struct La_riscv_regs unsigned long lr_sp; } La_riscv_regs; -/* Return values for calls from PLT on MIPS. */ +/* Return values for calls from PLT on RISC-V. */ typedef struct La_riscv_retval { unsigned long lrv_a0; diff --git a/glibc/sysdeps/riscv/dl-machine.h b/glibc/sysdeps/riscv/dl-machine.h index 5bd2e4a..b618bd9 100644 --- a/glibc/sysdeps/riscv/dl-machine.h +++ b/glibc/sysdeps/riscv/dl-machine.h @@ -136,7 +136,7 @@ elf_machine_load_address (void) add a3, a3, a2\n\ add a3, a3, " STRINGXP (SZREG) "\n\ # Call the function to run the initializers.\n\ - jal _dl_init_internal\n\ + jal _dl_init\n\ # Pass our finalizer function to _start.\n\ lla a0, _dl_fini\n\ # Jump to the user entry point.\n\ @@ -176,7 +176,7 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc, ElfW(Addr) r_info = reloc->r_info; const unsigned long int r_type = ELFW(R_TYPE) (r_info); ElfW(Addr) *addr_field = (ElfW(Addr) *) reloc_addr; - const ElfW(Sym) *const refsym = sym; + const ElfW(Sym) *const __attribute__((unused)) refsym = sym; struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type); ElfW(Addr) value = 0; if (sym_map != NULL) @@ -216,7 +216,7 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc, /* There's nothing to do if the symbol is in .tbss. */ if (__glibc_likely (sym->st_value >= sym_map->l_tls_initimage_size)) break; - value += sym_map->l_tls_initimage - sym_map->l_addr; + value += (ElfW(Addr)) sym_map->l_tls_initimage - sym_map->l_addr; } size_t size = sym->st_size; diff --git a/glibc/sysdeps/riscv/fpu/fegetenv.c b/glibc/sysdeps/riscv/fpu/fegetenv.c index da5d597..fbf9799 100644 --- a/glibc/sysdeps/riscv/fpu/fegetenv.c +++ b/glibc/sysdeps/riscv/fpu/fegetenv.c @@ -22,11 +22,13 @@ #include <fpu_control.h> int -fegetenv (fenv_t *envp) +__fegetenv (fenv_t *envp) { _FPU_GETCW (*envp); /* Success. */ return 0; } -libm_hidden_def (fegetenv) +libm_hidden_def (__fegetenv) +weak_alias (__fegetenv, fegetenv) +libm_hidden_weak (fegetenv) diff --git a/glibc/sysdeps/riscv/fpu/fegetround.c b/glibc/sysdeps/riscv/fpu/fegetround.c index b6bf66e..cd503ab 100644 --- a/glibc/sysdeps/riscv/fpu/fegetround.c +++ b/glibc/sysdeps/riscv/fpu/fegetround.c @@ -22,10 +22,12 @@ #include <fpu_control.h> int -fegetround (void) +__fegetround (void) { int round; _FPU_GETROUND (round); return round; } -libm_hidden_def (fegetround) +libm_hidden_def (__fegetround) +weak_alias (__fegetround, fegetround) +libm_hidden_weak (fegetround) diff --git a/glibc/sysdeps/riscv/fpu/feholdexcpt.c b/glibc/sysdeps/riscv/fpu/feholdexcpt.c index 3d8fa22..89203fc 100644 --- a/glibc/sysdeps/riscv/fpu/feholdexcpt.c +++ b/glibc/sysdeps/riscv/fpu/feholdexcpt.c @@ -19,14 +19,14 @@ 02111-1307 USA. */ #include <fenv.h> -#include <fpu_control.h> +#include <math_private.h> int -feholdexcept (fenv_t *envp) +__feholdexcept (fenv_t *envp) { - _FPU_GETCW (*envp); - _FPU_SETFLAGS (0); + libc_feholdexcept_riscv (envp); return 0; } - -libm_hidden_def (feholdexcept) +libm_hidden_def (__feholdexcept) +weak_alias (__feholdexcept, feholdexcept) +libm_hidden_weak (feholdexcept) diff --git a/glibc/sysdeps/riscv/fpu/fesetenv.c b/glibc/sysdeps/riscv/fpu/fesetenv.c index e34fdaf..dd089a9 100644 --- a/glibc/sysdeps/riscv/fpu/fesetenv.c +++ b/glibc/sysdeps/riscv/fpu/fesetenv.c @@ -19,13 +19,14 @@ 02111-1307 USA. */ #include <fenv.h> -#include <fpu_control.h> +#include <math_private.h> int -fesetenv (const fenv_t *envp) +__fesetenv (const fenv_t *envp) { - _FPU_SETCW (envp == FE_DFL_ENV ? 0 : *envp); + libc_fesetenv_riscv (envp); return 0; } - -libm_hidden_def (fesetenv) +libm_hidden_def (__fesetenv) +weak_alias (__fesetenv, fesetenv) +libm_hidden_weak (fesetenv) diff --git a/glibc/sysdeps/riscv/fpu/fesetround.c b/glibc/sysdeps/riscv/fpu/fesetround.c index 641d75e..5ae831a 100644 --- a/glibc/sysdeps/riscv/fpu/fesetround.c +++ b/glibc/sysdeps/riscv/fpu/fesetround.c @@ -22,7 +22,7 @@ #include <fpu_control.h> int -fesetround (int round) +__fesetround (int round) { switch (round) { @@ -36,5 +36,6 @@ fesetround (int round) return round; /* a nonzero value */ } } - -libm_hidden_def (fesetround) +libm_hidden_def (__fesetround) +weak_alias (__fesetround, fesetround) +libm_hidden_weak (fesetround) diff --git a/glibc/sysdeps/riscv/fpu/feupdateenv.c b/glibc/sysdeps/riscv/fpu/feupdateenv.c index 51611cd..b685132 100644 --- a/glibc/sysdeps/riscv/fpu/feupdateenv.c +++ b/glibc/sysdeps/riscv/fpu/feupdateenv.c @@ -19,17 +19,14 @@ 02111-1307 USA. */ #include <fenv.h> -#include <fpu_control.h> +#include <math_private.h> int -feupdateenv (const fenv_t *envp) +__feupdateenv (const fenv_t *envp) { - fenv_t env = *envp; - - /* rm = 0; rm |= fenv.rm; flags |= fenv.flags */ - _FPU_SETROUND (0); - asm volatile ("csrs fcsr, %0" : : "r"(env)); - + libc_feupdateenv_riscv (envp); return 0; } -libm_hidden_def (feupdateenv) +libm_hidden_def (__feupdateenv) +weak_alias (__feupdateenv, feupdateenv) +libm_hidden_weak (feupdateenv) diff --git a/glibc/sysdeps/riscv/fpu/fgetexcptflg.c b/glibc/sysdeps/riscv/fpu/fgetexcptflg.c index 537f5b7..3d6eac1 100644 --- a/glibc/sysdeps/riscv/fpu/fgetexcptflg.c +++ b/glibc/sysdeps/riscv/fpu/fgetexcptflg.c @@ -24,8 +24,6 @@ int fegetexceptflag (fexcept_t *flagp, int excepts) { - fpu_control_t temp; - /* Get the current exceptions. */ _FPU_GETFLAGS (*flagp); *flagp &= excepts; diff --git a/glibc/sysdeps/riscv/fpu/fraiseexcpt.c b/glibc/sysdeps/riscv/fpu/fraiseexcpt.c index 2a839d0..b9f555a 100644 --- a/glibc/sysdeps/riscv/fpu/fraiseexcpt.c +++ b/glibc/sysdeps/riscv/fpu/fraiseexcpt.c @@ -22,10 +22,11 @@ #include <fpu_control.h> int -feraiseexcept (int excepts) +__feraiseexcept (int excepts) { asm volatile ("csrs fflags, %0" : : "r"(excepts)); return 0; } - -libm_hidden_def (feraiseexcept) +libm_hidden_def (__feraiseexcept) +weak_alias (__feraiseexcept, feraiseexcept) +libm_hidden_weak (feraiseexcept) diff --git a/glibc/sysdeps/riscv/fpu/ftestexcept.c b/glibc/sysdeps/riscv/fpu/ftestexcept.c index 8235fa1..38686cb 100644 --- a/glibc/sysdeps/riscv/fpu/ftestexcept.c +++ b/glibc/sysdeps/riscv/fpu/ftestexcept.c @@ -19,15 +19,11 @@ 02111-1307 USA. */ #include <fenv.h> -#include <fpu_control.h> +#include <math_private.h> int fetestexcept (int excepts) { - int cw; - - _FPU_GETFLAGS (cw); - - return cw & excepts; + return libc_fetestexcept_riscv (excepts); } libm_hidden_def (fetestexcept) diff --git a/glibc/sysdeps/riscv/fpu/math_private.h b/glibc/sysdeps/riscv/fpu/math_private.h new file mode 100644 index 0000000..445ffed --- /dev/null +++ b/glibc/sysdeps/riscv/fpu/math_private.h @@ -0,0 +1,145 @@ +/* Private floating point rounding and exceptions handling. RISC-V version. + Copyright (C) 2014-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#ifndef RISCV_MATH_PRIVATE_H +#define RISCV_MATH_PRIVATE_H 1 + +#include <fenv.h> +#include <fpu_control.h> + +static __always_inline void +libc_feholdexcept_riscv (fenv_t *envp) +{ + _FPU_GETCW (*envp); + _FPU_SETFLAGS (0); +} + +#define libc_feholdexcept libc_feholdexcept_riscv +#define libc_feholdexceptf libc_feholdexcept_riscv +#define libc_feholdexceptl libc_feholdexcept_riscv + +static __always_inline void +libc_fesetround_riscv (int round) +{ + _FPU_SETROUND (round); +} + +#define libc_fesetround libc_fesetround_riscv +#define libc_fesetroundf libc_fesetround_riscv +#define libc_fesetroundl libc_fesetround_riscv + +static __always_inline void +libc_feholdexcept_setround_riscv (fenv_t *envp, int round) +{ + libc_fesetround_riscv (round); + libc_feholdexcept_riscv (envp); +} + +#define libc_feholdexcept_setround libc_feholdexcept_setround_riscv +#define libc_feholdexcept_setroundf libc_feholdexcept_setround_riscv +#define libc_feholdexcept_setroundl libc_feholdexcept_setround_riscv + +static __always_inline int +libc_fetestexcept_riscv (int ex) +{ + int cw; + + _FPU_GETFLAGS (cw); + + return cw & ex; +} + +#define libc_fetestexcept libc_fetestexcept_riscv +#define libc_fetestexceptf libc_fetestexcept_riscv +#define libc_fetestexceptl libc_fetestexcept_riscv + +static __always_inline void +libc_fesetenv_riscv (const fenv_t *envp) +{ + long env = (long) envp - (long) FE_DFL_ENV; + if (env != 0) + env = *envp; + + _FPU_SETCW (env); +} + +#define libc_fesetenv libc_fesetenv_riscv +#define libc_fesetenvf libc_fesetenv_riscv +#define libc_fesetenvl libc_fesetenv_riscv +#define libc_feresetround_noex libc_fesetenv_riscv +#define libc_feresetround_noexf libc_fesetenv_riscv +#define libc_feresetround_noexl libc_fesetenv_riscv + +static __always_inline int +libc_feupdateenv_test_riscv (const fenv_t *envp, int ex) +{ + fenv_t env = *envp; + int excepts; + + _FPU_SETROUND (0); + asm volatile ("csrrs %0, fcsr, %1" : "=r"(excepts) : "r"(env)); + + return excepts & ex; +} + +#define libc_feupdateenv_test libc_feupdateenv_test_riscv +#define libc_feupdateenv_testf libc_feupdateenv_test_riscv +#define libc_feupdateenv_testl libc_feupdateenv_test_riscv + +static __always_inline void +libc_feupdateenv_riscv (const fenv_t *envp) +{ + fenv_t env = *envp; + + _FPU_SETROUND (0); + asm volatile ("csrs fcsr, %0" : : "r"(env)); +} + +#define libc_feupdateenv libc_feupdateenv_riscv +#define libc_feupdateenvf libc_feupdateenv_riscv +#define libc_feupdateenvl libc_feupdateenv_riscv + +static __always_inline void +libc_feholdsetround_riscv (fenv_t *envp, int round) +{ + /* Note this implementation makes an improperly-formatted fenv_t and + so should only be used in conjunction with libc_feresetround. */ + int old_round; + asm volatile ("csrrw %0, frm, %1" : "=r"(old_round) : "r"(round)); + *envp = old_round; +} + +#define libc_feholdsetround libc_feholdsetround_riscv +#define libc_feholdsetroundf libc_feholdsetround_riscv +#define libc_feholdsetroundl libc_feholdsetround_riscv + +static __always_inline void +libc_feresetround_riscv (fenv_t *envp) +{ + /* Note this implementation takes an improperly-formatted fenv_t and + so should only be used in conjunction with libc_feholdsetround. */ + _FPU_SETROUND (*envp); +} + +#define libc_feresetround libc_feresetround_riscv +#define libc_feresetroundf libc_feresetround_riscv +#define libc_feresetroundl libc_feresetround_riscv + +#include_next <math_private.h> + +#endif diff --git a/glibc/sysdeps/riscv/memcpy.c b/glibc/sysdeps/riscv/memcpy.c index 523f311..94e6435 100644 --- a/glibc/sysdeps/riscv/memcpy.c +++ b/glibc/sysdeps/riscv/memcpy.c @@ -58,7 +58,6 @@ small: while (la < lend) BODY(la, lb, long); -maybe_done: a = (char*)la; b = (const char*)lb; if (__builtin_expect(a < end, 0)) diff --git a/glibc/sysdeps/riscv/nptl/lowlevellock.h b/glibc/sysdeps/riscv/nptl/lowlevellock.h deleted file mode 100644 index 834bc2a..0000000 --- a/glibc/sysdeps/riscv/nptl/lowlevellock.h +++ /dev/null @@ -1,262 +0,0 @@ -/* Copyright (C) 2011-2014 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _LOWLEVELLOCK_H -#define _LOWLEVELLOCK_H 1 - -#include <time.h> -#include <sys/param.h> -#include <bits/pthreadtypes.h> -#include <atomic.h> -#include <sysdep.h> -#include <kernel-features.h> - -#define FUTEX_WAIT 0 -#define FUTEX_WAKE 1 -#define FUTEX_REQUEUE 3 -#define FUTEX_CMP_REQUEUE 4 -#define FUTEX_WAKE_OP 5 -#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1) -#define FUTEX_LOCK_PI 6 -#define FUTEX_UNLOCK_PI 7 -#define FUTEX_TRYLOCK_PI 8 -#define FUTEX_WAIT_BITSET 9 -#define FUTEX_WAKE_BITSET 10 -#define FUTEX_PRIVATE_FLAG 128 -#define FUTEX_CLOCK_REALTIME 256 - -#define FUTEX_BITSET_MATCH_ANY 0xffffffff - -/* Values for 'private' parameter of locking macros. Yes, the - definition seems to be backwards. But it is not. The bit will be - reversed before passing to the system call. */ -#define LLL_PRIVATE 0 -#define LLL_SHARED FUTEX_PRIVATE_FLAG - - -#if !defined NOT_IN_libc || defined IS_IN_rtld -/* In libc.so or ld.so all futexes are private. */ -# ifdef __ASSUME_PRIVATE_FUTEX -# define __lll_private_flag(fl, private) \ - ((fl) | FUTEX_PRIVATE_FLAG) -# else -# define __lll_private_flag(fl, private) \ - ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex)) -# endif -#else -# ifdef __ASSUME_PRIVATE_FUTEX -# define __lll_private_flag(fl, private) \ - (((fl) | FUTEX_PRIVATE_FLAG) ^ (private)) -# else -# define __lll_private_flag(fl, private) \ - (__builtin_constant_p (private) \ - ? ((private) == 0 \ - ? ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex)) \ - : (fl)) \ - : ((fl) | (((private) ^ FUTEX_PRIVATE_FLAG) \ - & THREAD_GETMEM (THREAD_SELF, header.private_futex)))) -# endif -#endif - - -#define lll_futex_wait(futexp, val, private) \ - lll_futex_timed_wait(futexp, val, NULL, private) - -#define lll_futex_timed_wait(futexp, val, timespec, private) \ - ({ \ - INTERNAL_SYSCALL_DECL (__err); \ - long int __ret; \ - __ret = INTERNAL_SYSCALL (futex, __err, 4, (long) (futexp), \ - __lll_private_flag (FUTEX_WAIT, private), \ - (val), (timespec)); \ - INTERNAL_SYSCALL_ERROR_P (__ret, __err) ? -__ret : __ret; \ - }) - -#define lll_futex_wake(futexp, nr, private) \ - ({ \ - INTERNAL_SYSCALL_DECL (__err); \ - long int __ret; \ - __ret = INTERNAL_SYSCALL (futex, __err, 4, (long) (futexp), \ - __lll_private_flag (FUTEX_WAKE, private), \ - (nr), 0); \ - INTERNAL_SYSCALL_ERROR_P (__ret, __err) ? -__ret : __ret; \ - }) - -#define lll_robust_dead(futexv, private) \ - do \ - { \ - int *__futexp = &(futexv); \ - atomic_or (__futexp, FUTEX_OWNER_DIED); \ - lll_futex_wake (__futexp, 1, private); \ - } \ - while (0) - -/* Returns non-zero if error happened, zero if success. */ -#define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val, private) \ - ({ \ - INTERNAL_SYSCALL_DECL (__err); \ - long int __ret; \ - __ret = INTERNAL_SYSCALL (futex, __err, 6, (long) (futexp), \ - __lll_private_flag (FUTEX_CMP_REQUEUE, private),\ - (nr_wake), (nr_move), (mutex), (val)); \ - INTERNAL_SYSCALL_ERROR_P (__ret, __err); \ - }) - -/* Returns non-zero if error happened, zero if success. */ -#define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2, private) \ - ({ \ - INTERNAL_SYSCALL_DECL (__err); \ - long int __ret; \ - \ - __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp), \ - __lll_private_flag (FUTEX_WAKE_OP, private), \ - (nr_wake), (nr_wake2), (futexp2), \ - FUTEX_OP_CLEAR_WAKE_IF_GT_ONE); \ - INTERNAL_SYSCALL_ERROR_P (__ret, __err); \ - }) - -#define lll_trylock(futex) \ - ({ \ - atomic_compare_and_exchange_val_acq (&(futex), 1, 0) != 0; \ - }) - -#define lll_cond_trylock(futex) \ - ({ \ - atomic_compare_and_exchange_val_acq (&(futex), 2, 0) != 0; \ - }) - -#define lll_robust_trylock(futex, id) \ - ({ \ - atomic_compare_and_exchange_val_acq (&(futex), id, 0) != 0; \ - }) - -extern void __lll_lock_wait_private (int *futex) attribute_hidden; -extern void __lll_lock_wait (int *futex, int private) attribute_hidden; -extern int __lll_robust_lock_wait (int *futex, int private) attribute_hidden; - -#define lll_lock(futex, private) \ - ({ \ - int val = atomic_compare_and_exchange_val_acq (&(futex), 1, 0); \ - \ - if (__builtin_expect (val != 0, 0)) \ - { \ - if (__builtin_constant_p (private) && private == LLL_PRIVATE) \ - __lll_lock_wait_private (&(futex)); \ - else \ - __lll_lock_wait (&(futex), private); \ - } \ - }) - -#define lll_robust_lock(futex, id, private) \ - ({ \ - int result = 0; \ - if (atomic_compare_and_exchange_bool_acq (&(futex), id, 0) != 0) \ - result = __lll_robust_lock_wait (&(futex), private); \ - result; \ - }) - -#define lll_cond_lock(futex, private) \ - ({ \ - int val = atomic_compare_and_exchange_val_acq (&(futex), 2, 0); \ - \ - if (__builtin_expect (val != 0, 0)) \ - __lll_lock_wait (&(futex), private); \ - }) - -#define lll_robust_cond_lock(futex, id, private) \ - lll_robust_lock (futex, (id) | FUTEX_WAITERS, private) - - -extern int __lll_timedlock_wait (int *futex, const struct timespec *, - int private) attribute_hidden; -extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *, - int private) attribute_hidden; - -#define lll_timedlock(futex, abstime, private) \ - ({ \ - int val = atomic_compare_and_exchange_val_acq (&(futex), 1, 0); \ - int result = 0; \ - \ - if (__builtin_expect (val != 0, 0)) \ - result = __lll_timedlock_wait (&(futex), abstime, private); \ - result; \ - }) - -#define lll_robust_timedlock(futex, abstime, id, private) \ - ({ \ - int result = 0; \ - if (atomic_compare_and_exchange_bool_acq (&(futex), id, 0) != 0) \ - result = __lll_robust_timedlock_wait (&(futex), abstime, private); \ - result; \ - }) - -#define lll_unlock(lock, private) \ - ((void) ({ \ - int *__futex = &(lock); \ - int __val = atomic_exchange_rel (__futex, 0); \ - if (__builtin_expect (__val > 1, 0)) \ - lll_futex_wake (__futex, 1, private); \ - })) - -#define lll_robust_unlock(lock, private) \ - ((void) ({ \ - int *__futex = &(lock); \ - int __val = atomic_exchange_rel (__futex, 0); \ - if (__builtin_expect (__val & FUTEX_WAITERS, 0)) \ - lll_futex_wake (__futex, 1, private); \ - })) - -#define lll_islocked(futex) \ - (futex != 0) - - -/* Our internal lock implementation is identical to the binary-compatible - mutex implementation. */ - -/* Initializers for lock. */ -#define LLL_LOCK_INITIALIZER (0) -#define LLL_LOCK_INITIALIZER_LOCKED (1) - -/* The states of a lock are: - 0 - untaken - 1 - taken by one user - >1 - taken by more users */ - -/* The kernel notifies a process which uses CLONE_CLEARTID via futex - wakeup when the clone terminates. The memory location contains the - thread ID while the clone is running and is reset to zero - afterwards. */ -#define lll_wait_tid(tid) \ - do { \ - __typeof (tid) __tid; \ - while ((__tid = (tid)) != 0) \ - lll_futex_wait (&(tid), __tid, LLL_SHARED); \ - } while (0) - -extern int __lll_timedwait_tid (int *, const struct timespec *) - attribute_hidden; - -#define lll_timedwait_tid(tid, abstime) \ - ({ \ - int __res = 0; \ - if ((tid) != 0) \ - __res = __lll_timedwait_tid (&(tid), (abstime)); \ - __res; \ - }) - -#endif /* lowlevellock.h */ diff --git a/glibc/sysdeps/riscv/nptl/sysdep-cancel.h b/glibc/sysdeps/riscv/nptl/sysdep-cancel.h index 9ca31c4..3a3b116 100644 --- a/glibc/sysdeps/riscv/nptl/sysdep-cancel.h +++ b/glibc/sysdeps/riscv/nptl/sysdep-cancel.h @@ -28,7 +28,7 @@ happen before any instructions. So we use cfi_same_value instead of cfi_restore. */ -#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt +#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) # undef PSEUDO # define PSEUDO(name, syscall_name, args) \ @@ -93,10 +93,10 @@ # define STKOFF_RA (STKOFF_SVMSK + SZREG) # define STKSPACE (STKOFF_RA + SZREG) -# ifdef IS_IN_libpthread +# if IS_IN (libpthread) # define CENABLE call __pthread_enable_asynccancel # define CDISABLE call __pthread_disable_asynccancel -# elif defined IS_IN_librt +# elif IS_IN (librt) # define CENABLE call __librt_enable_asynccancel # define CDISABLE call __librt_disable_asynccancel # else diff --git a/glibc/sysdeps/riscv/setjmp.S b/glibc/sysdeps/riscv/setjmp.S index 33dfd6f..9327a91 100644 --- a/glibc/sysdeps/riscv/setjmp.S +++ b/glibc/sysdeps/riscv/setjmp.S @@ -63,7 +63,7 @@ ENTRY (__sigsetjmp) REG_S a3, 15*SZREG(a0) #endif -#if defined NOT_IN_libc && defined IS_IN_rtld +#if !IS_IN (libc) && IS_IN (rtld) /* In ld.so we never save the signal mask. */ li a0, 0 ret diff --git a/glibc/sysdeps/riscv/sotruss-lib.c b/glibc/sysdeps/riscv/sotruss-lib.c new file mode 100644 index 0000000..f7bf3f1 --- /dev/null +++ b/glibc/sysdeps/riscv/sotruss-lib.c @@ -0,0 +1,51 @@ +/* Override generic sotruss-lib.c to define actual functions for RISC-V. + Copyright (C) 2012-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <http://www.gnu.org/licenses/>. */ + +#define HAVE_ARCH_PLTENTER +#define HAVE_ARCH_PLTEXIT + +#include <elf/sotruss-lib.c> + +ElfW(Addr) +la_riscv_gnu_pltenter (ElfW(Sym) *sym __attribute__ ((unused)), + unsigned int ndx __attribute__ ((unused)), + uintptr_t *refcook, uintptr_t *defcook, + La_riscv_regs *regs, unsigned int *flags, + const char *symname, long int *framesizep) +{ + print_enter (refcook, defcook, symname, + regs->lr_reg[0], regs->lr_reg[1], regs->lr_reg[2], + *flags); + + /* No need to copy anything, we will not need the parameters in any case. */ + *framesizep = 0; + + return sym->st_value; +} + +unsigned int +la_riscv_gnu_pltexit (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook, + uintptr_t *defcook, + const struct La_riscv_regs *inregs, + struct La_riscv_retval *outregs, + const char *symname) +{ + print_exit (refcook, defcook, symname, outregs->lrv_a0); + + return 0; +} diff --git a/glibc/sysdeps/unix/sysv/linux/riscv/kernel-features.h b/glibc/sysdeps/unix/sysv/linux/riscv/kernel-features.h index 9283b3f..c3e5a50 100644 --- a/glibc/sysdeps/unix/sysv/linux/riscv/kernel-features.h +++ b/glibc/sysdeps/unix/sysv/linux/riscv/kernel-features.h @@ -21,9 +21,6 @@ #include_next <kernel-features.h> -/* asm-generic architectures do not have the utimes syscall. */ -#undef __ASSUME_UTIMES - /* Define this if your 32-bit syscall API requires 64-bit register pairs to start with an even-number register. */ #define __ASSUME_ALIGNED_REGISTER_PAIRS 1 diff --git a/glibc/sysdeps/unix/sysv/linux/riscv/shlib-versions b/glibc/sysdeps/unix/sysv/linux/riscv/shlib-versions new file mode 100644 index 0000000..7e837a2 --- /dev/null +++ b/glibc/sysdeps/unix/sysv/linux/riscv/shlib-versions @@ -0,0 +1 @@ +DEFAULT GLIBC_2.20 diff --git a/glibc/sysdeps/unix/sysv/linux/riscv/syscall.c b/glibc/sysdeps/unix/sysv/linux/riscv/syscall.c index 1265d45..2ebd7ee 100644 --- a/glibc/sysdeps/unix/sysv/linux/riscv/syscall.c +++ b/glibc/sysdeps/unix/sysv/linux/riscv/syscall.c @@ -21,14 +21,15 @@ long syscall (long syscall_number, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6, long arg7) { - long ret, err; + long ret; + INTERNAL_SYSCALL_DECL (err); ret = INTERNAL_SYSCALL_NCS(syscall_number, err, 7, arg1, arg2, arg3, arg4, arg5, arg6, arg7); if (INTERNAL_SYSCALL_ERROR_P (ret, err)) { - extern long __syscall_error() attribute_hidden; + extern long __syscall_error (void) attribute_hidden; return __syscall_error(); } |