Commit Graph

348 Commits

Author SHA1 Message Date
Adhemerval Zanella 06ab719d30 Fix Linux fcntl OFD locks for non-LFS architectures (BZ#20251)
This patch fixes the OFD ("file private") locks for architectures that
support non-LFS flock definition (__USE_FILE_OFFSET64 not defined). The
issue in this case is both F_OFD_{GETLK,SETLK,SETLKW} and
F_{SET,GET}L{W}K64 expects a flock64 argument and when using old
F_OFD_* flags with a non LFS flock argument the kernel might interpret
the underlying data wrongly.  Kernel idea originally was to avoid using
such flags in non-LFS syscall, but since GLIBC uses fcntl with LFS
semantic as default it is possible to provide the functionality and
avoid the bogus struct kernel passing by adjusting the struct manually
for the required flags.

The idea follows other LFS interfaces that provide two symbols:

  1. A new LFS fcntl64 is added on default ABI with the usual macros to
     select it for FILE_OFFSET_BITS=64.

  2. The Linux non-LFS fcntl use a stack allocated struct flock64 for
     F_OFD_{GETLK,SETLK,SETLKW} copy the results on the user provided
     struct.

  3. Keep a compat symbol with old broken semantic for architectures
     that do not define __OFF_T_MATCHES_OFF64_T.

So for architectures which defines __USE_FILE_OFFSET64, fcntl64 will
aliased to fcntl and no adjustment would be required.  So to actually
use F_OFD_* with LFS support the source must be built with LFS support
(_FILE_OFFSET_BITS=64).

Also F_OFD_SETLKW command is handled a cancellation point, as for
F_SETLKW{64}.

Checked on x86_64-linux-gnu and i686-linux-gnu.

	[BZ #20251]
	* NEWS: Mention fcntl64 addition.
	* csu/check_fds.c: Replace __fcntl_nocancel by __fcntl64_nocancel.
	* login/utmp_file.c: Likewise.
	* sysdeps/posix/fdopendir.c: Likewise.
	* sysdeps/posix/opendir.c: Likewise.
	* sysdeps/unix/pt-fcntl.c: Likewise.
	* include/fcntl.h (__libc_fcntl64, __fcntl64,
	__fcntl64_nocancel_adjusted): New prototype.
	(__fcntl_nocancel_adjusted): Remove prototype.
	* io/Makefile (routines): Add fcntl64.
	(CFLAGS-fcntl64.c): New rule.
	* io/Versions [GLIBC_2.28] (fcntl64): New symbol.
	[GLIBC_PRIVATE] (__libc_fcntl): Rename to __libc_fcntl64.
	* io/fcntl.h (fcntl64): Add prototype and redirect if
	__USE_FILE_OFFSET64 is defined.
	* io/fcntl64.c: New file.
	* manual/llio.text: Add a note for which commands fcntl acts a
	cancellation point.
	* nptl/Makefile (CFLAGS-fcntl64.c): New rule.
	* sysdeps/mach/hurd/fcntl.c: Alias fcntl to fcntl64 symbols.
	* sysdeps/mach/hurd/i386/libc.abilist [GLIBC_2.28] (fcntl, fcntl64):
	New symbols.
	* sysdeps/unix/sysv/linux/fcntl.c (__libc_fcntl): Fix F_GETLK64,
	F_OFD_GETLK, F_SETLK64, F_SETLKW64, F_OFD_SETLK, and F_OFD_SETLKW for
	non-LFS case.
	* sysdeps/unix/sysv/linux/fcntl64.c: New file.
	* sysdeps/unix/sysv/linux/fcntl_nocancel.c (__fcntl_nocancel): Rename
	to __fcntl64_nocancel.
	(__fcntl_nocancel_adjusted): Rename to __fcntl64_nocancel_adjusted.
	* sysdeps/unix/sysv/linux/not-cancel.h (__fcntl_nocancel): Rename
	to __fcntl64_nocancel.
	* sysdeps/unix/sysv/linux/tst-ofdlocks.c: New file.
	* sysdeps/unix/sysv/linux/tst-ofdlocks-compat.c: Likewise.
	* sysdeps/unix/sysv/linux/Makefile (tests): Add tst-ofdlocks.
	(tests-internal): Add tst-ofdlocks-compat.
	* sysdeps/unix/sysv/linux/aarch64/libc.abilist [GLIBC_2.28]
	(fcntl64): New symbol.
	* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise.
	* sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libc.abilist [GLIBC_2.28] (fcntl,
	fcntl64): Likewise.
	* sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libc.abilis: 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/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/s390/s390-32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
2018-06-26 13:22:53 -03:00
Zack Weinberg 329ea513b4 Avoid cancellable I/O primitives in ld.so.
Neither the <dlfcn.h> entry points, nor lazy symbol resolution, nor
initial shared library load-up, are cancellation points, so ld.so
should exclusively use I/O primitives that are not cancellable.  We
currently achieve this by having the cancellation hooks compile as
no-ops when IS_IN(rtld); this patch changes to using exclusively
_nocancel primitives in the source code instead, which makes the
intent clearer and significantly reduces the amount of code compiled
under IS_IN(rtld) as well as IS_IN(libc) -- in particular,
elf/Makefile no longer thinks we require a copy of unwind.c in
rtld-libc.a.  (The older mechanism is preserved as a backstop.)

The bulk of the change is splitting up the files that define the
_nocancel I/O functions, so they don't also define the variants that
*are* cancellation points; after which, the existing logic for picking
out the bits of libc that need to be recompiled as part of ld.so Just
Works.  I did this for all of the _nocancel functions, not just the
ones used by ld.so, for consistency.

fcntl was a little tricky because it's only a cancellation point for
certain opcodes (F_SETLKW(64), which can block), and the existing
__fcntl_nocancel wasn't applying the FCNTL_ADJUST_CMD hook, which
strikes me as asking for trouble, especially as the only nontrivial
definition of FCNTL_ADJUST_CMD (for powerpc64) changes F_*LK* opcodes.
To fix this, fcntl_common moves to fcntl_nocancel.c along with
__fcntl_nocancel, and changes its name to the extern (but hidden)
symbol __fcntl_nocancel_adjusted, so that regular fcntl can continue
calling it.  __fcntl_nocancel now applies FCNTL_ADJUST_CMD; so that
both both fcntl.c and fcntl_nocancel.c can see it, the only nontrivial
definition moves from sysdeps/u/s/l/powerpc/powerpc64/fcntl.c to
.../powerpc64/sysdep.h and becomes entirely a macro, instead of a macro
that calls an inline function.

The nptl version of libpthread also changes a little, because its
"compat-routines" formerly included files that defined all the
_nocancel functions it uses; instead of continuing to duplicate them,
I exported the relevant ones from libc.so as GLIBC_PRIVATE.  Since the
Linux fcntl.c calls a function defined by fcntl_nocancel.c, it can no
longer be used from libpthread.so; instead, introduce a custom
forwarder, pt-fcntl.c, and export __libc_fcntl from libc.so as
GLIBC_PRIVATE.  The nios2-linux ABI doesn't include a copy of vfork()
in libpthread, and it was handling that by manipulating
libpthread-routines in .../linux/nios2/Makefile; it is cleaner to do
what other such ports do, and have a pt-vfork.S that defines no symbols.

Right now, it appears that Hurd does not implement _nocancel I/O, so
sysdeps/generic/not-cancel.h will forward everything back to the
regular functions.  This changed the names of some of the functions
that sysdeps/mach/hurd/dl-sysdep.c needs to interpose.

	* elf/dl-load.c, elf/dl-misc.c, elf/dl-profile.c, elf/rtld.c
	* sysdeps/unix/sysv/linux/dl-sysdep.c
	Include not-cancel.h.  Use __close_nocancel instead of __close,
	__open64_nocancel instead of __open, __read_nocancel instead of
	__libc_read, and __write_nocancel instead of __libc_write.

	* csu/check_fds.c (check_one_fd)
	* sysdeps/posix/fdopendir.c (__fdopendir)
	* sysdeps/posix/opendir.c (__alloc_dir): Use __fcntl_nocancel
        instead of __fcntl and/or __libc_fcntl.

	* sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np)
	* sysdeps/unix/sysv/linux/pthread_getname.c (pthread_getname_np)
        * sysdeps/unix/sysv/linux/i386/smp.h (is_smp_system):
	Use __open64_nocancel instead of __open_nocancel.

	* sysdeps/unix/sysv/linux/not-cancel.h: Move all of the
	hidden_proto declarations to the end and issue them if either
	IS_IN(libc) or IS_IN(rtld).
	* sysdeps/unix/sysv/linux/Makefile [subdir=io] (sysdep_routines):
	Add close_nocancel, fcntl_nocancel, nanosleep_nocancel,
	open_nocancel, open64_nocancel, openat_nocancel, pause_nocancel,
	read_nocancel, waitpid_nocancel, write_nocancel.

        * io/Versions [GLIBC_PRIVATE]: Add __libc_fcntl,
        __fcntl_nocancel, __open64_nocancel, __write_nocancel.
        * posix/Versions: Add __nanosleep_nocancel, __pause_nocancel.

        * nptl/pt-fcntl.c: New file.
        * nptl/Makefile (pthread-compat-wrappers): Remove fcntl.
        (libpthread-routines): Add pt-fcntl.
        * include/fcntl.h (__fcntl_nocancel_adjusted): New function.
        (__libc_fcntl): Remove attribute_hidden.
	* sysdeps/unix/sysv/linux/fcntl.c (__libc_fcntl): Call
	__fcntl_nocancel_adjusted, not fcntl_common.
        (__fcntl_nocancel): Move to new file fcntl_nocancel.c.
	(fcntl_common): Rename to __fcntl_nocancel_adjusted; also move
	to fcntl_nocancel.c.
	* sysdeps/unix/sysv/linux/fcntl_nocancel.c: New file.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c: Remove file.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h:
	Define FCNTL_ADJUST_CMD here, as a self-contained macro.

	* sysdeps/unix/sysv/linux/close.c: Move __close_nocancel to...
	* sysdeps/unix/sysv/linux/close_nocancel.c: ...this new file.
	* sysdeps/unix/sysv/linux/nanosleep.c: Move __nanosleep_nocancel to...
	* sysdeps/unix/sysv/linux/nanosleep_nocancel.c: ...this new file.
	* sysdeps/unix/sysv/linux/open.c: Move __open_nocancel to...
	* sysdeps/unix/sysv/linux/open_nocancel.c: ...this new file.
	* sysdeps/unix/sysv/linux/open64.c: Move __open64_nocancel to...
	* sysdeps/unix/sysv/linux/open64_nocancel.c: ...this new file.
	* sysdeps/unix/sysv/linux/openat.c: Move __openat_nocancel to...
	* sysdeps/unix/sysv/linux/openat_nocancel.c: ...this new file.
	* sysdeps/unix/sysv/linux/openat64.c: Move __openat64_nocancel to...
	* sysdeps/unix/sysv/linux/openat64_nocancel.c: ...this new file.
	* sysdeps/unix/sysv/linux/pause.c: Move __pause_nocancel to...
	* sysdeps/unix/sysv/linux/pause_nocancel.c: ...this new file.
	* sysdeps/unix/sysv/linux/read.c: Move __read_nocancel to...
	* sysdeps/unix/sysv/linux/read_nocancel.c: ...this new file.
	* sysdeps/unix/sysv/linux/waitpid.c: Move __waitpid_nocancel to...
	* sysdeps/unix/sysv/linux/waitpid_nocancel.c: ...this new file.
	* sysdeps/unix/sysv/linux/write.c: Move __write_nocancel to...
	* sysdeps/unix/sysv/linux/write_nocancel.c: ...this new file.

        * sysdeps/unix/sysv/linux/nios2/Makefile: Don't override
        libpthread-routines.
        * sysdeps/unix/sysv/linux/nios2/pt-vfork.S: New file which
        defines nothing.

        * sysdeps/mach/hurd/dl-sysdep.c: Define __read instead of
        __libc_read, and __write instead of __libc_write.  Define
        __open64 in addition to __open.
2018-06-12 09:53:04 -04:00
Florian Weimer 1efe135861 nptl: Turn libpthread.so into a symbolic link to the real DSO
The linker script is no longer needed.
2018-03-01 16:14:47 +01:00
Florian Weimer 1a2f44a848 nptl: Drop libpthread_nonshared.a from libpthread.so
Fixes commit bd60ce8652 (nptl: Move
pthread_atfork to libc_nonshared.a).
2018-03-01 12:53:09 +01:00
Florian Weimer bd60ce8652 nptl: Move pthread_atfork to libc_nonshared.a
libpthread_nonshared.a is unused after this, so remove it from the
build.

There is no ABI impact because pthread_atfork was implemented using
__register_atfork in libc even before this change.

pthread_atfork has to be a weak alias because pthread_* names are not
reserved in libc.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-03-01 08:18:48 +01:00
Adhemerval Zanella 27761a1042 Refactor atfork handlers
Current implementation (sysdeps/nptl/fork.c) replicates the atfork
handlers list backward to invoke the child handlers after fork/clone
syscall.

The internal atfork handlers is implemented as a single-linked list
so a lock-free algorithm can be used, trading fork mulithread call
performance for some code complexity and dynamic stack allocation
(since the backwards list should not fail).

This patch refactor it to use a dynarary instead of a linked list.
It simplifies the external variables need to be exported and also
the internal atfork handler member definition.

The downside is a serialization of fork call in multithread, since to
operate on the dynarray the internal lock should be used.  However
as noted by Florian, it already acquires external locks for malloc
and libio so it is already hitting some lock contention.  Besides,
posix_spawn should be faster and more scalable to run external programs
in multithread environments.

Checked on x86_64-linux-gnu.

	* nptl/Makefile (routines): Remove unregister-atfork.
	* nptl/register-atfork.c (fork_handler_pool): Remove variable.
	(fork_handler_alloc): Remove function.
	(fork_handlers, fork_handler_init): New variables.
	(__fork_lock): Rename to atfork_lock.
	(__register_atfork, __unregister_atfork, libc_freeres_fn): Rewrite
	to use a dynamic array to add/remove atfork handlers.
	* sysdeps/nptl/fork.c (__libc_fork): Likewise.
	* sysdeps/nptl/fork.h (__fork_lock, __fork_handlers, __linkin_atfork):
	Remove declaration.
	(fork_handler): Remove next, refcntr, and need_signal member.
	(__run_fork_handler_type): New enum.
	(__run_fork_handlers): New prototype.
	* sysdeps/nptl/libc-lockP.h (__libc_atfork): Remove declaration.
2018-02-22 16:43:59 -03:00
Stefan Liebler 8724507385 Add runtime check if mutex will be elided in tst-mutex8 testcases.
An elided mutex don't fail destroy. Elision was disabled for the
test nptl/tst-mutex8 in nptl/Makefile. Thus we can run tests which
destroy a locked mutex.

As elision is only disabled for tst-mutex8, the variants
tst-mutex8-static, tst-mutexpi8 and tst-mutexpi8-static are still
failing if lock elision is enabled.

This patch adds a runtime check, if the checked type of mutex will
be elided. This check is using TUNABLE_GET_FULL to determine if
elision is enabled via the tunables framework.
The pthread_mutex_destroy tests are only run if we dont't assume an
elided mutex.

This way, we can run the whole glibc testsuite with or without enabled
lock elision.

ChangeLog:

	* nptl/Makefile (tst-mutex8-ENV): Delete.
	* nptl/tst-mutex8.c (check_type):
	Add runtime check if mutex will be elided.
2018-02-16 09:57:30 +01:00
Carlos O'Donell 2ec0e7eade Revert Intel CET changes to __jmp_buf_tag (Bug 22743)
In commit cba595c350 and commit
f81ddabffd, ABI compatibility with
applications was broken by increasing the size of the on-stack
allocated __pthread_unwind_buf_t beyond the oringal size.
Applications only have the origianl space available for
__pthread_unwind_register, and __pthread_unwind_next to use,
any increase in the size of __pthread_unwind_buf_t causes these
functions to write beyond the original structure into other
on-stack variables leading to segmentation faults in common
applications like vlc. The only workaround is to version those
functions which operate on the old sized objects, but this must
happen in glibc 2.28.

Thank you to Andrew Senkevich, H.J. Lu, and Aurelien Jarno, for
submitting reports and tracking the issue down.

The commit reverts the above mentioned commits and testing on
x86_64 shows that the ABI compatibility is restored. A tst-cleanup1
regression test linked with an older glibc now passes when run
with the newly built glibc. Previously a tst-cleanup1 linked with
an older glibc would segfault when run with an affected glibc build.

Tested on x86_64 with no regressions.

Signed-off-by: Carlos O'Donell <carlos@redhat.com>
2018-01-25 23:43:46 -08:00
Florian Weimer 10d200dbac nptl/tst-thread-exit-clobber: Run with any C++ compiler
We do not need thread_local support in the C++11 comiler, and the
minimum GCC version for glibc has C++11 support (if it has C++ support).
2018-01-16 21:46:37 +01:00
Florian Weimer b725132d2b nptl/tst-minstack-throw: Compile in C++11 mode with GNU extensions 2018-01-16 07:19:28 +01:00
Florian Weimer 860b0240a5 nptl: Add PTHREAD_MIN_STACK C++ throw test [BZ #22636] 2018-01-15 15:30:00 +01:00
Florian Weimer d8b778907e nptl: Add tst-minstack-cancel, tst-minstack-exit [BZ #22636]
I verified that without the guard accounting change in commit
630f4cc3aa (Fix stack guard size
accounting) and RTLD_NOW for libgcc_s introduced by commit
f993b87540 (nptl: Open libgcc.so with
RTLD_NOW during pthread_cancel), the tst-minstack-cancel test fails on
an AVX-512F machine.  tst-minstack-exit still passes, and either of
the mentioned commit by itself frees sufficient stack space to make
tst-minstack-cancel pass, too.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-01-11 13:13:14 +01:00
Florian Weimer 579396ee08 nptl: Add test for callee-saved register restore in pthread_exit
GCC PR 83641 results in a miscompilation of libpthread, which
causes pthread_exit not to restore callee-saved registers before
running destructors for objects on the stack.  This test detects
this situation:

info: unsigned int, direct pthread_exit call
tst-thread-exit-clobber.cc:80: numeric comparison failure
   left: 4148288912 (0xf741dd90); from: value
  right: 1600833940 (0x5f6ac994); from: magic_values.v2
info: double, direct pthread_exit call
info: unsigned int, indirect pthread_exit call
info: double, indirect pthread_exit call
error: 1 test failures
2018-01-08 14:57:25 +01:00
Palmer Dabbelt 8e13c51bb5 Avoid race conditions when rebuilding librt.so
`make check' sometimes triggers a rebuild of librt.so using
nptl/Makefile, which ignores librt's dependence on libpthread.  This
causes the build to blow up when we attempt to run the test suite on
RISC-V.

2018-01-06  Palmer Dabbelt  <palmer@sifive.com>

        * nptl/Makefile (/librt.so): Always depend on
        "$(shared-thread-library)".
2018-01-06 23:42:21 -08:00
Joseph Myers 688903eb3e Update copyright dates with scripts/update-copyrights.
* All files with FSF copyright notices: Update copyright dates
	using scripts/update-copyrights.
	* locale/programs/charmap-kw.h: Regenerated.
	* locale/programs/locfile-kw.h: Likewise.
2018-01-01 00:32:25 +00:00
Adhemerval Zanella 4735850f7a nptl: Consolidate pthread_{timed,try}join{_np}
This patch consolidates the pthread_join and gnu extensions to avoid
code duplication.  The function pthread_join, pthread_tryjoin_np, and
pthread_timedjoin_np are now based on pthread_timedjoin_ex.

It also fixes some inconsistencies on ESRCH, EINVAL, EDEADLK handling
(where each implementation differs from each other) and also on
clenup handler (which now always use a CAS).

Checked on i686-linux-gnu and x86_64-linux-gnu.

	* nptl/pthreadP.h (__pthread_timedjoin_np): Define.
	* nptl/pthread_join.c (pthread_join): Use __pthread_timedjoin_np.
	* nptl/pthread_tryjoin.c (pthread_tryjoin): Likewise.
	* nptl/pthread_timedjoin.c (cleanup): Use CAS on argument setting.
	(pthread_timedjoin_np): Define internal symbol and common code from
	pthread_join.
	* sysdeps/unix/sysv/linux/i386/lowlevellock.h (__lll_timedwait_tid):
	Remove superflous checks.
	* sysdeps/unix/sysv/linux/x86_64/lowlevellock.h (__lll_timedwait_tid):
	Likewise.

Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2017-12-20 11:32:54 -02:00
Florian Weimer 8a26ad2ab7 nptl: Implement pthread_self in libc.so [BZ #22635]
All binaries use TLS and thus need a properly set up TCB, so we can
simply return its address directly, instead of forwarding to the
libpthread implementation from libc.

For versioned symbols, the dynamic linker checks that the soname matches
the name supplied by the link editor, so a compatibility symbol in
libpthread is needed.

To avoid linking against the libpthread function in all cases, we would
have to bump the symbol version of libpthread in libc.so and supply a
compat symbol.  This commit does not do that because the function
implementation is so small, so the overhead by two active copies of the
same function might well be smaller than the increase in symbol table
size.
2017-12-20 11:42:04 +01:00
H.J. Lu f81ddabffd Linux/x86: Update cancel_jmp_buf to match __jmp_buf_tag [BZ #22563]
On x86, padding in struct __jmp_buf_tag is used for shadow stack pointer
to support shadow stack in Intel Control-flow Enforcemen Technology.
Since the cancel_jmp_buf array is passed to setjmp and longjmp by
casting it to pointer to struct __jmp_buf_tag, it should be as large
as struct __jmp_buf_tag.  Otherwise when shadow stack is enabled,
setjmp and longjmp will write and read beyond cancel_jmp_buf when saving
and restoring shadow stack pointer.

This patch adds bits/types/__cancel_jmp_buf_tag.h to define struct
__cancel_jmp_buf_tag so that Linux/x86 can add saved_mask to
cancel_jmp_buf.

Tested natively on i386, x86_64 and x32.  Tested hppa-linux-gnu with
build-many-glibcs.py.

	[BZ #22563]
	* bits/types/__cancel_jmp_buf_tag.h: New file.
	* sysdeps/unix/sysv/linux/x86/bits/types/__cancel_jmp_buf_tag.h
	* sysdeps/unix/sysv/linux/x86/pthreaddef.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/nptl/pthreadP.h: Likewise.
	* nptl/Makefile (headers): Add
	bits/types/__cancel_jmp_buf_tag.h.
	* nptl/descr.h [NEED_SAVED_MASK_IN_CANCEL_JMP_BUF]
	(pthread_unwind_buf): Add saved_mask to cancel_jmp_buf.
	* sysdeps/nptl/pthread.h: Include
	<bits/types/__cancel_jmp_buf_tag.h>.
	(__pthread_unwind_buf_t): Use struct __cancel_jmp_buf_tag with
	__cancel_jmp_buf.
	* sysdeps/unix/sysv/linux/hppa/pthread.h: Likewise.
2017-12-19 02:44:04 -08:00
H.J. Lu 36975e8e7e Replace = with += in CFLAGS-xxx.c/CPPFLAGS-xxx.c
Replace = with += in CFLAGS-xxx.c and CPPFLAGS-xxx.c to allow Makefile
under sysdeps to define CFLAGS-xx.c and CPPFLAGS-xxx.c.

	* argp/Makefile (CFLAGS-argp-help.c): Replace = with +=.
	(CFLAGS-argp-parse.c): Likewise.
	(CFLAGS-argp-fmtstream.c): Likewise.
	* crypt/Makefile (CPPFLAGS-sha256-crypt.c): Likewise.
	(CPPFLAGS-sha512-crypt.c): Likewise.
	(CPPFLAGS-md5-crypt.c): Likewise.
	* debug/Makefile (CFLAGS-stack_chk_fail.c): Likewise.
	(CFLAGS-stack_chk_fail_local.c): Likewise.
	(CFLAGS-backtrace.c): Likewise.
	(CFLAGS-sprintf_chk.c): Likewise.
	(CFLAGS-snprintf_chk.c): Likewise.
	(CFLAGS-vsprintf_chk.c): Likewise.
	(CFLAGS-vsnprintf_chk.c): Likewise.
	(CFLAGS-asprintf_chk.c): Likewise.
	(CFLAGS-vasprintf_chk.c): Likewise.
	(CFLAGS-obprintf_chk.c): Likewise.
	(CFLAGS-dprintf_chk.c): Likewise.
	(CFLAGS-vdprintf_chk.c): Likewise.
	(CFLAGS-printf_chk.c): Likewise.
	(CFLAGS-fprintf_chk.c): Likewise.
	(CFLAGS-vprintf_chk.c): Likewise.
	(CFLAGS-vfprintf_chk.c): Likewise.
	(CFLAGS-gets_chk.c): Likewise.
	(CFLAGS-fgets_chk.c): Likewise.
	(CFLAGS-fgets_u_chk.c): Likewise.
	(CFLAGS-fread_chk.c): Likewise.
	(CFLAGS-fread_u_chk.c): Likewise.
	(CFLAGS-swprintf_chk.c): Likewise.
	(CFLAGS-vswprintf_chk.c): Likewise.
	(CFLAGS-wprintf_chk.c): Likewise.
	(CFLAGS-fwprintf_chk.c): Likewise.
	(CFLAGS-vwprintf_chk.c): Likewise.
	(CFLAGS-vfwprintf_chk.c): Likewise.
	(CFLAGS-fgetws_chk.c): Likewise.
	(CFLAGS-fgetws_u_chk.c): Likewise.
	(CFLAGS-read_chk.c): Likewise.
	(CFLAGS-pread_chk.c): Likewise.
	(CFLAGS-pread64_chk.c): Likewise.
	(CFLAGS-recv_chk.c): Likewise.
	(CFLAGS-recvfrom_chk.c): Likewise.
	(CFLAGS-tst-longjmp_chk.c): Likewise.
	(CPPFLAGS-tst-longjmp_chk.c): Likewise.
	(CFLAGS-tst-longjmp_chk2.c): Likewise.
	(CPPFLAGS-tst-longjmp_chk2.c): Likewise.
	(CFLAGS-tst-longjmp_chk3.c): Likewise.
	(CPPFLAGS-tst-longjmp_chk3.c): Likewise.
	(CFLAGS-tst-chk1.c): Likewise.
	(CFLAGS-tst-chk2.c): Likewise.
	(CFLAGS-tst-chk3.c): Likewise.
	(CFLAGS-tst-chk4.cc): Likewise.
	(CFLAGS-tst-chk5.cc): Likewise.
	(CFLAGS-tst-chk6.cc): Likewise.
	(CFLAGS-tst-lfschk1.c): Likewise.
	(CFLAGS-tst-lfschk2.c): Likewise.
	(CFLAGS-tst-lfschk3.c): Likewise.
	(CFLAGS-tst-lfschk4.cc): Likewise.
	(CFLAGS-tst-lfschk5.cc): Likewise.
	(CFLAGS-tst-lfschk6.cc): Likewise.
	(CFLAGS-tst-ssp-1.c): Likewise.
	* dirent/Makefile (CFLAGS-scandir.c): Likewise.
	(CFLAGS-scandir64.c): Likewise.
	(CFLAGS-scandir-tail.c): Likewise.
	(CFLAGS-scandir64-tail.c): Likewise.
	* elf/Makefile (CPPFLAGS-dl-tunables.c): Likewise.
	(CFLAGS-dl-tunables.c): Likewise.
	(CFLAGS-dl-runtime.c): Likewise.
	(CFLAGS-dl-lookup.c): Likewise.
	(CFLAGS-dl-iterate-phdr.c): Likewise.
	(CFLAGS-vismain.c): Likewise.
	(CFLAGS-tst-linkall-static.c): Likewise.
	(CFLAGS-tst-linkall-static.c): Likewise.
	(CPPFLAGS-dl-load.c): Likewise.
	(CFLAGS-ldconfig.c): Likewise.
	(CFLAGS-dl-cache.c): Likewise.
	(CFLAGS-cache.c): Likewise.
	(CFLAGS-rtld.c): Likewise.
	(CFLAGS-multiload.c): Likewise.
	(CFLAGS-filtmod1.c): Likewise.
	(CFLAGS-tst-align.c): Likewise.
	(CFLAGS-tst-align2.c): Likewise.
	(CFLAGS-tst-alignmod.c): Likewise.
	(CFLAGS-tst-alignmod2.c): Likewise.
	(CPPFLAGS-tst-execstack.c): Likewise.
	(CFLAGS-tst-ptrguard1-static.c): Likewise.
	(CFLAGS-tst-latepthreadmod.c): Likewise.
	* grp/Makefile (CFLAGS-getgrgid_r.c): Likewise.
	(CFLAGS-getgrnam_r.c): Likewise.
	(CFLAGS-getgrent_r.c): Likewise.
	(CFLAGS-getgrent.c): Likewise.
	(CFLAGS-fgetgrent.c): Likewise.
	(CFLAGS-fgetgrent_r.c): Likewise.
	(CFLAGS-putgrent.c): Likewise.
	(CFLAGS-initgroups.c): Likewise.
	(CFLAGS-getgrgid.c): Likewise.
	* gshadow/Makefile (CFLAGS-getsgent_r.c): Likewise.
	(CFLAGS-getsgent.c): Likewise.
	(CFLAGS-fgetsgent.c): Likewise.
	(CFLAGS-fgetsgent_r.c): Likewise.
	(CFLAGS-putsgent.c): Likewise.
	(CFLAGS-getsgnam.c): Likewise.
	(CFLAGS-getsgnam_r.c): Likewise.
	* iconv/Makefile (CFLAGS-iconv_prog.c): Likewise.
	(CFLAGS-iconv_charmap.c): Likewise.
	(CFLAGS-dummy-repertoire.c): Likewise.
	(CFLAGS-charmap.c): Likewise.
	(CFLAGS-linereader.c): Likewise.
	(CFLAGS-simple-hash.c): Likewise.
	(CFLAGS-gconv_conf.c): Likewise.
	(CFLAGS-iconvconfig.c): Likewise.
	* inet/Makefile (CFLAGS-gethstbyad_r.c): Likewise.
	(CFLAGS-gethstbyad.c): Likewise.
	(CFLAGS-gethstbynm_r.c): Likewise.
	(CFLAGS-gethstbynm.c): Likewise.
	(CFLAGS-gethstbynm2_r.c): Likewise.
	(CFLAGS-gethstbynm2.c): Likewise.
	(CFLAGS-gethstent_r.c): Likewise.
	(CFLAGS-gethstent.c): Likewise.
	(CFLAGS-rcmd.c): Likewise.
	(CFLAGS-getnetbynm_r.c): Likewise.
	(CFLAGS-getnetbynm.c): Likewise.
	(CFLAGS-getnetbyad_r.c): Likewise.
	(CFLAGS-getnetbyad.c): Likewise.
	(CFLAGS-getnetent_r.c): Likewise.
	(CFLAGS-getnetent.c): Likewise.
	(CFLAGS-getaliasent_r.c): Likewise.
	(CFLAGS-getaliasent.c): Likewise.
	(CFLAGS-getrpcent_r.c): Likewise.
	(CFLAGS-getrpcent.c): Likewise.
	(CFLAGS-getservent_r.c): Likewise.
	(CFLAGS-getservent.c): Likewise.
	(CFLAGS-getprtent_r.c): Likewise.
	(CFLAGS-getprtent.c): Likewise.
	(CFLAGS-either_ntoh.c): Likewise.
	(CFLAGS-either_hton.c): Likewise.
	(CFLAGS-getnetgrent.c): Likewise.
	(CFLAGS-getnetgrent_r.c): Likewise.
	(CFLAGS-tst-checks-posix.c): Likewise.
	(CFLAGS-tst-sockaddr.c): Likewise.
	* intl/Makefile (CFLAGS-tst-gettext.c): Likewise.
	(CFLAGS-tst-translit.c): Likewise.
	(CFLAGS-tst-gettext2.c): Likewise.
	(CFLAGS-tst-codeset.c): Likewise.
	(CFLAGS-tst-gettext3.c): Likewise.
	(CFLAGS-tst-gettext4.c): Likewise.
	(CFLAGS-tst-gettext5.c): Likewise.
	(CFLAGS-tst-gettext6.c): Likewise.
	* io/Makefile (CFLAGS-open.c): Likewise.
	(CFLAGS-open64.c): Likewise.
	(CFLAGS-creat.c): Likewise.
	(CFLAGS-creat64.c): Likewise.
	(CFLAGS-fcntl.c): Likewise.
	(CFLAGS-poll.c): Likewise.
	(CFLAGS-ppoll.c): Likewise.
	(CFLAGS-lockf.c): Likewise.
	(CFLAGS-statfs.c): Likewise.
	(CFLAGS-fstatfs.c): Likewise.
	(CFLAGS-statvfs.c): Likewise.
	(CFLAGS-fstatvfs.c): Likewise.
	(CFLAGS-fts.c): Likewise.
	(CFLAGS-fts64.c): Likewise.
	(CFLAGS-ftw.c): Likewise.
	(CFLAGS-ftw64.c): Likewise.
	(CFLAGS-lockf.c): Likewise.
	(CFLAGS-posix_fallocate.c): Likewise.
	(CFLAGS-posix_fallocate64.c): Likewise.
	(CFLAGS-fallocate.c): Likewise.
	(CFLAGS-fallocate64.c): Likewise.
	(CFLAGS-read.c): Likewise.
	(CFLAGS-write.c): Likewise.
	(CFLAGS-test-stat.c): Likewise.
	(CFLAGS-test-lfs.c): Likewise.
	* libio/Makefile (CFLAGS-fileops.c): Likewise.
	(CFLAGS-fputc.c): Likewise.
	(CFLAGS-fputwc.c): Likewise.
	(CFLAGS-freopen64.c): Likewise.
	(CFLAGS-freopen.c): Likewise.
	(CFLAGS-fseek.c): Likewise.
	(CFLAGS-fseeko64.c): Likewise.
	(CFLAGS-fseeko.c): Likewise.
	(CFLAGS-ftello64.c): Likewise.
	(CFLAGS-ftello.c): Likewise.
	(CFLAGS-fwide.c): Likewise.
	(CFLAGS-genops.c): Likewise.
	(CFLAGS-getc.c): Likewise.
	(CFLAGS-getchar.c): Likewise.
	(CFLAGS-getwc.c): Likewise.
	(CFLAGS-getwchar.c): Likewise.
	(CFLAGS-iofclose.c): Likewise.
	(CFLAGS-iofflush.c): Likewise.
	(CFLAGS-iofgetpos64.c): Likewise.
	(CFLAGS-iofgetpos.c): Likewise.
	(CFLAGS-iofgets.c): Likewise.
	(CFLAGS-iofgetws.c): Likewise.
	(CFLAGS-iofputs.c): Likewise.
	(CFLAGS-iofputws.c): Likewise.
	(CFLAGS-iofread.c): Likewise.
	(CFLAGS-iofsetpos64.c): Likewise.
	(CFLAGS-iofsetpos.c): Likewise.
	(CFLAGS-ioftell.c): Likewise.
	(CFLAGS-iofwrite.c): Likewise.
	(CFLAGS-iogetdelim.c): Likewise.
	(CFLAGS-iogetline.c): Likewise.
	(CFLAGS-iogets.c): Likewise.
	(CFLAGS-iogetwline.c): Likewise.
	(CFLAGS-ioputs.c): Likewise.
	(CFLAGS-ioseekoff.c): Likewise.
	(CFLAGS-ioseekpos.c): Likewise.
	(CFLAGS-iosetbuffer.c): Likewise.
	(CFLAGS-iosetvbuf.c): Likewise.
	(CFLAGS-ioungetc.c): Likewise.
	(CFLAGS-ioungetwc.c): Likewise.
	(CFLAGS-oldfileops.c): Likewise.
	(CFLAGS-oldiofclose.c): Likewise.
	(CFLAGS-oldiofgetpos64.c): Likewise.
	(CFLAGS-oldiofgetpos.c): Likewise.
	(CFLAGS-oldiofsetpos64.c): Likewise.
	(CFLAGS-oldiofsetpos.c): Likewise.
	(CFLAGS-peekc.c): Likewise.
	(CFLAGS-putc.c): Likewise.
	(CFLAGS-putchar.c): Likewise.
	(CFLAGS-putwc.c): Likewise.
	(CFLAGS-putwchar.c): Likewise.
	(CFLAGS-rewind.c): Likewise.
	(CFLAGS-wfileops.c): Likewise.
	(CFLAGS-wgenops.c): Likewise.
	(CFLAGS-oldiofopen.c): Likewise.
	(CFLAGS-iofopen.c): Likewise.
	(CFLAGS-iofopen64.c): Likewise.
	(CFLAGS-oldtmpfile.c): Likewise.
	(CFLAGS-tst_putwc.c): Likewise.
	* locale/Makefile (CFLAGS-md5.c): Likewise.
	(CFLAGS-charmap.c): Likewise.
	(CFLAGS-locfile.c): Likewise.
	(CFLAGS-charmap-dir.c): Likewise.
	* login/Makefile (CFLAGS-grantpt.c): Likewise.
	(CFLAGS-getpt.c): Likewise.
	(CFLAGS-pt_chown.c): Likewise.
	* malloc/Makefile (CFLAGS-mcheck-init.c): Likewise.
	(CFLAGS-obstack.c): Likewise.
	* math/Makefile (CFLAGS-test-tgmath3.c): Likewise.
	(CFLAGS-test-double-vlen4-wrappers.c): Likewise.
	(CFLAGS-test-double-vlen8-wrappers.c): Likewise.
	(CFLAGS-test-float-vlen8-wrappers.c): Likewise.
	(CFLAGS-test-float-vlen16-wrappers.c): Likewise.
	(CFLAGS-test-tgmath.c): Likewise.
	(CFLAGS-test-tgmath2.c): Likewise.
	(CFLAGS-test-tgmath-ret.c): Likewise.
	(CFLAGS-test-powl.c): Likewise.
	(CFLAGS-test-snan.c): Likewise.
	(CFLAGS-test-signgam-finite.c): Likewise.
	(CFLAGS-test-signgam-finite-c99.c): Likewise.
	(CFLAGS-test-signgam-finite-c11.c): Likewise.
	(CFLAGS-test-signgam-uchar.c): Likewise.
	(CFLAGS-test-signgam-uchar-init.c): Likewise.
	(CFLAGS-test-signgam-uchar-static.c): Likewise.
	(CFLAGS-test-signgam-uchar-init-static.c): Likewise.
	(CFLAGS-test-signgam-uint.c): Likewise.
	(CFLAGS-test-signgam-uint-init.c): Likewise.
	(CFLAGS-test-signgam-uint-static.c): Likewise.
	(CFLAGS-test-signgam-uint-init-static.c): Likewise.
	(CFLAGS-test-signgam-ullong.c): Likewise.
	(CFLAGS-test-signgam-ullong-init.c): Likewise.
	(CFLAGS-test-signgam-ullong-static.c): Likewise.
	(CFLAGS-test-signgam-ullong-init-static.c): Likewise.
	(CFLAGS-test-math-cxx11.cc): Likewise.
	(CFLAGS-test-math-isinff.cc): Likewise.
	(CFLAGS-test-math-iszero.cc): Likewise.
	(CFLAGS-test-math-issignaling.cc): Likewise.
	(CFLAGS-test-math-iscanonical.cc): Likewise.
	(CFLAGS-test-iszero-excess-precision.c): Likewise.
	(CFLAGS-test-iseqsig-excess-precision.c): Likewise.
	(CFLAGS-test-flt-eval-method.c): Likewise.
	(CFLAGS-test-fe-snans-always-signal.c): Likewise.
	(CFLAGS-test-finite-macros.c): Likewise.
	* misc/Makefile (CFLAGS-select.c): Likewise.
	(CFLAGS-tsearch.c): Likewise.
	(CFLAGS-lsearch.c): Likewise.
	(CFLAGS-pselect.c): Likewise.
	(CFLAGS-readv.c): Likewise.
	(CFLAGS-writev.c): Likewise.
	(CFLAGS-preadv.c): Likewise.
	(CFLAGS-preadv64.c): Likewise.
	(CFLAGS-pwritev.c): Likewise.
	(CFLAGS-pwritev64.c): Likewise.
	(CFLAGS-preadv2.c): Likewise.
	(CFLAGS-preadv64v2.c): Likewise.
	(CFLAGS-pwritev2.c): Likewise.
	(CFLAGS-pwritev64v2.c): Likewise.
	(CFLAGS-usleep.c): Likewise.
	(CFLAGS-syslog.c): Likewise.
	(CFLAGS-error.c): Likewise.
	(CFLAGS-getpass.c): Likewise.
	(CFLAGS-mkstemp.c): Likewise.
	(CFLAGS-mkstemp64.c): Likewise.
	(CFLAGS-getsysstats.c): Likewise.
	(CFLAGS-getusershell.c): Likewise.
	(CFLAGS-err.c): Likewise.
	(CFLAGS-tst-tsearch.c): Likewise.
	(CFLAGS-msync.c): Likewise.
	(CFLAGS-fdatasync.c): Likewise.
	(CFLAGS-fsync.c): Likewise.
	* nptl/Makefile (CFLAGS-nptl-init.c): Likewise.
	(CFLAGS-unwind.c): Likewise.
	(CFLAGS-unwind-forcedunwind.c): Likewise.
	(CFLAGS-pthread_cancel.c): Likewise.
	(CFLAGS-pthread_setcancelstate.c): Likewise.
	(CFLAGS-pthread_setcanceltype.c): Likewise.
	(CFLAGS-cancellation.c): Likewise.
	(CFLAGS-libc-cancellation.c): Likewise.
	(CFLAGS-pthread_exit.c): Likewise.
	(CFLAGS-forward.c): Likewise.
	(CFLAGS-pthread_testcancel.c): Likewise.
	(CFLAGS-pthread_join.c): Likewise.
	(CFLAGS-pthread_timedjoin.c): Likewise.
	(CFLAGS-pthread_once.c): Likewise.
	(CFLAGS-pthread_cond_wait.c): Likewise.
	(CFLAGS-sem_wait.c): Likewise.
	(CFLAGS-sem_timedwait.c): Likewise.
	(CFLAGS-fcntl.c): Likewise.
	(CFLAGS-lockf.c): Likewise.
	(CFLAGS-pread.c): Likewise.
	(CFLAGS-pread64.c): Likewise.
	(CFLAGS-pwrite.c): Likewise.
	(CFLAGS-pwrite64.c): Likewise.
	(CFLAGS-wait.c): Likewise.
	(CFLAGS-waitpid.c): Likewise.
	(CFLAGS-sigwait.c): Likewise.
	(CFLAGS-msgrcv.c): Likewise.
	(CFLAGS-msgsnd.c): Likewise.
	(CFLAGS-tcdrain.c): Likewise.
	(CFLAGS-open.c): Likewise.
	(CFLAGS-open64.c): Likewise.
	(CFLAGS-pause.c): Likewise.
	(CFLAGS-recv.c): Likewise.
	(CFLAGS-send.c): Likewise.
	(CFLAGS-accept.c): Likewise.
	(CFLAGS-sendto.c): Likewise.
	(CFLAGS-connect.c): Likewise.
	(CFLAGS-recvfrom.c): Likewise.
	(CFLAGS-recvmsg.c): Likewise.
	(CFLAGS-sendmsg.c): Likewise.
	(CFLAGS-close.c): Likewise.
	(CFLAGS-read.c): Likewise.
	(CFLAGS-write.c): Likewise.
	(CFLAGS-nanosleep.c): Likewise.
	(CFLAGS-sigsuspend.c): Likewise.
	(CFLAGS-msync.c): Likewise.
	(CFLAGS-fdatasync.c): Likewise.
	(CFLAGS-fsync.c): Likewise.
	(CFLAGS-pt-system.c): Likewise.
	(CFLAGS-tst-cleanup2.c): Likewise.
	(CFLAGS-tst-cleanupx2.c): Likewise.
	(CFLAGS-flockfile.c): Likewise.
	(CFLAGS-ftrylockfile.c): Likewise.
	(CFLAGS-funlockfile.c): Likewise.
	(CFLAGS-tst-initializers1.c): Likewise.
	(CFLAGS-tst-initializers1-c89.c): Likewise.
	(CFLAGS-tst-initializers1-c99.c): Likewise.
	(CFLAGS-tst-initializers1-c11.c): Likewise.
	(CFLAGS-tst-initializers1-gnu89.c): Likewise.
	(CFLAGS-tst-initializers1-gnu99.c): Likewise.
	(CFLAGS-tst-initializers1-gnu11.c): Likewise.
	* nscd/Makefile (CFLAGS-nscd_getpw_r.c): Likewise.
	(CFLAGS-nscd_getgr_r.c): Likewise.
	(CFLAGS-nscd_gethst_r.c): Likewise.
	(CFLAGS-nscd_getai.c): Likewise.
	(CFLAGS-nscd_initgroups.c): Likewise.
	* posix/Makefile (CFLAGS-getaddrinfo.c): Likewise.
	(CFLAGS-pause.c): Likewise.
	(CFLAGS-pread.c): Likewise.
	(CFLAGS-pread64.c): Likewise.
	(CFLAGS-pwrite.c): Likewise.
	(CFLAGS-pwrite64.c): Likewise.
	(CFLAGS-sleep.c): Likewise.
	(CFLAGS-wait.c): Likewise.
	(CFLAGS-waitid.c): Likewise.
	(CFLAGS-waitpid.c): Likewise.
	(CFLAGS-getopt.c): Likewise.
	(CFLAGS-wordexp.c): Likewise.
	(CFLAGS-sysconf.c): Likewise.
	(CFLAGS-pathconf.c): Likewise.
	(CFLAGS-fpathconf.c): Likewise.
	(CFLAGS-spawn.c): Likewise.
	(CFLAGS-spawnp.c): Likewise.
	(CFLAGS-spawni.c): Likewise.
	(CFLAGS-glob.c): Likewise.
	(CFLAGS-glob64.c): Likewise.
	(CFLAGS-getconf.c): Likewise.
	(CFLAGS-nanosleep.c): Likewise.
	* pwd/Makefile (CFLAGS-getpwent_r.c): Likewise.
	(CFLAGS-getpwent.c): Likewise.
	(CFLAGS-getpw.c): Likewise.
	(CFLAGS-fgetpwent_r.c): Likewise.
	* resolv/Makefile (CFLAGS-res_hconf.c): Likewise.
	* rt/Makefile (CFLAGS-aio_suspend.c): Likewise.
	(CFLAGS-mq_timedreceive.c): Likewise.
	(CFLAGS-mq_timedsend.c): Likewise.
	(CFLAGS-clock_nanosleep.c): Likewise.
	(CFLAGS-librt-cancellation.c): Likewise.
	* shadow/Makefile (CFLAGS-getspent_r.c): Likewise.
	(CFLAGS-getspent.c): Likewise.
	(CFLAGS-fgetspent.c): Likewise.
	(CFLAGS-fgetspent_r.c): Likewise.
	(CFLAGS-putspent.c): Likewise.
	(CFLAGS-getspnam.c): Likewise.
	(CFLAGS-getspnam_r.c): Likewise.
	* signal/Makefile (CFLAGS-sigpause.c): Likewise.
	(CFLAGS-sigsuspend.c): Likewise.
	(CFLAGS-sigtimedwait.c): Likewise.
	(CFLAGS-sigwait.c): Likewise.
	(CFLAGS-sigwaitinfo.c): Likewise.
	(CFLAGS-sigreturn.c): Likewise.
	* stdio-common/Makefile (CFLAGS-vfprintf.c): Likewise.
	(CFLAGS-vfwprintf.c): Likewise.
	(CFLAGS-tmpfile.c): Likewise.
	(CFLAGS-tmpfile64.c): Likewise.
	(CFLAGS-tempname.c): Likewise.
	(CFLAGS-psignal.c): Likewise.
	(CFLAGS-vprintf.c): Likewise.
	(CFLAGS-cuserid.c): Likewise.
	(CFLAGS-errlist.c): Likewise.
	(CFLAGS-siglist.c): Likewise.
	(CFLAGS-scanf15.c): Likewise.
	(CFLAGS-scanf17.c): Likewise.
	* stdlib/Makefile (CFLAGS-bsearch.c): Likewise.
	(CFLAGS-msort.c): Likewise.
	(CFLAGS-qsort.c): Likewise.
	(CFLAGS-system.c): Likewise.
	(CFLAGS-fmtmsg.c): Likewise.
	(CFLAGS-strfmon.c): Likewise.
	(CFLAGS-strfmon_l.c): Likewise.
	(CFLAGS-strfromd.c): Likewise.
	(CFLAGS-strfromf.c): Likewise.
	(CFLAGS-strfroml.c): Likewise.
	(CFLAGS-tst-bsearch.c): Likewise.
	(CFLAGS-tst-qsort.c): Likewise.
	(CFLAGS-tst-makecontext2.c): Likewise.
	* sunrpc/Makefile (CFLAGS-xbootparam_prot.c): Likewise.
	(CFLAGS-xnlm_prot.c): Likewise.
	(CFLAGS-xrstat.c): Likewise.
	(CFLAGS-xyppasswd.c): Likewise.
	(CFLAGS-xklm_prot.c): Likewise.
	(CFLAGS-xrex.c): Likewise.
	(CFLAGS-xsm_inter.c): Likewise.
	(CFLAGS-xmount.c): Likewise.
	(CFLAGS-xrusers.c): Likewise.
	(CFLAGS-xspray.c): Likewise.
	(CFLAGS-xnfs_prot.c): Likewise.
	(CFLAGS-xrquota.c): Likewise.
	(CFLAGS-xkey_prot.c): Likewise.
	(CFLAGS-auth_unix.c): Likewise.
	(CFLAGS-key_call.c): Likewise.
	(CFLAGS-pmap_rmt.c): Likewise.
	(CFLAGS-clnt_perr.c): Likewise.
	(CFLAGS-openchild.c): Likewise.
	* sysvipc/Makefile (CFLAGS-msgrcv.c): Likewise.
	(CFLAGS-msgsnd.c): Likewise.
	* termios/Makefile (CFLAGS-tcdrain.c): Likewise.
	* time/Makefile (CFLAGS-tzfile.c): Likewise.
	(CFLAGS-tzset.c): Likewise.
	(CFLAGS-getdate.c): Likewise.
	(CFLAGS-test_time.c): Likewise.
	(CPPFLAGS-tst-tzname.c): Likewise.
	* timezone/Makefile (CFLAGS-zdump.c): Likewise.
	(CFLAGS-zic.c): Likewise.
	* wcsmbs/Makefile (CFLAGS-wcwidth.c): Likewise.
	(CFLAGS-wcswidth.c): Likewise.
	(CFLAGS-wcstol.c): Likewise.
	(CFLAGS-wcstoul.c): Likewise.
	(CFLAGS-wcstoll.c): Likewise.
	(CFLAGS-wcstoull.c): Likewise.
	(CFLAGS-wcstod.c): Likewise.
	(CFLAGS-wcstold.c): Likewise.
	(CFLAGS-wcstof128.c): Likewise.
	(CFLAGS-wcstof.c): Likewise.
	(CFLAGS-wcstol_l.c): Likewise.
	(CFLAGS-wcstoul_l.c): Likewise.
	(CFLAGS-wcstoll_l.c): Likewise.
	(CFLAGS-wcstoull_l.c): Likewise.
	(CFLAGS-wcstod_l.c): Likewise.
	(CFLAGS-wcstold_l.c): Likewise.
	(CFLAGS-wcstof128_l.c): Likewise.
	(CFLAGS-wcstof_l.c): Likewise.
	(CPPFLAGS-tst-wchar-h.c): Likewise.
	(CPPFLAGS-wcstold_l.c): Likewise.

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
2017-12-11 13:11:33 -08:00
Rogerio Alves 07ed18d26a Add elision tunables
This patch adds several new tunables to control the behavior of
elision on supported platforms[1].   Since elision now depends
on tunables, we should always *compile* with elision enabled,
and leave the code disabled, but available for runtime
selection.  This gives us *much* better compile-time testing of
the existing code to avoid bit-rot[2].

Tested on ppc, ppc64, ppc64le, s390x and x86_64.

[1] This part of the patch was initially proposed by
Paul Murphy but was "staled" because the framework have changed
since the patch was originally proposed:

https://patchwork.sourceware.org/patch/10342/

[2] This part of the patch was inititally proposed as a RFC by
Carlos O'Donnell.  Make sense to me integrate this on the patch:

https://sourceware.org/ml/libc-alpha/2017-05/msg00335.html

	* elf/dl-tunables.list: Add elision parameters.
	* manual/tunables.texi: Add entries about elision tunable.
	* sysdeps/unix/sysv/linux/powerpc/elision-conf.c:
	Add callback functions to dynamically enable/disable elision.
	Add multiple callbacks functions to set elision parameters.
	Deleted __libc_enable_secure check.
	* sysdeps/unix/sysv/linux/s390/elision-conf.c: Likewise.
	* sysdeps/unix/sysv/linux/x86/elision-conf.c: Likewise.
	* configure: Regenerated.
	* configure.ac: Option enable_lock_elision was deleted.
	* config.h.in: ENABLE_LOCK_ELISION flag was deleted.
	* config.make.in: Remove references to enable_lock_elision.
	* manual/install.texi: Elision configure option was removed.
	* INSTALL: Regenerated to remove enable_lock_elision.
	* nptl/Makefile:
	Disable elision so it can verify error case for destroying a mutex.
	* sysdeps/powerpc/nptl/elide.h:
	Cleanup ENABLE_LOCK_ELISION check.
	Deleted macros for the case when ENABLE_LOCK_ELISION was not defined.
	* sysdeps/s390/configure: Regenerated.
	* sysdeps/s390/configure.ac: Remove references to enable_lock_elision..
	* nptl/tst-mutex8.c:
	Deleted all #ifndef ENABLE_LOCK_ELISION from the test.
	* sysdeps/powerpc/powerpc32/sysdep.h:
	Deleted all ENABLE_LOCK_ELISION checks.
	* sysdeps/powerpc/powerpc64/sysdep.h: Likewise.
	* sysdeps/powerpc/sysdep.h: Likewise.
	* sysdeps/s390/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/force-elision.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/elision-conf.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/force-elision.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/lowlevellock.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/Makefile: Remove references to
	enable-lock-elision.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
2017-12-05 17:48:48 -02:00
Andreas Schwab feda96a178 Remove traces of tst-typesizes 2017-11-07 16:17:18 +01:00
Joseph Myers c10c5267a8 Remove non-add-on Banner files.
Various subdirectories of glibc include Banner files to put some text
in the output of executing libc.so.6, under "Available extensions".

Some of those subdirectories (e.g. crypt) may originally have been
add-ons (and so optional, so a particular glibc build might or might
not have included them), but except for libidn they aren't now (or if
only included in some builds, in the case of soft-fp, the inclusion
depends on the architecture for which glibc is configured rather than
having any glibc configuration for which it's an optional feature),
and it doesn't seem useful for the libc.so.6 output to call out a few
features like that.

This patch removes the non-add-on Banner files, updating contrib.texi
where they noted contributions not otherwise mentioned there.

Tested for x86_64.

	* crypt/Banner: Remove file.
	* nptl/Banner: Likewise.
	* resolv/Banner: Likewise.
	* soft-fp/Banner: Likewise.
	* nptl/Makefile ($(objpfx)banner.h): Remove rule.
	($(objpfx)version.d): Remove dependency on banner.h.
	($(objpfx)version.os): Likewise.
	* nptl/version.c (banner): Do not include banner.h.
	* manual/contrib.texi: Update entries for Richard Henderson, Jakub
	Jelinek and BIND code.
2017-09-21 17:49:51 +00:00
Andreas Schwab 40c06a3d04 Add test for bug 21041 2017-08-09 10:47:33 +02:00
Andreas Schwab d5afb38503 Fix missing redirects in testsuite targets 2017-08-07 18:13:36 +02:00
Carlos O'Donell 5920a4a624 mutex: Fix robust mutex lock acquire (Bug 21778)
65810f0ef0 fixed a robust mutex bug but
introduced BZ 21778: if the CAS used to try to acquire a lock fails, the
expected value is not updated, which breaks other cases in the loce
acquisition loop.  The fix is to simply update the expected value with
the value returned by the CAS, which ensures that behavior is as if the
first case with the CAS never happened (if the CAS fails).

This is a regression introduced in the last release.

Tested on x86_64, i686, ppc64, ppc64le, s390x, aarch64, armv7hl.
2017-07-29 00:02:03 -04:00
Carlos O'Donell faf8c066df rwlock: Fix explicit hand-over (bug 21298)
Without this fix, the rwlock can fail to execute the explicit hand-over
in certain cases (e.g., empty critical sections that switch quickly between
read and write phases).  This can then lead to errors in how __wrphase_futex
is accessed, which in turn can lead to deadlocks.
2017-07-28 00:23:58 -04:00
Szabolcs Nagy de895ddcd7 Disable single thread optimization for open_memstream
Single thread optimization is valid if at thread creation time the
optimization can be disabled.  This is in principle true for all
stream objects that user code can access (and thus needs locking),
using the same internal list as fflush(0) uses.  However in glibc
open_memstream is not on that list (BZ 21735) so the optimization
has to be disabled.

	* libio/memstream.c (__open_memstream): Set _IO_FLAGS2_NEED_LOCK.
	* libio/wmemstream.c (open_wmemstream): Likewise.
	* nptl/tst-memstream.c: New.
2017-07-14 16:09:56 +01:00
Tulio Magno Quites Machado Filho 6e75b0110d Move tst-mutex*8* to tests-internal
The following tests depend on ENABLE_LOCK_ELISION, which is only
available on tests-internal.

 - nptl/tst-mutex8
 - nptl/tst-mutex8-static
 - nptl/tst-mutexpi8
 - nptl/tst-mutexpi8-static

	* nptl/Makefile (tests): Move nptl/tst-mutex8, nptl/tst-mutex8-static,
	nptl/tst-mutexpi8 and nptl/tst-mutexpi8-static to...
	(tests-internal): ... here.
2017-05-25 14:53:40 -03:00
Adhemerval Zanella fdbb0d98ba posix: Consolidate Linux fsync syscall
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.
2017-05-18 18:06:47 -03:00
Adhemerval Zanella 51209cbf51 posix: Consolidate Linux fdatasync syscall
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.
2017-05-18 18:06:47 -03:00
Adhemerval Zanella 3c9399f507 posix: Consolidate Linux msync syscall
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.
2017-05-18 18:06:47 -03:00
Adhemerval Zanella b3b00aa8b0 posix: Consolidate Linux sigsuspend implementation
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.
2017-05-18 18:06:47 -03:00
Adhemerval Zanella 3d0ad5a8df posix: Consolidate Linux nanosleep syscall
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.
2017-05-18 18:06:47 -03:00
Zack Weinberg 7c3018f9e4 Suppress internal declarations for most of the testsuite.
This patch adds a new build module called 'testsuite'.
IS_IN (testsuite) implies _ISOMAC, as do IS_IN_build and __cplusplus
(which means several ad-hoc tests for __cplusplus can go away).
libc-symbols.h now suppresses almost all of *itself* when _ISOMAC is
defined; in particular, _ISOMAC mode does not get config.h
automatically anymore.

There are still quite a few tests that need to see internal gunk of
one variety or another.  For them, we now have 'tests-internal' and
'test-internal-extras'; files in this category will still be compiled
with MODULE_NAME=nonlib, and everything proceeds as it always has.
The bulk of this patch is moving tests from 'tests' to
'tests-internal'.  There is also 'tests-static-internal', which has
the same effect on files in 'tests-static', and 'modules-names-tests',
which has the *inverse* effect on files in 'modules-names' (it's
inverted because most of the things in modules-names are *not* tests).
For both of these, the file must appear in *both* the new variable and
the old one.

There is also now a special case for when libc-symbols.h is included
without MODULE_NAME being defined at all.  (This happens during the
creation of libc-modules.h, and also when preprocessing Versions
files.)  When this happens, IS_IN is set to be always false and
_ISOMAC is *not* defined, which was the status quo, but now it's
explicit.

The remaining changes to C source files in this patch seemed likely to
cause problems in the absence of the main change.  They should be
relatively self-explanatory.  In a few cases I duplicated a definition
from an internal header rather than move the test to tests-internal;
this was a judgement call each time and I'm happy to change those
however reviewers feel is more appropriate.

	* Makerules: New subdir configuration variables 'tests-internal'
	and 'test-internal-extras'.  Test files in these categories will
	still be compiled with MODULE_NAME=nonlib.  Test files in the
	existing categories (tests, xtests, test-srcs, test-extras) are
	now compiled with MODULE_NAME=testsuite.
	New subdir configuration variable 'modules-names-tests'.  Files
	which are in both 'modules-names' and 'modules-names-tests' will
	be compiled with MODULE_NAME=testsuite instead of
	MODULE_NAME=extramodules.
	(gen-as-const-headers): Move to tests-internal.
	(do-tests-clean, common-mostlyclean): Support tests-internal.
	* Makeconfig (built-modules): Add testsuite.
	* Makefile: Change libof-check-installed-headers-c and
	libof-check-installed-headers-cxx to 'testsuite'.
	* Rules: Likewise.  Support tests-internal.
	* benchtests/strcoll-inputs/filelist#en_US.UTF-8:
	Remove extra-modules.mk.

	* config.h.in: Don't check for __OPTIMIZE__ or __FAST_MATH__ here.
	* include/libc-symbols.h: Move definitions of _GNU_SOURCE,
	PASTE_NAME, PASTE_NAME1, IN_MODULE, IS_IN, and IS_IN_LIB to the
	very top of the file and rationalize their order.
	If MODULE_NAME is not defined at all, define IS_IN to always be
	false, and don't define _ISOMAC.
	If any of IS_IN (testsuite), IS_IN_build, or __cplusplus are
	true, define _ISOMAC and suppress everything else in this file,
	starting with the inclusion of config.h.
	Do check for inappropriate definitions of __OPTIMIZE__ and
	__FAST_MATH__ here, but only if _ISOMAC is not defined.
        Correct some out-of-date commentary.

	* include/math.h: If _ISOMAC is defined, undefine NO_LONG_DOUBLE
	and _Mlong_double_ before including math.h.
	* include/string.h: If _ISOMAC is defined, don't expose
	_STRING_ARCH_unaligned. Move a comment to a more appropriate
	location.

	* include/errno.h, include/stdio.h, include/stdlib.h, include/string.h
	* include/time.h, include/unistd.h, include/wchar.h: No need to
	check __cplusplus nor use __BEGIN_DECLS/__END_DECLS.

	* misc/sys/cdefs.h (__NTHNL): New macro.
	* sysdeps/m68k/m680x0/fpu/bits/mathinline.h
	(__m81_defun): Use __NTHNL to avoid errors with GCC 6.

	* elf/tst-env-setuid-tunables.c: Include config.h with _LIBC
	defined, for HAVE_TUNABLES.
	* inet/tst-checks-posix.c: No need to define _ISOMAC.
	* intl/tst-gettext2.c: Provide own definition of N_.
	* math/test-signgam-finite-c99.c: No need to define _ISOMAC.
	* math/test-signgam-main.c: No need to define _ISOMAC.
	* stdlib/tst-strtod.c: Convert to test-driver. Split locale_test to...
	* stdlib/tst-strtod1i.c: ...this new file.
	* stdlib/tst-strtod5.c: Convert to test-driver and add copyright notice.
        Split tests of __strtod_internal to...
	* stdlib/tst-strtod5i.c: ...this new file.
	* string/test-string.h: Include stdint.h. Duplicate definition of
	inhibit_loop_to_libcall here (from libc-symbols.h).
	* string/test-strstr.c: Provide dummy definition of
	libc_hidden_builtin_def when including strstr.c.
	* sysdeps/ia64/fpu/libm-symbols.h: Suppress entire file in _ISOMAC
	mode; no need to test __STRICT_ANSI__ nor __cplusplus as well.
	* sysdeps/x86_64/fpu/math-tests-arch.h: Include cpu-features.h.
	Don't include init-arch.h.
	* sysdeps/x86_64/multiarch/test-multiarch.h: Include cpu-features.h.
	Don't include init-arch.h.

	* elf/Makefile: Move tst-ptrguard1-static, tst-stackguard1-static,
	tst-tls1-static, tst-tls2-static, tst-tls3-static, loadtest,
	unload, unload2, circleload1, neededtest, neededtest2,
	neededtest3, neededtest4, tst-tls1, tst-tls2, tst-tls3,
	tst-tls6, tst-tls7, tst-tls8, tst-dlmopen2, tst-ptrguard1,
	tst-stackguard1, tst-_dl_addr_inside_object, and all of the
	ifunc tests to tests-internal.
	Don't add $(modules-names) to test-extras.
	* inet/Makefile: Move tst-inet6_scopeid_pton to tests-internal.
	Add tst-deadline to tests-static-internal.
	* malloc/Makefile: Move tst-mallocstate and tst-scratch_buffer to
	tests-internal.
	* misc/Makefile: Move tst-atomic and tst-atomic-long to tests-internal.
	* nptl/Makefile: Move tst-typesizes, tst-rwlock19, tst-sem11,
	tst-sem12, tst-sem13, tst-barrier5, tst-signal7, tst-tls3,
	tst-tls3-malloc, tst-tls5, tst-stackguard1, tst-sem11-static,
	tst-sem12-static, and tst-stackguard1-static to tests-internal.
        Link tests-internal with libpthread also.
	Don't add $(modules-names) to test-extras.
	* nss/Makefile: Move tst-field to tests-internal.
	* posix/Makefile: Move bug-regex5, bug-regex20, bug-regex33,
	tst-rfc3484, tst-rfc3484-2, and tst-rfc3484-3 to tests-internal.
	* stdlib/Makefile: Move tst-strtod1i, tst-strtod3, tst-strtod4,
	tst-strtod5i, tst-tls-atexit, and tst-tls-atexit-nodelete to
	tests-internal.
        * sunrpc/Makefile: Move tst-svc_register to tests-internal.
	* sysdeps/powerpc/Makefile: Move test-get_hwcap and
	test-get_hwcap-static to tests-internal.
	* sysdeps/unix/sysv/linux/Makefile: Move tst-setgetname to
	tests-internal.
	* sysdeps/x86_64/fpu/Makefile: Add all libmvec test modules to
	modules-names-tests.
2017-05-11 19:27:59 -04:00
Adhemerval Zanella dfaaee33ba Consolidate Linux write syscall
This patch consolidates the write Linux syscall implementation on
sysdeps/unix/sysv/linux/write.c.

Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32,
arch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu.

	* include/unistd.h (write): Add hidden proto.
	* io/Makefile (CFLAGS-write.c): New rule.
	* nptl/Makefile (CFLAGS-write.c): Likewise.
	* sysdeps/unix/sysv/linux/write.c: New file.
2017-05-11 17:27:30 -03:00
Adhemerval Zanella f6a191a6ee Consolidate Linux read syscall
This patch consolidates the read Linux syscall implementation on
sysdeps/unix/sysv/linux/read.c.  This leads to a different frame
pointer creation on some architectures:

  * It fixes BZ#21428 on aarch64, since now the returned address
    for the read syscall can be correctly found out by
    backtrace_symbols.

  * It makes tst-backtrace{5,6} fails on powerpc due an issue on
    its custom backtrace implementation.  It is fixed on subsequent
    patch from this set.

Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32,
arch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu.

	[BZ #21428]
	* include/unistd.h (read): Add hidden proto.
	* io/Makefile (CFLAGS-read.c): New rule.
	* nptl/Makefile (CFLAGS-read.c): New rule.
	* sysdeps/unix/sysv/linux/read.c: New file.
2017-05-11 17:27:30 -03:00
Adhemerval Zanella 0f01acb340 Consolidate Linux close syscall generation
This patch consolidates the close Linux syscall generation on
sysdeps/unix/sysv/linux/close.c.

Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32,
arch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu.

	* nptl/Makefile (CFLAGS-close.c): New flag.
	* sysdeps/unix/sysv/linux/close.c: New file.
2017-05-11 15:49:10 -03:00
Carlos O'Donell f8bf15febc Bug 20116: Fix use after free in pthread_create()
The commit documents the ownership rules around 'struct pthread' and
when a thread can read or write to the descriptor. With those ownership
rules in place it becomes obvious that pd->stopped_start should not be
touched in several of the paths during thread startup, particularly so
for detached threads. In the case of detached threads, between the time
the thread is created by the OS kernel and the creating thread checks
pd->stopped_start, the detached thread might have already exited and the
memory for pd unmapped. As a regression test we add a simple test which
exercises this exact case by quickly creating detached threads with
large enough stacks to ensure the thread stack cache is bypassed and the
stacks are unmapped. Before the fix the testcase segfaults, after the
fix it works correctly and completes without issue.

For a detailed discussion see:
https://www.sourceware.org/ml/libc-alpha/2017-01/msg00505.html
2017-01-28 19:21:44 -05:00
Florian Weimer faf0e9c841 nptl: Add tst-robust-fork 2017-01-27 06:53:20 +01:00
Torvald Riegel 65810f0ef0 robust mutexes: Fix broken x86 assembly by removing it
lll_robust_unlock on i386 and x86_64 first sets the futex word to
FUTEX_WAITERS|0 before calling __lll_unlock_wake, which will set the
futex word to 0.  If the thread is killed between these steps, then the
futex word will be FUTEX_WAITERS|0, and the kernel (at least current
upstream) will not set it to FUTEX_OWNER_DIED|FUTEX_WAITERS because 0 is
not equal to the TID of the crashed thread.

The lll_robust_lock assembly code on i386 and x86_64 is not prepared to
deal with this case because the fastpath tries to only CAS 0 to TID and
not FUTEX_WAITERS|0 to TID; the slowpath simply waits until it can CAS 0
to TID or the futex_word has the FUTEX_OWNER_DIED bit set.

This issue is fixed by removing the custom x86 assembly code and using
the generic C code instead.  However, instead of adding more duplicate
code to the custom x86 lowlevellock.h, the code of the lll_robust* functions
is inlined into the single call sites that exist for each of these functions
in the pthread_mutex_* functions.  The robust mutex paths in the latter
have been slightly reorganized to make them simpler.

This patch is meant to be easy to backport, so C11-style atomics are not
used.

	[BZ #20985]
	* nptl/Makefile: Adapt.
	* nptl/pthread_mutex_cond_lock.c (LLL_ROBUST_MUTEX_LOCK): Remove.
	(LLL_ROBUST_MUTEX_LOCK_MODIFIER): New.
	* nptl/pthread_mutex_lock.c (LLL_ROBUST_MUTEX_LOCK): Remove.
	(LLL_ROBUST_MUTEX_LOCK_MODIFIER): New.
	(__pthread_mutex_lock_full): Inline lll_robust* functions and adapt.
	* nptl/pthread_mutex_timedlock.c (pthread_mutex_timedlock): Inline
	lll_robust* functions and adapt.
	* nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock_full): Likewise.
	* sysdeps/nptl/lowlevellock.h (__lll_robust_lock_wait,
	__lll_robust_lock, lll_robust_cond_lock, __lll_robust_timedlock_wait,
	__lll_robust_timedlock, __lll_robust_unlock): Remove.
	* sysdeps/unix/sysv/linux/i386/lowlevellock.h (lll_robust_lock,
	lll_robust_cond_lock, lll_robust_timedlock, lll_robust_unlock): Remove.
	* sysdeps/unix/sysv/linux/x86_64/lowlevellock.h (lll_robust_lock,
	lll_robust_cond_lock, lll_robust_timedlock, lll_robust_unlock): Remove.
	* sysdeps/unix/sysv/linux/sparc/lowlevellock.h (__lll_robust_lock_wait,
	__lll_robust_lock, lll_robust_cond_lock, __lll_robust_timedlock_wait,
	__lll_robust_timedlock, __lll_robust_unlock): Remove.
	* nptl/lowlevelrobustlock.c: Remove file.
	* nptl/lowlevelrobustlock.sym: Likewise.
	* sysdeps/unix/sysv/linux/i386/lowlevelrobustlock.S: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S: Likewise.
2017-01-13 17:16:07 +01:00
Torvald Riegel cc25c8b4c1 New pthread rwlock that is more scalable.
This replaces the pthread rwlock with a new implementation that uses a
more scalable algorithm (primarily through not using a critical section
anymore to make state changes).  The fast path for rdlock acquisition and
release is now basically a single atomic read-modify write or CAS and a few
branches.  See nptl/pthread_rwlock_common.c for details.

	* nptl/DESIGN-rwlock.txt: Remove.
	* nptl/lowlevelrwlock.sym: Remove.
	* nptl/Makefile: Add new tests.
	* nptl/pthread_rwlock_common.c: New file.  Contains the new rwlock.
	* nptl/pthreadP.h (PTHREAD_RWLOCK_PREFER_READER_P): Remove.
	(PTHREAD_RWLOCK_WRPHASE, PTHREAD_RWLOCK_WRLOCKED,
	PTHREAD_RWLOCK_RWAITING, PTHREAD_RWLOCK_READER_SHIFT,
	PTHREAD_RWLOCK_READER_OVERFLOW, PTHREAD_RWLOCK_WRHANDOVER,
	PTHREAD_RWLOCK_FUTEX_USED): New.
	* nptl/pthread_rwlock_init.c (__pthread_rwlock_init): Adapt to new
	implementation.
	* nptl/pthread_rwlock_rdlock.c (__pthread_rwlock_rdlock_slow): Remove.
	(__pthread_rwlock_rdlock): Adapt.
	* nptl/pthread_rwlock_timedrdlock.c
	(pthread_rwlock_timedrdlock): Adapt.
	* nptl/pthread_rwlock_timedwrlock.c
	(pthread_rwlock_timedwrlock): Adapt.
	* nptl/pthread_rwlock_trywrlock.c (pthread_rwlock_trywrlock): Adapt.
	* nptl/pthread_rwlock_tryrdlock.c (pthread_rwlock_tryrdlock): Adapt.
	* nptl/pthread_rwlock_unlock.c (pthread_rwlock_unlock): Adapt.
	* nptl/pthread_rwlock_wrlock.c (__pthread_rwlock_wrlock_slow): Remove.
	(__pthread_rwlock_wrlock): Adapt.
	* nptl/tst-rwlock10.c: Adapt.
	* nptl/tst-rwlock11.c: Adapt.
	* nptl/tst-rwlock17.c: New file.
	* nptl/tst-rwlock18.c: New file.
	* nptl/tst-rwlock19.c: New file.
	* nptl/tst-rwlock2b.c: New file.
	* nptl/tst-rwlock8.c: Adapt.
	* nptl/tst-rwlock9.c: Adapt.
	* sysdeps/aarch64/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* sysdeps/arm/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* sysdeps/hppa/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* sysdeps/ia64/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* sysdeps/m68k/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* sysdeps/microblaze/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* sysdeps/mips/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* sysdeps/nios2/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* sysdeps/s390/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* sysdeps/sh/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* sysdeps/sparc/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* sysdeps/tile/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h
	(pthread_rwlock_t): Adapt.
	* sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h
	(pthread_rwlock_t): Adapt.
	* sysdeps/x86/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* nptl/nptl-printers.py (): Adapt.
	* nptl/nptl_lock_constants.pysym: Adapt.
	* nptl/test-rwlock-printers.py: Adapt.
	* nptl/test-rwlockattr-printers.c: Adapt.
	* nptl/test-rwlockattr-printers.py: Adapt.
2017-01-10 11:50:17 +01:00
Joseph Myers bfff8b1bec Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
Torvald Riegel ed19993b5b New condvar implementation that provides stronger ordering guarantees.
This is a new implementation for condition variables, required
after http://austingroupbugs.net/view.php?id=609 to fix bug 13165.  In
essence, we need to be stricter in which waiters a signal or broadcast
is required to wake up; this couldn't be solved using the old algorithm.
ISO C++ made a similar clarification, so this also fixes a bug in
current libstdc++, for example.

We can't use the old algorithm anymore because futexes do not guarantee
to wake in FIFO order.  Thus, when we wake, we can't simply let any
waiter grab a signal, but we need to ensure that one of the waiters
happening before the signal is woken up.  This is something the previous
algorithm violated (see bug 13165).

There's another issue specific to condvars: ABA issues on the underlying
futexes.  Unlike mutexes that have just three states, or semaphores that
have no tokens or a limited number of them, the state of a condvar is
the *order* of the waiters.  A waiter on a semaphore can grab a token
whenever one is available; a condvar waiter must only consume a signal
if it is eligible to do so as determined by the relative order of the
waiter and the signal.
Therefore, this new algorithm maintains two groups of waiters: Those
eligible to consume signals (G1), and those that have to wait until
previous waiters have consumed signals (G2).  Once G1 is empty, G2
becomes the new G1.  64b counters are used to avoid ABA issues.

This condvar doesn't yet use a requeue optimization (ie, on a broadcast,
waking just one thread and requeueing all others on the futex of the
mutex supplied by the program).  I don't think doing the requeue is
necessarily the right approach (but I haven't done real measurements
yet):
* If a program expects to wake many threads at the same time and make
that scalable, a condvar isn't great anyway because of how it requires
waiters to operate mutually exclusive (due to the mutex usage).  Thus, a
thundering herd problem is a scalability problem with or without the
optimization.  Using something like a semaphore might be more
appropriate in such a case.
* The scalability problem is actually at the mutex side; the condvar
could help (and it tries to with the requeue optimization), but it
should be the mutex who decides how that is done, and whether it is done
at all.
* Forcing all but one waiter into the kernel-side wait queue of the
mutex prevents/avoids the use of lock elision on the mutex.  Thus, it
prevents the only cure against the underlying scalability problem
inherent to condvars.
* If condvars use short critical sections (ie, hold the mutex just to
check a binary flag or such), which they should do ideally, then forcing
all those waiter to proceed serially with kernel-based hand-off (ie,
futex ops in the mutex' contended state, via the futex wait queues) will
be less efficient than just letting a scalable mutex implementation take
care of it.  Our current mutex impl doesn't employ spinning at all, but
if critical sections are short, spinning can be much better.
* Doing the requeue stuff requires all waiters to always drive the mutex
into the contended state.  This leads to each waiter having to call
futex_wake after lock release, even if this wouldn't be necessary.

	[BZ #13165]
	* nptl/pthread_cond_broadcast.c (__pthread_cond_broadcast): Rewrite to
	use new algorithm.
	* nptl/pthread_cond_destroy.c (__pthread_cond_destroy): Likewise.
	* nptl/pthread_cond_init.c (__pthread_cond_init): Likewise.
	* nptl/pthread_cond_signal.c (__pthread_cond_signal): Likewise.
	* nptl/pthread_cond_wait.c (__pthread_cond_wait): Likewise.
	(__pthread_cond_timedwait): Move here from pthread_cond_timedwait.c.
	(__condvar_confirm_wakeup, __condvar_cancel_waiting,
	__condvar_cleanup_waiting, __condvar_dec_grefs,
	__pthread_cond_wait_common): New.
	(__condvar_cleanup): Remove.
	* npt/pthread_condattr_getclock.c (pthread_condattr_getclock): Adapt.
	* npt/pthread_condattr_setclock.c (pthread_condattr_setclock):
	Likewise.
	* npt/pthread_condattr_getpshared.c (pthread_condattr_getpshared):
	Likewise.
	* npt/pthread_condattr_init.c (pthread_condattr_init): Likewise.
	* nptl/tst-cond1.c: Add comment.
	* nptl/tst-cond20.c (do_test): Adapt.
	* nptl/tst-cond22.c (do_test): Likewise.
	* sysdeps/aarch64/nptl/bits/pthreadtypes.h (pthread_cond_t): Adapt
	structure.
	* sysdeps/arm/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
	* sysdeps/ia64/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
	* sysdeps/m68k/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
	* sysdeps/microblaze/nptl/bits/pthreadtypes.h (pthread_cond_t):
	Likewise.
	* sysdeps/mips/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
	* sysdeps/nios2/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
	* sysdeps/s390/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
	* sysdeps/sh/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
	* sysdeps/tile/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
	* sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h (pthread_cond_t):
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h (pthread_cond_t):
	Likewise.
	* sysdeps/x86/bits/pthreadtypes.h (pthread_cond_t): Likewise.
	* sysdeps/nptl/internaltypes.h (COND_NWAITERS_SHIFT): Remove.
	(COND_CLOCK_BITS): Adapt.
	* sysdeps/nptl/pthread.h (PTHREAD_COND_INITIALIZER): Adapt.
	* nptl/pthreadP.h (__PTHREAD_COND_CLOCK_MONOTONIC_MASK,
	__PTHREAD_COND_SHARED_MASK): New.
	* nptl/nptl-printers.py (CLOCK_IDS): Remove.
	(ConditionVariablePrinter, ConditionVariableAttributesPrinter): Adapt.
	* nptl/nptl_lock_constants.pysym: Adapt.
	* nptl/test-cond-printers.py: Adapt.
	* sysdeps/unix/sysv/linux/hppa/internaltypes.h (cond_compat_clear,
	cond_compat_check_and_clear): Adapt.
	* sysdeps/unix/sysv/linux/hppa/pthread_cond_timedwait.c: Remove file ...
	* sysdeps/unix/sysv/linux/hppa/pthread_cond_wait.c
	(__pthread_cond_timedwait): ... and move here.
	* nptl/DESIGN-condvar.txt: Remove file.
	* nptl/lowlevelcond.sym: Likewise.
	* nptl/pthread_cond_timedwait.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_broadcast.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_signal.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_timedwait.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_wait.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_broadcast.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_signal.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_timedwait.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_wait.S: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
2016-12-31 14:56:47 +01:00
Carlos O'Donell 81e0662e5f Fix failing pretty printer tests when CPPFLAGS has optimizations.
The value of CPPFLAGS provided by the environment may have optimizations
that interfere with the pretty printer test requirements. To override
such optimizations the pretty printer tests must also specify CPPFLAGS.
The existing pretty printer tests are fixed and the
README.pretty-printers is updated with the new requirement.
2016-12-23 13:46:56 -05:00
Martin Galvan 23b5cae1af Add pretty printers for the NPTL lock types
This patch adds pretty printers for the following NPTL types:

- pthread_mutex_t
- pthread_mutexattr_t
- pthread_cond_t
- pthread_condattr_t
- pthread_rwlock_t
- pthread_rwlockattr_t

To load the pretty printers into your gdb session, do the following:

python
import sys
sys.path.insert(0, '/path/to/glibc/build/nptl/pretty-printers')
end

source /path/to/glibc/source/pretty-printers/nptl-printers.py

You can check which printers are registered and enabled by issuing the
'info pretty-printer' gdb command. Printers should trigger automatically when
trying to print a variable of one of the types mentioned above.

The printers are architecture-independent, and were tested on an AMD64 running
Ubuntu 14.04 and an x86 VM running Fedora 24.

In order to work, the printers need to know the values of various flags that
are scattered throughout pthread.h and pthreadP.h as enums and #defines. Since
replicating these constants in the printers file itself would create a
maintenance burden, I wrote a script called gen-py-const.awk that Makerules uses
to extract the constants. This script is pretty much the same as gen-as-const.awk,
except it doesn't cast the constant values to 'long' and is thorougly documented.
The constants need only to be enumerated in a .pysym file, which is then referenced
by a Make variable called gen-py-const-headers.

As for the install directory, I discussed this with Mike Frysinger and Siddhesh
Poyarekar, and we agreed that it can be handled in a separate patch, and shouldn't
block merging of this one.

In addition, I've written a series of test cases for the pretty printers.
Each lock type (mutex, condvar and rwlock) has two test programs, one for itself
and other for its related 'attributes' object. Each test program in turn has a
PExpect-based Python script that drives gdb and compares its output to the
expected printer's. The tests run on the glibc host, which is assumed to have
both gdb and PExpect; if either is absent the tests will fail with code 77
(UNSUPPORTED). For cross-testing you should use cross-test-ssh.sh as test-wrapper.
I've tested the printers on both native builds and a cross build using a Beaglebone
Black running Debian, with the build system's filesystem shared with the board
through NFS.

Finally, I've written a README that explains all this and more.

	* INSTALL: Regenerated.
	* Makeconfig: Add comments and whitespace to make the control flow
	clearer.
	(+link-printers-tests, +link-pie-printers-tests, CFLAGS-printers-tests,
	installed-rtld-LDFLAGS, built-rtld-LDFLAGS, link-libc-rpath,
	link-libc-tests-after-rpath-link, link-libc-printers-tests): New.
	(rtld-LDFLAGS, rtld-tests-LDFLAGS, link-libc-tests-rpath-link,
	link-libc-tests): Use the new variables as required.
	* Makerules ($(py-const)): New rule.
	generated: Add $(py-const).
	* README.pretty-printers: New file.
	* Rules (tests-printers-programs, tests-printers-out, py-env): New.
	(others): Depend on $(py-const).
	(tests): Depend on $(tests-printers-programs) or $(tests-printers-out),
	as required.  Pass $(tests-printers) to merge-test-results.sh.
	* manual/install.texi: Add requirements for testing the pretty printers.
	* nptl/Makefile (gen-py-const-headers, pretty-printers, tests-printers,
	CFLAGS-test-mutexattr-printers.c CFLAGS-test-mutex-printers.c,
	CFLAGS-test-condattr-printers.c, CFLAGS-test-cond-printers.c,
	CFLAGS-test-rwlockattr-printers.c CFLAGS-test-rwlock-printers.c,
	tests-printers-libs): Define.
	* nptl/nptl-printers.py: New file.
	* nptl/nptl_lock_constants.pysym: Likewise.
	* nptl/test-cond-printers.c: Likewise.
	* nptl/test-cond-printers.py: Likewise.
	* nptl/test-condattr-printers.c: Likewise.
	* nptl/test-condattr-printers.py: Likewise.
	* nptl/test-mutex-printers.c: Likewise.
	* nptl/test-mutex-printers.py: Likewise.
	* nptl/test-mutexattr-printers.c: Likewise.
	* nptl/test-mutexattr-printers.py: Likewise.
	* nptl/test-rwlock-printers.c: Likewise.
	* nptl/test-rwlock-printers.py: Likewise.
	* nptl/test-rwlockattr-printers.c: Likewise.
	* nptl/test-rwlockattr-printers.py: Likewise.
	* scripts/gen-py-const.awk: Likewise.
	* scripts/test_printers_common.py: Likewise.
	* scripts/test_printers_exceptions.py: Likewise.
2016-12-08 18:59:02 +05:30
Adhemerval Zanella 3c7f1f59cd Consolidate lseek/lseek64/llseek implementations
This patch consolidates all Linux lseek/lseek64/llseek implementation
in on on sysdeps/unix/sysv/linux/lseek{64}.c.  It also removes the llseek
file and instead consolidate the LFS lseek implementation on lseek64.c
as for other LFS symbols implementations.

The general idea is:

  - lseek: ABIs that not define __OFF_T_MATCHES_OFF64_T will preferable
  use __NR__llseek if kernel supports it, otherwise they will use __NR_lseek.
  ABIs that defines __OFF_T_MATCHES_OFF64_T won't produce any symbol.

  - lseek64: ABIs with __OFF_T_MATCHES_OFF64_T will preferable use __NR_lseek
  (since it will use 64-bit arguments without low/high splitting) and
  __NR__llseek if __NR_lseek is not defined (for some ILP32 ports).

  - llseek: files will be removed and symbols will be aliased ot lseek64.

ABI without __OFF_T_MATCHES_OFF64_T and without __NR_llseek (basically MIPS64n32
so far) are covered by building lseek with off_t as expected and lseek64
using __NR_lseek (as expected for off64_t being passed using 64-bit registers).

For this consolidation I mantained the x32 assembly specific implementation
because to correctly fix this it would required both the x32 fix for
{INLINE,INTERNAL}_SYSCALL [1] and a wrapper to correctly subscribe it to
return 64 bits instead of default 32 bits (as for times).  It could a future
cleanup.

It is based on my previous {INTERNAL,INLINE}_SYSCALL_CALL macro [2],
although it is mainly for simplification.

Tested on x86_64, i686, aarch64, armhf, and powerpc64le.

	* nptl/Makefile (libpthread-routines): Remove ptw-llseek and add
	ptw-lseek64.
	* sysdeps/unix/sysv/linux/Makefile (sysdeps_routines): Remove llseek.
	* sysdeps/unix/sysv/linux/alpha/Makefile  (sysdeps_routines):
	Likewise.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/llseek.c: Remove file.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/lseek.c: Remove file.
	* sysdeps/unix/sysv/linux/mips/mips64/llseek.c: Likewise.
	* sysdeps/unix/sysv/linux/llseek.c: Remove file.
	* sysdeps/unix/sysv/linux/lseek.c: New file.
	* sysdeps/unix/sysv/linux/lseek64.c: Add default Linux implementation.
	* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list: Remove lseek and
	__libc_lseek64 from auto-generation.
	* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/lseek64.S: New file.

[1] https://sourceware.org/ml/libc-alpha/2016-08/msg00443.html
[2] https://sourceware.org/ml/libc-alpha/2016-08/msg00646.html
2016-11-08 16:04:33 -02:00
Adhemerval Zanella 706e6749de posix: Correctly enable/disable cancellation on Linux posix_spawn
This patch correctly enable and disable asynchronous cancellation on
Linux posix_spawn.  Current code invert the logic by enabling and
disabling instead.  It also adds a new test to check if posix_spawn
is not a cancellation entrypoint.

Checked on x86_64, i686, powerpc64le, and aarch64.

	* nptl/Makefile (tests): Add tst-exec5.
	* nptl/tst-exec5.c: New file.
	* sysdeps/unix/sysv/linux/spawni.c (__spawni): Correctly enable and disable
	asynchronous cancellation.
2016-09-20 17:18:15 -03:00
Adhemerval Zanella 91dd866ff1 nptl: Set sem_open as a non cancellation point (BZ #15765)
This patch changes sem_open to not act as a cancellation point.
Cancellation is disable at start and reenable in function exit.
It fixes BZ #15765.

Tested on x86_64 and i686.

	[BZ #15765]
	* nptl/Makefile (tests): Add tst-sem16.
	* nptl/tst-sem16.c: New file.
	* nptl/sem_open.c (sem_open): Disable asynchronous cancellation.
2016-09-15 11:14:25 -03:00
Florian Weimer a0a9b6e376 Remove the ptw-% patterns
Nothing depends on the PTW macro anymore, so the mechanism to define
PTW for recompliations of libc routines is no longer needed.  The
source files are still recompiled for the nptl directory, just without
the “ptw-” prefix.

(Reducing the number of pattern rules in sysd-rules is critical for
improving make performance.)
2016-09-14 16:02:06 +02:00
Florian Weimer 6c444ad6e9 elf: Do not use memalign for TCB/TLS blocks allocation [BZ #17730]
Instead, call malloc and explicitly align the pointer.

There is no external location to store the original (unaligned)
pointer, and this commit increases the allocation size to store
the pointer at a fixed location relative to the TCB pointer.

The manual alignment means that some space goes unused which
was previously made available for subsequent allocations.
However, in the TLS_DTV_AT_TP case, the manual alignment code
avoids aligning the pre-TCB to the TLS block alignment.  (Even
while using memalign, the allocation had some unused padding
in front.)

This concludes the removal of memalign calls from the TLS code,
and the new tst-tls3-malloc test verifies that only core malloc
routines are used.
2016-08-03 16:16:57 +02:00