summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Assume that accept4 is always available and worksfw/accept4Florian Weimer2017-04-1414-161/+239
| | | | | | | Simplify the Linux accept4 implementation based on the assumption that it is available in some way. __ASSUME_ACCEPT4_SOCKETCALL was previously unused, so remove it. Its functionality is implied by the complex #if condition in accept4.c.
* Assume that O_CLOEXEC is always defined and worksFlorian Weimer2017-04-1327-576/+96
|
* Assume that dup3 is availableFlorian Weimer2017-04-139-82/+21
|
* Assume that pipe2 is always availableFlorian Weimer2017-04-136-83/+23
| | | | | The Debian patches (which are already required to build glibc before this commit) contain an implementation of pipe2.
* Assume that O_NOFOLLOW is always definedFlorian Weimer2017-04-136-24/+15
|
* resolv: Remove EDNS fallback [BZ #21369]Florian Weimer2017-04-135-64/+77
| | | | | | EDNS is disabled by default (so there is interoperability issue), and the fallback code is problematic because it prevents an application from obtaining DNSSEC data after a FORMERR response.
* resolv: Reduce EDNS payload size to 1200 bytes [BZ #21361]Florian Weimer2017-04-1310-14/+652
| | | | This hardens the stub resolver against fragmentation-based attacks.
* resolv: Support an exactly sized buffer in ns_name_pack [BZ #21359]Florian Weimer2017-04-136-4/+260
| | | | | | | This bug did not affect name resolution because those functions indirectly call ns_name_pack with a buffer which is always larger than the generated query packet, even in the case of the longest-possible domain name.
* resolv: Remove internal and unused definitions from <resolv.h>Florian Weimer2017-04-136-20/+24
| | | | | | | The RES_F_* constants are only used with the private _res._flags member. RES_EXHAUSTIVE is unused. The removed function declarations refer to functions not actually exported by glibc, so they are unusable by applications.
* powerpc: Optimized strncat for POWER8Rajalakshmi Srinivasaraghavan2017-04-135-2/+50
| | | | | | | | | | | | | | | | | | With new optimized strnlen for POWER8 [1], this patch adds strncat for power8 to make use of optimized strlen and strnlen. This is faster than POWER7 current implementation for larger strings. Tested on powerpc64 and powerpc64le. [1] https://sourceware.org/ml/libc-alpha/2017-03/msg00491.html * sysdeps/powerpc/powerpc64/multiarch/Makefile (sysdep_routines): Add strncat-power8. * sysdeps/powerpc/powerpc64/multiarch/strncat.c (strncat): Add __strncat_power8 to ifunc list. * sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c (strncat): Add __strncat_power8 to list of strncat functions. * sysdeps/powerpc/powerpc64/multiarch/strncat-power8.c: New file.
* Consolidate Linux mmap implementation (BZ#21270)Adhemerval Zanella2017-04-1225-584/+275
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch consolidates all Linux mmap implementations on default sysdeps/unix/sysv/linux/mmap{64}.c one. To accomodate all required architecture specific requeriments a new internal header is created (mmap_internal.h) where each architecture add its specific code requirements. Currently only x86_64 (to define MMAP_PREPARE to add MAP_32BITS), s390 (which have a different kernel ABI for mmap), m68k (which have variable minimum page sizes), and MIPS n32 (which zero extend the offset to handle negative one correctly) redefine the new header. The patch also fixes BZ#21270 where default mmap64 on architectures which uses mmap2 silent truncates large offsets value (larger than 1 << (page shift + 8 * sizeof (off_t)) or 1<<44 on architectures with 4096 bytes page size). The new consolidate implementation returns EINVAL as allowed by POSIX. It also adds a tests for on current tst-mmap-offset one. I have run a full make check on x86_64, x86_64-32, i686, aarch64, armhf, powerpc, powerpc64le, sparc64, and sparcv9 without any regressions. I also ran some basic tests (tst-mmap-offset) on sh4, m68k, and on qemu simulated MIPS32 and MIPS64. [BZ #21270] * posix/tst-mmap-offset.c (do_prepare): New function. (do_test): Rename to do_test_bz18877 and use FAIL_RET. (do_test_bz21270): New function. * sysdeps/unix/sysv/linux/aarch64/mmap.c: Remove file. * sysdeps/unix/sysv/linux/arm/mmap.c: Remove file. * sysdeps/unix/sysv/linux/generic/wordsize-32/mmap.c: Likewise. * sysdeps/unix/sysv/linux/hppa/mmap.c: Likewise. * sysdeps/unix/sysv/linux/i386/mmap.c: Likewise. * sysdeps/unix/sysv/linux/m68k/mmap.S: Likewise. * sysdeps/unix/sysv/linux/m68k/mmap64.c: Likewise. * sysdeps/unix/sysv/linux/microblaze/mmap.S: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/mmap.c: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n32/mmap.c: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n64/mmap64.c: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/mmap.S: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/mmap64.S: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/mmap.S: Likewise. * sysdeps/unix/sysv/linux/wordsize-64/mmap.c: Likewise. * sysdeps/unix/sysv/linux/wordsize-64/mmap64.c: Likewise. * sysdeps/unix/sysv/linux/x86_64/64/mmap.c: Likewise. * sysdeps/unix/sysv/linux/mmap_internal.h: New file. * sysdeps/unix/sysv/linux/m68k/mmap_internal.h: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n32/mmap_internal.h: Likewise. * sysdeps/unix/sysv/linux/s390/mmap_internal.h: Likewise. * sysdeps/unix/sysv/linux/x86_64/64/mmap_internal.h: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list: Remove mmap from auto-generation list. * sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/mmap.c: New file. * sysdeps/unix/sysv/linux/mmap64.c (__mmap64): Add check for invalid offsets and support for mmap2 syscall.
* posix: Add cleanup on the trap list for globtest.shAdhemerval Zanella2017-04-122-3/+10
| | | | | | | This patch prevents lingering files for SIGSEGV failures by adding a cleanup handler on trap handler. Checked on x86_64-linux-gnu. * posix/globtest.sh: Add cleanup routine on trap 0.
* powerpc: refactor memcmp and memmove IFUNC.Wainer dos Santos Moschetta2017-04-117-52/+29
| | | | | | | | | | | | | | | | | Clean up the IFUNC implementations for powerpc in order to remove unneeded macro definitions. Tested on ppc64le with and without --disable-multi-arch flag. * sysdeps/powerpc/powerpc64/multiarch/memcmp-power4.S: Define the implementation-specific function name and remove unneeded macros definition. * sysdeps/powerpc/powerpc64/multiarch/memcmp-power7.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/memmove-power7.S: Likewise. * sysdeps/powerpc/powerpc64/power4/memcmp.S: Set a default function name if not defined and pass as parameter to macros accordingly. * sysdeps/powerpc/powerpc64/power7/memcmp.S: Likewise. * sysdeps/powerpc/powerpc64/power7/memmove.S: Likewise.
* powerpc: refactor memcpy and mempcpy IFUNC.Wainer dos Santos Moschetta2017-04-1115-119/+64
| | | | | | | | | | | | | | | | | | | | | | | | | Clean up the IFUNC implementations for powerpc in order to remove unneeded macro definitions. Tested on ppc64le with and without --disable-multi-arch flag. * sysdeps/powerpc/powerpc64/multiarch/memcpy-a2.S: Define the implementation-specific function name and remove unneeded macros definition. * sysdeps/powerpc/powerpc64/multiarch/memcpy-cell.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/memcpy-power4.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/memcpy-power6.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/memcpy-power7.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/memcpy-ppc64.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/mempcpy-power7.S: Likewise. * sysdeps/powerpc/powerpc64/a2/memcpy.S: Set a default function name if not defined and pass as parameter to macros accordingly. * sysdeps/powerpc/powerpc64/cell/memcpy.S: Likewise. * sysdeps/powerpc/powerpc64/memcpy.S: Likewise. * sysdeps/powerpc/powerpc64/power4/memcpy.S: Likewise. * sysdeps/powerpc/powerpc64/power6/memcpy.S: Likewise. * sysdeps/powerpc/powerpc64/power7/memcpy.S: Likewise. * sysdeps/powerpc/powerpc64/power7/mempcpy.S: Likewise.
* powerpc: refactor memchr, memrchr, and rawmemchr IFUNC.Wainer dos Santos Moschetta2017-04-117-48/+32
| | | | | | | | | | | | | | | | | | Clean up the IFUNC implementations for powerpc in order to remove unneeded macro definitions. Tested on ppc64le with and without --disable-multi-arch flag. * sysdeps/powerpc/powerpc64/multiarch/memchr-power7.S: Define the implementation-specific function name and remove unneeded macros definition. * sysdeps/powerpc/powerpc64/multiarch/memrchr-power7.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/rawmemchr-power7.S: Likewise. * sysdeps/powerpc/powerpc64/power7/memchr.S: Set a default function name if not defined and pass as parameter to macros accordingly. * sysdeps/powerpc/powerpc64/power7/memrchr.S: Likewise. * sysdeps/powerpc/powerpc64/power7/rawmemchr.S: Likewise.
* powerpc: refactor memset IFUNC.Wainer dos Santos Moschetta2017-04-1111-85/+46
| | | | | | | | | | | | | | | | | | | | | Clean up the IFUNC implementations for powerpc in order to remove unneeded macro definitions. Tested on ppc64le with and without --disable-multi-arch flag. * sysdeps/powerpc/powerpc64/multiarch/memset-power4.S: Define the implementation-specific function name and remove unneeded macros definition. * sysdeps/powerpc/powerpc64/multiarch/memset-power6.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/memset-power7.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/memset-power8.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/memset-ppc64.S: Likewise. * sysdeps/powerpc/powerpc64/memset.S: Set a default function name if not defined and pass as parameter to macros accordingly. * sysdeps/powerpc/powerpc64/power4/memset.S: Likewise. * sysdeps/powerpc/powerpc64/power6/memset.S: Likewise. * sysdeps/powerpc/powerpc64/power7/memset.S: Likewise. * sysdeps/powerpc/powerpc64/power8/memset.S: Likewise.
* powerpc: refactor strcasestr and strstr IFUNC.Wainer dos Santos Moschetta2017-04-115-34/+22
| | | | | | | | | | | | | | | Clean up the IFUNC implementations for powerpc in order to remove unneeded macro definitions. Tested on ppc64le with and without --disable-multi-arch flag. * sysdeps/powerpc/powerpc64/multiarch/strcasestr-power8.S: Define the strcasestr implementation name and remove unneeded macros definition. * sysdeps/powerpc/powerpc64/multiarch/strstr-power7.S: Define strstr implementation name and remove unneeded macros definition. * sysdeps/powerpc/powerpc64/power7/strstr.S: Set a default function name if not defined and pass as parameter to macros accordingly. * sysdeps/powerpc/powerpc64/power8/strcasestr.S: Likewise.
* powerpc: refactor strchr, strchrnul, and strrchr IFUNC.Wainer dos Santos Moschetta2017-04-1112-97/+60
| | | | | | | | | | | | | | | | | | | | | | | Clean up the IFUNC implementations for powerpc in order to remove unneeded macro definitions. Tested on ppc64le with and without --disable-multi-arch flag. * sysdeps/powerpc/powerpc64/multiarch/strchr-power7.S: Define the implementation-specific function name and remove unneeded macros definition. * sysdeps/powerpc/powerpc64/multiarch/strchr-power8.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/strchr-ppc64.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/strchrnul-power7.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/strchrnul-power8.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/strrchr-power7.S: Likewise. * sysdeps/powerpc/powerpc64/power7/strchr.S: Set a default function name if not defined and pass as parameter to macros accordingly. * sysdeps/powerpc/powerpc64/power7/strchrnul.S: Likewise. * sysdeps/powerpc/powerpc64/power7/strrchr.S: Likewise. * sysdeps/powerpc/powerpc64/power8/strchr.S: Likewise. * sysdeps/powerpc/powerpc64/strchr.S: Likewise.
* powerpc: refactor strnlen and strlen IFUNC.Wainer dos Santos Moschetta2017-04-119-64/+40
| | | | | | | | | | | | | | | | | | | Clean up the IFUNC implementations for powerpc in order to remove unneeded macro definitions. Tested on ppc64le with and without --disable-multi-arch flag. * sysdeps/powerpc/powerpc64/multiarch/strlen-power7.S: Define the strlen implementation name and remove unneeded macros definition. * sysdeps/powerpc/powerpc64/multiarch/strlen-power8.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/strlen-ppc64.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/strnlen-power7.S: Define the strnlen implementation name and remove unneeded macros definition. * sysdeps/powerpc/powerpc64/power7/strlen.S: Set a default function name if not defined and pass as parameter to macros accordingly. * sysdeps/powerpc/powerpc64/power7/strnlen.S: Likewise. * sysdeps/powerpc/powerpc64/power8/strlen.S: Likewise. * sysdeps/powerpc/powerpc64/strlen.S: Likewise.
* powerpc: refactor strcasecmp, strcmp, and strncmp IFUNC.Wainer dos Santos Moschetta2017-04-1120-171/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clean up the IFUNC implementations for powerpc in order to remove unneeded macro definitions. Tested on ppc64le with and without --disable-multi-arch flag. * sysdeps/powerpc/powerpc64/multiarch/strcasecmp_l-power7.S: Define the implementation-specific function name and remove unneeded macros definition. * sysdeps/powerpc/powerpc64/multiarch/strcmp-power7.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/strcmp-power8.S Likewise. * sysdeps/powerpc/powerpc64/multiarch/strcmp-power9.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/strcmp-ppc64.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/strncmp-power4.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/strncmp-power7.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/strncmp-power8.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/strncmp-power9.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/strncmp-ppc64.S: Likewise. * sysdeps/powerpc/powerpc64/power4/strncmp.S: Set a default function name if not defined and pass as parameter to macros accordingly. * sysdeps/powerpc/powerpc64/power7/strcmp.S: Likewise. * sysdeps/powerpc/powerpc64/power7/strncmp.S: Likewise. * sysdeps/powerpc/powerpc64/power8/strcmp.S: Likewise. * sysdeps/powerpc/powerpc64/power8/strncmp.S: Likewise. * sysdeps/powerpc/powerpc64/power9/strcmp.S: Likewise. * sysdeps/powerpc/powerpc64/power9/strncmp.S: Likewise. * sysdeps/powerpc/powerpc64/strcmp.S: Likewise. * sysdeps/powerpc/powerpc64/strncmp.S: Likewise.
* powerpc: refactor stpcpy, stpncpy, strcpy, and strncpy IFUNC.Wainer dos Santos Moschetta2017-04-1110-99/+54
| | | | | | | | | | | | | | | | | | | | Clean up the IFUNC implementations for powerpc in order to remove unneeded macro definitions. Tested on ppc64le with and without --disable-multi-arch flag. * sysdeps/powerpc/powerpc64/multiarch/stpcpy-power8.S: Define the implementation-specific function name and remove unneeded macros definition. * sysdeps/powerpc/powerpc64/multiarch/stpncpy-power7.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/stpncpy-power8.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/strcpy-power8.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/strncpy-power7.S: Likewise. * sysdeps/powerpc/powerpc64/multiarch/strncpy-power8.S: Likewise. * sysdeps/powerpc/powerpc64/power7/strncpy.S: Set a default function name if not defined. * sysdeps/powerpc/powerpc64/power8/strcpy.S: Likewise. * sysdeps/powerpc/powerpc64/power8/strncpy.S: Likewise.
* Support auxilliary vector components for cache geometries.Paul Clarke2017-04-112-0/+19
| | | | | | | | | | | | Add support to getauxval() for new types to get L1, L2, L3 cache sizes, cache line sizes, and cache associativities. The new types for getauxval() were added in the stream for Linux kernel v4.11 in commit 98a5f361b8625c6f4841d6ba013bbf0e80d08147. * elf/elf.h (AT_L1I_CACHESIZE, AT_L1I_CACHEGEOMETRY, AT_L1D_CACHESIZE, AT_L1D_CACHEGEOMETRY, AT_L2_CACHESIZE, AT_L2_CACHEGEOMETRY, AT_L3_CACHESIZE, AT_L3_CACHEGEOMETRY): New. Add auxvec identifiers from kernel arch/powerpc/include/uapi/asm/auxvec.h.
* manual: readdir, readdir64 are thread-safeFlorian Weimer2017-04-112-9/+26
| | | | | | | | They only modify the state in the dirstream argument, and we generally do not treat this as a reason to mark a function as not thread-safe. For an example, see random_r, which is marked as thread-safe even though the random state is not protected by a lock.
* Consolidate pthreadtype.h placementConsolidate pthreadtype.h placementAdhemerval Zanella2017-04-105-0/+11
| | | | | | | | | | | | | | | | | | | | | This patch moves all arch specific pthreadtypes.h to a similar path for all architectures (sysdeps/unix/sysv/<arch>/bits). No functional or build change is expected. The idea is mainly to organize the header placement for all architectures. Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu, arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu, microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu, powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu, tile{pro,gx}-linux-gnu, and x86_64-linux-gnu). * sysdeps/unix/sysv/linux/x86/Implies: New file. * sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h: Move to ... * sysdeps/alpha/nptl/bits/pthreadtypes.h: ... here. * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Move to ... * sysdeps/powerpc/nptl/bits/pthreadtypes.h: ... here. * sysdeps/x86/bits/pthreadtypes.h: Move to ... * sysdeps/x86/nptl/bits/pthreadtypes.h: ... here.
* Add sysdeps/x86/dl-procinfo.cH.J. Lu2017-04-104-28/+61
| | | | | | | | | | Add sysdeps/x86/dl-procinfo.c for x86 version of processor capability information to reduce duplication between i386 and x86_64 dl-procinfo.c. * sysdeps/i386/dl-procinfo.c: Include <sysdeps/x86/dl-procinfo.c>. * sysdeps/x86_64/dl-procinfo.c: Likewise. * sysdeps/x86/dl-procinfo.c: New file.
* Remove unneeded declarations from math_private.hGabriel F. T. Gomes2017-04-104-20/+11
| | | | | | | | | | | | | | | | | The declarations of many functions in math_private.h are not required since __MATHDECL and __MATHDECLX, in math.h, already provide the declarations for these functions. This patch removes the declarations from math_private.h. It also adds the inclusion of math.h to the files which depended on the declaration of functions in math_private.h. Tested for powerpc64le and s390x. * sysdeps/generic/math_private.h: Remove declarations of many functions that are already declared in math.h. * sysdeps/ieee754/ldbl-128/e_logl.c: Include math.h to get the declaration for __frexpl. * sysdeps/ieee754/ldbl-128ibm/e_logl.c: Include math.h to get the declarations for __scalbnl and fabsl.
* Check for __mprotect failure in _dl_map_segments [BZ #20831]Dmitry V. Levin2017-04-092-8/+19
| | | | | | * elf/dl-map-segments.h (_dl_map_segments): Check for failure of __mprotect to change protection on the excess portion to disallow all access.
* Check if SSE is available with HAS_CPU_FEATUREH.J. Lu2017-04-0716-14/+39
| | | | | | | | | | | | | | | | | | | | | | | | Similar to other CPU feature checks, check if SSE is available with HAS_CPU_FEATURE. * sysdeps/i386/fpu/fclrexcpt.c (__feclearexcept): Use HAS_CPU_FEATURE to check for SSE. * sysdeps/i386/fpu/fedisblxcpt.c (fedisableexcept): Likewise. * sysdeps/i386/fpu/feenablxcpt.c (feenableexcept): Likewise. * sysdeps/i386/fpu/fegetenv.c (__fegetenv): Likewise. * sysdeps/i386/fpu/fegetmode.c (fegetmode): Likewise. * sysdeps/i386/fpu/feholdexcpt.c (__feholdexcept): Likewise. * sysdeps/i386/fpu/fesetenv.c (__fesetenv): Likewise. * sysdeps/i386/fpu/fesetmode.c (fesetmode): Likewise. * sysdeps/i386/fpu/fesetround.c (__fesetround): Likewise. * sysdeps/i386/fpu/feupdateenv.c (__feupdateenv): Likewise. * sysdeps/i386/fpu/fgetexcptflg.c (__fegetexceptflag): Likewise. * sysdeps/i386/fpu/fsetexcptflg.c (__fesetexceptflag): Likewise. * sysdeps/i386/fpu/ftestexcept.c (fetestexcept): Likewise. * sysdeps/i386/setfpucw.c (__setfpucw): Likewise. * sysdeps/x86/cpu-features.h (bit_cpu_SSE): New. (index_cpu_SSE): Likewise. (reg_SSE): Likewise.
* getopt: merge from gnulib: use angle-bracket includes consistentlyPaul Eggert2017-04-072-1/+5
| | | | * posix/getopt1.c: Include <config.h>, not "config.h".
* getopt: annotate files with relationship to gnulib.Zack Weinberg2017-04-078-9/+22
| | | | | | | | | | | | | | As the final act in this patchset, adjust the "This file is part of the GNU C Library" message at the top of each file to indicate which files are synced with gnulib. * posix/bits/getopt_core.h, posix/bits/getopt_ext.h * posix/getopt.c, posix/getopt1.c, posix/getopt_int.h: Mention in top-of-file boilerplate that these files are shared with gnulib. * posix/getopt.h, posix/bits/getopt_posix.h: Mention in top-of-file boilerplate that these files are NOT shared with gnulib, unlike the rest of the getopt implementation.
* getopt: eliminate __need_getopt by splitting up getopt.h.Zack Weinberg2017-04-0711-187/+248
| | | | | | | | | | | | | | | | | | | | | | __need_getopt is misnamed; what it really means is "we want only the getopt features specified in POSIX, not the GNU extensions". Because this code is shared with gnulib, it winds up being cleanest to split getopt.h into *four* headers. getopt_core.h and getopt_ext.h will be shared with gnulib, getopt_posix.h will be just for glibc, and each project will have its own copy of getopt.h. * posix/bits/getopt_core.h, posix/bits/getopt_ext.h: New files, intended to be shared with gnulib. * posix/bits/getopt_posix.h: New file, not intended to be shared with gnulib. * posix/getopt.h: Now just includes features.h, bits/getopt_core.h, and bits/getopt_ext.h. Will no longer be shared with gnulib. * include/bits/getopt_core.h, include/bits/getopt_ext.h * include/bits/getopt_posix.h: New wrappers. * posix/Makefile: Install new headers. * posix/unistd.h, libio/stdio.h: Include bits/getopt_posix.h instead of getopt.h.
* getopt: merge _GL_UNUSED annotations from gnulibZack Weinberg2017-04-073-1/+51
| | | | | | | | | | | | | | | | gnulib now has annotations on at least some functions to cater to compilation with -Wunused-parameter. In order to follow suit cleanly, I've added to libc-symbols.h some of the _GL_* macros that gnulib-common.m4 puts into config.h. (I don't think they belong in sys/cdefs.h, at least not without further thought.) At this point all gnulib-side changes to getopt.c have been merged. * include/libc-symbols.h: For gnulib compatibility, define _GL_UNUSED, _GL_UNUSED_LABEL, _GL_ATTRIBUTE_PURE, and _GL_ATTRIBUTE_CONST. * posix/getopt.c (_getopt_initialize): Mark argc and argv parameters with _GL_UNUSED.
* getopt: merge from gnulib: alloca avoidanceZack Weinberg2017-04-073-127/+167
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In one place, glibc's getopt uses alloca to construct a linked list of possibilities for an "ambiguous" long option. In gnulib, malloc should be used instead. Providing for both cases complicates things a fair bit. Instead of merging straight across, therefore, I have chosen to rewrite it using a boolean vector instead of a linked list. There is then only one allocation that might need freeing; in glibc it can honor __libc_use_alloca as usual, and in gnulib we define __libc_use_alloca to always be false, so we don't need ifdefs in the middle of the function. This should also be slightly more efficient in the normal case of long options being fully spelled out -- I think most people aren't even aware they _can_ sometimes abbreviate long options. One interesting consequence is that the list of possibilities is now printed in exactly the order they appear in the list of long options, instead of the first possibility being shuffled to the end. This shouldn't be a big deal but it did break one test that relied on the exact text of this error message. (The reason the previous patch was "in aid of" merging from gnulib is I didn't want to have to make this change in two places.) (The patch looks bigger than it really is because there's a fair bit of reindentation and code rearrangement.) * posix/getopt.c: When used standalone, define __libc_use_alloca as always false and alloca to abort if called. (process_long_option): Rewrite handling of ambiguous long options to use a single boolean vector, not a linked list; use __libc_use_alloca to decide whether to allocate this using alloca. * posix/tst-getopt_long1.c: Adjust text of expected error message.
* getopt: refactor long-option handlingZack Weinberg2017-04-073-305/+219
| | | | | | | | | | | | | | | There were two copies of the bulk of the code to handle long options. Now there is only one. (Yes, this is in aid of merging from gnulib.) The change to bug-getopt4.c clarifies the error messages when the test fails. * posix/getopt.c (process_long_option): New function split out from _getopt_internal_r. (_getopt_internal_r): Replace both copies of the long-option processing code with calls to process_long_option. * posix/bug-getopt4.c (one_test): Print argv[0] in error messages. (do_test): Differentiate argv[0] in the two subtests.
* getopt: tidy up _getopt_initialize a bitZack Weinberg2017-04-073-16/+10
| | | | | | | | | | | | | | | | _getopt_data.__posixly_correct is completely redundant to _getopt_data.__ordering, and some work that logically belongs in _getopt_initialize was being done by _getopt_internal_r, making the code harder to understand. As a side effect, getenv will no longer be called if the first character of the options string is '+' or '-', which is probably a Good Thing. (Perhaps we should have a flag character that specifically asks for the permutation behavior?) * posix/getopt_int.h (_getopt_data): Remove __posixly_correct field. * posix/getopt.c (_getopt_internal_r): Move some initialization code... (_getopt_initialize): ...here. Don't set d->__posixly_correct.
* getopt: merge from gnulib: function prototype adjustmentsZack Weinberg2017-04-075-65/+102
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For standards compliance, getopt, getopt_long, and getopt_long_only in glibc have to take 'char *const *argv' even though they can mutate the array. gnulib has tried to clean this up as much as possible: all the internal functions use 'char **argv', and when used standalone, so do getopt_long and getopt_long_only. Also brought over are __nonnull annotations, corrections to documentation, and apparently it is no longer necessary to worry about conflicting prototypes for getopt. The macroification of the definitions of getopt and __posix_getopt goes beyond what is currently in gnulib. At this point getopt1.c and getopt_int.h are identical to their gnulib versions. * posix/getopt.h: Add backup definition of __nonnull for consistency with gnulib. Define __getopt_argv_const to const if not already defined. (getopt): Update doc comment from gnulib. Prototype unconditionally. Add __nonnull annotation. (__posix_getopt): Add __nonnull annotation. (getopt_long, getopt_long_only): Use __getopt_argv_const in prototypes for consistency with gnulib. Add __nonnull annotations. * posix/getopt.c (_getopt_initialize, _getopt_internal_r) (getopt_internal): Change 'argv' argument to type 'char **'. Remove now-unnecessary casts. (getopt, __posix_getopt): Eliminate repetition with a macro. Cast 'argv' to 'char **' when calling _getopt_internal. * posix/getopt1.c (getopt_long, getopt_long_only): Use __getopt_argv_const for consistency with gnulib. Cast 'argv' to 'char **' when calling _getopt_internal. (_getopt_long_r, _getopt_long_only_r): Change 'argv' argument to type 'char **'. (main): Constify 'long_options'. * posix/getopt_int.h (getopt_internal, _getopt_internal_r) (_getopt_long_r, _getopt_long_only_r): Change 'argv' argument to type 'char **'.
* getopt: clean up error reportingZack Weinberg2017-04-076-326/+421
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | getopt can print a whole bunch of error messages, and when used standalone (from gnulib) it uses fprintf to do that. But fprintf is a cancellation point and getopt isn't, and also applying fprintf to a stream in wide-character mode is not allowed. glibc has an internal function called __fxprintf that writes a narrow format string to a stream regardless of mode, but it only handles ASCII format strings, and it's still a cancellation point. getopt's messages are translated, so they might not be ASCII. So getopt has an error message to an asprintf buffer, monkeys with internal flag bits on stderr to disable cancellation, and then calls __fxprintf(stderr, "%s", buffer). There isn't even a helper function, the code is duplicated every time. This patch fixes __fxprintf to handle arbitrary multibyte format strings, and adds a variant __fxprintf_nocancel that does the same thing but also isn't a cancellation point. (It still _works_ by monkeying with internal flag bits on the FILE, but that's not really a layering violation for code in stdio-common.) All of the #ifdef _LIBC blocks can then be reduced to their standalone versions with a little help from some macros at the top of the file. I also wrote a test case to verify that getopt really isn't a cancellation point, and I'm glad I did, because it found two bugs, one of which wasn't even to do with cancellation (see previous patch). * stdio-common/fxprintf.c (__fxprintf_nocancel): New function. (locked_vfxprintf): New helper function. Handle arbitrary multibyte strings, not just ASCII. * include/stdio.h: Declare __fxprintf_nocancel. * posix/getopt.c: When _LIBC is defined, define fprintf to __fxprintf_nocancel, flockfile to _IO_flockfile, and funlockfile to _IO_funlockfile. When neither _LIBC nor _POSIX_THREAD_SAFE_FUNCTIONS is defined, define flockfile and funlockfile as no-ops. (_getopt_internal_r): Remove all internal #ifdef _LIBC blocks; the standalone error-printing code can now be used for libc as well. Add an flockfile/funlockfile pair around one case where the error message is printed in several chunks. Don't use fputc. * posix/tst-getopt-cancel.c: New test. * posix/Makefile: Run it.
* getopt: fix fencepost error in ambiguous-W-option handlingZack Weinberg2017-04-072-1/+3
| | | | | | | | | | | | | | | | | getopt_long contains an undocumented (AFAICT) feature in which, if you put "W;" in the short-options list, then '-W foo' and '-Wfoo' are treated as equivalent to '--foo'. This is implemented with a partial second copy of the code for handling long options, and that code increments optind one too many times when recovering from an ambiguous abbreviated option, which can cause the main loop to walk past the end of argv and crash. I discovered this while writing a test case that tries to exercise all of getopt's error reporting paths; I wouldn't be surprised to learn that this feature is never used by real applications. * posix/getopt.c (_getopt_internal_r): Don't increment d->optind a second time when reporting ambiguous -W options.
* getopt: merge straightforward changes from gnulibZack Weinberg2017-04-074-158/+92
| | | | | | | | | | | | | | | | | This covers changes with little or no consequences when the code is used in glibc. * posix/getopt_int.h: Include getopt.h. Use impl-namespace names for all arguments to _getopt_internal and _getopt_internal_r. Declare __ordering enum outside the struct. Harmonize comments with gnulib. * posix/getopt1.c: Simplify #ifdeffage at top of file. Remove ELIDE_CODE logic entirely. Move inclusion of stdlib.h to #ifdef TEST block and make unconditional. Do not define NULL. * posix/getopt.c: Partial merge from gnulib, covering the initial includes and global declarations, commentary, and a couple of semantically-neutral code changes.
* getopt: merge from gnulib: don't use `...' quotesZack Weinberg2017-04-075-66/+70
| | | | | | | | | | | | I'm not sure whether this is official GNU style now, but `...' quotes haven't looked properly balanced in most people's terminal fonts since 2001ish? and gnulib has chosen to switch over to '...' quotes. I'm merging this separately from the other changes in gnulib because it's very mechanical. * posix/getopt.c, posix/getopt.h, posix/getopt1.c, posix/getopt_int.h: Use '...' instead of `...' for quotation marks inside comments and strings.
* getopt: remove USE_NONOPTION_FLAGSZack Weinberg2017-04-0710-211/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | glibc's implementation of getopt includes code to parse an environment variable named _XXX_GNU_nonoption_argv_flags_ (where XXX is the current process's PID in decimal); but all of it has been #ifdefed out since 2001, with no official way to turn it back on. According to commentary in our config.h.in, bash version 2.0 set this environment variable to indicate argv elements that were the result of glob expansion and therefore should not be treated as options, but the feature was "disabled later" because "it caused problems". According to bash's CHANGES file, "later" was release 2.01; it gives no more detail about what the problems were. Version 2.0 of bash was released on the last day of 1996, and version 2.01 in June of 1997. Twenty years later, I think it is safe to assume that this environment variable isn't coming back. * config.h.in (USE_NONOPTION_FLAGS): Remove. * csu/init-first.c: Remove all #ifdef USE_NONOPTION_FLAGS blocks. * sysdeps/mach/hurd/i386/init-first.c: Likewise. * posix/getopt_int.h: Likewise. * posix/getopt.c: Likewise. Also remove SWAP_FLAGS and the __libc_argc and __libc_argv externs, which were only used by #ifdef USE_NONOPTION_FLAGS blocks. * posix/getopt_init.c: Remove file. * posix/Makefile (routines): Remove getopt_init. * include/getopt.h: Don't declare __getopt_initialize_environment. * manual/getopt.texi: Remove mention of USE_NONOPTION_FLAGS in a comment.
* resolv: Remove IQUERY supportFlorian Weimer2017-04-073-18/+7
|
* sparc: Fix .udiv plt on libcAdhemerval Zanella2017-04-065-0/+15
| | | | | | | | | | | | | | | | | | | | With the removal of divdi3 object from sparcv9-linux-gnu build, its definition came from libgcc and its functions internall calls .udiv. Since glibc also exports these symbols for compatibility reasons, it will end up creating PLT calls internally in libc.so. To avoid it, this patch uses the linker option --wrap to replace all the internal libc.so .udiv calls to the wrapper __wrap_.udiv. Along with strong alias in the udiv implementations, it makes linker do local calls. Checked on sparcv9-linux-gnu. * sysdeps/sparc/sparc32/Makefile (libc.so-gnulib): New rule. * sysdeps/sparc/sparc32/sparcv8/udiv.S (.udiv): Make a strong_alias to __wrap_.udiv. * sysdeps/sparc/sparc32/sparcv9/udiv.S (.udiv): Likewise. * sysdeps/sparc/sparc32/udiv.S (.udiv): Likewise.
* Build divdi3 only for architecture that required itAdhemerval Zanella2017-04-0611-11/+140
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As noted in [1], divdi3 object is only exported in a handful ABIs (i386, m68k, powerpc32, s390-32, and ia64), however it is built for all current architectures regardless. This patch refact the make rules for this object to so only the aforementioned architectures that actually require it builds it. Also, to avoid internal PLT calls to the exported symbol from the module, glibc uses an internal header (symbol-hacks.h) which is unrequired (and in fact breaks the build for architectures that intend to get symbol definitions from libgcc.a). The patch also changes it to create its own header (divdi3-symbol-hacks.h) and adjust the architectures that require it accordingly. I checked the build/check (with run-built-tests=no) on the following architectures (which I think must cover all supported ABI/builds) using GCC 6.3: aarch64-linux-gnu alpha-linux-gnu arm-linux-gnueabihf hppa-linux-gnu ia64-linux-gnu m68k-linux-gnu microblaze-linux-gnu mips64-n32-linux-gnu mips-linux-gnu mips64-linux-gnu nios2-linux-gnu powerpc-linux-gnu powerpc-linux-gnu-power4 powerpc64-linux-gnu powerpc64le-linux-gnu s390x-linux-gnu s390-linux-gnu sh4-linux-gnu sh4-linux-gnu-soft sparc64-linux-gnu sparcv9-linux-gnu tilegx-linux-gnu tilegx-linux-gnu-32 tilepro-linux-gnu x86_64-linux-gnu x86_64-linux-gnu-x32 i686-linux-gnu I only saw one regression on sparcv9-linux-gnu (extra PLT call to .udiv) which I address in next patch in the set. It also correctly build SH with GCC 7.0.1 (without any regression from c89721e25d). [1] https://sourceware.org/ml/libc-alpha/2017-03/msg00243.html * sysdeps/i386/symbol-hacks.h: New file. * sysdeps/m68k/symbol-hacks.h: New file. * sysdeps/powerpc/powerpc32/symbol-hacks.h: New file. * sysdeps/s390/s390-32/symbol-hacks.h: New file. * sysdeps/unix/sysv/linux/i386/Makefile [$(subdir) = csu] (sysdep_routines): New rule: divdi3 object. [$(subdir) = csu] (sysdep-only-routines): Likewise. [$(subdir) = csu] (CFLAGS-divdi3.c): Likewise. * sysdeps/unix/sysv/linux/m68k/Makefile [$(subdir) = csu] (sysdep_routines): Likewise. [$(subdir) = csu] (sysdep-only-routines): Likewise. [$(subdir) = csu] (CFLAGS-divdi3.c): Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile [$(subdir) = csu] (sysdep_routines): Likewise. [$(subdir) = csu] (sysdep-only-routines): Likewise. [$(subdir) = csu] (CFLAGS-divdi3.c): Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/Makefile [$(subdir) = csu] (sysdep_routines): Likewise. [$(subdir) = csu] (sysdep-only-routines): Likewise. [$(subdir) = csu] (CFLAGS-divdi3.c): Likewise. * sysdeps/wordsize-32/Makefile: Remove file. * sysdeps/wordsize-32/symbol-hacks.h: Definitions move to ... * sysdeps/wordsize-32/divdi3-symbol-hacks.h: ... here.
* Define TEST_FUNCTION_ARGV in elf/tst-dlopen-aout.cH.J. Lu2017-04-052-1/+6
| | | | | * elf/tst-dlopen-aout.c (TEST_FUNCTION): Removed. (TEST_FUNCTION_ARGV): New.
* Update elf tests to use the support test driver.Wainer dos Santos Moschetta2017-04-0572-159/+202
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replaced test-skeleton.c with support/test-driver.c and adjusted the tests accordinly. Checked on x86_64. * elf/next.c: Import support/test-driver.c instead of test-skeleton.c and delete TEST_FUNCTION macro definition. * elf/nodelete.c: Likewise. * elf/order2.c: Likewise. * elf/tst-_dl_addr_inside_object.c: Likewise. * elf/tst-addr1.c: Likewise. * elf/tst-align.c: Likewise. * elf/tst-align2.c: Likewise. * elf/tst-audit11.c: Likewise. * elf/tst-audit12.c: Likewise. * elf/tst-audit2.c: Likewise. * elf/tst-audit9.c: Likewise. * elf/tst-auxv.c: Likewise and define TEST_FUNCTION_ARGV macro. * elf/tst-deep1.c: Likewise. * elf/tst-dl-iter-static.c: Likewise. * elf/tst-dlmodcount.c: Likewise. * elf/tst-dlmopen1.c: Likewise. * elf/tst-dlmopen2.c: Likewise. * elf/tst-dlmopen3.c: Likewise. * elf/tst-dlopen-aout.c: Likewise. * elf/tst-dlopenrpath.c: Likewise. * elf/tst-dlsym-error.c: Likewise. * elf/tst-execstack-needed.c: Likewise. * elf/tst-execstack-prog.c: Likewise. * elf/tst-execstack.c: Likewise. * elf/tst-global1.c: Likewise. * elf/tst-gnu2-tls1.c: Likewise. * elf/tst-latepthread.c: Likewise. * elf/tst-leaks1.c: Likewise. * elf/tst-linkall-static.c: Likewise. (do_test): New function. * elf/tst-nodelete-opened.c: Likewise. * elf/tst-nodelete.cc: Likewise. * elf/tst-nodelete2.c: Likewise. * elf/tst-noload.c: Likewise. * elf/tst-null-argv.c: Likewise and define TEST_FUNCTION_ARGV marcro. * elf/tst-order-main.c: Likewise. * elf/tst-pathopt.c: Likewise. * elf/tst-pie2.c: Likewise. * elf/tst-piemod1.c: Likewise. * elf/tst-prelink.c: Likewise. * elf/tst-protected1a.c: Likewise. * elf/tst-protected1b.c: Likewise. * elf/tst-ptrguard1.c: Likewise, import getopt.h, and define _GNU_SOURCE macro. (cmdline_process_function): New function. * elf/tst-relsort1.c: Likewise. * elf/tst-stackguard1.c: Likewise, import getopt.h, and define _GNU_SOURCE macro. (cmdline_process_function): New function. * elf/tst-thrlock.c: Likewise. * elf/tst-tls-dlinfo.c: Likewise. * elf/tst-tls-manydynamic.c: Likewise and import support/xthread.h. * elf/tst-tls1.c: Likewise. * elf/tst-tls10.c: Likewise. * elf/tst-tls11.c: Likewise. * elf/tst-tls12.c: Likewise. * elf/tst-tls13.c: Likewise. * elf/tst-tls14.c: Likewise. * elf/tst-tls15.c: Likewise. * elf/tst-tls16.c: Likewise. * elf/tst-tls17.c: Likewise. * elf/tst-tls18.c: Likewise. * elf/tst-tls19.c: Likewise. * elf/tst-tls2.c: Likewise. * elf/tst-tls3.c: Likewise. * elf/tst-tls4.c: Likewise. * elf/tst-tls5.c: Likewise. * elf/tst-tls6.c: Likewise. * elf/tst-tls7.c: Likewise. * elf/tst-tls8.c: Likewise. * elf/tst-tls9.c: Likewise. * elf/tst-tlsalign-extern.c: Likewise. * elf/tst-tlsalign.c: Likewise. * elf/tst-unique1.c: Likewise. * elf/tst-unique2.c: Likewise. * elf/vismain.c: Likewise.
* Add page tests to string/test-strnlen.Wainer dos Santos Moschetta2017-04-052-0/+60
| | | | | | | | | | | | | | | | | | May be tricky for otimized implementations to handle strings around page boundary once, for instance, it is performed unaligned loads or when maxlen is used as a hint for vectorized loops. The test cases should unveil regression bugs on these cases. To some extend do_random_tests in string/test-strnlen tests strings placed at page end but it does not cover all cases. So this change adds tests which consists of placing strings of varying sizes ending at the page boundary. It also combines with different values of maxlen. Tested on ppc64le and x86_64. * string/test-strnlen.c (do_page_tests): New function to check length of strings ending at the page boundary. (test_main): Added call to the do_page_tests function.
* powerpc64: Add POWER8 strnlenWainer dos Santos Moschetta2017-04-056-5/+485
| | | | | | | | | | | | | | | | | | | | | | | | Added strnlen POWER8 otimized for long strings. It delivers same performance as POWER7 implementation for short strings. This takes advantage of reasonably performing unaligned loads and bit permutes to check the first 1-16 bytes until quadword aligned, then checks in 64 bytes strides until unsafe, then 16 bytes, truncating the count if need be. Likewise, the POWER7 code is recycled for less than 32 bytes strings. Tested on ppc64 and ppc64le. * sysdeps/powerpc/powerpc64/multiarch/Makefile (sysdep_routines): Add strnlen-power8. * sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c (strnlen): Add __strnlen_power8 to list of strnlen functions. * sysdeps/powerpc/powerpc64/multiarch/strnlen-power8.S: New file. * sysdeps/powerpc/powerpc64/multiarch/strnlen.c (__strnlen): Add __strnlen_power8 to ifunc list. * sysdeps/powerpc/powerpc64/power8/strnlen.S: New file.
* Update wcsmbs tests to use the support test driverWainer dos Santos Moschetta2017-04-049-16/+20
| | | | | | | | | | | | | | | | | Replaced test-skeleton.c with support/test-driver.c and adjusted the tests accordinly. Checked on x86_64-linux-gnu. * wcsmbs/tst-btowc.c: Import support/test-driver.c and remove the TEST_FUNCTION macro definition. * wcsmbs/tst-mbrtowc2.c: Likewise. * wcsmbs/tst-mbsrtowcs.c: Likewise. * wcsmbs/tst-wchar-h.c: Likewise. * wcsmbs/tst-wcpncpy.c: Likewise. * wcsmbs/tst-wcrtomb.c: Likewise. * wcsmbs/tst-wcsnlen.c: Likewise. * wcsmbs/tst-wcstof.c: Likewise.
* Remove CALL_THREAD_FCT macroAdhemerval Zanella2017-04-045-78/+6
| | | | | | | | | | | | | | | | This patch removes CALL_THREAD_FCT macro usage and its defition for x86. For 32 bits it usage is only for force 16 stack alignment, however stack is already explicit aligned in clone syscall. For 64 bits and x32 it just a function call and there is no need to code it with inline assembly. Checked on i686-linux-gnu, x86_64-linux-gnu, and x86_64-linux-gnu-x32. * nptl/pthread_create.c (START_THREAD_DEFN): Remove CALL_THREAD_FCT macro usage. * sysdeps/i386/nptl/tls.h (CALL_THREAD_FCT): Remove definition. * sysdeps/x86_64/nptl/tls.h (CALL_THREAD_FCT): Likewise. * sysdeps/x86_64/32/nptl/tls.h: Remove file.