diff options
Diffstat (limited to 'libc/sysdeps')
40 files changed, 467 insertions, 170 deletions
diff --git a/libc/sysdeps/gnu/configure b/libc/sysdeps/gnu/configure index 70aaa9019..e7f0e4395 100644 --- a/libc/sysdeps/gnu/configure +++ b/libc/sysdeps/gnu/configure @@ -1,4 +1,4 @@ -# This file is generated from configure.in by Autoconf. DO NOT EDIT! +# This file is generated from configure.ac by Autoconf. DO NOT EDIT! # Local configure fragment for sysdeps/gnu. diff --git a/libc/sysdeps/gnu/configure.in b/libc/sysdeps/gnu/configure.ac index ce251df0c..ce251df0c 100644 --- a/libc/sysdeps/gnu/configure.in +++ b/libc/sysdeps/gnu/configure.ac diff --git a/libc/sysdeps/i386/configure b/libc/sysdeps/i386/configure index 53b6a619d..5dcc15990 100755 --- a/libc/sysdeps/i386/configure +++ b/libc/sysdeps/i386/configure @@ -29,7 +29,7 @@ $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile -# This file is generated from configure.in by Autoconf. DO NOT EDIT! +# This file is generated from configure.ac by Autoconf. DO NOT EDIT! # Local configure fragment for sysdeps/i386. # We no longer support i386 since it lacks the atomic instructions diff --git a/libc/sysdeps/i386/configure.in b/libc/sysdeps/i386/configure.ac index 96ab7b0f5..96ab7b0f5 100644 --- a/libc/sysdeps/i386/configure.in +++ b/libc/sysdeps/i386/configure.ac diff --git a/libc/sysdeps/ieee754/dbl-64/sincos32.c b/libc/sysdeps/ieee754/dbl-64/sincos32.c index f253b8ce8..49aa14895 100644 --- a/libc/sysdeps/ieee754/dbl-64/sincos32.c +++ b/libc/sysdeps/ieee754/dbl-64/sincos32.c @@ -147,10 +147,9 @@ __sin32 (double x, double res, double res1) __dbl_mp (x, &c, p); /* c = x */ __sub (&b, &c, &a, p); /* if a > 0 return min (res, res1), otherwise return max (res, res1). */ - if (a.d[0] > 0) - return (res < res1) ? res : res1; - else - return (res > res1) ? res : res1; + if ((a.d[0] > 0 && res >= res1) || (a.d[0] <= 0 && res <= res1)) + res = res1; + return res; } /* Receive double x and two double results of cos(x) and return result which is @@ -181,10 +180,9 @@ __cos32 (double x, double res, double res1) __dbl_mp (x, &c, p); /* c = x */ __sub (&b, &c, &a, p); /* if a > 0 return max (res, res1), otherwise return min (res, res1). */ - if (a.d[0] > 0) - return (res > res1) ? res : res1; - else - return (res < res1) ? res : res1; + if ((a.d[0] > 0 && res <= res1) || (a.d[0] <= 0 && res >= res1)) + res = res1; + return res; } /* Compute sin() of double-length number (X + DX) as Multi Precision number and diff --git a/libc/sysdeps/ieee754/ldbl-opt/configure b/libc/sysdeps/ieee754/ldbl-opt/configure index 6e69038b9..ad9d77b88 100755 --- a/libc/sysdeps/ieee754/ldbl-opt/configure +++ b/libc/sysdeps/ieee754/ldbl-opt/configure @@ -1,4 +1,4 @@ -# This file is generated from configure.in by Autoconf. DO NOT EDIT! +# This file is generated from configure.ac by Autoconf. DO NOT EDIT! # Local configure fragment for sysdeps/ieee754/ldbl-opt/. diff --git a/libc/sysdeps/ieee754/ldbl-opt/configure.in b/libc/sysdeps/ieee754/ldbl-opt/configure.ac index a77fadd1c..a77fadd1c 100644 --- a/libc/sysdeps/ieee754/ldbl-opt/configure.in +++ b/libc/sysdeps/ieee754/ldbl-opt/configure.ac diff --git a/libc/sysdeps/mach/configure b/libc/sysdeps/mach/configure index 3af372560..61ac7d968 100644 --- a/libc/sysdeps/mach/configure +++ b/libc/sysdeps/mach/configure @@ -65,7 +65,7 @@ $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_preproc -# This file is generated from configure.in by Autoconf. DO NOT EDIT! +# This file is generated from configure.ac by Autoconf. DO NOT EDIT! if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mig", so it can be a program name with args. diff --git a/libc/sysdeps/mach/configure.in b/libc/sysdeps/mach/configure.ac index db85f47ea..db85f47ea 100644 --- a/libc/sysdeps/mach/configure.in +++ b/libc/sysdeps/mach/configure.ac diff --git a/libc/sysdeps/mach/hurd/configure b/libc/sysdeps/mach/hurd/configure index 84948a549..a0f97217e 100755 --- a/libc/sysdeps/mach/hurd/configure +++ b/libc/sysdeps/mach/hurd/configure @@ -1,4 +1,4 @@ -# This file is generated from configure.in by Autoconf. DO NOT EDIT! +# This file is generated from configure.ac by Autoconf. DO NOT EDIT! $as_echo "#define NO_HIDDEN 1" >>confdefs.h diff --git a/libc/sysdeps/mach/hurd/configure.in b/libc/sysdeps/mach/hurd/configure.ac index ad915a568..ad915a568 100644 --- a/libc/sysdeps/mach/hurd/configure.in +++ b/libc/sysdeps/mach/hurd/configure.ac diff --git a/libc/sysdeps/posix/getaddrinfo.c b/libc/sysdeps/posix/getaddrinfo.c index 0f4b88514..8ff74b496 100644 --- a/libc/sysdeps/posix/getaddrinfo.c +++ b/libc/sysdeps/posix/getaddrinfo.c @@ -197,7 +197,22 @@ gaih_inet_serv (const char *servicename, const struct gaih_typeproto *tp, &rc, &herrno, NULL, &localcanon)); \ if (rc != ERANGE || herrno != NETDB_INTERNAL) \ break; \ - tmpbuf = extend_alloca (tmpbuf, tmpbuflen, 2 * tmpbuflen); \ + if (!malloc_tmpbuf && __libc_use_alloca (alloca_used + 2 * tmpbuflen)) \ + tmpbuf = extend_alloca_account (tmpbuf, tmpbuflen, 2 * tmpbuflen, \ + alloca_used); \ + else \ + { \ + char *newp = realloc (malloc_tmpbuf ? tmpbuf : NULL, \ + 2 * tmpbuflen); \ + if (newp == NULL) \ + { \ + result = -EAI_MEMORY; \ + goto free_and_return; \ + } \ + tmpbuf = newp; \ + malloc_tmpbuf = true; \ + tmpbuflen = 2 * tmpbuflen; \ + } \ } \ if (status == NSS_STATUS_SUCCESS && rc == 0) \ h = &th; \ @@ -209,7 +224,8 @@ gaih_inet_serv (const char *servicename, const struct gaih_typeproto *tp, { \ __set_h_errno (herrno); \ _res.options |= old_res_options & RES_USE_INET6; \ - return -EAI_SYSTEM; \ + result = -EAI_SYSTEM; \ + goto free_and_return; \ } \ if (herrno == TRY_AGAIN) \ no_data = EAI_AGAIN; \ @@ -1666,13 +1682,13 @@ rfc3484_sort (const void *p1, const void *p2, void *arg) /* Fill in the results in all the records. */ for (int i = 0; i < src->nresults; ++i) - if (src->results[i].index == a1_index) + if (a1_index != -1 && src->results[i].index == a1_index) { assert (src->results[i].native == -1 || src->results[i].native == a1_native); src->results[i].native = a1_native; } - else if (src->results[i].index == a2_index) + else if (a2_index != -1 && src->results[i].index == a2_index) { assert (src->results[i].native == -1 || src->results[i].native == a2_native); @@ -2532,7 +2548,14 @@ getaddrinfo (const char *name, const char *service, tmp.addr[0] = 0; tmp.addr[1] = 0; tmp.addr[2] = htonl (0xffff); - tmp.addr[3] = sinp->sin_addr.s_addr; + /* Special case for lo interface, the source address + being possibly different than the interface + address. */ + if ((ntohl(sinp->sin_addr.s_addr) & 0xff000000) + == 0x7f000000) + tmp.addr[3] = htonl(0x7f000001); + else + tmp.addr[3] = sinp->sin_addr.s_addr; } else { diff --git a/libc/sysdeps/powerpc/configure b/libc/sysdeps/powerpc/configure index 4afbc29ab..fccee659a 100755 --- a/libc/sysdeps/powerpc/configure +++ b/libc/sysdeps/powerpc/configure @@ -1,4 +1,4 @@ -# This file is generated from configure.in by Autoconf. DO NOT EDIT! +# This file is generated from configure.ac by Autoconf. DO NOT EDIT! # Local configure fragment for sysdeps/powerpc. # Accept binutils which knows about ".machine". diff --git a/libc/sysdeps/powerpc/configure.in b/libc/sysdeps/powerpc/configure.ac index 28cc85934..28cc85934 100644 --- a/libc/sysdeps/powerpc/configure.in +++ b/libc/sysdeps/powerpc/configure.ac diff --git a/libc/sysdeps/powerpc/powerpc32/configure b/libc/sysdeps/powerpc/powerpc32/configure index 31c571d9a..fe5a79234 100644 --- a/libc/sysdeps/powerpc/powerpc32/configure +++ b/libc/sysdeps/powerpc/powerpc32/configure @@ -1,4 +1,4 @@ -# This file is generated from configure.in by Autoconf. DO NOT EDIT! +# This file is generated from configure.ac by Autoconf. DO NOT EDIT! # Local configure fragment for sysdeps/powerpc/powerpc32. # See whether gas has R_PPC_REL16 relocs. diff --git a/libc/sysdeps/powerpc/powerpc32/configure.in b/libc/sysdeps/powerpc/powerpc32/configure.ac index 21d3f5ee5..21d3f5ee5 100644 --- a/libc/sysdeps/powerpc/powerpc32/configure.in +++ b/libc/sysdeps/powerpc/powerpc32/configure.ac diff --git a/libc/sysdeps/powerpc/powerpc64/configure b/libc/sysdeps/powerpc/powerpc64/configure index 5ddac5592..92ec607e0 100644 --- a/libc/sysdeps/powerpc/powerpc64/configure +++ b/libc/sysdeps/powerpc/powerpc64/configure @@ -1,4 +1,4 @@ -# This file is generated from configure.in by Autoconf. DO NOT EDIT! +# This file is generated from configure.ac by Autoconf. DO NOT EDIT! # Local configure fragment for sysdeps/powerpc/powerpc64. # The Aix ld uses global .symbol_names instead of symbol_names diff --git a/libc/sysdeps/powerpc/powerpc64/configure.in b/libc/sysdeps/powerpc/powerpc64/configure.ac index 67aac663d..67aac663d 100644 --- a/libc/sysdeps/powerpc/powerpc64/configure.in +++ b/libc/sysdeps/powerpc/powerpc64/configure.ac diff --git a/libc/sysdeps/powerpc/powerpc64/power7/stpcpy.S b/libc/sysdeps/powerpc/powerpc64/power7/stpcpy.S new file mode 100644 index 000000000..727dd06e7 --- /dev/null +++ b/libc/sysdeps/powerpc/powerpc64/power7/stpcpy.S @@ -0,0 +1,24 @@ +/* Optimized stpcpy implementation for PowerPC64/POWER7. + Copyright (C) 2013 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 USE_AS_STPCPY +#include <sysdeps/powerpc/powerpc64/power7/strcpy.S> + +weak_alias (__stpcpy, stpcpy) +libc_hidden_def (__stpcpy) +libc_hidden_builtin_def (stpcpy) diff --git a/libc/sysdeps/powerpc/powerpc64/power7/strcpy.S b/libc/sysdeps/powerpc/powerpc64/power7/strcpy.S new file mode 100644 index 000000000..5c341a148 --- /dev/null +++ b/libc/sysdeps/powerpc/powerpc64/power7/strcpy.S @@ -0,0 +1,274 @@ +/* Optimized strcpy/stpcpy implementation for PowerPC64/POWER7. + Copyright (C) 2013 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/>. */ + +#include <sysdep.h> + +/* Implements the function + + char * [r3] strcpy (char *dest [r3], const char *src [r4]) + + or + + char * [r3] strcpy (char *dest [r3], const char *src [r4]) + + if USE_AS_STPCPY is defined. It tries to use aligned memory accesses + when possible using the following algorithm: + + if (((((uintptr_t)dst & 0x7UL) == 0) && ((uintptr_t)src & 0x7UL) == 0)) + goto aligned_doubleword_copy; + if (((((uintptr_t)dst & 0x3UL) == 0) && ((uintptr_t)src & 0x3UL) == 0)) + goto aligned_word_copy; + if (((uintptr_t)dst & 0x7UL) == ((uintptr_t)src & 0x7UL)) + goto same_alignment; + goto unaligned; + + The aligned comparison are made using cmpb instructions. */ + +#ifdef USE_AS_STPCPY +# define FUNC_NAME __stpcpy +#else +# define FUNC_NAME strcpy +#endif + + .machine power7 +EALIGN (FUNC_NAME, 4, 0) + CALL_MCOUNT 2 + +#define rTMP r0 +#ifdef USE_AS_STPCPY +#define rRTN r3 /* pointer to previous word/doubleword in dest */ +#else +#define rRTN r12 /* pointer to previous word/doubleword in dest */ +#endif +#define rSRC r4 /* pointer to previous word/doubleword in src */ +#define rMASK r5 /* mask 0xffffffff | 0xffffffffffffffff */ +#define rWORD r6 /* current word from src */ +#define rALT r7 /* alternate word from src */ +#define rRTNAL r8 /* alignment of return pointer */ +#define rSRCAL r9 /* alignment of source pointer */ +#define rALCNT r10 /* bytes to read to reach 8 bytes alignment */ +#define rSUBAL r11 /* doubleword minus unaligned displacement */ + +#ifndef USE_AS_STPCPY +/* Save the dst pointer to use as return value. */ + mr rRTN, r3 +#endif + or rTMP, rSRC, rRTN + clrldi. rTMP, rTMP, 61 + bne L(check_word_alignment) + b L(aligned_doubleword_copy) + +L(same_alignment): +/* Src and dst with same alignment: align both to doubleword. */ + mr rALCNT, rRTN + lbz rWORD, 0(rSRC) + subfic rSUBAL, rRTNAL, 8 + addi rRTN, rRTN, 1 + addi rSRC, rSRC, 1 + cmpdi cr7, rWORD, 0 + stb rWORD, 0(rALCNT) + beq cr7, L(s2) + + add rALCNT, rALCNT, rSUBAL + subf rALCNT, rRTN, rALCNT + addi rALCNT, rALCNT, 1 + mtctr rALCNT + b L(s1) + + .align 4 +L(s0): + addi rSRC, rSRC, 1 + lbz rWORD, -1(rSRC) + cmpdi cr7, rWORD, 0 + stb rWORD, -1(rALCNT) + beqlr cr7 + mr rRTN, rALCNT +L(s1): + addi rALCNT, rRTN,1 + bdnz L(s0) + b L(aligned_doubleword_copy) + .align 4 +L(s2): + mr rRTN, rALCNT + blr + +/* For doubleword aligned memory, operate using doubleword load and stores. */ + .align 4 +L(aligned_doubleword_copy): + li rMASK, 0 + addi rRTN, rRTN, -8 + ld rWORD, 0(rSRC) + b L(g2) + + .align 4 +L(g0): ldu rALT, 8(rSRC) + stdu rWORD, 8(rRTN) + cmpb rTMP, rALT, rMASK + cmpdi rTMP, 0 + bne L(g1) + ldu rWORD, 8(rSRC) + stdu rALT, 8(rRTN) +L(g2): cmpb rTMP, rWORD, rMASK + cmpdi rTMP, 0 /* If rTMP is 0, no null's have been found. */ + beq L(g0) + + mr rALT, rWORD +/* We've hit the end of the string. Do the rest byte-by-byte. */ +L(g1): +#ifdef __LITTLE_ENDIAN__ + extrdi. rTMP, rALT, 8, 56 + stbu rALT, 8(rRTN) + beqlr- + extrdi. rTMP, rALT, 8, 48 + stbu rTMP, 1(rRTN) + beqlr- + extrdi. rTMP, rALT, 8, 40 + stbu rTMP, 1(rRTN) + beqlr- + extrdi. rTMP, rALT, 8, 32 + stbu rTMP, 1(rRTN) + beqlr- + extrdi. rTMP, rALT, 8, 24 + stbu rTMP, 1(rRTN) + beqlr- + extrdi. rTMP, rALT, 8, 16 + stbu rTMP, 1(rRTN) + beqlr- + extrdi. rTMP, rALT, 8, 8 + stbu rTMP, 1(rRTN) + beqlr- + extrdi rTMP, rALT, 8, 0 + stbu rTMP, 1(rRTN) +#else + extrdi. rTMP, rALT, 8, 0 + stbu rTMP, 8(rRTN) + beqlr + extrdi. rTMP, rALT, 8, 8 + stbu rTMP, 1(rRTN) + beqlr + extrdi. rTMP, rALT, 8, 16 + stbu rTMP, 1(rRTN) + beqlr + extrdi. rTMP, rALT, 8, 24 + stbu rTMP, 1(rRTN) + beqlr + extrdi. rTMP, rALT, 8, 32 + stbu rTMP, 1(rRTN) + beqlr + extrdi. rTMP, rALT, 8, 40 + stbu rTMP, 1(rRTN) + beqlr + extrdi. rTMP, rALT, 8, 48 + stbu rTMP, 1(rRTN) + beqlr + stbu rALT, 1(rRTN) +#endif + blr + +L(check_word_alignment): + clrldi. rTMP, rTMP, 62 + beq L(aligned_word_copy) + rldicl rRTNAL, rRTN, 0, 61 + rldicl rSRCAL, rSRC, 0, 61 + cmpld cr7, rSRCAL, rRTNAL + beq cr7, L(same_alignment) + b L(unaligned) + +/* For word aligned memory, operate using word load and stores. */ + .align 4 +L(aligned_word_copy): + li rMASK, 0 + addi rRTN, rRTN, -4 + lwz rWORD, 0(rSRC) + b L(g5) + + .align 4 +L(g3): lwzu rALT, 4(rSRC) + stwu rWORD, 4(rRTN) + cmpb rTMP, rALT, rMASK + cmpwi rTMP, 0 + bne L(g4) + lwzu rWORD, 4(rSRC) + stwu rALT, 4(rRTN) +L(g5): cmpb rTMP, rWORD, rMASK + cmpwi rTMP, 0 /* If rTMP is 0, no null in word. */ + beq L(g3) + + mr rALT, rWORD +/* We've hit the end of the string. Do the rest byte-by-byte. */ +L(g4): +#ifdef __LITTLE_ENDIAN__ + rlwinm. rTMP, rALT, 0, 24, 31 + stbu rALT, 4(rRTN) + beqlr- + rlwinm. rTMP, rALT, 24, 24, 31 + stbu rTMP, 1(rRTN) + beqlr- + rlwinm. rTMP, rALT, 16, 24, 31 + stbu rTMP, 1(rRTN) + beqlr- + rlwinm rTMP, rALT, 8, 24, 31 + stbu rTMP, 1(rRTN) +#else + rlwinm. rTMP, rALT, 8, 24, 31 + stbu rTMP, 4(rRTN) + beqlr + rlwinm. rTMP, rALT, 16, 24, 31 + stbu rTMP, 1(rRTN) + beqlr + rlwinm. rTMP, rALT, 24, 24, 31 + stbu rTMP, 1(rRTN) + beqlr + stbu rALT, 1(rRTN) +#endif + blr + +/* Oh well. In this case, we just do a byte-by-byte copy. */ + .align 4 +L(unaligned): + lbz rWORD, 0(rSRC) + addi rRTN, rRTN, -1 + cmpdi rWORD, 0 + beq L(u2) + + .align 5 +L(u0): lbzu rALT, 1(rSRC) + stbu rWORD, 1(rRTN) + cmpdi rALT, 0 + beq L(u1) + lbzu rWORD, 1(rSRC) + stbu rALT, 1(rRTN) + cmpdi rWORD, 0 + beq L(u2) + lbzu rALT, 1(rSRC) + stbu rWORD, 1(rRTN) + cmpdi rALT, 0 + beq L(u1) + lbzu rWORD, 1(rSRC) + stbu rALT, 1(rRTN) + cmpdi rWORD, 0 + bne L(u0) +L(u2): stbu rWORD, 1(rRTN) + blr +L(u1): stbu rALT, 1(rRTN) + blr +END (FUNC_NAME) + +#ifndef USE_AS_STPCPY +libc_hidden_builtin_def (strcpy) +#endif diff --git a/libc/sysdeps/powerpc/powerpc64/stpcpy.S b/libc/sysdeps/powerpc/powerpc64/stpcpy.S index c0b39729e..09aa3be6b 100644 --- a/libc/sysdeps/powerpc/powerpc64/stpcpy.S +++ b/libc/sysdeps/powerpc/powerpc64/stpcpy.S @@ -16,103 +16,8 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ -#include <sysdep.h> - -/* See strlen.s for comments on how the end-of-string testing works. */ - -/* char * [r3] stpcpy (char *dest [r3], const char *src [r4]) */ - -EALIGN (__stpcpy, 4, 0) - CALL_MCOUNT 2 - -#define rTMP r0 -#define rRTN r3 -#define rDEST r3 /* pointer to previous word in dest */ -#define rSRC r4 /* pointer to previous word in src */ -#define rWORD r6 /* current word from src */ -#define rFEFE r7 /* 0xfefefeff */ -#define r7F7F r8 /* 0x7f7f7f7f */ -#define rNEG r9 /* ~(word in src | 0x7f7f7f7f) */ -#define rALT r10 /* alternate word from src */ - - or rTMP, rSRC, rDEST - clrldi. rTMP, rTMP, 62 - addi rDEST, rDEST, -4 - bne L(unaligned) - - lis rFEFE, -0x101 - lis r7F7F, 0x7f7f - lwz rWORD, 0(rSRC) - addi rFEFE, rFEFE, -0x101 - addi r7F7F, r7F7F, 0x7f7f - b L(g2) - -L(g0): lwzu rALT, 4(rSRC) - stwu rWORD, 4(rDEST) - add rTMP, rFEFE, rALT - nor rNEG, r7F7F, rALT - and. rTMP, rTMP, rNEG - bne- L(g1) - lwzu rWORD, 4(rSRC) - stwu rALT, 4(rDEST) -L(g2): add rTMP, rFEFE, rWORD - nor rNEG, r7F7F, rWORD - and. rTMP, rTMP, rNEG - beq+ L(g0) - - mr rALT, rWORD -/* We've hit the end of the string. Do the rest byte-by-byte. */ -L(g1): -#ifdef __LITTLE_ENDIAN__ - rlwinm. rTMP, rALT, 0, 24, 31 - stbu rALT, 4(rDEST) - beqlr- - rlwinm. rTMP, rALT, 24, 24, 31 - stbu rTMP, 1(rDEST) - beqlr- - rlwinm. rTMP, rALT, 16, 24, 31 - stbu rTMP, 1(rDEST) - beqlr- - rlwinm rTMP, rALT, 8, 24, 31 - stbu rTMP, 1(rDEST) - blr -#else - rlwinm. rTMP, rALT, 8, 24, 31 - stbu rTMP, 4(rDEST) - beqlr- - rlwinm. rTMP, rALT, 16, 24, 31 - stbu rTMP, 1(rDEST) - beqlr- - rlwinm. rTMP, rALT, 24, 24, 31 - stbu rTMP, 1(rDEST) - beqlr- - stbu rALT, 1(rDEST) - blr -#endif - -/* Oh well. In this case, we just do a byte-by-byte copy. */ - .align 4 - nop -L(unaligned): - lbz rWORD, 0(rSRC) - addi rDEST, rDEST, 3 - cmpwi rWORD, 0 - beq- L(u2) - -L(u0): lbzu rALT, 1(rSRC) - stbu rWORD, 1(rDEST) - cmpwi rALT, 0 - beq- L(u1) - nop /* Let 601 load start of loop. */ - lbzu rWORD, 1(rSRC) - stbu rALT, 1(rDEST) - cmpwi rWORD, 0 - bne+ L(u0) -L(u2): stbu rWORD, 1(rDEST) - blr -L(u1): stbu rALT, 1(rDEST) - blr -END (__stpcpy) +#define USE_AS_STPCPY +#include <sysdeps/powerpc/powerpc64/strcpy.S> weak_alias (__stpcpy, stpcpy) libc_hidden_def (__stpcpy) diff --git a/libc/sysdeps/powerpc/powerpc64/strcpy.S b/libc/sysdeps/powerpc/powerpc64/strcpy.S index a7fd85bad..793325d7b 100644 --- a/libc/sysdeps/powerpc/powerpc64/strcpy.S +++ b/libc/sysdeps/powerpc/powerpc64/strcpy.S @@ -22,25 +22,38 @@ /* char * [r3] strcpy (char *dest [r3], const char *src [r4]) */ -EALIGN (strcpy, 4, 0) +#ifdef USE_AS_STPCPY +# define FUNC_NAME __stpcpy +#else +# define FUNC_NAME strcpy +#endif + +EALIGN (FUNC_NAME, 4, 0) CALL_MCOUNT 2 #define rTMP r0 -#define rRTN r3 /* incoming DEST arg preserved as result */ -#define rSRC r4 /* pointer to previous word in src */ -#define rDEST r5 /* pointer to previous word in dest */ +#ifdef USE_AS_STPCPY +#define rRTN r3 /* pointer to previous word/doubleword in dest */ +#else +#define rRTN r12 /* pointer to previous word/doubleword in dest */ +#endif +#define rSRC r4 /* pointer to previous word/doubleword in src */ #define rWORD r6 /* current word from src */ -#define rFEFE r7 /* constant 0xfefefefefefefeff (-0x0101010101010101) */ -#define r7F7F r8 /* constant 0x7f7f7f7f7f7f7f7f */ -#define rNEG r9 /* ~(word in s1 | 0x7f7f7f7f7f7f7f7f) */ +#define rFEFE r7 /* constant 0xfefefeff | 0xfefefefefefefeff */ +#define r7F7F r8 /* constant 0x7f7f7f7f | 0x7f7f7f7f7f7f7f7f */ +#define rNEG r9 /* ~(word in s1 | r7F7F) */ #define rALT r10 /* alternate word from src */ - dcbt 0,rSRC +#ifndef USE_AS_STPCPY +/* Save the dst pointer to use as return value. */ + mr rRTN, r3 +#endif or rTMP, rSRC, rRTN clrldi. rTMP, rTMP, 61 - addi rDEST, rRTN, -8 - dcbtst 0,rRTN - bne L(unaligned) + bne L(check_word_alignment) + +/* For doubleword aligned memory, operate using doubleword load and stores. */ + addi rRTN, rRTN, -8 lis rFEFE, -0x101 lis r7F7F, 0x7f7f @@ -53,13 +66,13 @@ EALIGN (strcpy, 4, 0) b L(g2) L(g0): ldu rALT, 8(rSRC) - stdu rWORD, 8(rDEST) + stdu rWORD, 8(rRTN) add rTMP, rFEFE, rALT nor rNEG, r7F7F, rALT and. rTMP, rTMP, rNEG bne- L(g1) ldu rWORD, 8(rSRC) - stdu rALT, 8(rDEST) + stdu rALT, 8(rRTN) L(g2): add rTMP, rFEFE, rWORD nor rNEG, r7F7F, rWORD and. rTMP, rTMP, rNEG @@ -70,77 +83,134 @@ L(g2): add rTMP, rFEFE, rWORD L(g1): #ifdef __LITTLE_ENDIAN__ extrdi. rTMP, rALT, 8, 56 - stb rALT, 8(rDEST) + stbu rALT, 8(rRTN) beqlr- extrdi. rTMP, rALT, 8, 48 - stb rTMP, 9(rDEST) + stbu rTMP, 1(rRTN) beqlr- extrdi. rTMP, rALT, 8, 40 - stb rTMP, 10(rDEST) + stbu rTMP, 1(rRTN) beqlr- extrdi. rTMP, rALT, 8, 32 - stb rTMP, 11(rDEST) + stbu rTMP, 1(rRTN) beqlr- extrdi. rTMP, rALT, 8, 24 - stb rTMP, 12(rDEST) + stbu rTMP, 1(rRTN) beqlr- extrdi. rTMP, rALT, 8, 16 - stb rTMP, 13(rDEST) + stbu rTMP, 1(rRTN) beqlr- extrdi. rTMP, rALT, 8, 8 - stb rTMP, 14(rDEST) + stbu rTMP, 1(rRTN) beqlr- extrdi rTMP, rALT, 8, 0 - stb rTMP, 15(rDEST) - blr + stbu rTMP, 1(rRTN) #else extrdi. rTMP, rALT, 8, 0 - stb rTMP, 8(rDEST) + stbu rTMP, 8(rRTN) beqlr- extrdi. rTMP, rALT, 8, 8 - stb rTMP, 9(rDEST) + stbu rTMP, 1(rRTN) beqlr- extrdi. rTMP, rALT, 8, 16 - stb rTMP, 10(rDEST) + stbu rTMP, 1(rRTN) beqlr- extrdi. rTMP, rALT, 8, 24 - stb rTMP, 11(rDEST) + stbu rTMP, 1(rRTN) beqlr- extrdi. rTMP, rALT, 8, 32 - stb rTMP, 12(rDEST) - beqlr- + stbu rTMP, 1(rRTN) + beqlr extrdi. rTMP, rALT, 8, 40 - stb rTMP, 13(rDEST) + stbu rTMP, 1(rRTN) beqlr- extrdi. rTMP, rALT, 8, 48 - stb rTMP, 14(rDEST) + stbu rTMP, 1(rRTN) beqlr- - stb rALT, 15(rDEST) + stbu rALT, 1(rRTN) +#endif blr + +L(check_word_alignment): + clrldi. rTMP, rTMP, 62 + bne L(unaligned) + +/* For word aligned memory, operate using word load and stores. */ + addi rRTN, rRTN, -4 + + lis rFEFE, -0x101 + lis r7F7F, 0x7f7f + lwz rWORD, 0(rSRC) + addi rFEFE, rFEFE, -0x101 + addi r7F7F, r7F7F, 0x7f7f + b L(g5) + +L(g3): lwzu rALT, 4(rSRC) + stwu rWORD, 4(rRTN) + add rTMP, rFEFE, rALT + nor rNEG, r7F7F, rALT + and. rTMP, rTMP, rNEG + bne- L(g4) + lwzu rWORD, 4(rSRC) + stwu rALT, 4(rRTN) +L(g5): add rTMP, rFEFE, rWORD + nor rNEG, r7F7F, rWORD + and. rTMP, rTMP, rNEG + beq+ L(g3) + + mr rALT, rWORD +/* We've hit the end of the string. Do the rest byte-by-byte. */ +L(g4): +#ifdef __LITTLE_ENDIAN__ + rlwinm. rTMP, rALT, 0, 24, 31 + stbu rALT, 4(rRTN) + beqlr- + rlwinm. rTMP, rALT, 24, 24, 31 + stbu rTMP, 1(rRTN) + beqlr- + rlwinm. rTMP, rALT, 16, 24, 31 + stbu rTMP, 1(rRTN) + beqlr- + rlwinm rTMP, rALT, 8, 24, 31 + stbu rTMP, 1(rRTN) +#else + rlwinm. rTMP, rALT, 8, 24, 31 + stbu rTMP, 4(rRTN) + beqlr- + rlwinm. rTMP, rALT, 16, 24, 31 + stbu rTMP, 1(rRTN) + beqlr- + rlwinm. rTMP, rALT, 24, 24, 31 + stbu rTMP, 1(rRTN) + beqlr- + stbu rALT, 1(rRTN) #endif + blr /* Oh well. In this case, we just do a byte-by-byte copy. */ .align 4 nop L(unaligned): lbz rWORD, 0(rSRC) - addi rDEST, rRTN, -1 + addi rRTN, rRTN, -1 cmpwi rWORD, 0 beq- L(u2) L(u0): lbzu rALT, 1(rSRC) - stbu rWORD, 1(rDEST) + stbu rWORD, 1(rRTN) cmpwi rALT, 0 beq- L(u1) nop /* Let 601 load start of loop. */ lbzu rWORD, 1(rSRC) - stbu rALT, 1(rDEST) + stbu rALT, 1(rRTN) cmpwi rWORD, 0 bne+ L(u0) -L(u2): stb rWORD, 1(rDEST) +L(u2): stbu rWORD, 1(rRTN) blr -L(u1): stb rALT, 1(rDEST) +L(u1): stbu rALT, 1(rRTN) blr +END (FUNC_NAME) -END (strcpy) +#ifndef USE_AS_STPCPY libc_hidden_builtin_def (strcpy) +#endif diff --git a/libc/sysdeps/s390/s390-32/configure b/libc/sysdeps/s390/s390-32/configure index 669bb9be5..024565f85 100644 --- a/libc/sysdeps/s390/s390-32/configure +++ b/libc/sysdeps/s390/s390-32/configure @@ -1,4 +1,4 @@ -# This file is generated from configure.in by Autoconf. DO NOT EDIT! +# This file is generated from configure.ac by Autoconf. DO NOT EDIT! # Local configure fragment for sysdeps/s390. $as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h diff --git a/libc/sysdeps/s390/s390-32/configure.in b/libc/sysdeps/s390/s390-32/configure.ac index b5af4e12f..b5af4e12f 100644 --- a/libc/sysdeps/s390/s390-32/configure.in +++ b/libc/sysdeps/s390/s390-32/configure.ac diff --git a/libc/sysdeps/s390/s390-64/configure b/libc/sysdeps/s390/s390-64/configure index 669bb9be5..024565f85 100644 --- a/libc/sysdeps/s390/s390-64/configure +++ b/libc/sysdeps/s390/s390-64/configure @@ -1,4 +1,4 @@ -# This file is generated from configure.in by Autoconf. DO NOT EDIT! +# This file is generated from configure.ac by Autoconf. DO NOT EDIT! # Local configure fragment for sysdeps/s390. $as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h diff --git a/libc/sysdeps/s390/s390-64/configure.in b/libc/sysdeps/s390/s390-64/configure.ac index b5af4e12f..b5af4e12f 100644 --- a/libc/sysdeps/s390/s390-64/configure.in +++ b/libc/sysdeps/s390/s390-64/configure.ac diff --git a/libc/sysdeps/sh/configure b/libc/sysdeps/sh/configure index b0f3b2fa2..110eb65b0 100644 --- a/libc/sysdeps/sh/configure +++ b/libc/sysdeps/sh/configure @@ -1,4 +1,4 @@ -# This file is generated from configure.in by Autoconf. DO NOT EDIT! +# This file is generated from configure.ac by Autoconf. DO NOT EDIT! # Local configure fragment for sysdeps/sh. $as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h diff --git a/libc/sysdeps/sh/configure.in b/libc/sysdeps/sh/configure.ac index 21400c447..21400c447 100644 --- a/libc/sysdeps/sh/configure.in +++ b/libc/sysdeps/sh/configure.ac diff --git a/libc/sysdeps/sparc/configure b/libc/sysdeps/sparc/configure index 63e02de4a..90a86f6da 100644 --- a/libc/sysdeps/sparc/configure +++ b/libc/sysdeps/sparc/configure @@ -1,4 +1,4 @@ -# This file is generated from configure.in by Autoconf. DO NOT EDIT! +# This file is generated from configure.ac by Autoconf. DO NOT EDIT! # Local configure fragment for sysdeps/sparc. # Check for support of VIS3 et al. instructions in the assembler. diff --git a/libc/sysdeps/sparc/configure.in b/libc/sysdeps/sparc/configure.ac index 982077c9b..982077c9b 100644 --- a/libc/sysdeps/sparc/configure.in +++ b/libc/sysdeps/sparc/configure.ac diff --git a/libc/sysdeps/sparc/sparc32/fpu/s_fdim.S b/libc/sysdeps/sparc/sparc32/fpu/s_fdim.S index 2f0c5ce58..22f69ce51 100644 --- a/libc/sysdeps/sparc/sparc32/fpu/s_fdim.S +++ b/libc/sysdeps/sparc/sparc32/fpu/s_fdim.S @@ -30,7 +30,8 @@ ENTRY(__fdim) fbug 1f st %g0, [%sp + 76] ldd [%sp + 72], %f0 - fnegd %f0, %f2 + fnegs %f0, %f2 + fmovs %f1, %f3 1: retl fsubd %f0, %f2, %f0 END(__fdim) diff --git a/libc/sysdeps/unix/sysv/linux/configure b/libc/sysdeps/unix/sysv/linux/configure index 88fab5662..84dfbb87d 100644 --- a/libc/sysdeps/unix/sysv/linux/configure +++ b/libc/sysdeps/unix/sysv/linux/configure @@ -1,4 +1,4 @@ -# This file is generated from configure.in by Autoconf. DO NOT EDIT! +# This file is generated from configure.ac by Autoconf. DO NOT EDIT! # Local configure fragment for sysdeps/unix/sysv/linux. # Don't bother trying to generate any glue code to be compatible with the diff --git a/libc/sysdeps/unix/sysv/linux/configure.in b/libc/sysdeps/unix/sysv/linux/configure.ac index 5e5902d8e..5e5902d8e 100644 --- a/libc/sysdeps/unix/sysv/linux/configure.in +++ b/libc/sysdeps/unix/sysv/linux/configure.ac diff --git a/libc/sysdeps/unix/sysv/linux/powerpc/configure b/libc/sysdeps/unix/sysv/linux/powerpc/configure index 7df7e481f..50e3639be 100644 --- a/libc/sysdeps/unix/sysv/linux/powerpc/configure +++ b/libc/sysdeps/unix/sysv/linux/powerpc/configure @@ -1,4 +1,4 @@ -# This file is generated from configure.in by Autoconf. DO NOT EDIT! +# This file is generated from configure.ac by Autoconf. DO NOT EDIT! # Local configure fragment for sysdeps/unix/sysv/linux/powerpc/. diff --git a/libc/sysdeps/unix/sysv/linux/powerpc/configure.in b/libc/sysdeps/unix/sysv/linux/powerpc/configure.ac index 1768ab1f9..1768ab1f9 100644 --- a/libc/sysdeps/unix/sysv/linux/powerpc/configure.in +++ b/libc/sysdeps/unix/sysv/linux/powerpc/configure.ac diff --git a/libc/sysdeps/unix/sysv/linux/shm_open.c b/libc/sysdeps/unix/sysv/linux/shm_open.c index 41d93155a..482b49cfe 100644 --- a/libc/sysdeps/unix/sysv/linux/shm_open.c +++ b/libc/sysdeps/unix/sysv/linux/shm_open.c @@ -148,14 +148,15 @@ shm_open (const char *name, int oflag, mode_t mode) while (name[0] == '/') ++name; - if (name[0] == '\0') + namelen = strlen (name); + + /* Validate the filename. */ + if (name[0] == '\0' || namelen > NAME_MAX || strchr (name, '/') == NULL) { - /* The name "/" is not supported. */ __set_errno (EINVAL); return -1; } - namelen = strlen (name); fname = (char *) alloca (mountpoint.dirlen + namelen + 1); __mempcpy (__mempcpy (fname, mountpoint.dir, mountpoint.dirlen), name, namelen + 1); @@ -237,14 +238,15 @@ shm_unlink (const char *name) while (name[0] == '/') ++name; - if (name[0] == '\0') + namelen = strlen (name); + + /* Validate the filename. */ + if (name[0] == '\0' || namelen > NAME_MAX || strchr (name, '/') == NULL) { - /* The name "/" is not supported. */ __set_errno (ENOENT); return -1; } - namelen = strlen (name); fname = (char *) alloca (mountpoint.dirlen + namelen + 1); __mempcpy (__mempcpy (fname, mountpoint.dir, mountpoint.dirlen), name, namelen + 1); diff --git a/libc/sysdeps/x86_64/configure b/libc/sysdeps/x86_64/configure index 923241195..5a83a53aa 100644 --- a/libc/sysdeps/x86_64/configure +++ b/libc/sysdeps/x86_64/configure @@ -29,7 +29,7 @@ $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile -# This file is generated from configure.in by Autoconf. DO NOT EDIT! +# This file is generated from configure.ac by Autoconf. DO NOT EDIT! # Local configure fragment for sysdeps/x86_64. diff --git a/libc/sysdeps/x86_64/configure.in b/libc/sysdeps/x86_64/configure.ac index c682f93c3..c682f93c3 100644 --- a/libc/sysdeps/x86_64/configure.in +++ b/libc/sysdeps/x86_64/configure.ac diff --git a/libc/sysdeps/x86_64/preconfigure b/libc/sysdeps/x86_64/preconfigure index d5abba882..c8f1e0e13 100644 --- a/libc/sysdeps/x86_64/preconfigure +++ b/libc/sysdeps/x86_64/preconfigure @@ -1,4 +1,4 @@ -# This file is generated from configure.in by Autoconf. DO NOT EDIT! +# This file is generated from configure.ac by Autoconf. DO NOT EDIT! # Local preconfigure fragment for sysdeps/x86_64 test -n "$base_machine" || case "$machine" in diff --git a/libc/sysdeps/x86_64/preconfigure.in b/libc/sysdeps/x86_64/preconfigure.ac index 600700ea1..600700ea1 100644 --- a/libc/sysdeps/x86_64/preconfigure.in +++ b/libc/sysdeps/x86_64/preconfigure.ac |