diff options
Diffstat (limited to 'libc/sysdeps/sparc')
-rw-r--r-- | libc/sysdeps/sparc/Makefile | 4 | ||||
-rw-r--r-- | libc/sysdeps/sparc/backtrace.c | 159 | ||||
-rw-r--r-- | libc/sysdeps/sparc/fpu/libm-test-ulps | 162 | ||||
-rw-r--r-- | libc/sysdeps/sparc/sparc32/backtrace.h | 7 | ||||
-rw-r--r-- | libc/sysdeps/sparc/sparc32/memchr.S | 3 | ||||
-rw-r--r-- | libc/sysdeps/sparc/sparc32/sparcv9/Makefile | 2 | ||||
-rw-r--r-- | libc/sysdeps/sparc/sparc32/sparcv9/backtrace.h | 7 | ||||
-rw-r--r-- | libc/sysdeps/sparc/sparc32/sparcv9/bits/atomic.h | 14 | ||||
-rw-r--r-- | libc/sysdeps/sparc/sparc64/Makefile | 1 | ||||
-rw-r--r-- | libc/sysdeps/sparc/sparc64/backtrace.c | 57 | ||||
-rw-r--r-- | libc/sysdeps/sparc/sparc64/backtrace.h | 7 | ||||
-rw-r--r-- | libc/sysdeps/sparc/sparc64/bits/atomic.h | 28 | ||||
-rw-r--r-- | libc/sysdeps/sparc/sparc64/memchr.S | 3 |
13 files changed, 376 insertions, 78 deletions
diff --git a/libc/sysdeps/sparc/Makefile b/libc/sysdeps/sparc/Makefile index 3f0c09640..31aaeaed8 100644 --- a/libc/sysdeps/sparc/Makefile +++ b/libc/sysdeps/sparc/Makefile @@ -3,6 +3,10 @@ long-double-fcts = yes pie-ccflag = -fPIE +ifeq ($(subdir),debug) +CFLAGS-backtrace.c += -funwind-tables +endif + ifeq ($(subdir),gmon) sysdep_routines += sparc-mcount endif diff --git a/libc/sysdeps/sparc/backtrace.c b/libc/sysdeps/sparc/backtrace.c new file mode 100644 index 000000000..48f3cf6c1 --- /dev/null +++ b/libc/sysdeps/sparc/backtrace.c @@ -0,0 +1,159 @@ +/* Return backtrace of current program state. + Copyright (C) 2013 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by David S. Miller <davem@davemloft.net> + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, see <http://www.gnu.org/licenses/>. */ + +#include <execinfo.h> +#include <stddef.h> +#include <sysdep.h> +#include <sys/trap.h> +#include <dlfcn.h> +#include <unwind.h> +#include <backtrace.h> + +struct layout +{ + unsigned long locals[8]; + unsigned long ins[6]; + unsigned long next; + void *return_address; +}; + +struct trace_arg +{ + void **array; + _Unwind_Word cfa; + int cnt; + int size; +}; + +#ifdef SHARED +static _Unwind_Reason_Code (*unwind_backtrace) (_Unwind_Trace_Fn, void *); +static _Unwind_Ptr (*unwind_getip) (struct _Unwind_Context *); +static _Unwind_Word (*unwind_getcfa) (struct _Unwind_Context *); +static void *libgcc_handle; + +/* Dummy version in case libgcc_s does not contain the real code. */ +static _Unwind_Word +dummy_getcfa (struct _Unwind_Context *ctx __attribute__ ((unused))) +{ + return 0; +} + +static void +init (void) +{ + libgcc_handle = __libc_dlopen ("libgcc_s.so.1"); + + if (libgcc_handle == NULL) + return; + + unwind_backtrace = __libc_dlsym (libgcc_handle, "_Unwind_Backtrace"); + unwind_getip = __libc_dlsym (libgcc_handle, "_Unwind_GetIP"); + if (unwind_getip == NULL) + unwind_backtrace = NULL; + unwind_getcfa = (__libc_dlsym (libgcc_handle, "_Unwind_GetCFA") + ?: dummy_getcfa); +} +#else +# define unwind_backtrace _Unwind_Backtrace +# define unwind_getip _Unwind_GetIP +# define unwind_getcfa _Unwind_GetCFA +#endif + +static _Unwind_Reason_Code +backtrace_helper (struct _Unwind_Context *ctx, void *a) +{ + struct trace_arg *arg = a; + _Unwind_Ptr ip; + + /* We are first called with address in the __backtrace function. + Skip it. */ + if (arg->cnt != -1) + { + ip = unwind_getip (ctx); + arg->array[arg->cnt] = (void *) ip; + + /* Check whether we make any progress. */ + _Unwind_Word cfa = unwind_getcfa (ctx); + + if (arg->cnt > 0 && arg->array[arg->cnt - 1] == arg->array[arg->cnt] + && cfa == arg->cfa) + return _URC_END_OF_STACK; + arg->cfa = cfa; + } + if (++arg->cnt == arg->size) + return _URC_END_OF_STACK; + return _URC_NO_REASON; +} + +int +__backtrace (void **array, int size) +{ + struct trace_arg arg = { .array = array, .cfa = 0, .size = size, .cnt = -1 }; + bool use_unwinder; + int count; + + if (!size) + return 0; + + use_unwinder = true; +#ifdef SHARED + __libc_once_define (static, once); + + __libc_once (once, init); + if (unwind_backtrace == NULL) + use_unwinder = false; +#endif + + if (use_unwinder == false) + { + struct layout *current; + unsigned long fp, i7; + + asm volatile ("mov %%fp, %0" : "=r"(fp)); + asm volatile ("mov %%i7, %0" : "=r"(i7)); + current = (struct layout *) (fp + BACKTRACE_STACK_BIAS); + + array[0] = (void *) i7; + + if (size == 1) + return 1; + + backtrace_flush_register_windows(); + for (count = 1; count < size; count++) + { + array[count] = current->return_address; + if (!current->next) + break; + current = (struct layout *) (current->next + BACKTRACE_STACK_BIAS); + } + } + else + { + unwind_backtrace (backtrace_helper, &arg); + + /* _Unwind_Backtrace seems to put NULL address above + _start. Fix it up here. */ + if (arg.cnt > 1 && arg.array[arg.cnt - 1] == NULL) + --arg.cnt; + count = arg.cnt != -1 ? arg.cnt : 0; + } + return count; +} +weak_alias (__backtrace, backtrace) +libc_hidden_def (__backtrace) diff --git a/libc/sysdeps/sparc/fpu/libm-test-ulps b/libc/sysdeps/sparc/fpu/libm-test-ulps index f282a160a..6eee78843 100644 --- a/libc/sysdeps/sparc/fpu/libm-test-ulps +++ b/libc/sysdeps/sparc/fpu/libm-test-ulps @@ -204,6 +204,38 @@ ldouble: 1 Test "Real part of: cacos (-0.5 - 0 i) == 2.094395102393195492308428922186335256131 + +0 i": ildouble: 1 ldouble: 1 +Test "Imaginary part of: cacos (-0x1.fp-1025 + 1.5 i) == 1.570796326794896619231321691639751442099 - 1.194763217287109304111930828519090523536 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: cacos (-0x1.fp-1025 - 1.5 i) == 1.570796326794896619231321691639751442099 + 1.194763217287109304111930828519090523536 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Real part of: cacos (-0x1.fp-129 + 1.5 i) == 1.570796326794896619231321691639751442100 - 1.194763217287109304111930828519090523536 i": +float: 1 +ifloat: 1 +Test "Imaginary part of: cacos (-0x1.fp-129 + 1.5 i) == 1.570796326794896619231321691639751442100 - 1.194763217287109304111930828519090523536 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Real part of: cacos (-0x1.fp-129 - 1.5 i) == 1.570796326794896619231321691639751442100 + 1.194763217287109304111930828519090523536 i": +float: 1 +ifloat: 1 +Test "Imaginary part of: cacos (-0x1.fp-129 - 1.5 i) == 1.570796326794896619231321691639751442100 + 1.194763217287109304111930828519090523536 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: cacos (-0x1.fp-16385 + 1.5 i) == 1.570796326794896619231321691639751442099 - 1.194763217287109304111930828519090523536 i": +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: cacos (-0x1.fp-16385 - 1.5 i) == 1.570796326794896619231321691639751442099 + 1.194763217287109304111930828519090523536 i": +ildouble: 1 +ldouble: 1 Test "Imaginary part of: cacos (-0x1p500 + 1.0 i) == 3.141592653589793238462643383279502884197 - 3.472667374605326000180332928505464606058e2 i": ildouble: 1 ldouble: 1 @@ -262,6 +294,32 @@ ifloat: 1 Test "Imaginary part of: cacos (0.75 + 1.25 i) == 1.11752014915610270578240049553777969 - 1.13239363160530819522266333696834467 i": ildouble: 1 ldouble: 1 +Test "Imaginary part of: cacos (0x1.fp-1025 + 1.5 i) == 1.570796326794896619231321691639751442099 - 1.194763217287109304111930828519090523536 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: cacos (0x1.fp-1025 - 1.5 i) == 1.570796326794896619231321691639751442099 + 1.194763217287109304111930828519090523536 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: cacos (0x1.fp-129 + 1.5 i) == 1.570796326794896619231321691639751442097 - 1.194763217287109304111930828519090523536 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: cacos (0x1.fp-129 - 1.5 i) == 1.570796326794896619231321691639751442097 + 1.194763217287109304111930828519090523536 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: cacos (0x1.fp-16385 + 1.5 i) == 1.570796326794896619231321691639751442099 - 1.194763217287109304111930828519090523536 i": +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: cacos (0x1.fp-16385 - 1.5 i) == 1.570796326794896619231321691639751442099 + 1.194763217287109304111930828519090523536 i": +ildouble: 1 +ldouble: 1 Test "Imaginary part of: cacos (0x1.fp1023 + 0x1.fp1023 i) == 7.853981633974483096156608458198757210493e-1 - 7.107906849659093345062145442726115449315e2 i": double: 1 idouble: 1 @@ -481,6 +539,32 @@ double: 1 idouble: 1 ildouble: 1 ldouble: 1 +Test "Imaginary part of: casin (-0x1.fp-1025 + 1.5 i) == -2.989196569048182929051881765490354365918e-309 + 1.194763217287109304111930828519090523536 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: casin (-0x1.fp-1025 - 1.5 i) == -2.989196569048182929051881765490354365918e-309 - 1.194763217287109304111930828519090523536 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: casin (-0x1.fp-129 + 1.5 i) == -1.579176199917649005841160751101628985741e-39 + 1.194763217287109304111930828519090523536 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: casin (-0x1.fp-129 - 1.5 i) == -1.579176199917649005841160751101628985741e-39 - 1.194763217287109304111930828519090523536 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: casin (-0x1.fp-16385 + 1.5 i) == -4.516698239814521372306784062043266700598e-4933 + 1.194763217287109304111930828519090523536 i": +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: casin (-0x1.fp-16385 - 1.5 i) == -4.516698239814521372306784062043266700598e-4933 - 1.194763217287109304111930828519090523536 i": +ildouble: 1 +ldouble: 1 Test "Imaginary part of: casin (-0x1p500 + 1.0 i) == -1.570796326794896619231321691639751442099 + 3.472667374605326000180332928505464606058e2 i": ildouble: 1 ldouble: 1 @@ -520,6 +604,32 @@ ifloat: 1 Test "Imaginary part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i": ildouble: 1 ldouble: 1 +Test "Imaginary part of: casin (0x1.fp-1025 + 1.5 i) == 2.989196569048182929051881765490354365918e-309 + 1.194763217287109304111930828519090523536 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: casin (0x1.fp-1025 - 1.5 i) == 2.989196569048182929051881765490354365918e-309 - 1.194763217287109304111930828519090523536 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: casin (0x1.fp-129 + 1.5 i) == 1.579176199917649005841160751101628985741e-39 + 1.194763217287109304111930828519090523536 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: casin (0x1.fp-129 - 1.5 i) == 1.579176199917649005841160751101628985741e-39 - 1.194763217287109304111930828519090523536 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: casin (0x1.fp-16385 + 1.5 i) == 4.516698239814521372306784062043266700598e-4933 + 1.194763217287109304111930828519090523536 i": +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: casin (0x1.fp-16385 - 1.5 i) == 4.516698239814521372306784062043266700598e-4933 - 1.194763217287109304111930828519090523536 i": +ildouble: 1 +ldouble: 1 Test "Imaginary part of: casin (0x1.fp1023 + 0x1.fp1023 i) == 7.853981633974483096156608458198757210493e-1 + 7.107906849659093345062145442726115449315e2 i": double: 1 idouble: 1 @@ -635,6 +745,19 @@ idouble: 2 ifloat: 1 ildouble: 2 ldouble: 2 +Test "Real part of: casinh (-1.5 + 0x1.fp-1025 i) == -1.194763217287109304111930828519090523536 + 2.989196569048182929051881765490354365918e-309 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Real part of: casinh (-1.5 + 0x1.fp-129 i) == -1.194763217287109304111930828519090523536 + 1.579176199917649005841160751101628985741e-39 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Real part of: casinh (-1.5 + 0x1.fp-16385 i) == -1.194763217287109304111930828519090523536 + 4.516698239814521372306784062043266700598e-4933 i": +ildouble: 1 +ldouble: 1 Test "Real part of: casinh (-1.5 - 0 i) == -1.194763217287109304111930828519090523536 - 0 i": double: 2 float: 1 @@ -642,6 +765,19 @@ idouble: 2 ifloat: 1 ildouble: 2 ldouble: 2 +Test "Real part of: casinh (-1.5 - 0x1.fp-1025 i) == -1.194763217287109304111930828519090523536 - 2.989196569048182929051881765490354365918e-309 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Real part of: casinh (-1.5 - 0x1.fp-129 i) == -1.194763217287109304111930828519090523536 - 1.579176199917649005841160751101628985741e-39 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Real part of: casinh (-1.5 - 0x1.fp-16385 i) == -1.194763217287109304111930828519090523536 - 4.516698239814521372306784062043266700598e-4933 i": +ildouble: 1 +ldouble: 1 Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i": double: 5 float: 1 @@ -730,11 +866,37 @@ double: 1 idouble: 1 ildouble: 1 ldouble: 1 +Test "Real part of: casinh (1.5 + 0x1.fp-1025 i) == 1.194763217287109304111930828519090523536 + 2.989196569048182929051881765490354365918e-309 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Real part of: casinh (1.5 + 0x1.fp-129 i) == 1.194763217287109304111930828519090523536 + 1.579176199917649005841160751101628985741e-39 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Real part of: casinh (1.5 + 0x1.fp-16385 i) == 1.194763217287109304111930828519090523536 + 4.516698239814521372306784062043266700598e-4933 i": +ildouble: 1 +ldouble: 1 Test "Real part of: casinh (1.5 - 0 i) == 1.194763217287109304111930828519090523536 - 0 i": double: 1 idouble: 1 ildouble: 1 ldouble: 1 +Test "Real part of: casinh (1.5 - 0x1.fp-1025 i) == 1.194763217287109304111930828519090523536 - 2.989196569048182929051881765490354365918e-309 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Real part of: casinh (1.5 - 0x1.fp-129 i) == 1.194763217287109304111930828519090523536 - 1.579176199917649005841160751101628985741e-39 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Real part of: casinh (1.5 - 0x1.fp-16385 i) == 1.194763217287109304111930828519090523536 - 4.516698239814521372306784062043266700598e-4933 i": +ildouble: 1 +ldouble: 1 # catan Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i": diff --git a/libc/sysdeps/sparc/sparc32/backtrace.h b/libc/sysdeps/sparc/sparc32/backtrace.h new file mode 100644 index 000000000..089f8b4d2 --- /dev/null +++ b/libc/sysdeps/sparc/sparc32/backtrace.h @@ -0,0 +1,7 @@ +/* Private macros for guiding the backtrace implementation, sparc32 + version. */ + +#define backtrace_flush_register_windows() \ + asm volatile ("ta %0" : : "i" (ST_FLUSH_WINDOWS)) + +#define BACKTRACE_STACK_BIAS 0 diff --git a/libc/sysdeps/sparc/sparc32/memchr.S b/libc/sysdeps/sparc/sparc32/memchr.S index 295005dd8..7ea782538 100644 --- a/libc/sysdeps/sparc/sparc32/memchr.S +++ b/libc/sysdeps/sparc/sparc32/memchr.S @@ -139,7 +139,4 @@ ENTRY(__memchr) END(__memchr) weak_alias (__memchr, memchr) -#if !__BOUNDED_POINTERS__ -weak_alias (__memchr, __ubp_memchr) -#endif libc_hidden_builtin_def (memchr) diff --git a/libc/sysdeps/sparc/sparc32/sparcv9/Makefile b/libc/sysdeps/sparc/sparc32/sparcv9/Makefile index 8a9330f7a..7d475b089 100644 --- a/libc/sysdeps/sparc/sparc32/sparcv9/Makefile +++ b/libc/sysdeps/sparc/sparc32/sparcv9/Makefile @@ -10,13 +10,11 @@ ASFLAGS-.o += -Wa,-Av9d ASFLAGS-.os += -Wa,-Av9d ASFLAGS-.op += -Wa,-Av9d ASFLAGS-.og += -Wa,-Av9d -ASFLAGS-.ob += -Wa,-Av9d ASFLAGS-.oS += -Wa,-Av9d else ASFLAGS-.o += -Wa,-Av9a ASFLAGS-.os += -Wa,-Av9a ASFLAGS-.op += -Wa,-Av9a ASFLAGS-.og += -Wa,-Av9a -ASFLAGS-.ob += -Wa,-Av9a ASFLAGS-.oS += -Wa,-Av9a endif diff --git a/libc/sysdeps/sparc/sparc32/sparcv9/backtrace.h b/libc/sysdeps/sparc/sparc32/sparcv9/backtrace.h new file mode 100644 index 000000000..8d6c75671 --- /dev/null +++ b/libc/sysdeps/sparc/sparc32/sparcv9/backtrace.h @@ -0,0 +1,7 @@ +/* Private macros for guiding the backtrace implementation, sparc32 v9 + version. */ + +#define backtrace_flush_register_windows() \ + asm volatile ("flushw") + +#define BACKTRACE_STACK_BIAS 0 diff --git a/libc/sysdeps/sparc/sparc32/sparcv9/bits/atomic.h b/libc/sysdeps/sparc/sparc32/sparcv9/bits/atomic.h index b1a89584f..937d7a149 100644 --- a/libc/sysdeps/sparc/sparc32/sparcv9/bits/atomic.h +++ b/libc/sysdeps/sparc/sparc32/sparcv9/bits/atomic.h @@ -55,10 +55,16 @@ typedef uintmax_t uatomic_max_t; ({ \ __typeof (*(mem)) __acev_tmp; \ __typeof (mem) __acev_mem = (mem); \ - __asm __volatile ("cas [%4], %2, %0" \ - : "=r" (__acev_tmp), "=m" (*__acev_mem) \ - : "r" (oldval), "m" (*__acev_mem), "r" (__acev_mem), \ - "0" (newval) : "memory"); \ + if (__builtin_constant_p (oldval) && (oldval) == 0) \ + __asm __volatile ("cas [%3], %%g0, %0" \ + : "=r" (__acev_tmp), "=m" (*__acev_mem) \ + : "m" (*__acev_mem), "r" (__acev_mem), \ + "0" (newval) : "memory"); \ + else \ + __asm __volatile ("cas [%4], %2, %0" \ + : "=r" (__acev_tmp), "=m" (*__acev_mem) \ + : "r" (oldval), "m" (*__acev_mem), "r" (__acev_mem), \ + "0" (newval) : "memory"); \ __acev_tmp; }) /* This can be implemented if needed. */ diff --git a/libc/sysdeps/sparc/sparc64/Makefile b/libc/sysdeps/sparc/sparc64/Makefile index 2b7b83035..fb161ea13 100644 --- a/libc/sysdeps/sparc/sparc64/Makefile +++ b/libc/sysdeps/sparc/sparc64/Makefile @@ -12,6 +12,5 @@ ASFLAGS-.o += -Wa,-Av9d ASFLAGS-.os += -Wa,-Av9d ASFLAGS-.op += -Wa,-Av9d ASFLAGS-.og += -Wa,-Av9d -ASFLAGS-.ob += -Wa,-Av9d ASFLAGS-.oS += -Wa,-Av9d endif diff --git a/libc/sysdeps/sparc/sparc64/backtrace.c b/libc/sysdeps/sparc/sparc64/backtrace.c deleted file mode 100644 index 230ca1fa2..000000000 --- a/libc/sysdeps/sparc/sparc64/backtrace.c +++ /dev/null @@ -1,57 +0,0 @@ -/* Return backtrace of current program state. - Copyright (C) 2008-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by David S. Miller <davem@davemloft.net> - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If - not, see <http://www.gnu.org/licenses/>. */ - -#include <execinfo.h> -#include <stddef.h> -#include <bp-checks.h> -#include <sysdep.h> - -struct layout -{ - unsigned long locals[8]; - unsigned long ins[6]; - unsigned long next; - void *__unbounded return_address; -}; - -int -__backtrace (void **array, int size) -{ - struct layout *current; - unsigned long fp; - int count; - - asm volatile ("flushw"); - asm volatile ("mov %%fp, %0" : "=r"(fp)); - current = (struct layout *__unbounded) (fp + STACK_BIAS); - current = BOUNDED_1 (current); - - for (count = 0; count < size; count++) - { - array[count] = current->return_address; - if (!current->next) - break; - current = (struct layout *__unbounded) (current->next + STACK_BIAS); - current = BOUNDED_1 (current); - } - - return count; -} -weak_alias (__backtrace, backtrace) -libc_hidden_def (__backtrace) diff --git a/libc/sysdeps/sparc/sparc64/backtrace.h b/libc/sysdeps/sparc/sparc64/backtrace.h new file mode 100644 index 000000000..b9c95c51c --- /dev/null +++ b/libc/sysdeps/sparc/sparc64/backtrace.h @@ -0,0 +1,7 @@ +/* Private macros for guiding the backtrace implementation, sparc64 + version. */ + +#define backtrace_flush_register_windows() \ + asm volatile ("flushw") + +#define BACKTRACE_STACK_BIAS STACK_BIAS diff --git a/libc/sysdeps/sparc/sparc64/bits/atomic.h b/libc/sysdeps/sparc/sparc64/bits/atomic.h index 0afbb4ba5..96611de42 100644 --- a/libc/sysdeps/sparc/sparc64/bits/atomic.h +++ b/libc/sysdeps/sparc/sparc64/bits/atomic.h @@ -55,20 +55,32 @@ typedef uintmax_t uatomic_max_t; ({ \ __typeof (*(mem)) __acev_tmp; \ __typeof (mem) __acev_mem = (mem); \ - __asm __volatile ("cas [%4], %2, %0" \ - : "=r" (__acev_tmp), "=m" (*__acev_mem) \ - : "r" (oldval), "m" (*__acev_mem), "r" (__acev_mem), \ - "0" (newval) : "memory"); \ + if (__builtin_constant_p (oldval) && (oldval) == 0) \ + __asm __volatile ("cas [%3], %%g0, %0" \ + : "=r" (__acev_tmp), "=m" (*__acev_mem) \ + : "m" (*__acev_mem), "r" (__acev_mem), \ + "0" (newval) : "memory"); \ + else \ + __asm __volatile ("cas [%4], %2, %0" \ + : "=r" (__acev_tmp), "=m" (*__acev_mem) \ + : "r" (oldval), "m" (*__acev_mem), "r" (__acev_mem), \ + "0" (newval) : "memory"); \ __acev_tmp; }) #define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \ ({ \ __typeof (*(mem)) __acev_tmp; \ __typeof (mem) __acev_mem = (mem); \ - __asm __volatile ("casx [%4], %2, %0" \ - : "=r" (__acev_tmp), "=m" (*__acev_mem) \ - : "r" ((long) (oldval)), "m" (*__acev_mem), \ - "r" (__acev_mem), "0" ((long) (newval)) : "memory"); \ + if (__builtin_constant_p (oldval) && (oldval) == 0) \ + __asm __volatile ("casx [%3], %%g0, %0" \ + : "=r" (__acev_tmp), "=m" (*__acev_mem) \ + : "m" (*__acev_mem), "r" (__acev_mem), \ + "0" ((long) (newval)) : "memory"); \ + else \ + __asm __volatile ("casx [%4], %2, %0" \ + : "=r" (__acev_tmp), "=m" (*__acev_mem) \ + : "r" ((long) (oldval)), "m" (*__acev_mem), \ + "r" (__acev_mem), "0" ((long) (newval)) : "memory"); \ __acev_tmp; }) #define atomic_exchange_acq(mem, newvalue) \ diff --git a/libc/sysdeps/sparc/sparc64/memchr.S b/libc/sysdeps/sparc/sparc64/memchr.S index ee700b6e2..0cd2573a0 100644 --- a/libc/sysdeps/sparc/sparc64/memchr.S +++ b/libc/sysdeps/sparc/sparc64/memchr.S @@ -256,7 +256,4 @@ ENTRY(__memchr) END(__memchr) weak_alias (__memchr, memchr) -#if !__BOUNDED_POINTERS__ -weak_alias (__memchr, __ubp_memchr) -#endif libc_hidden_builtin_def (memchr) |