Commit Graph

542 Commits

Author SHA1 Message Date
Adhemerval Zanella
4c8cb283ec nptl: Remove pwrite from libpthread
The libc version is identical and built with same flags, it is also
uses as the default version.

Checked on x86_64-linux-gnu.
2021-03-26 13:37:18 -03:00
Adhemerval Zanella
dd795c6c24 nptl: Remove pread from libpthread
The libc version is identical and built with same flags, it is also
uses as the default version.

Checked on x86_64-linux-gnu.
2021-03-26 13:37:18 -03:00
Adhemerval Zanella
40873cdd38 nptl: Remove open from libpthread
The libc version is identical and built with same flags.  The libc
version is set as the default version.

Checked on x86_64-linux-gnu.
2021-03-26 13:37:14 -03:00
Adhemerval Zanella
c5c3588475 nptl: Remove lseek from libpthread
The libc version is identical and built with same flags.  The libc
version is set as the default version.

The libpthread compat symbol requires to mask it when building the
loader object otherwise ld might complain about a missing
versioned symbol (as for alpha).

Checked on x86_64-linux-gnu.
2021-03-26 13:36:17 -03:00
Adhemerval Zanella
78d1724d53 nptl: Remove send from libpthread
The libc version is identical and built with same flags.  Both aarch64
and nios2 also requires to export __send and tt was done previously with
the HAVE_INTERNAL_SEND_SYMBOL (which forced the symbol creation).

All __send callers are internal to libc and the original issue that
required the symbol export was due a missing libc_hidden_def.  So
a compat symbol is added for __send and the libc_hidden_def is
defined regardless.

Checked on x86_64-linux-gnu and i686-linux-gnu.
2021-03-26 13:36:17 -03:00
Adhemerval Zanella
a894053318 signal: Add __libc_sigaction
The generic implementation basically handle the system agnostic logic
(filtering out the invalid signals) while the __libc_sigaction is
the function with implements the system and architecture bits.

Checked on x86_64-linux-gnu and i686-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
d5ddd583da nptl: Move system to libc
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
9cf242997d nptl: Move fcntl from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
729cb5a2a7 nptl: Remove sendmsg from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
0cf67de816 nptl: Remove recvmsg from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
2d6f4ebd65 nptl: Remove sigwait from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
1e157b9cb4 nptl: Remove tcdrain from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
c29386fd50 nptl: Remove pause from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
0c9d4925fe nptl: Remove msync from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
fc495dc4e9 nptl: Remove fsync from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
6f2e00cac5 nptl: Remove sendto from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
643a88a9c1 nptl: Remove recvfrom from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
494c3beec9 nptl: Remove recv from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
3ddf9bc185 nptl: Remove connect from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
c59f716993 nptl: Remove accept from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:38 -03:00
Adhemerval Zanella
bdfed2e2cd nptl: Remove close from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:24 -03:00
Adhemerval Zanella
baab50cfb9 nptl: Remove read from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 08:21:29 -03:00
Adhemerval Zanella
173e0ab081 nptl: Remove write from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 08:20:43 -03:00
Adhemerval Zanella
7384193b71 nptl: Move fork into libc
This is part of the libpthread removal project:

   <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

Checked on x86_64-linux-gnu.
2021-03-12 10:19:58 -03:00
Adhemerval Zanella
2b47727c68 posix: Consolidate register-atfork
Both htl and nptl uses a different data structure to implement atfork
handlers.  The nptl one was refactored by 27761a1042 to use a dynarray
which simplifies the code.

This patch moves the nptl one to be the generic implementation and
replace Hurd linked one.  Different than previous NPTL, Hurd also uses
a global lock, so performance should be similar.

