summaryrefslogtreecommitdiff
path: root/sysdeps/unix
Commit message (Collapse)AuthorAgeFilesLines
* Fix another x86 sys/ucontext.h namespace issue (bug 21457).Joseph Myers2017-06-191-1/+1
| | | | | | | | | | | This patch fixes a namespace issue for one more field in the x86 sys/ucontext.h that I missed in my previous changes. Tested for x86_64. [BZ #21457] * sysdeps/unix/sysv/linux/x86/sys/ucontext.h [__x86_64__] (struct _libc_xmmreg): Use __ctx in defining field.
* Define struct rusage in sys/wait.h when required (bug 21575).Joseph Myers2017-06-194-234/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some older standards (XPG4.2 through POSIX.1:2001, XSI only) require sys/wait.h to include the definition of struct rusage. This is missing in glibc. This patch adds the required definition. struct rusage is moved to a new header bits/types/struct_rusage.h to avoid bringing in the whole of sys/resource.h (although the standards in question do allow the whole of sys/resource.h to be brought in). In the five bits/resource.h headers, the only variation between the definitions of struct rusage is that the sysdeps/unix/sysv/linux version is prepared for x32 (by having anonymous unions with __syscall_slong_t fields) and the others are not. Thus, this version is suitable for use generically (everything other than x32 simply has __syscall_slong_t the same as long int, so there are no API or ABI changes involved, and anonymous unions are already a required language feature for glibc headers elsewhere), and this patch uses it as a base for the single implementation of bits/types/struct_rusage.h. Tested for x86_64, and with build-many-glibcs.py. [BZ #21575] * resource/bits/types/struct_rusage.h: New file. * include/bits/types/struct_rusage.h: Likewise. * bits/resource.h (struct rusage): Include <bits/types/struct_rusage.h> instead of defining here. * sysdeps/unix/sysv/linux/bits/resource.h (struct rusage): Likewise. * sysdeps/unix/sysv/linux/alpha/bits/resource.h (struct rusage): Likewise. * sysdeps/unix/sysv/linux/mips/bits/resource.h (struct rusage): Likewise. * sysdeps/unix/sysv/linux/sparc/bits/resource.h (struct rusage): Likewise. * resource/Makefile (headers): Add bits/types/struct_rusage.h. * posix/sys/wait.h [__USE_XOPEN_EXTENDED && !__USE_XOPEN2K8]: Include <bits/types/struct_rusage.h>
* S390: Fix build with gcc configured with --enable-default-pie. [BZ #21537]Stefan Liebler2017-06-191-19/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Building glibc with gcc configured with --enable-default-pie failed on s390 due to assembler messages: ../sysdeps/unix/sysv/linux/s390/s390-32/__makecontext_ret.S:44: Error: junk at end of line, first unrecognized character is `@' HIDDEN_JUMPTARGET was expanded to exit@PLT@GOTOFF. If SHARED is not defined, HIDDEN_JUMPTARGET is defined to JUMPTARGET in sysdeps/s390/s390-32/sysdep.h. There it expanded to exit@PLT in non SHARED case as PIC is defined if gcc is configured with --enable-default-pie. Thus I've changed the "ifdef PIC" to "ifdef SHARED" as we do not want PLTs in the static obj files. I've also changed this in sysdeps/s390/s390-64/sysdep.h. I've also adjusted sysdeps/unix/sysv/linux/s390/s390-32/__makecontext_ret.S. If glibc is configured with --disable-hidden-plt, then NO_HIDDEN is defined. In SHARED case HIDDEN_JUMPTARGET would be expanded to exit@PLT@GOTOFF instead of __GI_exit@GOTOFF. Now we jump to: - __GI_exit if SHARED is defined - exit@PLT if SHARED and NO_HIDDEN is defined - exit if both are not defined. On s390 31bit we have to setup GOT pointer in r12 if we use a PLT stub. Therefore I use SYSCALL_PIC_SETUP from sysdep.h and added the missing semicolons. ChangeLog: [BZ #21537] * sysdeps/s390/s390-32/sysdep.h (JUMPTARGET, SYSCALL_PIC_SETUP): Check SHARED instead of PIC. (SYSCALL_PIC_SETUP): Add missing semicolons. * sysdeps/s390/s390-64/sysdep.h (JUMPTARGET, SYSCALL_PIC_SETUP): Check SHARED instead of PIC. * sysdeps/unix/sysv/linux/s390/s390-32/__makecontext_ret.S (__makecontext_ret): Adjust code to jump to exit.
* s390: optimize syscall functionChristian Borntraeger2017-06-192-18/+6
| | | | | | | | | | | | | | Since kernel 2.6.0 all Linux version accept the system call number in register 1 for svc 0. There is no need to have special handling that uses EX for system calls < 256. This will simplify and speed up that code. A microbenchmark doing "syscall(__NR_getpid);" in a loops gets faster by ~12%. * sysdeps/unix/sysv/linux/s390/s390-32/syscall.S: Simplify code by always using SVC 0 instead of EX. * sysdeps/unix/sysv/linux/s390/s390-64/syscall.S: Likewise.
* linux: Consolidate sync_file_range implementationAdhemerval Zanella2017-06-152-1/+1
| | | | | | | | | | | | | | | This patch consolidates Linux sync_file_range at default sysdeps/unix/sysv/linux/sync_file_range.c implementation. It also moves the rules flags from generic io/Makefile to Linux one due the fact it is a Linux-only symbol. Checked on i686-linux-gnu and x86_64-linux-gnu. * io/Makefile (CFLAGS-sync_file_range.c): Remove rule. * sysdeps/unix/sysv/linux/Makefile (CFLAGS-sync_file_range.c): New rule. * sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: Remove sync_file_range.
* Remove __need macros from errno.h (__need_Emath, __need_error_t).Zack Weinberg2017-06-145-135/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is fairly complicated, not because the users of __need_Emath and __need_error_t have complicated requirements, but because the core changes had a lot of fallout. __need_error_t exists for gnulib compatibility in argz.h and argp.h. error_t itself is a Hurdism, an enum containing all the E-constants, so you can do 'p (error_t) errno' in gdb and get a symbolic value. argz.h and argp.h use it for function return values, and they want to fall back to 'int' when that's not available. There is no reason why these nonstandard headers cannot just go ahead and include all of errno.h; so we do that. __need_Emath is defined only by .S files; what they _really_ need is for errno.h to avoid declaring anything other than the E-constants (e.g. 'extern int __errno_location(void);' is a syntax error in assembly language). This is replaced with a check for __ASSEMBLER__ in errno.h, plus a carefully documented requirement for bits/errno.h not to define anything other than macros. That in turn has the consequence that bits/errno.h must not define errno - fortunately, all live ports use the same definition of errno, so I've moved it to errno.h. The Hurd bits/errno.h must also take care not to define error_t when __ASSEMBLER__ is defined, which involves repeating all of the definitions twice, but it's a generated file so that's okay. * stdlib/errno.h: Remove __need_Emath and __need_error_t logic. Reorganize file. Declare errno here. When __ASSEMBLER__ is defined, don't declare anything other than the E-constants. * include/errno.h: Change conditional for exposing internal declarations to (not _ISOMAC and not __ASSEMBLER__). * bits/errno.h: Remove logic for __need_Emath. Document requirements for a port-specific bits/errno.h. * sysdeps/unix/sysv/linux/bits/errno.h * sysdeps/unix/sysv/linux/alpha/bits/errno.h * sysdeps/unix/sysv/linux/hppa/bits/errno.h * sysdeps/unix/sysv/linux/mips/bits/errno.h * sysdeps/unix/sysv/linux/sparc/bits/errno.h: Add multiple-include guard and check against improper inclusion. Remove __need_Emath logic. Don't declare errno here. Ensure all constants are defined as simple integer literals. Consistent formatting. * sysdeps/mach/hurd/errnos.awk: Likewise. Only define error_t and enum __error_t_codes if __ASSEMBLER__ is not defined. * sysdeps/mach/hurd/bits/errno.h: Regenerate. * argp/argp.h, string/argz.h: Don't define __need_error_t before including errno.h. * sysdeps/i386/i686/fpu/multiarch/s_cosf-sse2.S * sysdeps/i386/i686/fpu/multiarch/s_sincosf-sse2.S * sysdeps/i386/i686/fpu/multiarch/s_sinf-sse2.S * sysdeps/x86_64/fpu/s_cosf.S * sysdeps/x86_64/fpu/s_sincosf.S * sysdeps/x86_64/fpu/s_sinf.S: Just include errno.h; don't define __need_Emath or include bits/errno.h directly.
* Remove __need_IOV_MAX and __need_FOPEN_MAX.Zack Weinberg2017-06-143-61/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | __need_FOPEN_MAX wasn't being used anywhere. __need_IOV_MAX was more complicated; the basic deal is that sys/uio.h wants to define a constant named UIO_MAXIOV and bits/xopen_lim.h wants to define a constant named IOV_MAX, with the same meaning. For no apparent reason this was being handled via bits/stdio_lim.h -- stdio.h is NOT supposed to define IOV_MAX -- and some mess in Makerules. Also, bits/uio.h on Linux was being used as a dumping ground for extension functions. So now we have bits/uio_lim.h, which defines __IOV_MAX. bits/xopen_lim.h and sys/uio.h use that to define their respective constants. We also now have bits/uio-ext.h, which is the official Proper Home for extensions to sys/uio.h. bits/uio.h is removed, and stdio_lim.h doesn't define IOV_MAX at all. * bits/uio_lim.h, sysdeps/unix/sysv/linux/bits/uio_lim.h * bits/uio-ext.h, sysdeps/unix/sysv/linux/bits/uio-ext.h: New file. * bits/uio.h, sysdeps/unix/sysv/linux/bits/uio.h: Delete file. * include/bits/xopen_lim.h: Use bits/uio_lim.h to get the value for IOV_MAX. * misc/Makefile: Install bits/uio-ext.h and bits/uio_lim.h. Don't install bits/uio.h. * misc/sys/uio.h: Don't include bits/uio.h. Do include bits/types/struct_iovec.h and bits/uio_lim.h. Set UIO_MAXIOV based on __IOV_MAX. Under __USE_GNU, also include bits/uio-ext.h. * stdio-common/stdio_lim.h.in: Remove logic for __need_FOPEN_MAX and __need_IOV_MAX. Don't define IOV_MAX at all. * Makerules (stdio_lim.h): Remove logic for setting IOV_MAX. * sysdeps/unix/sysv/linux/bits/fcntl-linux.h: Include bits/types/struct_iovec.h, not bits/uio.h. Use __ssize_t, not ssize_t, in function prototypes. Don't use hard TAB for double space after period in comments.
* PowerPC64 FRAME_PARM_SAVEAlan Modra2017-06-141-13/+13
| | | | | | | | | | | | | I think FRAME_PARM[1-9]_SAVE confuse the code, particularly FRAME_PARM9_SAVE. There are only 8 parameter save slots! * sysdeps/powerpc/powerpc64/sysdep.h: (FRAME_BACKCHAIN, FRAME_CR_SAVE, FRAME_LR_SAVE): Move out of conditional. (FRAME_PARM1_SAVE, FRAME_PARM2_SAVE, FRAME_PARM3_SAVE, FRAME_PARM4_SAVE, FRAME_PARM5_SAVE, FRAME_PARM6_SAVE, FRAME_PARM7_SAVE, FRAME_PARM8_SAVE, FRAME_PARM9_SAVE): Delete. * sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S: Replace uses of FRAME_PARM[1-9]_SAVE with FRAME_PARM_SAVE plus offset.
* mips: Fix store/load gp registers to/from ucontext_tGordana Cmiljanovic2017-06-136-81/+180
| | | | | | | | | | | | | | | | | | | | | | | | | | General purpose registers in mcontext_t structure are 8 bytes long for both MIPS32/MIPS64. get/set/make/swap context implementations for MIPS O32 incorrectly assume that general purpose registers in this structure are 4 bytes long. This patch is fixing that. Tested for MIPS O32 LE and BE. Compared objdump of modified functions for mips n32 and mips n64. [BZ #21548] * sysdeps/unix/sysv/linux/mips/getcontext.S: Define MCONTEXT_SZGREG as 8 and use it when copying general purpose registers. * sysdeps/unix/sysv/linux/mips/makecontext.S: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/Makefile: Include new test for mips o32. * sysdeps/unix/sysv/linux/mips/mips32/bug-getcontext-mips-gp.c: Added new test for mips o32. * sysdeps/unix/sysv/linux/mips/setcontext.S: Define MCONTEXT_SZGREG as 8 and use it when copying general purpose registers. * sysdeps/unix/sysv/linux/mips/swapcontext.S: Likewise.
* Remove __need_schedparam and __cpu_set_t_defined.Zack Weinberg2017-06-121-121/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | bits/sched.h has logic to expose only an impl-namespace variant of struct sched_param (i.e. struct __sched_param), but nothing uses it, and the only header that includes bits/sched.h is sched.h. The __need_schedparam logic can therefore be removed. bits/sched.h also has a great deal of code relating to cpu_set_t objects that was *almost* the same between the two versions of bits/sched.h in the tree; a little spelunking indicated that this is because some bug fixes got applied to the Linux-specific bits/sched.h but not the generic one. Introduce a new header, bits/cpu-set.h, containing the version of that code with the bugfixes, have sched.h include it directly, and delete all of the code from both versions of bits/sched.h. Also remove the unnecessary name mangling in the definition of struct sched_param -- POSIX specifies a field 'sched_priority', so there is no reason to define it as '__sched_priority' and then paper over that with a macro. (Just in case someone was using the internal name, 'sched_priority' remains a macro defined to expand to itself, and '__sched_priority' now expands to 'sched_priority'.) Finally, as long as I'm touching these files anyway, merge new constants from linux/sched.h into the Linux bits/sched.h. * bits/sched.h: Remove __need_schedparam logic and replace with a normal multiple-include guard. Change field name in struct sched_param from __sched_priority to sched_priority. Delete everything under #ifndef __cpu_set_t_defined. * sysdeps/unix/sysv/linux/bits/sched.h: Likewise. Also sync with kernel sched.h, adding SCHED_ISO and SCHED_DEADLINE constants. * posix/sched.h: Include bits/cpu-set.h as well as bits/sched.h. For compatibility, #define sched_priority to itself, and #define __sched_priority as sched_priority. * posix/bits/cpu-set.h: New file containing, verbatim, the code that was under #ifndef __cpu_set_t_defined in sysdeps/unix/sysv/linux/bits/sched.h. * include/bits/cpu-set.h: New wrapper. * posix/Makefile: Install bits/cpu-set.h.
* powerpc: add sysconf support for cache geometriesPaul Clarke2017-06-093-0/+170
| | | | | | | | | | | | | | | | | | | | | | | | | | There is currently no "cross-platform" (x86 and POWER) support for determining the cacheline size. This patch adds support to sysconf() to correctly report cacheline sizes based on the information in the auxilliary vector. Thus, using sysconf() is a cross-platform (x86 and POWER) solution for determining cacheline sizes. Support is added (on powerpc) for: _SC_LEVEL1_ICACHE_SIZE _SC_LEVEL1_ICACHE_ASSOC _SC_LEVEL1_ICACHE_LINESIZE _SC_LEVEL1_DCACHE_SIZE _SC_LEVEL1_DCACHE_ASSOC _SC_LEVEL1_DCACHE_LINESIZE _SC_LEVEL2_CACHE_SIZE _SC_LEVEL2_CACHE_ASSOC _SC_LEVEL2_CACHE_LINESIZE _SC_LEVEL3_CACHE_SIZE _SC_LEVEL3_CACHE_ASSOC _SC_LEVEL3_CACHE_LINESIZE * sysdeps/unix/sysv/linux/powerpc/sysconf.c: New file. Add powerpc-specific overrides for L1, L2, L3 CACHE_SIZEs, CACHE_ASSOCs, and CACHE_LINESIZEs, retrieving from auxv. * sysdeps/unix/sysv/linux/powerpc/test-powerpc-linux-sysconf.c: New file. Invoke newly supported sysconf values for powerpc, and report results. If none are supported, report so. * sysdeps/unix/sysv/linux/powerpc/Makefile (tests): Add new test, tst-sysconf.
* Fix waitid namespace (bug 21561).Joseph Myers2017-06-091-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In sys/wait.h, waitid and associated constants and types are UX-shaded in XPG4.2 (so not in XPG4), and XSI-shaded in POSIX before 2008, so should be appropriately conditional in the headers. This patch fixes the conditionals accordingly. (WCONTINUED is actually still XSI-shaded in POSIX.1:2008, but W* is also reserved there without XSI-shading, so nothing special needs to be done about the conditionals on WCONTINUED to conform to POSIX.1:2008 namespace rules.) Tested for x86_64. [BZ #21561] * posix/sys/wait.h (idtype_t): Change [__USE_XOPEN] condition to [__USE_XOPEN_EXTENDED]. (id_t): Likewise. (include of <bits/types/siginfo_t.h): Likewise. (waitid): Likewise. * sysdeps/unix/sysv/linux/bits/waitflags.h (WSTOPPED): Condition on [__USE_XOPEN_EXTENDED || __USE_XOPEN2K8]. (WEXITED): Likewise. (WCONTINUED): Likewise. (WNOWAIT): Likewise. * conform/Makefile (test-xfail-XPG4/stdlib.h/conform): Remove. (test-xfail-XPG4/sys/wait.h/conform): Likewise. (test-xfail-POSIX/sys/wait.h/conform): Likewise.
* Update nios2, sparc32 localplt.data files for recent GCC change.Joseph Myers2017-06-092-4/+5
| | | | | | | | | | | | | | | | | | | | | | A recent GCC change to expand floating-point classification built-in functions inline using integer rather than floating-point arithmetic in some cases resulted in localplt test failures for nios2 and sparc32 <https://sourceware.org/ml/libc-testresults/2017-q2/msg00320.html>. This patch updates the localplt.data files in question to mark the relevant symbols as optional / add a new optional symbol. (The GCC patch has been reverted because of other problems it caused, but one can assume it will be applied again, without changes that would affect the PLT entries generated, once those issues have been resolved.) Tested with build-many-glibcs.py. * sysdeps/unix/sysv/linux/nios2/localplt.data (__gtdf2): Mark libc.so PLT entry optional. (__gtsf2): Likewise. (__unorddf2): Likewise. (__unordsf2): Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/localplt.data (_Q_fgt): New optional libc.so PLT entry.
* aarch64: Fix undefined behavior in _dl_procinfoSiddhesh Poyarekar2017-06-091-3/+3
| | | | | | | | | 1 << 31 is undefined, so replace it with a cleaner check. Also remove magic numbers in comments. * sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h: Remove mention of magic numbers in comments. (_dl_procinfo): Fix undefined behavior
* ld.so: Consolidate 2 strtouls into _dl_strtoul [BZ #21528]H.J. Lu2017-06-081-1/+1
| | | | | | | | | | | | | | | | | | | | | There are 2 minimal strtoul implementations in ld.so: 1. __strtoul_internal in elf/dl-minimal.c. 2. tunables_strtoul in elf/dl-tunables.c. This patch adds _dl_strtoul to replace them. Tested builds with and without --enable-tunables. [BZ #21528] * elf/dl-minimal.c (__strtoul_internal): Removed. (strtoul): Likewise. * elf/dl-misc.c (_dl_strtoul): New function. * elf/dl-tunables.c (tunables_strtoul): Removed. (tunable_initialize): Replace tunables_strtoul with _dl_strtoul. * elf/rtld.c (process_envvars): Likewise. * sysdeps/unix/sysv/linux/dl-librecon.h (_dl_osversion_init): Likewise. * sysdeps/generic/ldsodefs.h (_dl_strtoul): New prototype.
* Remove __need macros from stdio.h and wchar.h.Zack Weinberg2017-06-081-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | wint_t is a little finicky because it might be defined by stddef.h, which belongs to the compiler. In addition to the _types_, a bunch of other declarations shared between wctype.h and wchar.h are factored out to their own header. * libio/bits/types/FILE.h, libio/bits/types/__FILE.h * wcsmbs/bits/types/mbstate_t.h, wcsmbs/bits/types/__mbstate_t.h * wcsmbs/bits/types/wint_t.h: New single-type definition files. * wctype/bits/wctype-wchar.h: New file holding declarations shared between wctype.h and wchar.h. * libio/Makefile, wcsmbs/Makefile, wctype/Makefile: Install them. * include/bits/types/FILE.h, include/bits/types/__FILE.h * include/bits/types/mbstate_t.h, include/bits/types/__mbstate_t.h * include/bits/types/wint_t.h, include/bits/wcsmbs-wchar.h: New wrappers. * include/stdio.h, include/wchar.h, include/wctype.h: No need to handle __need macros. * grp/grp.h, gshadow/gshadow.h, hurd/hurd.h, iconv/gconv.h * libio/stdio.h, mach/mach.h, misc/mntent.h, pwd/pwd.h * shadow/shadow.h, stdio-common/printf.h, wcsmbs/uchar.h * wcsmbs/wchar.h, wctype/wctype.h * sysdeps/generic/_G_config.h, sysdeps/unix/sysv/linux/_G_config.h Use the new files instead of __need macros.
* Remove check for NULL buffer passed to `ptsname_r'Arjun Shankar2017-06-071-6/+0
| | | | | | | | | | | | | | `ptsname_r' is declared in stdlib.h to only accept a `nonnull' second argument and therefore GCC may choose to make optimizations based on the assumption that this argument is NULL. This means that potentially, GCC can optimize away the NULL check at some point in the future. Since this is a programming interface, we might as well remove the NULL check ourselves. This also warrants a change to the `ptsname_r' manual page that must be submitted to the corresponding mailing list. In addition, remove the NULL buffer test in login/tst-ptsname.c.
* Use test-driver in sysdeps/unix/sysv/linux/tst-clone2.cArjun Shankar2017-06-071-4/+3
|
* aarch64: Add hwcap string routinesSiddhesh Poyarekar2017-06-072-8/+65
| | | | | | | | | | | | | Add support for routines in dl-procinfo.h to show string versions of HWCAP entries when a program is invoked with the LD_SHOW_AUXV environment variable set and also to aid in path resolution for ldconfig. * sysdeps/unix/sysv/linux/aarch64/dl-procinfo.c (_dl_aarch64_cap_flags): New array. * sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h (_dl_hwcap_string, _dl_string_hwcap, _dl_procinfo): Implement functions.
* aarch64: Allow overriding HWCAP_CPUID feature check using HWCAP_MASKSiddhesh Poyarekar2017-06-072-4/+50
| | | | | | | | | | | | | | | | Now that LD_HWCAP_MASK (or glibc.tune.hwcap_mask) is read early enough to influence cpu feature check in aarch64, use it to influence multiarch selection. Setting LD_HWCAP_MASK such that it clears HWCAP_CPUID will now disable multiarch for the binary. HWCAP_CPUID is also now set in HWCAP_IMPORTANT so that it is set by default. With this patch, this feature is only usable with dyanmically linked binaries because LD_HWCAP_MASK is not read for static binaries. A future patch fixes that. * sysdeps/unix/sysv/linux/aarch64/cpu-features.c (init_cpu_features): Use glibc.tune.hwcap_mask. * sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h: New file.
* Add include guards to dl-procinfo.hSiddhesh Poyarekar2017-06-072-0/+6
| | | | | | | | | | | | | | The dl-procinfo.h for linux/s390 and linux/i386 don't have include guards, which causes them to fail since addition of LD_HWCAP_MASK to tunables. Add _DL_I386_PROCINFO_H guard to avoid redefining _dl_procinfo on multiple includes and also allow the subsequent include of another dl-procinfo.h to work. Verified with a build test on i686. * sysdeps/unix/sysv/linux/i386/dl-procinfo.h: Add include guard. * sysdeps/unix/sysv/linux/s390/dl-procinfo.h: Likewise.
* Optimize generic spinlock code and use C11 like atomic macros.Stefan Liebler2017-06-064-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch optimizes the generic spinlock code. The type pthread_spinlock_t is a typedef to volatile int on all archs. Passing a volatile pointer to the atomic macros which are not mapped to the C11 atomic builtins can lead to extra stores and loads to stack if such a macro creates a temporary variable by using "__typeof (*(mem)) tmp;". Thus, those macros which are used by spinlock code - atomic_exchange_acquire, atomic_load_relaxed, atomic_compare_exchange_weak - have to be adjusted. According to the comment from Szabolcs Nagy, the type of a cast expression is unqualified (see http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_423.htm): __typeof ((__typeof (*(mem)) *(mem)) tmp; Thus from spinlock perspective the variable tmp is of type int instead of type volatile int. This patch adjusts those macros in include/atomic.h. With this construct GCC >= 5 omits the extra stores and loads. The atomic macros are replaced by the C11 like atomic macros and thus the code is aligned to it. The pthread_spin_unlock implementation is now using release memory order instead of sequentially consistent memory order. The issue with passed volatile int pointers applies to the C11 like atomic macros as well as the ones used before. I've added a glibc_likely hint to the first atomic exchange in pthread_spin_lock in order to return immediately to the caller if the lock is free. Without the hint, there is an additional jump if the lock is free. I've added the atomic_spin_nop macro within the loop of plain reads. The plain reads are also realized by C11 like atomic_load_relaxed macro. The new define ATOMIC_EXCHANGE_USES_CAS determines if the first try to acquire the spinlock in pthread_spin_lock or pthread_spin_trylock is an exchange or a CAS. This is defined in atomic-machine.h for all architectures. The define SPIN_LOCK_READS_BETWEEN_CMPXCHG is now removed. There is no technical reason for throwing in a CAS every now and then, and so far we have no evidence that it can improve performance. If that would be the case, we have to adjust other spin-waiting loops elsewhere, too! Using a CAS loop without plain reads is not a good idea on many targets and wasn't used by one. Thus there is now no option to do so. Architectures are now using the generic spinlock automatically if they do not provide an own implementation. Thus the pthread_spin_lock.c files in sysdeps folder are deleted. ChangeLog: * NEWS: Mention new spinlock implementation. * include/atomic.h: (__atomic_val_bysize): Cast type to omit volatile qualifier. (atomic_exchange_acq): Likewise. (atomic_load_relaxed): Likewise. (ATOMIC_EXCHANGE_USES_CAS): Check definition. * nptl/pthread_spin_init.c (pthread_spin_init): Use atomic_store_relaxed. * nptl/pthread_spin_lock.c (pthread_spin_lock): Use C11-like atomic macros. * nptl/pthread_spin_trylock.c (pthread_spin_trylock): Likewise. * nptl/pthread_spin_unlock.c (pthread_spin_unlock): Use atomic_store_release. * sysdeps/aarch64/nptl/pthread_spin_lock.c: Delete File. * sysdeps/arm/nptl/pthread_spin_lock.c: Likewise. * sysdeps/hppa/nptl/pthread_spin_lock.c: Likewise. * sysdeps/m68k/nptl/pthread_spin_lock.c: Likewise. * sysdeps/microblaze/nptl/pthread_spin_lock.c: Likewise. * sysdeps/mips/nptl/pthread_spin_lock.c: Likewise. * sysdeps/nios2/nptl/pthread_spin_lock.c: Likewise. * sysdeps/aarch64/atomic-machine.h (ATOMIC_EXCHANGE_USES_CAS): Define. * sysdeps/alpha/atomic-machine.h: Likewise. * sysdeps/arm/atomic-machine.h: Likewise. * sysdeps/i386/atomic-machine.h: Likewise. * sysdeps/ia64/atomic-machine.h: Likewise. * sysdeps/m68k/coldfire/atomic-machine.h: Likewise. * sysdeps/m68k/m680x0/m68020/atomic-machine.h: Likewise. * sysdeps/microblaze/atomic-machine.h: Likewise. * sysdeps/mips/atomic-machine.h: Likewise. * sysdeps/powerpc/powerpc32/atomic-machine.h: Likewise. * sysdeps/powerpc/powerpc64/atomic-machine.h: Likewise. * sysdeps/s390/atomic-machine.h: Likewise. * sysdeps/sparc/sparc32/atomic-machine.h: Likewise. * sysdeps/sparc/sparc32/sparcv9/atomic-machine.h: Likewise. * sysdeps/sparc/sparc64/atomic-machine.h: Likewise. * sysdeps/tile/tilegx/atomic-machine.h: Likewise. * sysdeps/tile/tilepro/atomic-machine.h: Likewise. * sysdeps/unix/sysv/linux/hppa/atomic-machine.h: Likewise. * sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h: Likewise. * sysdeps/unix/sysv/linux/nios2/atomic-machine.h: Likewise. * sysdeps/unix/sysv/linux/sh/atomic-machine.h: Likewise. * sysdeps/x86_64/atomic-machine.h: Likewise.
* x86-64: Update LO_HI_LONG for p{readv,writev}{64}v2H.J. Lu2017-06-052-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The kernel interface for p{readv,writev}{64}v is (unsigned long fd, {const }struct iovec *iov, unsigned long vlen, unsigned long pos_l, unsigned long pos_h) Except for targets which define __ARCH_WANT_COMPAT_SYS_PREADV64 and __ARCH_WANT_COMPAT_SYS_PWRITEV64, (unsigned long fd, {const }struct iovec *iov, unsigned long vlen, off64_t pos) is used for p{readv,writev}{64}v. X32 is the only such target. The LO_HI_LONG macro is used to pass offset to the pos_l and pos_h pair. Since pos_h is ignored when size of offset == sizeof of pos_l, x86-64 has #define LO_HI_LONG(val) (val) But the kernel interface for p{readv,writev}{64}v2 is (unsigned long fd, {const }struct iovec *iov, unsigned long vlen, unsigned long pos_l, unsigned long pos_h, int flags) Except for targets which define __ARCH_WANT_COMPAT_SYS_PREADV64V2 and __ARCH_WANT_COMPAT_SYS_PWRITEV64V2, (unsigned long fd, {const }struct iovec *iov, unsigned long vlen, off64_t pos, int flags) is used for p{readv,writev}{64}v2. X32 is the only such target. Update x86-64 LO_HI_LONG to pass 0 as the high part of the offset argument for p{readv,writev}{64}v2 and define a different LO_HI_LONG for x32 to only pass one argument for offset. Tested on x32 and x86-64. * sysdeps/unix/sysv/linux/x86_64/sysdep.h (LO_HI_LONG): Pass 0 as the high part of offset. * sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h (LO_HI_LONG): New.
* Define SIG_HOLD for XPG4 (bug 21538).Joseph Myers2017-06-056-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | Various bits/signum.h headers define SIG_HOLD if __USE_UNIX98. That should be __USE_XOPEN, as this macro is in XPG4. This patch fixes the conditionals accordingly. Because of other header bugs, this does not allow any XFAILs to be removed (however, the XPG4/signal.h/conform XFAIL only depends on a few such straightforward header bugs, not on the more complicated to fix ucontext_t issues, as ucontext_t isn't included in signal.h in XPG4). Tested for x86_64. [BZ #21538] * bits/signum.h (SIG_HOLD): Define if [__USE_XOPEN], not [__USE_UNIX98]. * sysdeps/unix/bsd/bits/signum.h (SIG_HOLD): Likewise. * sysdeps/unix/sysv/linux/alpha/bits/signum.h (SIG_HOLD): Likewise. * sysdeps/unix/sysv/linux/bits/signum.h (SIG_HOLD): Likewise. * sysdeps/unix/sysv/linux/hppa/bits/signum.h (SIG_HOLD): Likewise. * sysdeps/unix/sysv/linux/mips/bits/signum.h (SIG_HOLD): Likewise. * sysdeps/unix/sysv/linux/sparc/bits/signum.h (SIG_HOLD): Likewise.
* Fix struct sigaltstack namespace (bug 21517).Joseph Myers2017-06-059-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | glibc defines the stack_t type with the tag struct sigaltstack. This is not permitted by POSIX; sigaltstack is only reserved with file scope in the namespace of ordinary identifiers, not the tag namespace, and in the case where stack_t is obtained from ucontext.h rather than signal.h, it's not reserved with file scope at all. This patch removes the tag accordingly and updates uses in glibc of struct sigaltstack. This is similar to the removal of the "struct siginfo" tag a few years ago: C++ name mangling changes are an unavoidable consequence. A NEWS item is added to note the changed mangling. There is inevitably some risk of breaking builds of anything that relies on the struct sigaltstack name (though the first few hits I looked at from codesearch.debian.net generally seemed to involve code that could use the stack_t name conditionally, so depending on how they determine the conditionals they may work with glibc not defining the struct tag anyway). Tested for x86_64 and x86, and with build-many-glibcs.py. [BZ #21517] * bits/types/stack_t.h (stack_t): Remove struct tag. * sysdeps/unix/sysv/linux/bits/types/stack_t.h (stack_t): Likewise. * sysdeps/unix/sysv/linux/mips/bits/types/stack_t.h (stack_t): Likewise. * debug/segfault.c (install_handler): Use stack_t instead of struct sigaltstack. * hurd/hurd/signal.h (struct hurd_sigstate): Likewise. * hurd/trampoline.c (_hurd_setup_sighandler): Likewise. * include/signal.h (__sigaltstack): Likwise. * signal/sigaltstack.c (__sigaltstack): Likewise. * signal/signal.h (sigaltstack): Likewise. * sysdeps/mach/hurd/i386/signal-defines.sym (SIGALTSTACK__SS_SP__OFFSET): Likewise. (SIGALTSTACK__SS_SIZE__OFFSET): Likewise. (SIGALTSTACK__SS_FLAGS__OFFSET): Likewise. * sysdeps/mach/hurd/sigaltstack.c (__sigaltstack): Likewise. * sysdeps/mach/hurd/sigstack.c (sigstack): Likewise. * sysdeps/unix/sysv/linux/alpha/sys/procfs.h (struct elf_prstatus): Likewise. * sysdeps/unix/sysv/linux/hppa/____longjmp_chk.c (CHECK_SP): Likewise. * sysdeps/unix/sysv/linux/ia64/sys/procfs.h (struct elf_prstatus): Likewise. * sysdeps/unix/sysv/linux/m68k/____longjmp_chk.c (CHECK_SP): Likewise. * sysdeps/unix/sysv/linux/powerpc/sys/procfs.h (struct elf_prstatus): Likewise. * sysdeps/unix/sysv/linux/sh/sys/procfs.h (struct elf_prstatus): Likewise. * sysdeps/unix/sysv/linux/sys/procfs.h (struct elf_prstatus): Likewise.
* Add shim header for bits/syscall.h.Zack Weinberg2017-06-011-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | On Linux-based configurations, bits/syscall.h is a generated file. To avoid build-ordering problems, the Linux sys/syscall.h only includes bits/syscall.h if _LIBC is not defined. After the _ISOMAC-testsuite changes, this means any test case that includes sys/syscall.h tries to pull in bits/syscall.h. This would be fine, because it'll definitely have been generated by the time we start compiling tests, except that the generated <builddir>/misc/bits/syscall.h is not visible in the include path, because nothing needed it till now. So we either get the bits/syscall.h from the host system, or the build fails. The fix is simple: add a shim header for bits/syscall.h. I put it in sysdeps/unix/sysv/linux/include instead of the top-level include/ because bits/syscall.h doesn't exist at all on other configurations as far as I can tell. This is known to affect nptl/tst-cond2[45]. Thanks to John David Anglin for noticing the problem. [BZ #21514] * sysdeps/unix/sysv/linux/include/bits/syscall.h: New shim header pointing to the generated file in <builddir>/misc/bits/syscall.h.
* Fix more namespace issues in sys/ucontext.h (bug 21457).Joseph Myers2017-06-018-142/+235
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Continuing the fixes for namespace issues in sys/ucontext.h, this patch moves various symbols into the implementation namespace in the absence of __USE_MISC. As with previous changes, it is nonexhaustive, just covering more straightforward cases. Structure fields are generally changed to have a prefix __ in the absence of __USE_MISC, via a macro __ctx (used without a space before the open parenthesis, since the result is a single identifier). Various macros such as NGREG also have leading __ added. No changes are made to structure tags (and thus to C++ name mangling), except that in the (unused) file sysdeps/i386/sys/ucontext.h, structures defined inside other structures as the type for a field have their tags removed in the non-__USE_MISC case (those structure tags would not in any case have been visible in C++, because in C++ the scope of such a tag is limited to the containing structure). No changes are made to the contents of bits/sigcontext.h, or to whether it is included. Because of remaining namespace issues, this patch does not yet fix the bug or allow any XFAILs to be removed. Tested for x86_64 and x86, and with build-many-glibcs.py. [BZ #21457] * sysdeps/arm/sys/ucontext.h (NGREG): Rename to __NGREG and define NGREG to __NGREG if [__USE_MISC]. (gregset_t): Define using __NGREG. (__ctx): New macro. (mcontext_t): Use __ctx in defining fields. * sysdeps/i386/sys/ucontext.h (NGREG): Rename to __NGREG and define NGREG to __NGREG if [__USE_MISC]. (gregset_t): Define using __NGREG. (__ctx): New macro. (__ctxt): Likewise. (fpregset_t): Use __ctx and __ctxt in defining fields. (mcontext_t): Likewise. * sysdeps/m68k/sys/ucontext.h (NGREG): Rename to __NGREG and define NGREG to __NGREG if [__USE_MISC]. (gregset_t): Define using __NGREG. (__ctx): New macro. (mcontext_t): Use __ctx in defining fields. * sysdeps/mips/sys/ucontext.h (NGREG): Rename to __NGREG and define NGREG to __NGREG if [__USE_MISC]. (gregset_t): Define using __NGREG. (__ctx): New macro. (fpregset_t): Use __ctx in defining fields. (mcontext_t): Likewise. * sysdeps/unix/sysv/linux/alpha/sys/ucontext.h (NGREG): Rename to __NGREG and define NGREG to __NGREG if [__USE_MISC]. (gregset_t): Define using __NGREG. (NFPREG): Rename to __NFPREG and define NFPREG to __NFPREG if [__USE_MISC]. (fpregset_t): Define using __NFPREG. * sysdeps/unix/sysv/linux/m68k/sys/ucontext.h (NGREG): Rename to __NGREG and define NGREG to __NGREG if [__USE_MISC]. (gregset_t): Define using __NGREG. (__ctx): New macro. (fpregset_t): Use __ctx in defining fields. (mcontext_t): Likewise. * sysdeps/unix/sysv/linux/mips/sys/ucontext.h (NGREG): Rename to __NGREG and define NGREG to __NGREG if [__USE_MISC]. (NFPREG): Rename to __NFPREG and define NFPREG to __NFPREG if [__USE_MISC]. (gregset_t): Define using __NGREG. (__ctx): New macro. (fpregset_t): Use __ctx in defining fields. (mcontext_t): Likewise. * sysdeps/unix/sysv/linux/nios2/sys/ucontext.h (__ctx): New macro. (mcontext_t): Use __ctx in defining fields. * sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h (__ctx): New macro. [__WORDSIZE == 32] (NGREG): Rename to __NGREG and define NGREG to __NGREG if [__USE_MISC]. [__WORDSIZE == 32] (gregset_t): Define using __NGREG. [__WORDSIZE == 32] (fpregset_t): Use __ctx in defining fields. (mcontext_t): Likewise. [__WORDSIZE != 32] (NGREG): Rename to __NGREG and define NGREG to __NGREG if [__USE_MISC]. [__WORDSIZE != 32] (NFPREG): Rename to __NFPREG and define NFPREG to __NFPREG if [__USE_MISC]. [__WORDSIZE != 32] (NVRREG): Rename to __NVRREG and define NVRREG to __NVRREG if [__USE_MISC]. [__WORDSIZE != 32] (gregset_t): Define using __NGREG. [__WORDSIZE != 32] (fpregset_t): Define using __NFPREG. [__WORDSIZE != 32] (vscr_t): Use __ctx in defining fields. [__WORDSIZE != 32] (vrregset_t): Likewise. [__WORDSIZE != 32] (mcontext_t): Likewise. * sysdeps/unix/sysv/linux/s390/sys/ucontext.h (__ctx): New macro. (__psw_t): Use __ctx in defining fields. (NGREG): Rename to __NGREG and define NGREG to __NGREG if [__USE_MISC]. (gregset_t): Define using __NGREG. (fpreg_t): Use __ctx in defining fields. (fpregset_t): Likewise. (mcontext_t): Likewise. * sysdeps/unix/sysv/linux/sh/sys/ucontext.h (NGREG): Rename to __NGREG and define NGREG to __NGREG if [__USE_MISC]. (gregset_t): Define using __NGREG. (NFPREG): Rename to __NFPREG and define NFPREG to __NFPREG if [__USE_MISC]. (fpregset_t): Define using __NFPREG. (__ctx): New macro. (mcontext_t): Use __ctx in defining fields. * sysdeps/unix/sysv/linux/x86/sys/ucontext.h (__ctx): New macro. [__x86_64__] (NGREG): Rename to __NGREG and define NGREG to __NGREG if [__USE_MISC]. [__x86_64__] (gregset_t): Define using __NGREG. [__x86_64__] (struct _libc_fpxreg): Use __ctx in defining fields. [__x86_64__] (struct _libc_fpstate): Likewise. [__x86_64__] (mcontext_t): Likewise. [!__x86_64__] (NGREG): Rename to __NGREG and define NGREG to __NGREG if [__USE_MISC]. [!__x86_64__] (gregset_t): Define using __NGREG. [!__x86_64__] (struct _libc_fpreg): Use __ctx in defining fields. [!__x86_64__] (struct _libc_fpstate): Likewise. [!__x86_64__] (mcontext_t): Likewise.
* Avoid tickling a linker bug from microblaze pt-vfork.S.Zack Weinberg2017-06-013-2/+50
| | | | | | | | | | | | | | | | | | | | libpthread used to have its own vfork implementation that differed from libc's only in having a pointless micro-optimization. There is no longer any use to having a separate copy in libpthread, but the historical ABI requires a compatibility shim. microblaze was trying to be slightly too clever about how it did this, and tickled a linker bug. The linker bug should get fixed eventually, but there's no reason for us to keep tickling it in the meantime. This doesn't reuse the generic pt-vfork.c because microblaze doesn't have IFUNC support yet, and it doesn't reuse aarch64/pt-vfork.c because that fails to generate a tailcall (with GCC 7.1.1). * sysdeps/unix/sysv/linux/microblaze/pt-vfork.S: Don't include alpha/pt-vfork.S. Provide own compat shim for vfork and __vfork. * sysdeps/unix/sysv/linux/microblaze/vfork.S: Add __libc_vfork alias. * sysdeps/unix/sysv/linux/microblaze/localplt.data: libpthread.so no longer references __errno_location.
* posix: Implement preadv2 and pwritev2Adhemerval Zanella2017-05-3139-0/+348
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support of preadv2 and pwritev2 which are similar to preadv/pwritev but with an extra flag argument. As for preadv/pwritev both interfaces are added a non-standard GNU API. For default 'posix' implementation trying to emulate the Linux supported flags is troublesome: * We can not temporary change the file state of the O_DSYNC and O_SYNC flags to emulate RWF_{D}SYNC (attempts to change the state of using fcntl are silently ignored). * IOCB_HIPRI requires the file opened in O_DIRECT and uses an internal semantic not provided by any other flag (O_NONBLOCK for instance). So default sysdeps/posix implementations fails with EOPNOTSUPP for any non supported flag (which are none currently) calls generic preadv/pwritev. Basically this implementation supports only preadv2 called as preadv (with flags sets to 0). The Linux one uses the preadv2/pwritev2 syscall if defined, otherwise it call preadv/writev. Instead of using the previous __ASSUME_* to unconditionally issue the syscall (and avoid building the fallback routine), it call pread/write if the preadv2/pwritev2 syscalls fails. The idea is just avoid adding another __ASSUME_* and checking each architecture on every kernel bump and simplify code conditionals. Checked on x86_64-linux-gnu and on i686-linux-gnu and a check with run-built-tests=no on aarch64-linux-gnu, alpha-linux-gnu, arm-linux-gnueabihf, ia64-linux-gnu, m68k-linux-gnu, microblaze-linux-gnu, mips{64,64n32}-linux-gnu, nios2-linux-gnu, powerpc{64,64le}-linux-gnu, s390{x}-linux-gnu, sparc{64,v9}-linux-gnu, tile{gx,pro}-linux-gnu, and sh4-linux-gnu (all using gcc 6.3). * NEWS: Add note about pwritev2 and preadv2 inclusion. * misc/Makefile (routines): Add preadv2, preadv64v2, pwritev2, and pwritev64v2. (tests): Add tst-preadvwritev2 and tst-preadvwritev64v2. * misc/Versions (GLIBC_2.26): Add preadv2, preadv64v2, pwritev2, and pwritev64v2. * misc/preadv2.c: New file. * misc/preadv64v2.c: Likewise. * misc/pwritev2.c: Likewise. * misc/pwritev64v2.c: Likewise. * misc/tst-preadvwritev2.c: Likewise. * misc/tst-preadvwritev64v2.c: Likewise. * manual/llio.texi: Add preadv2 and pwritev2 documentation. * misc/sys/uio.h [__USE_GNU && !__USE_FILE_OFFSET64] (preadv2): New prototype. [__USE_GNU && !__USE_FILE_OFFSET64] (pwritev2): Likewise. [__USE_GNU && __USE_FILE_OFFSET64] (preadv64v2): Likewise. [__USE_GNU && __USE_FILE_OFFSET64] (pwritev64v2): Likewise. * misc/tst-preadvwritev-common.c (PREADV): Define if not defined. (PWRITEV): Likewise. (do_test_with_offset): Use PREADV and PWRITEV macros and check for ENOSYS. * nptl/tst-cancel4.c (tf_pwritev2): New test. (tf_preadv2): Likewise. (tf_fsync): Add tf_pwritev2 and tf_preadv2. * sysdeps/posix/preadv2.c: Likewise. * sysdeps/posix/preadv64v2.c: Likewise. * sysdeps/posix/pwritev2.c: Likewise. * sysdeps/posix/pwritev64v2.c: Likewise. * sysdeps/unix/sysv/linux/kernel-features.h: Add comment for syscall support in kernel. * sysdeps/unix/sysv/linux/preadv2.c: Likewise. * sysdeps/unix/sysv/linux/preadv64v2.c: Likewise. * sysdeps/unix/sysv/linux/pwritev2.c: Likewise. * sysdeps/unix/sysv/linux/pwritev64v2.c: Likewise. * sysdeps/unix/sysv/linux/preadv.c (preadv): Add libc_hidden_def. * sysdeps/unix/sysv/linux/preadv64.c (preadv64): Likewise. * sysdeps/unix/sysv/linux/pwritev.c (pwritev): Likewise. * sysdeps/unix/sysv/linux/pwritev64.c (pwritev64): Likewise. * sysdeps/unix/sysv/linux/bits/uio.h: Add supported preadv2/pwritev2 support flags on Linux. * sysdeps/unix/sysv/linux/aarch64/libc.abilist (GLIBC_2.26): Add preadv2, preadv64v2, pwritev2, pwritev64v2. * sysdeps/unix/sysv/linux/alpha/libc.abilist (GLIBC_2.26): Likewise. * sysdeps/unix/sysv/linux/arm/libc.abilist (GLIBC_2.26): Likewise. * sysdeps/unix/sysv/linux/hppa/libc.abilist (GLIBC_2.26): Likewise. * sysdeps/unix/sysv/linux/i386/libc.abilist (GLIBC_2.26): Likewise. * sysdeps/unix/sysv/linux/ia64/libc.abilist (GLIBC_2.26): Likewise. * sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist (GLIBC_2.26): Likewise. * sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist (GLIBC_2.26): Likewise. * sysdeps/unix/sysv/linux/microblaze/libc.abilist (GLIBC_2.26): Likewise. * sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist (GLIBC_2.26): Likewise. * sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist (GLIBC_2.26): Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist (GLIBC_2.26): Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist (GLIBC_2.26): Likewise. * sysdeps/unix/sysv/linux/nios2/libc.abilist (GLIBC_2.26): Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist (GLIBC_2.26): Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist (GLIBC_2.26): Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist (GLIBC_2.26): Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist (GLIBC_2.26): Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist (GLIBC_2.26): Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist (GLIBC_2.26): Likewise. * sysdeps/unix/sysv/linux/sh/libc.abilist (GLIBC_2.26): Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist (GLIBC_2.26): Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist (GLIBC_2.26): Likewise. * sysdeps/sysv/linux/tile/tilegx/tilegx32/libc.abilist (GLIBC_2.26): Likewise. * sysdeps/sysv/linux/tile/tilegx/tilegx64/libc.abilist (GLIBC_2.26): Likewise. * sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist (GLIBC_2.26): Likewise. * sysdeps/unix/sysv/linux/x86_64/64/libc.abilist (GLIBC_2.26): Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist (GLIBC_2.26): Likewise.
* Delay initialization of CPU features struct in static binariesSiddhesh Poyarekar2017-05-311-18/+5
| | | | | | | | | | | | | | | | | | | | | Allow the CPU features structure set up to be overridden by tunables by delaying it to until after tunables are initialized. The initialization is already delayed in dynamically linked glibc, it is only in static binaries that the initialization is set early to allow it to influence IFUNC relocations that happen in libc-start. It is a bit too early however and there is a good place between tunables initialization and IFUNC relocations where this can be done. Verified that this does not regress the testsuite. * csu/libc-start.c [!ARCH_INIT_CPU_FEATURES]: Define ARCH_INIT_CPU_FEATURES. (LIBC_START_MAIN): Call it. * sysdeps/unix/sysv/linux/aarch64/libc-start.c (__libc_start_main): Remove. (ARCH_INIT_CPU_FEATURES): New macro. * sysdeps/x86/libc-start.c (__libc_start_main): Remove. (ARCH_INIT_CPU_FEATURES): New macro.
* Add reallocarray functionDennis Wölfing2017-05-3028-0/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The reallocarray function is an extension from OpenBSD. It is an integer-overflow-safe replacement for realloc(p, X*Y) and malloc(X*Y) (realloc(NULL, X*Y)). It can therefore help in preventing certain security issues in code. This is an updated version of a patch originally submitted by Rüdiger Sonderfeld in May 2014 [1]. Checked on i686-linux-gnu and x86_64-linux-gnu. [1] <https://sourceware.org/ml/libc-alpha/2014-05/msg00481.html>. 2017-05-30 Dennis Wölfing <denniswoelfing@gmx.de> Rüdiger Sonderfeld <ruediger@c-plusplus.de> * include/stdlib.h (__libc_reallocarray): New declaration. * malloc/Makefile (routines): Add reallocarray. (tests): Add tst-reallocarray.c. * malloc/Versions: Add reallocarray and __libc_reallocarray. * malloc/malloc-internal.h (check_mul_overflow_size_t): New inline function. * malloc/malloc.h (reallocarray): New declaration. * stdlib/stdlib.h (reallocarray): Likewise. * malloc/reallocarray.c: New file. * malloc/tst-reallocarray.c: New test file. * manual/memory.texi: Document reallocarray. * sysdeps/unix/sysv/linux/aarch64/libc.abilist: Add reallocarray. * sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/tilepro/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
* arm: Fix typo in array countSiddhesh Poyarekar2017-05-242-2/+2
| | | | | | | | | | I just noticed that the array count for the hwcap flags list in ARM is off by 10, i.e. 37 instead of 27. Following patch fixes this. * sysdeps/unix/sysv/linux/arm/dl-procinfo.c (_dl_arm_cap_flags): Fix array subscript. * sysdeps/unix/sysv/linux/arm/dl-procinfo.h (_DL_HWCAP_COUNT): Fix count.
* Fix sys/ucontext.h namespace from signal.h etc. inclusion (bug 21457).Joseph Myers2017-05-2315-109/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The various sys/ucontext.h headers include <signal.h> and all the headers split out of <bits/sigstack.h>. (Except that the powerpc version does not include <signal.h>.) None of the standard versions defining ucontext.h require or permit such inclusions; rather, they all say that the stack_t and sigset_t types from signal.h are defined. This patch fixes the headers to include just the bits/ headers for those types (and the existing includes of bits/sigcontext.h). Since bits/types/sigset_t.h is now being included instead of bits/types/__sigset_t.h, __sigset_t uses in the headers are replaced by direct use of the public sigset_t type. sysdeps/unix/sysv/linux/x86/bits/sigcontext.h was relying on the prior inclusion of <signal.h> to define types such as __uint32_t, so gets a bits/types.h include added to provide those types. Although one could keep some or all of the includes under a __USE_MISC conditional, that seems unnecessary to me, especially given the lack of a <signal.h> include in the powerpc version meaning that portable programs already cannot rely on such an include. Tested for x86_64 and x86, and with build-many-glibcs.py. As with other such fixes, more namespace issues remain so this does not permit any XFAILs to be removed or bugs to be closed. [BZ #21457] * sysdeps/arm/sys/ucontext.h: Do not include <signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or <bits/ss_flags.h>. Include <bits/types/sigset_t.h> instead of <bits/types/__sigset_t.h>. (ucontext_t): Use sigset_t instead of __sigset_t. * sysdeps/generic/sys/ucontext.h: Do not include <signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or <bits/ss_flags.h>. Include <bits/types/sigset_t.h> instead of <bits/types/__sigset_t.h>. (ucontext_t): Use sigset_t instead of __sigset_t. * sysdeps/i386/sys/ucontext.h: Do not include <signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or <bits/ss_flags.h>. Include <bits/types/sigset_t.h> instead of <bits/types/__sigset_t.h>. (ucontext_t): Use sigset_t instead of __sigset_t. * sysdeps/m68k/sys/ucontext.h: Do not include <signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or <bits/ss_flags.h>. Include <bits/types/sigset_t.h> instead of <bits/types/__sigset_t.h>. (ucontext_t): Use sigset_t instead of __sigset_t. * sysdeps/mips/sys/ucontext.h: Do not include <signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or <bits/ss_flags.h>. Include <bits/types/sigset_t.h> instead of <bits/types/__sigset_t.h>. (ucontext_t): Use sigset_t instead of __sigset_t. * sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h: Do not include <signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or <bits/ss_flags.h>. Include <bits/types/sigset_t.h> instead of <bits/types/__sigset_t.h>. (ucontext_t): Use sigset_t instead of __sigset_t. * sysdeps/unix/sysv/linux/alpha/sys/ucontext.h: Do not include <signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or <bits/ss_flags.h>. Include <bits/types/sigset_t.h> instead of <bits/types/__sigset_t.h>. (ucontext_t): Use sigset_t instead of __sigset_t. * sysdeps/unix/sysv/linux/arm/sys/ucontext.h: Do not include <signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or <bits/ss_flags.h>. Include <bits/types/sigset_t.h> instead of <bits/types/__sigset_t.h>. (ucontext_t): Use sigset_t instead of __sigset_t. * sysdeps/unix/sysv/linux/hppa/sys/ucontext.h: Do not include <signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or <bits/ss_flags.h>. Include <bits/types/sigset_t.h> instead of <bits/types/__sigset_t.h>. (ucontext_t): Use sigset_t instead of __sigset_t. * sysdeps/unix/sysv/linux/ia64/sys/ucontext.h: Do not include <signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or <bits/ss_flags.h>. Include <bits/types/sigset_t.h>. * sysdeps/unix/sysv/linux/m68k/sys/ucontext.h: Do not include <signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or <bits/ss_flags.h>. Include <bits/types/sigset_t.h> instead of <bits/types/__sigset_t.h>. (ucontext_t): Use sigset_t instead of __sigset_t. * sysdeps/unix/sysv/linux/mips/sys/ucontext.h: Do not include <signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or <bits/ss_flags.h>. Include <bits/types/sigset_t.h> instead of <bits/types/__sigset_t.h>. (ucontext_t): Use sigset_t instead of __sigset_t. * sysdeps/unix/sysv/linux/nios2/sys/ucontext.h: Do not include <signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or <bits/ss_flags.h>. Include <bits/types/sigset_t.h> instead of <bits/types/__sigset_t.h>. (ucontext_t): Use sigset_t instead of __sigset_t. * sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h: Do not include <bits/sigstack.h>, <bits/types/struct_sigstack.h> or <bits/ss_flags.h>. * sysdeps/unix/sysv/linux/s390/sys/ucontext.h: Do not include <signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or <bits/ss_flags.h>. Include <bits/types/sigset_t.h> instead of <bits/types/__sigset_t.h>. (ucontext_t): Use sigset_t instead of __sigset_t. * sysdeps/unix/sysv/linux/sh/sys/ucontext.h: Do not include <signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or <bits/ss_flags.h>. Include <bits/types/sigset_t.h> instead of <bits/types/__sigset_t.h>. (ucontext_t): Use sigset_t instead of __sigset_t. * sysdeps/unix/sysv/linux/sparc/sys/ucontext.h: Do not include <signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or <bits/ss_flags.h>. Include <bits/types/sigset_t.h> instead of <bits/types/__sigset_t.h>. (ucontext_t): Use sigset_t instead of __sigset_t. * sysdeps/unix/sysv/linux/tile/sys/ucontext.h: Do not include <signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or <bits/ss_flags.h>. Include <bits/types/sigset_t.h> instead of <bits/types/__sigset_t.h>. (ucontext_t): Use sigset_t instead of __sigset_t. * sysdeps/unix/sysv/linux/x86/bits/sigcontext.h: Include <bits/types.h>. * sysdeps/unix/sysv/linux/x86/sys/ucontext.h: Do not include <signal.h>, <bits/sigstack.h>, <bits/types/struct_sigstack.h> or <bits/ss_flags.h>. Include <bits/types/sigset_t.h> instead of <bits/types/__sigset_t.h>. (ucontext_t): Use sigset_t instead of __sigset_t.
* Fix a bug in 'Remove __need macros from signal.h' (a992f506)Zack Weinberg2017-05-227-16/+21
| | | | | | | | | | | | | | | | | | | | | siginfo-arch.h is included in two different places, so the default definitions of the macros that it might or might not define need to be done conditionally afterward, not unconditionally beforehand. * sysdeps/unix/sysv/linux/bits/siginfo-consts.h (__SI_ASYNCIO_AFTER_SIGIO): Define default after including bits/siginfo-arch.h, only if not already defined. * sysdeps/unix/sysv/linux/bits/types/siginfo_t.h (__SI_ALIGNMENT, __SI_BAND_TYPE, __SI_CLOCK_T) (__SI_ERRNO_THEN_CODE, __SI_HAVE_SIGSYS, __SI_SEGFAULT_ADDL): Likewise. * sysdeps/unix/sysv/linux/ia64/bits/siginfo-arch.h * sysdeps/unix/sysv/linux/mips/bits/siginfo-arch.h * sysdeps/unix/sysv/linux/sparc/bits/siginfo-arch.h * sysdeps/unix/sysv/linux/tile/bits/siginfo-arch.h * sysdeps/unix/sysv/linux/x86/bits/siginfo-arch.h: Unconditionally define __SI_* macros.
* Remove __need macros from signal.h.Zack Weinberg2017-05-2041-2581/+712
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The types affected are __sig_atomic_t, sig_atomic_t, __sigset_t, sigset_t, sigval_t, sigevent_t, and siginfo_t. __sig_atomic_t is a scalar, so it's now directly available from bits/types.h. The others get bits/types/ headers. Side effects include: There have been small changes to which non-signal headers expose which subset of the signal-related types. A couple of architectures' nested siginfo_t fields had to be renamed to prevent undesired macro expansion. Internal code that wants to manipulate signal masks must now include <sigsetops.h> (which is not installed) and should be aware that __sigaddset, __sigandset, __sigdelset, __sigemptyset, and __sigorset no longer return a value (unlike the public API). Relatedly, the public signal.h no longer declares any of those functions. The obsolete sigmask() macro no longer has a system-specific definition -- in the cases where it matters, it didn't work anyway. New Linux architectures should create bits/siginfo-arch.h and/or bits/siginfo-consts-arch.h to customize their siginfo_t, rather than duplicating everything in bits/siginfo.h (which no longer exists). Add new __SI_* macros if necessary. Ports to other operating systems are strongly encouraged to generalize this scheme further. * bits/sigevent-consts.h * bits/siginfo-consts.h * bits/types/__sigset_t.h * bits/types/sigevent_t.h * bits/types/siginfo_t.h * sysdeps/unix/sysv/linux/bits/sigevent-consts.h * sysdeps/unix/sysv/linux/bits/siginfo-consts.h * sysdeps/unix/sysv/linux/bits/types/__sigset_t.h * sysdeps/unix/sysv/linux/bits/types/sigevent_t.h * sysdeps/unix/sysv/linux/bits/types/siginfo_t.h: New system-dependent bits headers. * sysdeps/unix/sysv/linux/bits/siginfo-arch.h * sysdeps/unix/sysv/linux/bits/siginfo-consts-arch.h * sysdeps/unix/sysv/linux/ia64/bits/siginfo-arch.h * sysdeps/unix/sysv/linux/ia64/bits/siginfo-consts-arch.h * sysdeps/unix/sysv/linux/mips/bits/siginfo-arch.h * sysdeps/unix/sysv/linux/sparc/bits/siginfo-arch.h * sysdeps/unix/sysv/linux/tile/bits/siginfo-arch.h * sysdeps/unix/sysv/linux/tile/bits/siginfo-consts-arch.h * sysdeps/unix/sysv/linux/x86/bits/siginfo-arch.h: New Linux-only system-dependent bits headers. * signal/bits/types/sig_atomic_t.h * signal/bits/types/sigset_t.h * signal/bits/types/sigval_t.h: New non-system-dependent bits headers. * sysdeps/generic/sigsetops.h * sysdeps/unix/sysv/linux/sigsetops.h: New internal headers. * include/bits/types/sig_atomic_t.h * include/bits/types/sigset_t.h * include/bits/types/sigval_t.h: New wrappers. * signal/sigsetops.h * bits/siginfo.h * bits/sigset.h * sysdeps/unix/sysv/linux/bits/siginfo.h * sysdeps/unix/sysv/linux/bits/sigset.h * sysdeps/unix/sysv/linux/ia64/bits/siginfo.h * sysdeps/unix/sysv/linux/mips/bits/siginfo.h * sysdeps/unix/sysv/linux/s390/bits/siginfo.h * sysdeps/unix/sysv/linux/sparc/bits/siginfo.h * sysdeps/unix/sysv/linux/tile/bits/siginfo.h * sysdeps/unix/sysv/linux/x86/bits/siginfo.h: Deleted. * signal/Makefile, sysdeps/unix/sysv/linux/Makefile: Update lists of installed headers. * posix/bits/types.h: Define __sig_atomic_t here. * signal/signal.h: Use the new bits headers; no need to handle __need_sig_atomic_t nor __need_sigset_t. Don't use __sigmask to define sigmask. * include/signal.h: No need to handle __need_sig_atomic_t nor __need_sigset_t. Don't define __sigemptyset. * io/sys/poll.h, setjmp/setjmp.h * sysdeps/arm/sys/ucontext.h, sysdeps/generic/sys/ucontext.h * sysdeps/i386/sys/ucontext.h, sysdeps/m68k/sys/ucontext.h * sysdeps/mach/hurd/i386/bits/sigcontext.h * sysdeps/mips/sys/ucontext.h, sysdeps/powerpc/novmxsetjmp.h * sysdeps/pthread/bits/sigthread.h * sysdeps/unix/sysv/linux/hppa/sys/ucontext.h * sysdeps/unix/sysv/linux/m68k/sys/ucontext.h * sysdeps/unix/sysv/linux/mips/sys/ucontext.h * sysdeps/unix/sysv/linux/nios2/sys/ucontext.h * sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h * sysdeps/unix/sysv/linux/s390/sys/ucontext.h * sysdeps/unix/sysv/linux/sh/sys/ucontext.h * sysdeps/unix/sysv/linux/sparc/sys/ucontext.h * sysdeps/unix/sysv/linux/tile/sys/ucontext.h * sysdeps/unix/sysv/linux/x86/sys/ucontext.h: Use bits/types/__sigset_t.h. * misc/sys/select.h, posix/spawn.h * sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h * sysdeps/unix/sysv/linux/sys/epoll.h * sysdeps/unix/sysv/linux/sys/signalfd.h: Use bits/types/sigset_t.h. * resolv/netdb.h, rt/mqueue.h: Use bits/types/sigevent_t.h. * rt/aio.h: Use bits/types/sigevent_t.h and bits/sigevent-consts.h. * socket/sys/socket.h: Don't include bits/sigset.h. * login/utmp_file.c, shadow/lckpwdf.c, signal/sigandset.c * signal/sigisempty.c, stdlib/abort.c, sysdeps/posix/profil.c * sysdeps/posix/sigignore.c, sysdeps/posix/sigintr.c * sysdeps/posix/signal.c, sysdeps/posix/sigset.c * sysdeps/posix/sprofil.c, sysdeps/posix/sysv_signal.c * sysdeps/unix/sysv/linux/nptl-signals.h: Include sigsetops.h. * signal/sigaddset.c, signal/sigandset.c, signal/sigdelset.c * signal/sigorset.c, stdlib/abort.c, sysdeps/posix/sigignore.c * sysdeps/posix/signal.c, sysdeps/posix/sigset.c: __sigaddset, __sigandset, __sigdelset, __sigemptyset, __sigorset now return no value. * signal/sigaddset.c, signal/sigdelset.c, signal/sigismem.c Include <errno.h>, <signal.h>, and <sigsetops.h> instead of "sigsetops.h". * signal/sigsetops.c: Explicitly define __sigismember, __sigaddset, and __sigdelset as compatibility symbols. * signal/Versions: Correct commentary on __sigpause, __sigaddset, __sigdelset, __sigismember. * inet/rcmd.c: Include sigsetops.h. Convert old code using __sigblock/__sigsetmask to use __sigprocmask and friends.
* Split up bits/sigstack.h.Joseph Myers2017-05-1924-191/+116
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | bits/sigstack.h contains four things: the legacy struct sigstack type, the preferred stack_t type, the SS_* enum values and macros for signal stack sizes. These vary in different ways between glibc configurations; in particular, the stack sizes vary much more than any of the other pieces. Furthermore, these pieces have different standard namespace rules for when they should be visible (not currently visible in conform/ results both because the relevant tests are XFAILed for sys/ucontext.h namespace issues, and because some of the expectations are incorrect in the same way as the headers, e.g. neither expectations nor headers reflect that current POSIX no longer has either the sigstack function or the sigstack structure). To reduce duplication of identical definitions, and facilitate namespace fixes without requiring the same feature test macro conditions to be repeated in many versions of the same header, this patch splits bits/sigstack.h up into four headers. It keeps the stack size macros, while new bits/types/struct_sigstack.h, bits/types/stack_t.h and bits/ss_flags.h are added for the other pieces. bits/types/struct_sigstack.h is the same everywhere, bits/types/stack_t.h has three variants different in the order of the structure elements (generic = MIPS Linux, and other Linux), and bits/ss_flags.h has generic and Linux variants. This patch includes the new headers everywhere that included <bits/sigstack.h>, so should cause no difference to what any public header defines. Subsequent namespace fixes would then remove or condition some of those includes. There should be no conflicts with Zack's changes to signal.h types, beyond the trivial conflict of both making additions to signal/Makefile's headers list; the two patches affect disjoint sets of types and other definitions. Tested for x86_64 and x86, and with build-many-glibcs.py. * bits/ss_flags.h: New file. * bits/types/stack_t.h: Likewise. * include/bits/types/struct_sigstack.h: Likewise. * signal/bits/types/struct_sigstack.h: Likewise. * sysdeps/unix/sysv/linux/bits/ss_flags.h: Likewise. * sysdeps/unix/sysv/linux/bits/types/stack_t.h: Likewise. * sysdeps/unix/sysv/linux/mips/bits/types/stack_t.h: Likewise. * signal/Makefile (headers): Add bits/types/struct_sigstack.h, bits/types/stack_t.h and bits/ss_flags.h. * signal/signal.h [__USE_XOPEN_EXTENDED || __USE_XOPEN2K8]: Include <bits/types/struct_sigstack.h>, <bits/types/stack_t.h> and <bits/ss_flags.h>. * bits/sigstack.h (struct sigstack): Remove. (stack_t): Likewise. (SS_ONSTACK): Likewise. (SS_DISABLE): Likewise. * sysdeps/unix/sysv/linux/aarch64/bits/sigstack.h (struct sigstack): Likewise. (stack_t): Likewise. (SS_ONSTACK): Likewise. (SS_DISABLE): Likewise. * sysdeps/unix/sysv/linux/alpha/bits/sigstack.h (struct sigstack): Likewise. (stack_t): Likewise. (SS_ONSTACK): Likewise. (SS_DISABLE): Likewise. * sysdeps/unix/sysv/linux/bits/sigstack.h (struct sigstack): Likewise. (stack_t): Likewise. (SS_ONSTACK): Likewise. (SS_DISABLE): Likewise. * sysdeps/unix/sysv/linux/mips/bits/sigstack.h: Likewise. * sysdeps/unix/sysv/linux/ia64/bits/sigstack.h (struct sigstack): Likewise. (stack_t): Likewise. (SS_ONSTACK): Likewise. (SS_DISABLE): Likewise. * sysdeps/unix/sysv/linux/powerpc/bits/sigstack.h (struct sigstack): Likewise. (stack_t): Likewise. (SS_ONSTACK): Likewise. (SS_DISABLE): Likewise. * sysdeps/unix/sysv/linux/sparc/bits/sigstack.h (struct sigstack): Likewise. (stack_t): Likewise. (SS_ONSTACK): Likewise. (SS_DISABLE): Likewise. * sysdeps/arm/sys/ucontext.h: Include <bits/types/struct_sigstack.h>, <bits/types/stack_t.h> and <bits/ss_flags.h>. * sysdeps/generic/sys/ucontext.h: Likewise. * sysdeps/i386/sys/ucontext.h: Likewise. * sysdeps/m68k/sys/ucontext.h: Likewise. * sysdeps/mips/sys/ucontext.h: Likewise. * sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h: Likewise. * sysdeps/unix/sysv/linux/alpha/sys/ucontext.h: Likewise. * sysdeps/unix/sysv/linux/arm/sys/ucontext.h: Likewise. * sysdeps/unix/sysv/linux/hppa/sys/ucontext.h: Likewise. * sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h: Likewise. * sysdeps/unix/sysv/linux/ia64/sys/ucontext.h: Likewise. * sysdeps/unix/sysv/linux/m68k/sys/ucontext.h: Likewise. * sysdeps/unix/sysv/linux/mips/sys/ucontext.h: Likewise. * sysdeps/unix/sysv/linux/nios2/sys/ucontext.h: Likewise. * sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h: Likewise. * sysdeps/unix/sysv/linux/s390/sys/ucontext.h: Likewise. * sysdeps/unix/sysv/linux/sh/sys/ucontext.h: Likewise. * sysdeps/unix/sysv/linux/sparc/sys/ucontext.h: Likewise. * sysdeps/unix/sysv/linux/tile/sys/ucontext.h: Likewise. * sysdeps/unix/sysv/linux/x86/sys/ucontext.h: Likewise.
* Fix makefile rules for vmsplice, splice, and open_by_handle_atAdhemerval Zanella2017-05-191-0/+3
| | | | | | | | | | | | | | | | Commits ecade1c, afbbc18, and a5a34d2 added compiler flags for vmsplice, splice, and open_by_handle_at respectively on default misc/Makefile. However such symbols are build only for Linux and the rules should on linux Makefile only. Checked on x86_64-linux-gnu. * misc/Makefile (CFLAGS-vmsplice.c): Remove rule. (CFLAGS-splice.c): Likewise. (CFLAGS-open_by_handle_at.c): Likewise. * sysdeps/unix/sysv/linux/Makefile (CFLAGS-vmsplice.c): New rule. (CFLAGS-splice.c): Likewise. (CFLAGS-open_by_handle_at.c): Likewise.
* posix: Consolidate Linux mq_timedsend syscallAdhemerval Zanella2017-05-182-1/+33
| | | | | | | | | | | | | | | This patch consolidates the mq_timedsend Linux syscall generation on sysdeps/unix/sysv/linux/mq_timedsend.c. It basically removes it from architecture auto-generation list. Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32, arch64-linux-gnu, arm-linux-gnueabihf, powerpc64le-linux-gnu, sparc64-linux-gnu, and sparcv9-linux-gnu. * rt/Makefile (CFLAGS-mq_timedsend.c): New flag. * sysdeps/unix/sysv/linux/mq_timedsend.c: New file. * sysdeps/unix/sysv/linux/syscalls.list (mq_timedsend): Remove from auto-generation list.
* posix: Consolidate Linux mq_timedreceive syscallAdhemerval Zanella2017-05-182-1/+34
| | | | | | | | | | | | | | | This patch consolidates the mq_timedreceive Linux syscall generation on sysdeps/unix/sysv/linux/mq_timedreceive.c. It basically removes it from architecture auto-generation list. Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32, arch64-linux-gnu, arm-linux-gnueabihf, powerpc64le-linux-gnu, sparc64-linux-gnu, and sparcv9-linux-gnu. * rt/Makefile (CFLAGS-mq_timedreceive.c): New flag. * sysdeps/unix/sysv/linux/mq_timedreceive.c: New file. * sysdeps/unix/sysv/linux/syscalls.list (mq_timedreceive): Remove from auto-generation list.
* linux: Consolidate Linux open_by_handle_at syscallAdhemerval Zanella2017-05-183-2/+39
| | | | | | | | | | | | | | | | | | This patch consolidates the open_by_handle_at Linux syscall generation on sysdeps/unix/sysv/linux/open_by_handle_at.c. It basically removes it from architectures auto-generation list. Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32, arch64-linux-gnu, arm-linux-gnueabihf, powerpc64le-linux-gnu, sparc64-linux-gnu, and sparcv9-linux-gnu. * sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Add open_by_handle_at. (CFLAGS-open_by_handle_at.c): New flag. * sysdeps/unix/sysv/linux/open_by_handle_at.c: New file. * sysdeps/unix/sysv/linux/syscalls.list (open_by_handle_at): New file. * misc/Makefile (CFLAGS-open_by_handle_at.c): New rule.
* linux: Consolidate Linux splice syscallAdhemerval Zanella2017-05-183-2/+28
| | | | | | | | | | | | | | | | | This patch consolidates the splice Linux syscall generation on sysdeps/unix/sysv/linux/splice.c. It basically removes it from architectures auto-generation list. Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32, arch64-linux-gnu, arm-linux-gnueabihf, powerpc64le-linux-gnu, sparc64-linux-gnu, and sparcv9-linux-gnu. * sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Add splice. (CFLAGS-splice.c): New flag. * sysdeps/unix/sysv/linux/splice.c: New file. * sysdeps/unix/sysv/linux/syscalls.list (splice): Remove from auto-generation syscall list. * misc/Makefile (CFLAGS-splice.c): New rule.
* linux: Consolidate Linux vmsplice syscallAdhemerval Zanella2017-05-183-2/+28
| | | | | | | | | | | | | | | | This patch consolidates the vmsplice Linux syscall generation on sysdeps/unix/sysv/linux/vmsplice.c. It basically removes it from architectures auto-generation list. Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32, arch64-linux-gnu, arm-linux-gnueabihf, powerpc64le-linux-gnu, sparc64-linux-gnu, and sparcv9-linux-gnu. * sysdeps/unix/sysv/linux/Makefile (CFLAGS-vmsplice.c): New flag. * sysdeps/unix/sysv/linux/syscalls.list (vmsplice): Remove from auto-generation syscall list. * sysdeps/unix/sysv/linux/vmsplice.c: New file. * misc/Makefile (CFLAGS-vmsplice.c): New rule.
* posix: Consolidate Linux fsync syscallAdhemerval Zanella2017-05-183-2/+28
| | | | | | | | | | | | | | | | | | | | | | | This patch consolidates the fsync Linux syscall generation on sysdeps/unix/sysv/linux/fsync.c. It basically removes it from architectures auto-generation list. For arm it also removes the __errno_location call since fsync is not called with SYSCALL_CANCEL with call arch-specific INLINE_SYSCALL macro which in turn will call __set_errno macro (and setting errno directly). Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32, arch64-linux-gnu, arm-linux-gnueabihf, powerpc64le-linux-gnu, sparc64-linux-gnu, and sparcv9-linux-gnu. * misc/Makefile (CFLAGS-fsync.c): New flag. * nptl/Makefile (CFLAGS-fsync.c): Likewise. * sysdeps/unix/syscalls.list (fsync): Remove from auto-generation syscall list. * sysdeps/unix/sysv/linux/fsync.c: New file. * sysdeps/unix/sysv/linux/arm/localplt.data [libpthread.so] (__errno_location): Remove.
* posix: Consolidate Linux fdatasync syscallAdhemerval Zanella2017-05-182-1/+29
| | | | | | | | | | | | | | | | This patch consolidates the fdatasync Linux syscall generation on sysdeps/unix/sysv/linux/fdatasync.c. It basically removes it from architectures auto-generation list. Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32, arch64-linux-gnu, arm-linux-gnueabihf, powerpc64le-linux-gnu, sparc64-linux-gnu, and sparcv9-linux-gnu. * misc/makefile (CFLAGS-datasync.c): New flag. * nptl/makefile (CFLAGS-datasync.c): Likewise. * sysdeps/unix/sysv/linux/syscalls.list (fdatasync): Remove from auto-generation syscall list. * sysdeps/unix/sysv/linux/fdatasync.c: New file.
* posix: Consolidate Linux msync syscallAdhemerval Zanella2017-05-182-1/+26
| | | | | | | | | | | | | | | This patch consolidates the msync Linux syscall generation on sysdeps/unix/sysv/linux/msync.c. It basically removes it from architectures auto-generation list. Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32, arch64-linux-gnu, arm-linux-gnueabihf, powerpc64le-linux-gnu, sparc64-linux-gnu, and sparcv9-linux-gnu. * misc/Makefile (CFLAGS-msync.c): New rule. * nptl/Makefile (CFLAGS-msync.c): Likewise. * sysdeps/unix/syscalls.list: Remove msync from auto-generation list. * sysdeps/unix/sysv/linux/msync.c: New file.
* posix: Consolidate Linux sigsuspend implementationAdhemerval Zanella2017-05-183-40/+0
| | | | | | | | | | | | | | | | | | | | This patch consolidates the sigsuspend Linux syscall generation on sysdeps/unix/sysv/linux/sigsuspend.c. It basically removes the alpha assembly version which call the old sigsusped interface using only the first doubleword from sigset. Current minimum supported kernel on alpha (3.2) enforces rt_sigsuspend on the architecture (__ARCH_WANT_SYS_RT_SIGSUSPEND option on kernel), so it is possible to use the default implementation. Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32, arch64-linux-gnu, arm-linux-gnueabihf, powerpc64le-linux-gnu, sparc64-linux-gnu, and sparcv9-linux-gnu. * sysdeps/unix/sysv/linux/alpha/sigsuspend.S: Remove file. * sysdeps/unix/sysv/linux/sigsuspend.c: Simplify include list. * nptl/Makefile (CFLAGS-sigsuspend.c): New rule. * sysdeps/unix/sysv/linux/sparc/sparc64/Makefile (CFLAGS-sigsuspend.c): Remove rule.
* linux: Consolidate Linux tee implementationAdhemerval Zanella2017-05-183-2/+28
| | | | | | | | | | | | | | | | This patch consolidates the tee Linux syscall generation on sysdeps/unix/sysv/linux/tee.c. It basically removes it from architectures auto-generation list. Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32, arch64-linux-gnu, arm-linux-gnueabihf, powerpc64le-linux-gnu, sparc64-linux-gnu, and sparcv9-linux-gnu. * sysdeps/unix/sysv/linux/Makefile (sysdeps_routines): Add tee. (CFLAGS-tee.c): New rule. * sysdeps/unix/sysv/linux/syscalls.list: Remove tee from auto-generated list. * sysdeps/unix/sysv/linux/tee.c: New file.
* posix: Consolidate Linux nanosleep syscallAdhemerval Zanella2017-05-182-1/+30
| | | | | | | | | | | | | | | | This patch consolidates the nanosleep Linux syscall generation on sysdeps/unix/sysv/linux/nanosleep.c. It basically removes it from architectures auto-generation list. Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32, arch64-linux-gnu, arm-linux-gnueabihf, powerpc64le-linux-gnu, sparc64-linux-gnu, and sparcv9-linux-gnu. * nptl/Makefile (CFLAGS-nanosleep.c): New rule. * posix/Makefile (CFLAGS-nanosleep.c): Likewise. * sysdeps/unix/sysv/linux/nanosleep.c: New file. * sysdeps/unix/sysv/linux/syscalls.list: Remove nanosleep from auto-generated list.
* posix: Consolidate Linux waitpid syscallAdhemerval Zanella2017-05-186-28/+0
| | | | | | | | | | | | | | | | | | This patch consolidates the waitpid Linux syscall generation on sysdeps/unix/sysv/linux/waitpid.c. It basically removes it from architecture auto-generation list and also remove arch specific implementations. Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32, arch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu. * sysdeps/unix/sysv/linux/sh/syscalls.list: Remove waitpid from auto-generated list. * sysdeps/unix/sysv/linux/m68k/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/i386/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/sparc/syscalls.list: Remove file. * sysdeps/unix/sysv/linux/tile/waitpid.S: Likewise. * sysdeps/unix/sysv/linux/powerpc/syscalls.list: Likewise.
* posix: Consolidate Linux pause syscallAdhemerval Zanella2017-05-185-22/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch consolidates the pause Linux implementation on sysdeps/unix/sysv/linux/pause.c. If defined the pause syscall (__NR_pause) will be used, other ppoll with 0 arguments will be used instead. It has the small advantage of generic pause implementation with uses rt_sigprocmask plus rt_sigsuspend because it requires only one syscall and the pause is done atomically regarding signal handling (for instance, pause may not be interrupted if the signal arrives between the rt_sigprocmask and rt_sigsuspend syscall). Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32, arch64-linux-gnu, arm-linux-gnueabihf, powerpc64le-linux-gnu, sparc64-linux-gnu, and sparcv9-linux-gnu. * sysdeps/unix/sysv/linux/generic/pause.c: Remove file. * sysdeps/unix/sysv/linux/sparc/sparc64/pause.c: Likewise. * sysdeps/unix/sysv/linux/sparc/kernel-features.h [__arch64__] (__NR_pause): Undefine. * sysdeps/unix/sysv/linux/pause.c: New file. * sysdeps/unix/sysv/linux/syscalls.list: Remove pause from auto-generation list.