Commit Graph

2093 Commits

Author SHA1 Message Date
Joseph Myers 9acacaa02f Fix h_errno namespace (bug 18520).
The 2008 edition of POSIX removed h_errno, but some functions still
bring in references to the h_errno external symbol.  As this symbol is
not a part of the public ABI (only __h_errno_location is), this patch
fixes this by renaming the GLIBC_PRIVATE TLS symbol to __h_errno.

Tested for x86_64 and x86 (testsuite, and comparison of installed
shared libraries).  Disassembly of all shared libraries using h_errno
changes because of the renaming (and changes to associated TLS / GOT
offsets in some cases); disassembly of libpthread on x86_64 changes
more substantially because the enlargement of .dynsym affects
subsequent addresses.

	[BZ #18520]
	* inet/herrno.c (h_errno): Rename to __h_errno.
	(__libc_h_errno): Define as alias of __h_errno not h_errno.
	* include/netdb.h [IS_IN_LIB && !IS_IN (libc)] (h_errno): Define
	to __h_errno instead of h_errno.
	* nptl/herrno.c (h_errno): Rename to __h_errno.
	(__h_errno_location): Refer to __h_errno not h_errno.
	* resolv/Versions (h_errno): Rename to __h_errno.
	* conform/Makefile (test-xfail-XOPEN2K8/grp.h/linknamespace):
	Remove variable.
	(test-xfail-XOPEN2K8/pwd.h/linknamespace): Likewise.
2015-06-12 10:10:18 +00:00
Florian Weimer 1477b38307 pthread_key_create: Fix typo in comment 2015-06-11 11:48:22 +02:00
Gleb Fotengauer-Malinovskiy 78ad175b30 nptl: restore .interp section in libpthread.so
In commit 02657da2cf, .interp section
was removed from libpthread.so.  This led to an error:

  $ /lib64/libpthread.so.0
  Native POSIX Threads Library by Ulrich Drepper et al
  Copyright (C) 2015 Free Software Foundation, Inc.
  This is free software; see the source for copying conditions.
  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
  PARTICULAR PURPOSE.
  Forced unwind support included.
  Segmentation fault

  (gdb) bt
  #0  0x00000000000055a6 in _exit@plt ()

Unfortunately, there is no way to add a regression test for the bug
because .interp specifies the path to dynamic linker of the target
system.

[BZ #18479]
* nptl/pt-interp.c: New file.
* nptl/Makefile (libpthread-routines, libpthread-shared-only-routines):
Add pt-interp.
[$(build-shared) = yes] ($(objpfx)pt-interp.os): Depend on
$(common-objpfx)runtime-linker.h.
2015-06-10 10:18:12 +00:00
Torvald Riegel b634486d57 Fix missing wake-ups in pthread_rwlock_rdlock.
This adds wake-ups that would be missing if assuming that for a
non-writer-preferring rwlock, if one thread has acquired a rdlock and
does not release it, another thread will eventually acquire a rdlock too
despite concurrent write lock acquisition attempts.  BZ 14958 is about
supporting this assumption.  Strictly speaking, this isn't a valid
test case, but nonetheless worth supporting (see comment 7 of BZ 14958).
2015-06-04 15:34:30 +02:00
Torvald Riegel 3c9c61febe Fix lost wake-up when pthread_rwlock_timedrwlock times out.
If we set up a rwlock to prefer writers (and disallow recursive rdlock
acquisitions), then readers will block for writers that are blocked to
acquire the lock (otherwise, readers could constantly enter and exit,
and the writer would never get the lock).  However, the existing
implementation did not wake such readers when the writer timed out.
This patch adds the missing wake-up.
There's no similar case for writers being blocked on readers.
2015-06-04 15:31:59 +02:00
Roland McGrath 68c97aef62 Split timed-wait functions out of nptl/lowlevellock.c. 2015-05-26 14:49:13 -07:00
Adhemerval Zanella 60dce8b904 Remove socket.S implementation
This patch removes the socket.S implementation for all ports and replace
it by a C implementation using socketcall.  For ports that implement
the syscall directly, there is no change.

The patch idea is to simplify the socket function implementation that
uses the socketcall to be based on C implemetation instead of a pseudo
assembly implementation with arch specific parts.  The patch then remove
the assembly implementatation for the ports which uses socketcall
(i386, microblaze, mips, powerpc, sparc, m68k, s390 and sh).

I have cross-build GLIBC for afore-mentioned ports and tested on both
i386 and ppc32 without regressions.
2015-05-22 17:38:06 -03:00
Roland McGrath 992328e5e0 Fix nptl-init.c use of INTERNAL_SYSCALL_DECL. 2015-05-22 10:20:45 -07:00
Roland McGrath 7cea621278 NaCl: Set tid field to a unique value. 2015-05-20 14:52:05 -07:00
Roland McGrath 88ed594f5d BZ#18434: Fix sem_post EOVERFLOW check for [!__HAVE_64B_ATOMICS]. 2015-05-19 15:04:41 -07:00
Arjun Shankar 330fadfc62 Ensure `wint_t' is defined before use in include/stdio.h
While trying to get nptl/tst-initializers1.c to include the test skeleton, I
came across a couple of speed bumps. Firstly: after making the appropriate
changes to the test, running `make check' led to this error:

> In file included from ../malloc/malloc.h:24:0,
..
>                  from tst-initializers1.c:60:
> ../include/stdio.h:111:1: error: unknown type name `wint_t'
>  extern wint_t __getwc_unlocked (FILE *__fp);

So, `wint_t' is used before being defined. Question: Why did test-skeleton.c
not cause this error in any of the other tests that include it?

Anyway, I noticed include/stdio.h includes stddef.h, which in turn defines
`wint_t', but only if `__need_wint_t' is defined. So I put in a
`#define __need_wint_t' before the include to get rid of the error. Is that
the correct fix?

A subsequent `make && make check' led to this second error:

>                  from tst-initializers1-c89.c:1:
> ../test-skeleton.c: In function `main':
> ../test-skeleton.c:356:11: error: `for' loop initial declarations are only
>  allowed in C99 mode
>            for (struct temp_name_list *n = temp_name_list;

Although there seem to be several other C89 no-noes in test-skeleton.c, I
needed only to fix this specific one for gcc-4.8.3 to stop complaining.
2015-05-18 12:28:06 +05:30
Adhemerval Zanella 7bf8fb1042 libc-vdso.h place consolidation
This patch moves the libc-vdso.h internal header from bits folder to
default architecture one and also corrects the remaning includes in
the files.
2015-04-20 08:51:17 -03:00
Joseph Myers c2f5813ae0 Make sem_timedwait use FUTEX_CLOCK_REALTIME (bug 18138).
sem_timedwait converts absolute timeouts to relative to pass them to
the futex syscall.  (Before the recent reimplementation, on x86_64 it
used FUTEX_CLOCK_REALTIME, but not on other architectures.)

Correctly implementing POSIX requirements, however, requires use of
FUTEX_CLOCK_REALTIME; passing a relative timeout to the kernel does
not conform to POSIX.  The POSIX specification for sem_timedwait says
"The timeout shall be based on the CLOCK_REALTIME clock.".  The POSIX
specification for clock_settime says "If the value of the
CLOCK_REALTIME clock is set via clock_settime(), the new value of the
clock shall be used to determine the time of expiration for absolute
time services based upon the CLOCK_REALTIME clock. This applies to the
time at which armed absolute timers expire. If the absolute time
requested at the invocation of such a time service is before the new
value of the clock, the time service shall expire immediately as if
the clock had reached the requested time normally.".  If a relative
timeout is passed to the kernel, it is interpreted according to the
CLOCK_MONOTONIC clock, and so fails to meet that POSIX requirement in
the event of clock changes.

This patch makes sem_timedwait use lll_futex_timed_wait_bitset with
FUTEX_CLOCK_REALTIME when possible, as done in some other places in
NPTL.  FUTEX_CLOCK_REALTIME is always available for supported Linux
kernel versions; unavailability of lll_futex_timed_wait_bitset is only
an issue for hppa (an issue noted in
<https://sourceware.org/glibc/wiki/PortStatus>, and fixed by the
unreviewed
<https://sourceware.org/ml/libc-alpha/2014-12/msg00655.html> that
removes the hppa lowlevellock.h completely).

In the FUTEX_CLOCK_REALTIME case, the glibc code still needs to check
for negative tv_sec and handle that as timeout, because the Linux
kernel returns EINVAL not ETIMEDOUT for that case, so resulting in
failures of nptl/tst-abstime and nptl/tst-sem13 in the absence of that
check.  If we're trying to distinguish between Linux-specific and
generic-futex NPTL code, I suppose having this in an nptl/ file isn't
ideal, but there doesn't seem to be any better place at present.

It's not possible to add a testcase for this issue to the testsuite
because of the requirement to change the system clock as part of a
test (this is a case where testing would require some form of
container, with root in that container, and one whose CLOCK_REALTIME
is isolated from that of the host; I'm not sure what forms of
containers, short of a full virtual machine, provide that clock
isolation).

Tested for x86_64.  Also tested for powerpc with the testcase included
in the bug.

	[BZ #18138]
	* nptl/sem_waitcommon.c: Include <kernel-features.h>.
	(futex_abstimed_wait)
	[__ASSUME_FUTEX_CLOCK_REALTIME && lll_futex_timed_wait_bitset]:
	Use lll_futex_timed_wait_bitset with FUTEX_CLOCK_REALTIME instead
	of lll_futex_timed_wait.
2015-03-18 17:05:38 +00:00
Alexandre Oliva f8aeae3473 Fix DTV race, assert, DTV_SURPLUS Static TLS limit, and nptl_db garbage
for  ChangeLog

	[BZ #17090]
	[BZ #17620]
	[BZ #17621]
	[BZ #17628]
	* NEWS: Update.
	* elf/dl-tls.c (_dl_update_slotinfo): Clean up outdated DTV
	entries with Static TLS too.  Skip entries past the end of the
	allocated DTV, from Alan Modra.
	(tls_get_addr_tail): Update to glibc_likely/unlikely.  Move
	Static TLS DTV entry set up from...
	 (_dl_allocate_tls_init): ... here (fix modid assertion), ...
	* elf/dl-reloc.c (_dl_nothread_init_static_tls): ... here...
	* nptl/allocatestack.c (init_one_static_tls): ... and here...
	* elf/dlopen.c (dl_open_worker): Drop l_tls_modid upper bound
	for Static TLS.
	* elf/tlsdeschtab.h (map_generation): Return size_t.  Check
	that the slot we find is associated with the given map before
	using its generation count.
	* nptl_db/db_info.c: Include ldsodefs.h.
	(rtld_global, dtv_slotinfo_list, dtv_slotinfo): New typedefs.
	* nptl_db/structs.def (DB_RTLD_VARIABLE): New macro.
	(DB_MAIN_VARIABLE, DB_RTLD_GLOBAL_FIELD): Likewise.
	(link_map::l_tls_offset): New struct field.
	(dtv_t::counter): Likewise.
	(rtld_global): New struct.
	(_rtld_global): New rtld variable.
	(dl_tls_dtv_slotinfo_list): New rtld global field.
	(dtv_slotinfo_list): New struct.
	(dtv_slotinfo): Likewise.
	* nptl_db/td_symbol_list.c: Drop gnu/lib-names.h include.
	(td_lookup): Rename to...
	(td_mod_lookup): ... this.  Use new mod parameter instead of
	LIBPTHREAD_SO.
	* nptl_db/td_thr_tlsbase.c: Include link.h.
	(dtv_slotinfo_list, dtv_slotinfo): New functions.
	(td_thr_tlsbase): Check DTV generation.  Compute Static TLS
	addresses even if the DTV is out of date or missing them.
	* nptl_db/fetch-value.c (_td_locate_field): Do not refuse to
	index zero-length arrays.
	* nptl_db/thread_dbP.h: Include gnu/lib-names.h.
	(td_lookup): Make it a macro implemented in terms of...
	(td_mod_lookup): ... this declaration.
	* nptl_db/db-symbols.awk (DB_RTLD_VARIABLE): Override.
	(DB_MAIN_VARIABLE): Likewise.
2015-03-17 00:31:49 -03:00
Roland McGrath 44a6213c8e Let tests result in UNSUPPORTED; use that for unbuildable C++ cases 2015-03-10 15:13:14 -07:00
Roland McGrath 2cfe32bc05 Conditionalize some test code for SIGRTMIN, SA_SIGINFO. 2015-03-04 15:14:56 -08:00
Roland McGrath e4693aa7c1 Avoid C++ tests when the C++ cannot be linked. 2015-03-04 13:52:45 -08:00
Torvald Riegel 35264d1442 Make error checking effective in nptl/tst-cond25.c. 2015-02-16 18:11:14 +01:00
Andreas Schwab 2868e0703d Filter out PTHREAD_MUTEX_NO_ELISION_NP bit in pthread_mutexattr_gettype (BZ #15790)
pthread_mutexattr_settype adds PTHREAD_MUTEX_NO_ELISION_NP to kind,
which is an internal flag that pthread_mutexattr_gettype shouldn't
expose, since pthread_mutexattr_settype wouldn't accept it.
2015-02-12 09:26:00 +01:00
Roland McGrath 022f481264 NPTL: Conditionalize some sanity tests for SIGCANCEL/SIGSETXID. 2015-02-06 12:31:11 -08:00
Roland McGrath 1ac074e66e Conditionalize use of SIGRTMIN in nptl/tst-locale1.c. 2015-02-06 12:30:58 -08:00
Roland McGrath 9e7265f4e5 NPTL: Build tests using clone directly only for Linux. 2015-02-06 12:30:23 -08:00
Roland McGrath 62ad2abcd6 Use signal rather than sigaction in nptl/tst-cleanup2. 2015-02-06 12:30:05 -08:00
Roland McGrath cfa69b0bb2 Conditionalize some tests' use of SA_SIGINFO. 2015-02-06 12:29:50 -08:00
Roland McGrath ebf7d6eedb Fix nptl/tst-kill5 not to presume SIGRTMAX exists. 2015-02-06 12:22:23 -08:00
Roland McGrath ca0e0675a7 Clean up nptl/tst-join5 use of nanosleep. 2015-02-06 12:21:38 -08:00
Roland McGrath 8c28bbc6d9 Clean up NPTL system to be compat-only. 2015-02-06 10:53:38 -08:00
Roland McGrath ec2a88b3c6 Clean up NPTL longjmp to be compat-only. 2015-02-06 10:53:27 -08:00
Roland McGrath beff1d132c Clean up NPTL fork to be compat-only. 2015-02-06 10:53:07 -08:00
H.J. Lu e0da28a1b2 Also use uint64_t in __new_sem_wait_fast 2015-01-23 16:21:07 -08:00
H.J. Lu 22971c35e2 Use uint64_t and (uint64_t) 1 for 64-bit int
This patch replaces unsigned long int and 1UL with uint64_t and
(uint64_t) 1 to support ILP32 targets like x32.

	[BZ #17870]
	* nptl/sem_post.c (__new_sem_post): Replace unsigned long int
	with uint64_t.
	* nptl/sem_waitcommon.c (__sem_wait_cleanup): Replace 1UL with
	(uint64_t) 1.
	(__new_sem_wait_slow): Replace unsigned long int with uint64_t.
	Replace 1UL with (uint64_t) 1.
	* sysdeps/nptl/internaltypes.h (new_sem): Replace unsigned long
	int with uint64_t.
2015-01-23 14:48:40 -08:00
Carlos O'Donell 042e1521c7 Fix semaphore destruction (bug 12674).
This commit fixes semaphore destruction by either using 64b atomic
operations (where available), or by using two separate fields when only
32b atomic operations are available.  In the latter case, we keep a
conservative estimate of whether there are any waiting threads in one
bit of the field that counts the number of available tokens, thus
allowing sem_post to atomically both add a token and determine whether
it needs to call futex_wake.

See:
https://sourceware.org/ml/libc-alpha/2014-12/msg00155.html
2015-01-21 00:46:16 -05:00
Roland McGrath 7b052e33dd NPTL: Fix generic pthread_sigmask. 2015-01-08 14:26:51 -08:00
Roland McGrath cc40d25e50 NPTL: Fixed missed conditionalization of setxid hooey. 2015-01-08 13:41:14 -08:00
Roland McGrath 59ff172f80 NPTL: Refactor cpu_set_t validation to be sysdeps-controlled
This removes Linuxisms related to cpu_set_t validation from the
generic NPTL code and puts them into a new sysdeps header file.
2015-01-08 10:49:40 -08:00
Richard Henderson b92058573b Add -Wno-trampolines as needed 2015-01-08 08:32:44 -08:00
Adhemerval Zanella 14bb4e57c0 Function declaration cleanup
This patch changes the some function declaration from K&R style to
default ANSI C.

	* nptl/pthread_cancel.c (pthread_cancel): Use ANSI prototype.
	* nptl/pthread_cond_timedwait.c (__pthread_cond_timedwait): Likewise.
	* nptl/pthread_cond_wait.c (__pthread_cond_wait): Likewise.
	* nptl/pthread_exit.c (__pthread_exit): Likewise.
	* nptl/pthread_join.c (pthread_join): Likewise.
	* nptl/pthread_timedjoin.c (pthread_timedjoin_np): Likewise.
	* sysdeps/posix/waitid.c (__waitid): Likewise.
	* sysdeps/unix/sysv/linux/arm/pread.c (__libc_pread): Likewise.
	* sysdeps/unix/sysv/linux/arm/pread64.c (__libc_pread64): Likewise.
	* sysdeps/unix/sysv/linux/arm/pwrite.c (__libc_pwrite): Likewise.
	* sysdeps/unix/sysv/linux/arm/pwrite64.c (__libc_pwrite64): Likewise.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/pread.c (__libc_pread):
	Likewise.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/pread64.c
	(__libc_pread64): Likewise.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/pwrite.c
	(__libc_pwrite): Likewise.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/pwrite64.c
	(__libc_pwrite64): Likewsie.
	* sysdeps/unix/sysv/linux/mips/pread.c (__libc_pread): Likewise.
	* sysdeps/unix/sysv/linux/mips/pread64.c (__libc_pread64): Likewise.
	* sysdeps/unix/sysv/linux/mips/pwrite.c (__libc_pwrite): Likewise.
	* sysdeps/unix/sysv/linux/mips/pwrite64.c (__libc_pwrite64): Likewise.
	* sysdeps/unix/sysv/linux/msgrcv.c (__libc_msgrcv): Likewise.
	* sysdeps/unix/sysv/linux/msgsnd.c (__libc_msgsnd): Likewise.
	* sysdeps/unix/sysv/linux/openat.c (OPENAT_NOT_CANCEL): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/pread.c (__libc_pread):
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/pread64.c
	(__libc_pread64): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/pwrite.c (__libc_pwrite):
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/pwrite64.c
	(__libc_pwrite64): Likewise.
	* sysdeps/unix/sysv/linux/pread.c (__libc_pread): Likewise.
	* sysdeps/unix/sysv/linux/pread64.c (__libc_pread64): Likewise.
	* sysdeps/unix/sysv/linux/preadv.c (PREADV): Likewise.
	* sysdeps/unix/sysv/linux/pthread_kill.c (__pthread_kill): Likewise.
	* sysdeps/unix/sysv/linux/pwrite.c (__libc_pwrite): Likewise.
	* sysdeps/unix/sysv/linux/pwrite64.c (__libc_pwrite64): Likewise.
	* sysdeps/unix/sysv/linux/pwritev.c (__libc_pwritev): Likewise.
	* sysdeps/unix/sysv/linux/sh/pread.c (__libc_pread): Likewise.
	* sysdeps/unix/sysv/linux/sh/pread64.c (__libc_pread64): Likewise.
	* sysdeps/unix/sysv/linux/sh/pwrite.c (__libc_pwrite): Likewise.
	* sysdeps/unix/sysv/linux/sh/pwrite64.c (__libc_write64): Likewise.
	* sysdeps/unix/sysv/linux/sigsuspend.c (__sigsuspend): Likewise.
	* sysdeps/unix/sysv/linux/sigtimedwait.c (__sigtimedwait): Likewise.
	* sysdeps/unix/sysv/linux/sigwait.c (__sigwait): Likewise.
	* sysdeps/unix/sysv/linux/sigwaitinfo.c (__sigwaitinfo): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/msgrcv.c (__libc_msgrcv):
	Likewise.
2015-01-06 08:23:58 -08:00
Joseph Myers 522ad1d6f7 Use single year in copyright notice in banner in ntpl/version.c.
* nptl/version.c (banner): Use single year in copyright notice.
2015-01-02 17:45:48 +00:00
Joseph Myers 9706dc5f53 Update copyright dates not handled by scripts/update-copyrights.
I've updated copyright dates in glibc for 2015.  This is the patch for
the changes not generated by scripts/update-copyrights and subsequent
build / regeneration of generated files.  Apart from the files updated
last time (of which sotruss.ksh had moved to sotruss.sh during the
year) this also updates nptl/version.c (missed from 2006 until
October) and sysdeps/unix/sysv/linux/lddlibc4.c (missed since 2009).

	* NEWS: Update copyright dates.
	* catgets/gencat.c (print_version): Likewise.
	* csu/version.c (banner): Likewise.
	* debug/catchsegv.sh: Likewise.
	* debug/pcprofiledump.c (print_version): Likewise.
	* debug/xtrace.sh (do_version): Likewise.
	* elf/ldconfig.c (print_version): Likewise.
	* elf/ldd.bash.in: Likewise.
	* elf/pldd.c (print_version): Likewise.
	* elf/sotruss.sh: Likewise.
	* elf/sprof.c (print_version): Likewise.
	* iconv/iconv_prog.c (print_version): Likewise.
	* iconv/iconvconfig.c (print_version): Likewise.
	* locale/programs/locale.c (print_version): Likewise.
	* locale/programs/localedef.c (print_version): Likewise.
	* login/programs/pt_chown.c (print_version): Likewise.
	* malloc/memusage.sh (do_version): Likewise.
	* malloc/memusagestat.c (print_version): Likewise.
	* malloc/mtrace.pl: Likewise.
	* manual/libc.texinfo: Likewise.
	* nptl/version.c (banner): Likewise.
	* nscd/nscd.c (print_version): Likewise.
	* nss/getent.c (print_version): Likewise.
	* nss/makedb.c (print_version): Likewise.
	* posix/getconf.c (main): Likewise.
	* scripts/test-installation.pl: Likewise.
	* sysdeps/unix/sysv/linux/lddlibc4.c (main): Likewise.
2015-01-02 16:54:45 +00:00
Joseph Myers b168057aaa Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
H.J. Lu e401d5ca5d Replace %ld with %jd and cast to intmax_t 2014-12-30 08:06:35 -08:00
Roland McGrath dd6904541f NPTL: Move fork state variables to initializer files. 2014-12-17 14:33:28 -08:00
Roland McGrath f0481d971e Revert "Use pragmas rather than makefiles for necessary options for unwind code."
This reverts commit c324fcfe75.
2014-12-16 15:46:00 -08:00
Roland McGrath c324fcfe75 Use pragmas rather than makefiles for necessary options for unwind code. 2014-12-16 14:31:24 -08:00
Torvald Riegel d52c62df3d Add comments for the generic lowlevellock implementation.
Patch by Bernard Ogden <bernie.ogden@linaro.org>.
2014-12-15 22:49:29 +01:00
Torvald Riegel 045a6bcdd2 Fix nptl/tst-sem4: always start with a fresh semaphore. 2014-12-15 22:14:33 +01:00
Torvald Riegel 7f786dc12b Fix nptl/tst-mutex5.c: Do not skip tests if elision is enabled. 2014-12-15 22:14:32 +01:00
Roland McGrath e4f639e4a1 NPTL: Refactor named semaphore code to use shm-directory.h 2014-12-12 15:01:30 -08:00
Roland McGrath c76d1ff514 NPTL: Add stubs for Linux-only extension functions. 2014-12-12 14:52:14 -08:00
Roland McGrath 439c43f6ea Fix NPTL build for !__ASSUME_SET_ROBUST_LIST case. 2014-12-12 14:00:37 -08:00