Checked on x86_64-linux-gnu, i686-linux-gnu, and with a build for
i686-gnu.
2021-03-12 10:19:22 -03:00
Jakub Jelinek
f0419e6a10 [PATCH] pthread_once hangs when init routine throws an exception [BZ #18435]
This is another attempt at making pthread_once handle throwing exceptions
from the init routine callback.  As the new testcases show, just switching
to the cleanup attribute based cleanup does fix the tst-once5 test, but
breaks the new tst-oncey3 test.  That is because when throwing exceptions,
only the unwind info registered cleanups (i.e. C++ destructors or cleanup
attribute), when cancelling threads and there has been unwind info from the
cancellation point up to whatever needs cleanup both unwind info registered
cleanups and THREAD_SETMEM (self, cleanup, ...) registered cleanups are
invoked, but once we hit some frame with no unwind info, only the
THREAD_SETMEM (self, cleanup, ...) registered cleanups are invoked.
So, to stay fully backwards compatible (allow init routines without
unwind info which encounter cancellation points) and handle exception throwing
we actually need to register the pthread_once cleanups in both unwind info
and in the THREAD_SETMEM (self, cleanup, ...) way.
If an exception is thrown, only the former will happen and we in that case
need to also unregister the THREAD_SETMEM (self, cleanup, ...) registered
handler, because otherwise after catching the exception the user code could
call deeper into the stack some cancellation point, get cancelled and then
a stale cleanup handler would clobber stack and probably crash.
If a thread calling init routine is cancelled and unwind info ends before
the pthread_once frame, it will be cleaned up through self->cleanup as
before.  And if unwind info is present, unwind_stop first calls the
self->cleanup registered handler for the frame, then it will call the
unwind info registered handler but that will already see __do_it == 0
and do nothing.
2021-03-04 15:15:33 +01:00
Florian Weimer
5a664d7ae8 nptl: Move elision implementations into libc
The elision interfaces are closely aligned between the targets that
implement them, so declare them in the generic <lowlevellock.h>
file.

Empty .c stubs are provided, so that fewer makefile updates
under sysdeps are needed.  Also simplify initialization via
__libc_early_init.

The symbols __lll_clocklock_elision, __lll_lock_elision,
__lll_trylock_elision, __lll_unlock_elision, __pthread_force_elision
move into libc.  For the time being, non-hidden references are used
from libpthread to access them, but once that part of libpthread
is moved into libc, hidden symbols will be used again.  (Hidden
references seem desirable to reduce the likelihood of transactions
aborts.)
2021-02-23 14:59:34 +01:00
Florian Weimer
b5be9ae77e nptl: Move futex-internal into libc
This moves  __futex_abstimed_wait64 and
__futex_abstimed_wait_cancelable64 and exports these functions as
GLIBC_PRIVATE.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-02-22 18:30:52 +01:00
Florian Weimer
2f4019de81 nptl: Move lowlevellock into libc [BZ #15648]
And export __lll_lock_wait and __lll_lock_wait_private as
GLIBC_PRIVATE.  This should eliminate the need for the previous
riscv kludge.
2021-02-22 18:30:52 +01:00
Florian Weimer
541e53c9dd nptl: Move futex-internal.c into main nptl directory
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-02-22 18:30:52 +01:00
Florian Weimer
3f232aa36d nptl: Split libpthread-routines into one routine per line
And sort the lines lexicographically.  This will make it easier to review
patches which move symbols from libpthread to libc.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-02-22 18:30:52 +01:00
Adhemerval Zanella
da4aea0b5e pthread: Refactor semaphore code
The internal semaphore list code is moved to a specific file,
sem_routine.c, and the internal usage is simplified to only two
functions (one to insert a new semaphore and one to remove it
from the internal list).  There is no need to expose the
internal locking, neither how the semaphore mapping is implemented.

No functional or semantic change is expected, tested on
x86_64-linux-gnu.
2021-02-08 14:10:42 -03:00
Florian Weimer
e9fed2438a linux: Require /dev/shm as the shared memory file system
Previously, glibc would pick an arbitrary tmpfs file system from
/proc/mounts if /dev/shm was not available.  This could lead to
an unsuitable file system being picked for the backing storage for
shm_open, sem_open, and related functions.

This patch introduces a new function, __shm_get_name, which builds
the file name under the appropriate (now hard-coded) directory.  It is
called from the various shm_* and sem_* function.  Unlike the
SHM_GET_NAME macro it replaces, the callers handle the return values
and errno updates.  shm-directory.c is moved directly into the posix
subdirectory because it can be implemented directly using POSIX
functionality.  It resides in libc because it is needed by both
librt and nptl/htl.

In the sem_open implementation, tmpfname is initialized directly
from a string constant.  This happens to remove one alloca call.

Checked on x86_64-linux-gnu.
2021-02-08 14:10:42 -03:00
Florian Weimer
f5a6f846b0 nptl: Remove set*id, set*gid files which are not built 2021-01-04 16:27:46 +01:00
Paul Eggert
2b778ceb40 Update copyright dates with scripts/update-copyrights
I used these shell commands:

../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright
(cd ../glibc && git commit -am"[this commit message]")

and then ignored the output, which consisted lines saying "FOO: warning:
copyright statement not found" for each of 6694 files FOO.
I then removed trailing white space from benchtests/bench-pthread-locks.c
and iconvdata/tst-iconv-big5-hkscs-to-2ucs4.c, to work around this
diagnostic from Savannah:
remote: *** pre-commit check failed ...
remote: *** error: lines with trailing whitespace found
remote: error: hook declined to update refs/heads/master
2021-01-02 12:17:34 -08:00
Lucas A. M. Magalhaes
6185508101 nptl: Fix __futex_clocklock64 return error check [BZ #26964]
The earlier implementation of this, __lll_clocklock, calls lll_clockwait
that doesn't return the futex syscall error codes.  It always tries again
if that fails.

However in the current implementation, when the futex returns EAGAIN,
__futex_clocklock64 will also return EGAIN, even if the futex is taken.

This patch fixes the EAGAIN issue and also adds a check for EINTR.  As
futex syscall can return EINTR if the thread is interrupted by a signal.
In this case I'm assuming the function should continue trying to lock as
there is no mention to about it on POSIX.  Also add a test for both
scenarios.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2020-12-01 18:26:26 -03:00
Adhemerval Zanella
71eeae0325 nptl: Fix PTHREAD_PRIO_PROTECT timed lock
The 878fe624d4 changed lll_futex_timed_wait, which expects a relative
timeout, with a __futex_abstimed_wait64, which expects an absolute
timeout.  However the code still passes a relative timeout.

Also, the PTHREAD_PRIO_PROTECT support for clocks different than
CLOCK_REALTIME was broken since the inclusion of
pthread_mutex_clocklock (9d20e22e46) since lll_futex_timed_wait
always use CLOCK_REALTIME.

This patch fixes by removing the relative time calculation.  It
also adds some xtests that tests both thread and inter-process
usage.

Checked on x86_64-linux-gnu.
2020-11-27 09:59:13 -03:00
Adhemerval Zanella
74f418b29d nptl: Return EINVAL for pthread_mutex_clocklock/PI with CLOCK_MONOTONIC [BZ #26801]
Linux futex FUTEX_LOCK_PI operation only supports CLOCK_REALTIME,
so pthread_mutex_clocklock operation with priority aware mutexes
may fail depending of the input timeout.

Also, it is not possible to convert a CLOCK_MONOTONIC to a
CLOCK_REALTIME due the possible wall clock time change which might
invalid the requested timeout.

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

Reviewed-by: Lukasz Majewski <lukma@denx.de>
2020-11-25 10:46:22 -03:00
Adhemerval Zanella
5289cec4b8 nptl: Replace lll_timedwait with __futex_abstimed_wait64
Checked with x86_64-linux-gnu and i686-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
2020-11-25 10:43:18 -03:00
Samuel Thibault
3dbbd2ff92 Add {,sysdep-}ld-library-path make variable
On GNU/Hurd we not only need $(common-objpfx) in LD_LIBRARY_PATH when loading
dynamic objects, but also $(common-objpfx)/mach and $(common-objpfx)/hurd. This
adds an ld-library-path variable to be used as LD_LIBRARY_PATH basis in
Makefiles, and a sysdep-ld-library-path variable for sysdeps to add some
more paths, here mach/ and hurd/.
2020-11-16 21:15:20 +00:00
H.J. Lu
fbb71eddb3 tst-setuid1-static-ENV: Add $(common-objpfx)nss [BZ #26820]
commit def674652e
Author: Florian Weimer <fweimer@redhat.com>
Date:   Mon Apr 27 15:00:14 2020 +0200

    nptl/tst-setuid1-static: Improve isolation from system objects

    Static dlopen needs an LD_LIBRARY_PATH setting to avoid loading system
    libraries.

missed $(common-objpfx)nss.  Add $(common-objpfx)nss to LD_LIBRARY_PATH
for tst-setuid1-static to support

  struct passwd *pwd = getpwnam ("nobody");

in nptl/tst-setuid1.c.
2020-11-03 12:04:42 -08:00
Andreas Schwab
8f8052c2aa Revert "Fix missing redirects in testsuite targets"
This reverts commit d5afb38503.  The log files are actually created by the
various shell scripts that drive the tests.
2020-10-08 10:09:30 +02:00
Samuel Thibault
ac54c335e9 htl: Enable tst-cancelx?[45]
* nptl/{tst-cancel4-common.c, tst-cancel4-common.h, tst-cancel4.c,
tst-cancel5.c, tst-cancelx4.c, tst-cancelx5.c}: Move to sysdeps/pthread/
* nptl/Makefile: Move corresponding rules to...
* sysdeps/pthread/Makefile: ... here.
2020-08-06 23:38:35 +00:00
H.J. Lu
0ad926f349 nptl: Zero-extend arguments to SETXID syscalls [BZ #26248]
nptl has

/* Opcodes and data types for communication with the signal handler to
   change user/group IDs.  */
struct xid_command
{
  int syscall_no;
  long int id[3];
  volatile int cntr;
  volatile int error;
};

 /* This must be last, otherwise the current thread might not have
     permissions to send SIGSETXID syscall to the other threads.  */
  result = INTERNAL_SYSCALL_NCS (cmdp->syscall_no, 3,
                                 cmdp->id[0], cmdp->id[1], cmdp->id[2]);

But the second argument of setgroups syscal is a pointer:

       int setgroups (size_t size, const gid_t *list);

But on x32, pointers passed to syscall must have pointer type so that
they will be zero-extended.  The kernel XID arguments are unsigned and
do not require sign extension.  Change xid_command to

struct xid_command
{
  int syscall_no;
  unsigned long int id[3];
  volatile int cntr;
  volatile int error;
};

so that all arguments are zero-extended.  A testcase is added for x32 and
setgroups returned with EFAULT when running as root without the fix.
2020-07-27 12:32:41 -07:00
Samuel Thibault
269e4c17cd htl: Enable cancel*16 an cancel*20 tests
* nptl/tst-cancel16.c, tst-cancel20.c, tst-cancelx16.c, tst-cancelx20.c:
Move to...
* sysdeps/pthread: ... here.
* nptl/Makefile: Move corresponding references and rules to...
* sysdeps/pthread/Makefile: ... here.
* sysdeps/mach/hurd/i386/Makefile: Xfail tst-cancel*16 for now: missing
barrier pshared support, but test should be working otherwise.
2020-06-29 00:16:33 +00:00
Samuel Thibault
eca16db02d htl: Make sem_*wait cancellations points
By aligning its implementation on pthread_cond_wait.

* sysdeps/htl/sem-timedwait.c (cancel_ctx): New structure.
(cancel_hook): New function.
(__sem_timedwait_internal): Check for cancellation and register
cancellation hook that wakes the thread up, and check again for
cancellation on exit.
* nptl/tst-cancel13.c, nptl/tst-cancelx13.c: Move to...
* sysdeps/pthread/: ... here.
* nptl/Makefile: Move corresponding references and rules to...
* sysdeps/pthread/Makefile: ... here.
2020-06-24 01:19:49 +02:00
Samuel Thibault
9f6e508b42 htl: Enable tst-cancel25 test
* nptl/tst-cancel25.c: Move to...
* sysdeps/pthread/tst-cancel25.c: ... here.
(tf2) Do not test for SIGCANCEL when it is not defined.
* nptl/Makefile: Move corresponding reference to...
* sysdeps/pthread/Makefile: ... here.
2020-06-24 00:02:31 +02:00
Samuel Thibault
7a508406df nptl: Remove now-spurious tst-cancelx9 references
They were to be moved to sysdeps/pthread/Makefile in 45fce058f ('htl:
Enable more cancellation tests')

* nptl/Makefile: (tests): Remove tst-cancelx9.
(CFLAGS-tst-cancelx9.c): Remove.
2020-06-17 15:55:52 +02:00
Samuel Thibault
45fce058fe htl: Enable more cancellation tests
* nptl/tst-cancel-self-cancelstate.c, tst-cancel-self.c, tst-cancel9.c,
tst-cancelx9.c: Move to...
* sysdeps/pthread: ... here.
* nptl/Makefile: Move corresponding references and rules to...
* sysdeps/pthread/Makefile: ... here.
2020-06-14 16:16:59 +00:00
Samuel Thibault
62d97c3432 htl: Enable more cancel tests
* nptl/tst-cancel11.c, tst-cancel21-static.c, tst-cancel21.c, tst-cancel6.c, tst-cancelx11.c, tst-cancelx21.c, tst-cancelx6.c: Move to...
* sysdeps/pthread: ... here.
* nptl/Makefile: Move corresponding references and rules to...
* sysdeps/pthread/Makefile: ... here.
2020-06-10 21:34:19 +00:00
Samuel Thibault
dd7a8ad7ba pthread: Move back linking rules to nptl and htl
d6d74ec16 ('htl: Enable more tests') moved the linking rules from
nptl/Makefile and htl/Makefile to the shared sysdeps/pthread/Makefile.  But
e.g. on powerpc some tests are added in sysdeps/powerpc/Makefile, which is
included *after* sysdeps/pthread/Makefile, and thus the tests don't get
affected by the rules and fail to link.  For now let's just copy over the
set of rules in both nptl/Makefile and htl/Makefile.

* sysdeps/pthread/Makefile: Move libpthread linking rules to...
* htl/Makefile: ... here and...
* nptl/Makefile: ... there.
2020-06-08 14:34:22 +02:00
Samuel Thibault
314a431d37 htl: Enable more tests
* nptl/tst-_res1.c, tst-_res1mod1.c, tst-_res1mod2.c, tst-atfork2.c,
tst-atfork2mod.c, tst-fini1.c, tst-fini1mod.c, tst-tls4.c, tst-tls4moda.c,
tst-tls4modb.c: Move to...
* sysdeps/pthread: ... here.  Rename tst-tls4.c to tst-pt-tls4.c to avoid
conflicting with elf/tst-tls4.c.
* nptl/Makefile: Move corresponding references and rules to...
* sysdeps/pthread/Makefile: ... here.
2020-06-07 23:45:25 +00:00
Samuel Thibault
4bab9ad854 htl: Enable but XFAIL tst-flock2, tst-signal1, tst-signal2
They need setpshared support.

* nptl/tst-flock2.c, tst-signal1.c, tst-signal2.c: Move to...
* sysdeps/pthread: ... here.
* nptl/Makefile: Move corresponding tests references to...
* sysdeps/pthread/Makefile: ... here.
* sysdeps/mach/hurd/i386/Makefile (test-xfail-tst-flock2,
test-xfail-tst-signal1, test-xfail-tst-signal2): Add.
2020-06-07 16:14:23 +02:00
Samuel Thibault
d6d74ec16c htl: Enable more tests
* htl/Makefile: Remove rules adding libpthread.so and libpthread.a to link
lines.
* nptl/Makefile: Move rules adding libpthread.so and libpthread.a to
link lines to...
* sysdeps/pthread/Makefile: ... here.

* nptl/eintr.c, tst-align.c tst-align3.c tst-atfork1.c tst-backtrace1.c
tst-bad-schedattr.c tst-cancel-self-canceltype.c tst-cancel-self-cleanup.c
tst-cancel-self-testcancel.c tst-cancel1.c tst-cancel10.c tst-cancel12.c
tst-cancel14.c tst-cancel15.c tst-cancel18.c tst-cancel19.c tst-cancel2.c
tst-cancel22.c tst-cancel23.c tst-cancel26.c tst-cancel27.c tst-cancel28.c
tst-cancel3.c tst-cancel8.c tst-cancelx1.c tst-cancelx10.c tst-cancelx12.c
tst-cancelx14.c tst-cancelx15.c tst-cancelx18.c tst-cancelx2.c tst-cancelx3.c
tst-cancelx8.c tst-cleanup0.c tst-cleanup0.expect tst-cleanup1.c tst-cleanup2.c
tst-cleanup3.c tst-cleanupx0.c tst-cleanupx0.expect tst-cleanupx1.c
tst-cleanupx2.c tst-cleanupx3.c tst-clock1.c tst-create-detached.c tst-detach1.c
tst-eintr2.c tst-eintr3.c tst-eintr4.c tst-eintr5.c tst-exec1.c tst-exec2.c
tst-exec3.c tst-exit1.c tst-exit2.c tst-exit3.c tst-flock1.c tst-fork1.c
tst-fork2.c tst-fork3.c tst-fork4.c tst-getpid3.c tst-kill1.c tst-kill2.c
tst-kill3.c tst-kill4.c tst-kill5.c tst-kill6.c tst-locale1.c tst-locale2.c
tst-memstream.c tst-popen1.c tst-raise1.c tst-sem5.c tst-setuid3.c tst-signal4.c
tst-signal5.c tst-signal6.c tst-signal8.c tst-stack1.c tst-stdio1.c tst-stdio2.c
tst-sysconf.c tst-tls1.c tst-tls2.c tst-tsd1.c tst-tsd2.c tst-tsd5.c tst-tsd6.c
tst-umask1.c tst-unload.c tst-unwind-thread.c tst-vfork1.c tst-vfork1x.c
tst-vfork2.c tst-vfork2x.c: Move tests to...
* sysdeps/pthread: ... here.
Rename
tst-popen1.c -> tst-pt-popen1.c
tst-align.c -> tst-pt-align.c
tst-align3.c -> tst-pt-align3.c
tst-sysconf.c -> tst-pt-sysconf.c
tst-tls1.c -> tst-pt-tls1.c
tst-tls2.c -> tst-pt-tls2.c
tst-vfork1.c -> tst-pt-vfork1.c
tst-vfork2.c -> tst-pt-vfork2.c
to avoid conflicting with libio/tst-popen1.c, elf/tst-align.c,
posix/tst-sysconf.c, elf/tst-tls1.c, elf/tst-tls2.c, posix/tst-vfork1.c,
posix/tst-vfork2.c.

* nptl/Makefile: Move corresponding tests references and special rules to...
* sysdeps/pthread/Makefile: ... here.

* sysdeps/pthread/tst-stack1.c (do_test): Do not clamp stack size to
PTHREAD_STACK_MIN if not defined.

Tested on linux-x86_64 and hurd-i386
2020-06-07 13:35:54 +02:00
Samuel Thibault
be22a151f3 htl: Add sem_clockwait support
* sysdeps/htl/sem-timedwait.c (__sem_timedwait_internal): Add clock_id
parameter instead of hardcoding CLOCK_REALTIME.
(__sem_clockwait): New function.
(sem_clockwait): New weak alias.
* sysdeps/htl/sem-wait.c (__sem_timedwait_internal): Update declaration.
(__sem_wait): Update call to __sem_timedwait_internal.
* htl/Versions (GLIBC_2.32): Add sem_clockwait.
* sysdeps/mach/hurd/i386/libpthread.abilist (sem_clockwait): Add symbol.
* nptl/Makefile (tests): Move tst-sem5 to...
* sysdeps/pthread/Makefile (tests): ... here.
2020-06-07 03:14:49 +02:00
Florian Weimer
ec41af45a6 nptl: Add pthread_attr_setsigmask_np, pthread_attr_getsigmask_np
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
2020-06-02 11:59:18 +02:00
Florian Weimer
7538d46113 nptl: Make pthread_attr_t dynamically extensible
This introduces the function __pthread_attr_extension to allocate the
extension space, which is freed by pthread_attr_destroy.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2020-06-02 11:54:58 +02:00
Samuel Thibault
8081702460 htl: Make pthread_cond_destroy wait for threads to be woken
This allows to reuse the storage after calling pthread_cond_destroy.

* sysdeps/htl/bits/types/struct___pthread_cond.h (__pthread_cond):
Replace unused struct __pthread_condimpl *__impl field with unsigned int
__wrefs.
(__PTHREAD_COND_INITIALIZER): Update accordingly.
* sysdeps/htl/pt-cond-timedwait.c (__pthread_cond_timedwait_internal):
Register as waiter in __wrefs field. On unregistering, wake any pending
pthread_cond_destroy.
* sysdeps/htl/pt-cond-destroy.c (__pthread_cond_destroy): Register wake
request in __wrefs.
* nptl/Makefile (tests): Move tst-cond20 tst-cond21 to...
* sysdeps/pthread/Makefile (tests): ... here.
* nptl/tst-cond20.c nptl/tst-cond21.c: Move to...
* sysdeps/pthread/tst-cond20.c sysdeps/pthread/tst-cond21.c: ... here.
2020-06-01 17:38:31 +00:00
Samuel Thibault
a3e589d1f6 htl: Enable more cond tests
* nptl/Makefile (tests): Move tst-cond11 and tst-cond27 to...
* sysdeps/pthread/Makefile (tests): ... here.
2020-06-01 17:38:31 +00:00
Samuel Thibault
28cada0418 htl: Add clock variants
* htl/pt-join.c (__pthread_join): Move implementation to...
(__pthread_join_common): ... new function. Add try, timed and clock support.
(__pthread_join): Reimplement on top of __pthread_join_common.
(__pthread_tryjoin_np, __pthread_timedjoin_np, __pthread_clockjoin_np):
Implement on top of __pthread_join_common.
(pthread_tryjoin_np, pthread_timedjoin_np, pthread_clockjoin_np): New
aliases.

* hurd/hurdlock.c (__lll_abstimed_wait, __lll_abstimed_xwait,
__lll_abstimed_lock): Check for supported clock.

* sysdeps/htl/pt-cond-timedwait.c (__pthread_cond_timedwait_internal):
Add clockid parameter and support it.
(__pthread_cond_timedwait): Pass -1 as clockid.
(__pthread_cond_clockwait): New function.
(pthread_cond_clockwait): New alias.
* sysdeps/htl/pt-cond-wait.c (__pthread_cond_timedwait_internal): Update
prototype.
(__pthread_cond_wait): Pass -1 as clockid.

* sysdeps/htl/pt-rwlock-timedrdlock.c
(__pthread_rwlock_timedrdlock_internal): Add clockid parameter, and
support id.
(__pthread_rwlock_clockrdlock): New function.
(pthread_rwlock_clockrdlock): New alias.
* sysdeps/htl/pt-rwlock-rdlock.c (__pthread_rwlock_timedrdlock_internal): Update
prototype.
(__pthread_rwlock_rdlock): Pass -1 as clockid.

* sysdeps/htl/pt-rwlock-timedwrlock.c
(__pthread_rwlock_timedwrlock_internal): Add clockid parameter, and
support id.
(__pthread_rwlock_clockwrlock): New function.
(pthread_rwlock_clockwrlock): New alias.
* sysdeps/htl/pt-rwlock-wrlock.c (__pthread_rwlock_timedwrlock_internal): Update
prototype.
(__pthread_rwlock_wrlock): Pass -1 as clockid.

* sysdeps/mach/hurd/htl/pt-mutex-timedlock.c (__pthread_mutex_timedlock): Move implementation to
(__pthread_mutex_clocklock): New function with additional clockid
parameter and support it.
(pthread_mutex_clocklock): New alias.
(__pthread_mutex_timedlock): Reimplement on top of __pthread_mutex_clocklock.

* sysdeps/htl/pthread.h (pthread_tryjoin_np, pthread_timedjoin_np,
pthread_clockjoin_np, pthread_mutex_clocklock, pthread_cond_clockwait,
pthread_rwlock_clockrdlock, pthread_rwlock_clockwrlock): New prototypes.
* sysdeps/htl/pthreadP.h (__pthread_cond_clockwait): New prototype.

* htl/Versions (GLIBC_2.32): Add pthread_cond_clockwait,
pthread_mutex_clocklock, pthread_rwlock_clockrdlock, pthread_rwlock_clockwrlock,
pthread_tryjoin_np, pthread_timedjoin_np, pthread_clockjoin_np.
* sysdeps/mach/hurd/i386/libpthread.abilist (pthread_clockjoin_np,
pthread_cond_clockwait, pthread_mutex_clocklock, pthread_rwlock_clockrdlock,
pthread_rwlock_clockwrlock, pthread_timedjoin_np, pthread_tryjoin_np):
New functions.

* nptl/tst-abstime.c, nptl/tst-join10.c, nptl/tst-join11.c, nptl/tst-join12.c,
nptl/tst-join13.c, nptl/tst-join14.c, nptl/tst-join2.c, nptl/tst-join3.c,
nptl/tst-join8.c, nptl/tst-join9.c, nptl/tst-mutex-errorcheck.c,
nptl/tst-pthread-mutexattr.c, nptl/tst-mutex11.c, nptl/tst-mutex5.c,
nptl/tst-mutex7.c, nptl/tst-mutex7robus.c, nptl/tst-mutex9.c,
nptl/tst-rwlock12.c, nptl/tst-rwlock14.c: Move to sysdeps/pthread.
* sysdeps/pthread/tst-mutex8.c: Move back to nptl.
* nptl/Makefile (tests): Move tst-mutex5, tst-mutex7, tst-mutex7robust,
tst-mutex9, tst-mutex11, tst-rwlock12, tst-rwlock14, tst-join2, tst-join3,
tst-join8, tst-join9 tst-join10, tst-join11, tst-join12, tst-join13, tst-join14,
tst-abstime, tst-mutex-errorcheck, tst-pthread-mutexattr to ...
* sysdeps/pthread/Makefile (tests): ... here.
2020-05-26 00:46:07 +00:00
Florian Weimer
02802fafcf signal: Deprecate additional legacy signal handling functions
This needs a few test adjustments: In some cases, sigignore was
used for convenience (replaced with xsignal with SIG_IGN).  Tests
for the deprecated functions need to disable
-Wdeprecated-declarations, and for the sigmask deprecation,
-Wno-error.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2020-05-25 18:32:28 +02:00
Florian Weimer
cea81e2b7e nptl: Use __pthread_attr_copy in pthread_getattr_default_np (bug 25999)
pthread_getattr_default_np needs to make a deep copy.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
2020-05-20 20:29:10 +02:00
Florian Weimer
331c6e8a18 nptl: Add __pthread_attr_copy for copying pthread_attr_t objects
Also add the private type union pthread_attr_transparent, to reduce
the amount of casting that is required.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
2020-05-20 20:28:44 +02:00
Florian Weimer
07a73d5219 nptl: Move pthread_gettattr_np into libc
This is part of the libpthread removal project:

    <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

Use __getline instead of __getdelim to avoid a localplt failure.
Likewise for __getrlimit/getrlimit.

The abilist updates were performed by:

git ls-files 'sysdeps/unix/sysv/linux/**/libc.abilist' \
  | while read x ; do
    echo "GLIBC_2.32 pthread_getattr_np F" >> $x
done
python3 scripts/move-symbol-to-libc.py --only-linux pthread_getattr_np

The private export of __pthread_getaffinity_np is no longer needed, but
the hidden alias still necessary so that the symbol can be exported with
versioned_symbol.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
2020-05-20 20:27:49 +02:00
Florian Weimer
52302bc298 nptl: Move pthread_getaffinity_np into libc
This is part of the libpthread removal project:

    <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

The abilist updates were performed by:

git ls-files 'sysdeps/unix/sysv/linux/**/libc.abilist' \
  | while read x ; do
    echo "GLIBC_2.32 pthread_getaffinity_np F" >> $x
done
python3 scripts/move-symbol-to-libc.py pthread_getaffinity_np

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
2020-05-20 20:23:20 +02:00
Florian Weimer
1979819d68 nptl: Move pthread_attr_setaffinity_np into libc
This is part of the libpthread removal project:

    <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

The symbol did not previously exist in libc, so a new GLIBC_2.32
symbol is needed, to get correct dependency for binaries which
use the symbol but no longer link against libpthread.

The abilist updates were performed by:

git ls-files 'sysdeps/unix/sysv/linux/**/libc.abilist' \
  | while read x ; do
    echo "GLIBC_2.32 pthread_attr_setaffinity_np F" >> $x
done
python3 scripts/move-symbol-to-libc.py pthread_attr_setaffinity_np

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
2020-05-20 20:22:59 +02:00
Florian Weimer
714da1d4ea nptl: Replace some stubs with the Linux implementation
The stubs for pthread_getaffinity_np, pthread_getname_np,
pthread_setaffinity_np, pthread_setname_np are replaced, and corresponding
tests are moved.

After the removal of the NaCl port, nptl is Linux-specific, and the stubs
are no longer needed.  This effectively reverts commit
c76d1ff514 ("NPTL: Add stubs for Linux-only
extension functions.").

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2020-05-20 20:22:31 +02:00
Florian Weimer
def674652e nptl/tst-setuid1-static: Improve isolation from system objects
Static dlopen needs an LD_LIBRARY_PATH setting to avoid loading system
libraries.
2020-04-27 18:38:27 +02:00
Adhemerval Zanella
566e10aa72 signal: Only handle on NSIG signals on signal functions (BZ #25657)
The upper bits of the sigset_t s not fully initialized in the signal
mask calls that return information from kernel (sigprocmask,
sigpending, and pthread_sigmask), since the exported sigset_t size
(1024 bits) is larger than Linux support one (64 or 128 bits).
It might make sigisemptyset/sigorset/sigandset fail if the mask
is filled prior the call.

This patch changes the internal signal function to handle up to
supported Linux signal number (_NSIG), the remaining bits are
untouched.

Checked on x86_64-linux-gnu and i686-linux-gnu.
2020-04-21 15:10:10 -03:00
Adhemerval Zanella
c6663fee43 nptl: Move pthread_sigmask implementation to libc
This is part of the libpthread removal project:

  <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

A new symbol version is added on libc to force loading failure
instead of lazy binding one for newly binaries with old loaders.

Checked with a build against all affected ABIs.
2020-04-21 14:01:58 -03:00
Florian Weimer
f2323817dd nptl: Move pthread_setschedparam implementation into libc
This is part of the libpthread removal project:

  <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-02-20 08:57:01 +01:00
Florian Weimer
d5074b30fe nptl: Move pthread_getschedparam implementation into libc
This is part of the libpthread removal project:

  <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-02-20 08:57:01 +01:00
Florian Weimer
ad96df2cd9 nptl: Move pthread_cond_init implementation into libc
It is necessary to export __pthread_cond_init from libc because
the C11 condition variable needs it and is still left in libpthread.

This is part of the libpthread removal project:

  <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-02-20 08:57:01 +01:00
Florian Weimer
dc6cfdc934 nptl: Move pthread_cond_destroy implementation into libc
It is necessary to export __pthread_cond_destroy from libc because
the C11 condition variable needs it and is still left in libpthread.

This is part of the libpthread removal project:

  <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-02-20 08:57:01 +01:00
Florian Weimer
7da5c345a5 nptl: Move pthread_condattr_init implementation into libc
This is part of the libpthread removal project:

  <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-02-20 08:57:01 +01:00
Florian Weimer
249afce2e7 nptl: Move pthread_condattr_destroy implementation into libc
This is part of the libpthread removal project:

  <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-02-20 08:57:01 +01:00
Florian Weimer
dc260acd38 nptl: Move pthread_attr_setscope implementation into libc
This is part of the libpthread removal project:

  <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-02-20 08:57:01 +01:00
Florian Weimer
ed0a69b675 nptl: Move pthread_attr_getscope implementation into libc
This is part of the libpthread removal project:

  <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-02-20 08:57:01 +01:00
Florian Weimer
f0929a227b nptl: Move pthread_attr_setschedpolicy implementation into libc
This is part of the libpthread removal project:

  <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-02-20 08:57:01 +01:00
Florian Weimer
ce197a6e0a nptl: Move pthread_attr_getschedpolicy implementation into libc
This is part of the libpthread removal project:

  <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-02-20 08:57:01 +01:00
Florian Weimer
8923b9962c nptl: Sort routines list in Makefile alphabetically
This will make it easier to review changes which move implementations
from libpthread to libc.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-02-20 08:57:01 +01:00
Florian Weimer
7e56088050 nptl: Use .NOTPARALLEL in Makefile only if actually running tests
It is safe to build the tests in parallel.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-02-20 08:57:01 +01:00
Adhemerval Zanella
27d83441a2 Block all signals on timer_create thread (BZ#10815)
The behavior of the signal mask on threads created by timer_create
for SIGEV_THREAD timers are implementation-defined and glibc explicit
unblocks all signals before calling the user-defined function.

This behavior, although not incorrect standard-wise, opens a race if a
program using a blocked rt-signal plus sigwaitinfo (and without an
installed signal handler for the rt-signal) receives a signal while
executing the used-defined function for SIGEV_THREAD.

A better alternative discussed in bug report is to rather block all
signals (besides the internal ones not available to application
usage).

This patch fixes this issue by only unblocking SIGSETXID (used on
set*uid function) and SIGCANCEL (used for thread cancellation).

Checked on x86_64-linux-gnu and i686-linux-gnu.
2020-02-19 13:46:31 -03:00
Samuel Thibault
0cbc855acb pthread: Fix building tst-robust8 with nptl
NPTL's pthreadP.h needs internal definitions
2020-02-16 23:53:45 +01:00
Samuel Thibault
a25077a431 pthread: Move robust mutex tests from nptl to sysdeps/pthread
tst-robust8.c prints some mutex internals for nptl debugging, this
needed to be made conditioned by getting built with nptl.
2020-02-16 14:43:54 +00:00
Adhemerval Zanella
d1aea2805d nptl: Remove ununsed pthread-errnos.h rule 2020-02-14 21:09:12 -03:00
Samuel Thibault
c0463e8b79 pthread: Move some join tests from nptl to sysdeps/pthread
So they can be checked with htl too.
2020-02-10 01:21:46 +00:00
Samuel Thibault
6acd77229a pthread: Move most barrier tests from nptl to sysdeps/pthread
So they can be checked with htl too.
2020-02-10 01:03:55 +00:00
Samuel Thibault
8a195ec810 pthread: Move most sem tests from nptl to sysdeps/pthread
So they can be checked with htl too.
2020-02-10 01:03:54 +00:00
Samuel Thibault
819bb5e660 pthread: Move key tests from nptl to sysdeps/pthread
So they can be checked with htl too.
2020-02-10 01:03:54 +00:00
Samuel Thibault
d5ec049d44 pthread: Move some rwlock tests from nptl to sysdeps/pthread
So they can be checked with htl too.
2020-02-09 20:07:51 +00:00
Samuel Thibault
28c30a6232 pthread: Move most once tests from nptl to sysdeps/pthread
So they can be checked with htl too.
2020-02-09 19:50:21 +00:00
Samuel Thibault
d8f1f2d9ab pthread: Move most cond tests from nptl to sysdeps/pthread
So they can be checked with htl too.
2020-02-09 19:24:44 +00:00
Samuel Thibault
44a41fc253 pthread: Move some attr tests from nptl to sysdeps/pthread
So they can be checked with htl too.
2020-02-09 17:30:30 +00:00
Samuel Thibault
74159dc58a pthread: Move most mutex tests from nptl to sysdeps/pthread
So they can be checked with htl too.

XFAIL tst-mutex4, for which support is still missing in htl.
2020-02-09 17:17:06 +00:00
Samuel Thibault
71d52ac4d6 pthread: Move spin tests from nptl to sysdeps/pthread
So they can be checked with htl too.
2020-02-09 17:00:44 +00:00
Samuel Thibault
cca76b6db2 pthread: Move basic tests from nptl to sysdeps/pthread
So they can be checked with htl too.
2020-02-09 16:12:53 +00:00
Samuel Thibault
b05de10400 C11 threads: Move implementation to sysdeps/pthread
so it gets shared by nptl and htl. Also add htl versions of thrd_current and
thrd_yield.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-02-09 13:56:48 +01:00
DJ Delorie
279c68ce13 Run nptl/tst-pthread-getattr in a container
See https://bugzilla.redhat.com/show_bug.cgi?id=1653942

This test depends on the kernel's assignment of memory regions, but
running under ld.so explicitly changes those assignments, sometimes
sufficiently to cause the test to fail (esp with address space
randomization).

The easiest way to "fix" the test, is to run it the way the user would
- without ld.so.  Running it in a container does that.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2020-02-03 14:57:23 -05:00
Joseph Myers
d614a75396 Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00