Commit Graph

107 Commits

Author SHA1 Message Date
H.J. Lu d6cc1829aa x86: Use pad in pthread_unwind_buf to preserve shadow stack register
The pad array in struct pthread_unwind_buf is used by setjmp to save
shadow stack register.  We assert that size of struct pthread_unwind_buf
is no less than offset of shadow stack pointer + shadow stack pointer
size.

Since functions, like LIBC_START_MAIN, START_THREAD_DEFN as well as
these with thread cancellation, call setjmp, but never return after
__libc_unwind_longjmp, __libc_unwind_longjmp, which is defined as
__libc_longjmp on x86, doesn't need to restore shadow stack register.
__libc_longjmp, which is a private interface for thread cancellation
implementation in libpthread, is changed to call __longjmp_cancel,
instead of __longjmp.  __longjmp_cancel is a new internal function
in libc, which is similar to __longjmp, but doesn't restore shadow
stack register.

The compatibility longjmp and siglongjmp in libpthread.so are changed
to call __libc_siglongjmp, instead of __libc_longjmp, so that they will
restore shadow stack register.

Tested with build-many-glibcs.py.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* nptl/pthread_create.c (START_THREAD_DEFN): Clear previous
	handlers after setjmp.
	* setjmp/longjmp.c (__libc_longjmp): Don't define alias if
	defined.
	* sysdeps/unix/sysv/linux/x86/setjmpP.h: Include
	<libc-pointer-arith.h>.
	(_JUMP_BUF_SIGSET_BITS_PER_WORD): New.
	(_JUMP_BUF_SIGSET_NSIG): Changed to 96.
	(_JUMP_BUF_SIGSET_NWORDS): Changed to use ALIGN_UP and
	_JUMP_BUF_SIGSET_BITS_PER_WORD.
	* sysdeps/x86/Makefile (sysdep_routines): Add __longjmp_cancel.
	* sysdeps/x86/__longjmp_cancel.S: New file.
	* sysdeps/x86/longjmp.c: Likewise.
	* sysdeps/x86/nptl/pt-longjmp.c: Likewise.
2018-05-02 06:17:41 -07: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 06be6368da nptl: Define __PTHREAD_MUTEX_{NUSERS_AFTER_KIND,USE_UNION}
This patch adds two new internal defines to set the internal
pthread_mutex_t layout required by the supported ABIS:

  1. __PTHREAD_MUTEX_NUSERS_AFTER_KIND which control whether to define
     __nusers fields before or after __kind.  The preferred value for
     is 0 for new ports and it sets __nusers before __kind.

  2. __PTHREAD_MUTEX_USE_UNION which control whether internal __spins and
     __list members will be place inside an union for linuxthreads
     compatibility.  The preferred value is 0 for ports and it sets
     to not use an union to define both fields.

It fixes the wrong offsets value for __kind value on x86_64-linux-gnu-x32.
Checked with a make check run-built-tests=no on all afected ABIs.

	[BZ #22298]
	* nptl/allocatestack.c (allocate_stack): Check if
	__PTHREAD_MUTEX_HAVE_PREV is non-zero, instead if
	__PTHREAD_MUTEX_HAVE_PREV is defined.
	* nptl/descr.h (pthread): Likewise.
	* nptl/nptl-init.c (__pthread_initialize_minimal_internal):
	Likewise.
	* nptl/pthread_create.c (START_THREAD_DEFN): Likewise.
	* sysdeps/nptl/fork.c (__libc_fork): Likewise.
	* sysdeps/nptl/pthread.h (PTHREAD_MUTEX_INITIALIZER): Likewise.
	* sysdeps/nptl/bits/thread-shared-types.h
	(__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New
	defines.
	(__pthread_internal_list): Check __PTHREAD_MUTEX_USE_UNION instead
	of __WORDSIZE for internal layout.
	(__pthread_mutex_s): Check __PTHREAD_MUTEX_NUSERS_AFTER_KIND instead
	of __WORDSIZE for internal __nusers layout and __PTHREAD_MUTEX_USE_UNION
	instead of __WORDSIZE whether to use an union for __spins and __list
	fields.
	(__PTHREAD_MUTEX_HAVE_PREV): Define also for __PTHREAD_MUTEX_USE_UNION
	case.
	* sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h
	(__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New
	defines.
	* sysdeps/alpha/nptl/bits/pthreadtypes-arch.h
	(__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
	Likewise.
	* sysdeps/arm/nptl/bits/pthreadtypes-arch.h
	(__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
	Likewise.
	* sysdeps/hppa/nptl/bits/pthreadtypes-arch.h
	(__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
	Likewise.
	* sysdeps/ia64/nptl/bits/pthreadtypes-arch.h
	(__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
	Likewise.
	* sysdeps/m68k/nptl/bits/pthreadtypes-arch.h
	(__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
	Likewise.
	* sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h
	(__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
	Likewise.
	* sysdeps/mips/nptl/bits/pthreadtypes-arch.h
	(__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
	Likewise.
	* sysdeps/nios2/nptl/bits/pthreadtypes-arch.h
	(__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
	Likewise.
	* sysdeps/powerpc/nptl/bits/pthreadtypes-arch.h
	(__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
	Likewise.
	* sysdeps/s390/nptl/bits/pthreadtypes-arch.h
	(__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
	Likewise.
	* sysdeps/sh/nptl/bits/pthreadtypes-arch.h
	(__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
	Likewise.
	* sysdeps/sparc/nptl/bits/pthreadtypes-arch.h
	(__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
	Likewise.
	* sysdeps/tile/nptl/bits/pthreadtypes-arch.h
	(__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
	Likewise.
	* sysdeps/x86/nptl/bits/pthreadtypes-arch.h
	(__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION):
	Likewise.

Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2017-11-07 09:48:41 -02:00
Florian Weimer 83b09837ed nptl: Remove internal_function attribute 2017-08-31 18:52:00 +02:00
Adhemerval Zanella 01b87c656f ia64: Fix thread stack allocation permission set (BZ #21672)
This patch fixes ia64 failures on thread exit by madvise the required
area taking in consideration its disjoing stacks
(NEED_SEPARATE_REGISTER_STACK).  Also the snippet that setup the
madvise call to advertise kernel the area won't be used anymore in
near future is reallocated in allocatestack.c (for consistency to
put all stack management function in one place).

Checked on x86_64-linux-gnu and i686-linux-gnu for sanity (since
it is not expected code changes for architecture that do not
define NEED_SEPARATE_REGISTER_STACK) and also got a report that
it fixes ia64-linux-gnu failures from Sergei Trofimovich
<slyfox@gentoo.org>.

	[BZ #21672]
	* nptl/allocatestack.c [_STACK_GROWS_DOWN] (setup_stack_prot):
	Set to use !NEED_SEPARATE_REGISTER_STACK as well.
	(advise_stack_range): New function.
	* nptl/pthread_create.c (START_THREAD_DEFN): Move logic to mark
	stack non required to advise_stack_range at allocatestack.c
2017-08-29 13:29:19 -03:00
Szabolcs Nagy d2e0491883 Single threaded stdio optimization
Locking overhead can be significant in some stdio operations
that are common in single threaded applications.

This patch adds the _IO_FLAGS2_NEED_LOCK flag to indicate if
an _IO_FILE object needs to be locked and some of the stdio
functions just jump to their _unlocked variant when not.  The
flag is set on all _IO_FILE objects when the first thread is
created.  A new GLIBC_PRIVATE libc symbol, _IO_enable_locks,
was added to do this from libpthread.

The optimization can be applied to more stdio functions,
currently it is only applied to single flag check or single
non-wide-char standard operations.  The flag should probably
be never set for files with _IO_USER_LOCK, but that's just a
further optimization, not a correctness requirement.

The optimization is valid in a single thread because stdio
operations are non-as-safe (so lock state is not observable
from a signal handler) and stdio locks are recursive (so lock
state is not observable via deadlock).  The optimization is not
valid if a thread may be created while an stdio lock is taken
and thus it should be disabled if any user code may run during
an stdio operation (interposed malloc, printf hooks, etc).
This makes the optimization more complicated for some stdio
operations (e.g. printf), but those are bigger and thus less
important to optimize so this patch does not try to do that.

	* libio/libio.h (_IO_FLAGS2_NEED_LOCK, _IO_need_lock): Define.
	* libio/libioP.h (_IO_enable_locks): Declare.
	* libio/Versions (_IO_enable_locks): New symbol.
	* libio/genops.c (_IO_enable_locks): Define.
	(_IO_old_init): Initialize flags2.
	* libio/feof.c.c (_IO_feof): Avoid locking when not needed.
	* libio/ferror.c (_IO_ferror): Likewise.
	* libio/fputc.c (fputc): Likewise.
	* libio/putc.c (_IO_putc): Likewise.
	* libio/getc.c (_IO_getc): Likewise.
	* libio/getchar.c (getchar): Likewise.
	* libio/ioungetc.c (_IO_ungetc): Likewise.
	* nptl/pthread_create.c (__pthread_create_2_1): Enable stdio locks.
	* libio/iofopncook.c (_IO_fopencookie): Enable locking for the file.
	* sysdeps/pthread/flockfile.c (__flockfile): Likewise.
2017-07-04 16:05:12 +01:00
Adhemerval Zanella fa872e1b62 Clean pthread functions namespaces for C11 threads
This patch adds internal definition (through {libc_}hidden_{proto,def}) and
also change some strong to weak alias for symbols that might be used by C11
threads implementations.

The patchset should not change libc/libpthread functional, although object
changes are expected (since now internal symbols are used instead) and final
exported symbols through GLIBC_PRIVATE is also expanded (to cover libpthread
usage of __mmap{64}, __munmap, __mprotect).

Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,
microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
tile{pro,gx}-linux-gnu, and x86_64-linux-gnu).

	* include/sched.h (__sched_get_priority_max): Add libc hidden proto.
	(__sched_get_prioriry_min): Likewise.
	* include/sys/mman.h (__mmap): Likewise.
	(__mmap64): Likewise.
	(__munmap): Likewise.
	(__mprotect): Likewise.
	* include/termios.h (__tcsetattr): Likewise.
	* include/time.h (__nanosleep): Use hidden_proto instead of
	libc_hidden_proto.
	* posix/nanosleep.c (__nanosleep): Likewise.
	* misc/Versions (libc): Export __mmap, __munmap, __mprotect,
	__sched_get_priority_min, and __sched_get_priority_max under
	GLIBC_PRIVATE.
	* nptl/allocatestack.c (__free_stacks): Use internal definition for
	libc symbols.
	(change_stack_perm): Likewise.
	(allocate_stack): Likewise.
	* sysdeps/posix/gethostname.c: Likewise.
	* nptl/tpp.c (__init_sched_fifo_prio): Likewise.
	* sysdeps/unix/sysv/linux/i386/smp.h (is_smp_system): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/ioctl.c (__ioctl): Likewise.
	* nptl/pthreadP.h (__pthread_mutex_timedlock): Add definition.
	(__pthread_key_delete): Likewise.
	(__pthread_detach): Likewise.
	(__pthread_cancel): Likewise.
	(__pthread_mutex_trylock): Likewise.
	(__pthread_mutexattr_init): Likewise.
	(__pthread_mutexattr_settype): Likewise.
	* nptl/pthread_cancel.c (pthread_cancel): Change to internal name and
	create alias for exported one.
	* nptl/pthread_join.c (pthread_join): Likewise.
	* nptl/pthread_detach.c (pthread_detach): Likewise.
	* nptl/pthread_key_delete.c (pthread_key_delete): Likewise.
	* nptl/pthread_mutex_timedlock.c (pthread_mutex_timedlock): Likewise.
	* nptl/pthread_create.c: Change static requirements for pthread
	symbols.
	* nptl/pthread_equal.c (__pthread_equal): Change strong alias to weak
	for internal definition.
	* nptl/pthread_exit.c (__pthread_exit): Likewise.
	* nptl/pthread_getspecific.c (__pthread_getspecific): Likewise.
	* nptl/pthread_key_create.c (__pthread_key_create): Likewise.
	* nptl/pthread_mutex_destroy.c (__pthread_mutex_destroy): Likewise.
	* nptl/pthread_mutex_init.c (__pthread_mutex_init): Likewise.
	* nptl/pthread_mutex_lock.c (__pthread_mutex_lock): Likewise.
	* nptl/pthread_mutex_trylock.c (__pthread_mutex_trylock): Likewise.
	* nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock): Likewise.
	* nptl/pthread_mutexattr_init.c (__pthread_mutexattr_init): Likwise.
	* nptl/pthread_mutexattr_settype.c (__pthread_mutexattr_settype):
	Likewise.
	* nptl/pthread_self.c (__pthread_self): Likewise.
	* nptl/pthread_setspecific.c (__pthread_setspecific): Likewise.
	* sysdeps/unix/sysv/linux/tcsetattr.c (tcsetattr): Likewise.
	* misc/mmap.c (__mmap): Add internal symbol definition.
	* misc/mmap.c (__mmap64): Likewise.
	* sysdeps/unix/sysv/linux/mmap.c (__mmap): Likewise.
	* sysdeps/unix/sysv/linux/mmap64.c (__mmap): Likewise.
	(__mmap64): Likewise.
	* sysdeps/unix/sysv/linux/i386/Versions (libc) [GLIBC_PRIVATE):
	Add __uname.
2017-06-23 17:38:17 -03:00
Carlos O'Donell fa17b9c720 Bug 20116: Clarify behaviour of PD->lock.
Add comments to the concurrency notes to clarify the semaphore-like and
mutex-like behaviours of PD->lock.
2017-05-03 15:24:43 -04:00
Adhemerval Zanella a358c80530 Remove CALL_THREAD_FCT macro
This patch removes CALL_THREAD_FCT macro usage and its defition for
x86.  For 32 bits it usage is only for force 16 stack alignment,
however stack is already explicit aligned in clone syscall.  For
64 bits and x32 it just a function call and there is no need to
code it with inline assembly.

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

	* nptl/pthread_create.c (START_THREAD_DEFN): Remove
	CALL_THREAD_FCT macro usage.
	* sysdeps/i386/nptl/tls.h (CALL_THREAD_FCT): Remove definition.
	* sysdeps/x86_64/nptl/tls.h (CALL_THREAD_FCT): Likewise.
	* sysdeps/x86_64/32/nptl/tls.h: Remove file.
2017-04-04 18:03:35 -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
Joseph Myers bfff8b1bec Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
Carlos O'Donell d615a47355 nptl: support thread stacks that grow up
Gentoo has been carrying this for all arches since 2.17.

URL: http://bugs.gentoo.org/301642
2016-02-19 12:41:29 -05:00
Joseph Myers f7a9f785e5 Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
Joseph Myers 80d9be8122 Convert miscellaneous function definitions to prototype style.
This patch converts various miscellaneous functions definitions in
glibc, found with grep and not covered by my previous scripted
conversions, from old-style K&R to prototype-style.  These changes
were made manually.  This is not necessarily exhaustive as formatting
variants may have prevented my grep from finding some such
definitions.

Regarding the changes to files from GMP, they may originally have been
omitted when removing __STDC__ conditionals because of the files
coming from another package, but (a) GMP no longer has __STDC__
conditionals there anyway and (b) we don't try to keep these files
verbatim in sync with GMP (and there are licensing differences), so
making the change to them in glibc seems reasonable.

Tested for x86_64 and x86 (testsuite - this patch affects files
containing assertions).

	* debug/fortify_fail.c (__fortify_fail): Convert to
	prototype-style function definition.  Use internal_function.
	* libio/genops.c (save_for_backup): Convert to prototype-style
	function definition.
	* libio/wgenops.c (save_for_wbackup): Likewise.
	* login/grantpt.c (grantpt): Likewise.
	* login/ptsname.c (ptsname): Likewise.
	(__ptsname_r): Likewise.
	* login/unlockpt.c (unlockpt): Likewise.
	* mach/msgserver.c (__mach_msg_server): Likewise.
	* misc/efgcvt.c (__APPEND (FUNC_PREFIX, fcvt)): Likewise.
	(__APPEND (FUNC_PREFIX, ecvt)): Likewise.
	(__APPEND (FUNC_PREFIX, gcvt)): Likewise.
	* misc/efgcvt_r.c (__APPEND (FUNC_PREFIX, fcvt_r)): Likewise.
	(__APPEND (FUNC_PREFIX, ecvt_r)): Likewise.
	* nptl/cleanup_compat.c (_pthread_cleanup_push): Likewise.
	* nptl/cleanup_defer_compat.c (_pthread_cleanup_push_defer):
	Likewise.
	* nptl/libc_pthread_init.c (__libc_pthread_init): Likewise.  Use
	internal_function.
	* nptl/pthread_atfork.c (__pthread_atfork): Convert to
	prototype-style function definition.
	* nptl/pthread_create.c (__pthread_create_2_1): Likewise.
	[SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_1)]
	(__pthread_create_2_0): Likewise.
	* nptl/pthread_key_create.c (__pthread_key_create): Likewise.
	* nptl/register-atfork.c (__register_atfork): Likewise.
	* posix/glob.c (glob): Likewise.
	* posix/regcomp.c (re_comp): Likewise.
	* posix/regexec.c (re_exec): Likewise.
	* stdlib/add_n.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/cmp.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/divmod_1.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/divrem.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/lshift.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/mod_1.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/mul.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/mul_n.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/rshift.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/strtod.c (INTERNAL (STRTOF)): Convert to prototype-style
	function definition.
	(STRTOF): Likewise.
	* stdlib/strtod_l.c (__STRTOF): Likewise.
	* stdlib/strtol.c (INTERNAL (strtol)): Likewise.
	* stdlib/strtol_l.c (INTERNAL (__strtol_l)): Likewise.
	(__strtol_l): Likewise.
	* stdlib/sub_n.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* string/memrchr.c (MEMRCHR): Convert to prototype-style function
	definition.
	* string/strcasecmp.c (LOCALE_PARAM_DECL): Remove macro.
	[USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include argument
	type.
	(__strcasecmp): Convert to prototype-style function definition.
	* string/strncase.c (LOCALE_PARAM_DECL): Remove macro.
	[USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include argument
	type.
	(__strncasecmp): Convert to prototype-style function definition.
	* sunrpc/pm_getport.c (__libc_rpc_getport): Likewise.
	* sunrpc/xdr.c (xdr_union): Likewise.
	* sunrpc/xdr_array.c (xdr_array): Likewise.
	* sunrpc/xdr_ref.c (xdr_reference): Likewise.
	* sysdeps/m68k/m680x0/fpu/s_atan.c (__CONCATX(__,FUNC)): Likewise.
	* sysdeps/m68k/m680x0/fpu/s_isinf.c (__CONCATX(__,FUNC)):
	Likewise.
	* sysdeps/m68k/m680x0/fpu/s_scalbn.c (__CONCATX(__scalbn,suffix):
	Likewise.
	* sysdeps/m68k/m680x0/fpu/s_sincos.c (CONCATX(__,FUNC)): Likewise.
	* sysdeps/unix/sysv/linux/i386/scandir64.c (__old_scandir64):
	Likewise.
	* time/strftime_l.c (LOCALE_PARAM_DECL): Remove macro.
	(LOCALE_PARAM_PROTO): Likewise.
	[_LIBC && USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include
	argument type.
	(ut_argument_spec): Remove macro.
	(ut_argument_spec_iso): Rename to ut_argument_spec.
	(memcpy_lowcase): Use LOCALE_PARAM in declaration.  Convert to
	prototype-style function definition.
	(memcpy_uppcase): Likewise.
	(__strftime_internal): Likewise.
	(my_strftime): Likewise.
	* time/strptime_l.c (LOCALE_PARAM_PROTO): Remove macro.
	(LOCALE_PARAM_DECL): Likewise.
	[_LIBC] (LOCALE_PARAM): Include argument type.
	(__strptime_internal): Convert to prototype-style function
	definition.
	(strptime): Likewise.
	* wcsmbs/wcscasecmp.c (LOCALE_PARAM_DECL): Remove macro.
	[USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include argument
	type.
	(__wcscasecmp): Convert to prototype-style function definition.
	* wcsmbs/wcsncase.c (LOCALE_PARAM_DECL): Remove macro.
	[USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include argument
	type.
	(__wcsncasecmp): Convert to prototype-style function definition.
2015-10-20 21:27:22 +00:00
Joseph Myers 9dd346ff43 Convert 113 more function definitions to prototype style (files with assertions).
This mostly automatically-generated patch converts 113 function
definitions in glibc from old-style K&R to prototype-style.  Following
my other recent such patches, this one deals with the case of function
definitions in files that either contain assertions or where grep
suggested they might contain assertions - and thus where it isn't
possible to use a simple object code comparison as a sanity check on
the correctness of the patch, because line numbers are changed.

A few such automatically-generated changes needed to be supplemented
by manual changes for the result to compile.  openat64 had a prototype
declaration with "..." but an old-style definition in
sysdeps/unix/sysv/linux/dl-openat64.c, and "..." needed adding to the
generated prototype in the definition (I've filed
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68024> for diagnosing
such cases in GCC; the old state was undefined behavior not requiring
a diagnostic, but one seems a good idea).  In addition, as Florian has
noted regparm attribute mismatches between declaration and definition
are only diagnosed for prototype definitions, and five functions
needed internal_function added to their definitions (in the case of
__pthread_mutex_cond_lock, via the macro definition of
__pthread_mutex_lock) to compile on i386.

After this patch is in, remaining old-style definitions are probably
most readily fixed manually before we can turn on
-Wold-style-definition for all builds.

Tested for x86_64 and x86 (testsuite).

	* crypt/md5-crypt.c (__md5_crypt_r): Convert to prototype-style
	function definition.
	* crypt/sha256-crypt.c (__sha256_crypt_r): Likewise.
	* crypt/sha512-crypt.c (__sha512_crypt_r): Likewise.
	* debug/backtracesyms.c (__backtrace_symbols): Likewise.
	* elf/dl-minimal.c (_itoa): Likewise.
	* hurd/hurdmalloc.c (malloc): Likewise.
	(free): Likewise.
	(realloc): Likewise.
	* inet/inet6_option.c (inet6_option_space): Likewise.
	(inet6_option_init): Likewise.
	(inet6_option_append): Likewise.
	(inet6_option_alloc): Likewise.
	(inet6_option_next): Likewise.
	(inet6_option_find): Likewise.
	* io/ftw.c (FTW_NAME): Likewise.
	(NFTW_NAME): Likewise.
	(NFTW_NEW_NAME): Likewise.
	(NFTW_OLD_NAME): Likewise.
	* libio/iofwide.c (_IO_fwide): Likewise.
	* libio/strops.c (_IO_str_init_static_internal): Likewise.
	(_IO_str_init_static): Likewise.
	(_IO_str_init_readonly): Likewise.
	(_IO_str_overflow): Likewise.
	(_IO_str_underflow): Likewise.
	(_IO_str_count): Likewise.
	(_IO_str_seekoff): Likewise.
	(_IO_str_pbackfail): Likewise.
	(_IO_str_finish): Likewise.
	* libio/wstrops.c (_IO_wstr_init_static): Likewise.
	(_IO_wstr_overflow): Likewise.
	(_IO_wstr_underflow): Likewise.
	(_IO_wstr_count): Likewise.
	(_IO_wstr_seekoff): Likewise.
	(_IO_wstr_pbackfail): Likewise.
	(_IO_wstr_finish): Likewise.
	* locale/programs/localedef.c (normalize_codeset): Likewise.
	* locale/programs/locarchive.c (add_locale_to_archive): Likewise.
	(add_locales_to_archive): Likewise.
	(delete_locales_from_archive): Likewise.
	* malloc/malloc.c (__libc_mallinfo): Likewise.
	* math/gen-auto-libm-tests.c (init_fp_formats): Likewise.
	* misc/tsearch.c (__tfind): Likewise.
	* nptl/pthread_attr_destroy.c (__pthread_attr_destroy): Likewise.
	* nptl/pthread_attr_getdetachstate.c
	(__pthread_attr_getdetachstate): Likewise.
	* nptl/pthread_attr_getguardsize.c (pthread_attr_getguardsize):
	Likewise.
	* nptl/pthread_attr_getinheritsched.c
	(__pthread_attr_getinheritsched): Likewise.
	* nptl/pthread_attr_getschedparam.c
	(__pthread_attr_getschedparam): Likewise.
	* nptl/pthread_attr_getschedpolicy.c
	(__pthread_attr_getschedpolicy): Likewise.
	* nptl/pthread_attr_getscope.c (__pthread_attr_getscope):
	Likewise.
	* nptl/pthread_attr_getstack.c (__pthread_attr_getstack):
	Likewise.
	* nptl/pthread_attr_getstackaddr.c (__pthread_attr_getstackaddr):
	Likewise.
	* nptl/pthread_attr_getstacksize.c (__pthread_attr_getstacksize):
	Likewise.
	* nptl/pthread_attr_init.c (__pthread_attr_init_2_1): Likewise.
	(__pthread_attr_init_2_0): Likewise.
	* nptl/pthread_attr_setdetachstate.c
	(__pthread_attr_setdetachstate): Likewise.
	* nptl/pthread_attr_setguardsize.c (pthread_attr_setguardsize):
	Likewise.
	* nptl/pthread_attr_setinheritsched.c
	(__pthread_attr_setinheritsched): Likewise.
	* nptl/pthread_attr_setschedparam.c
	(__pthread_attr_setschedparam): Likewise.
	* nptl/pthread_attr_setschedpolicy.c
	(__pthread_attr_setschedpolicy): Likewise.
	* nptl/pthread_attr_setscope.c (__pthread_attr_setscope):
	Likewise.
	* nptl/pthread_attr_setstack.c (__pthread_attr_setstack):
	Likewise.
	* nptl/pthread_attr_setstackaddr.c (__pthread_attr_setstackaddr):
	Likewise.
	* nptl/pthread_attr_setstacksize.c (__pthread_attr_setstacksize):
	Likewise.
	* nptl/pthread_condattr_setclock.c (pthread_condattr_setclock):
	Likewise.
	* nptl/pthread_create.c (__find_in_stack_list): Likewise.
	* nptl/pthread_getattr_np.c (pthread_getattr_np): Likewise.
	* nptl/pthread_mutex_cond_lock.c (__pthread_mutex_lock): Define to
	use internal_function.
	* nptl/pthread_mutex_init.c (__pthread_mutex_init): Convert to
	prototype-style function definition.
	* nptl/pthread_mutex_lock.c (__pthread_mutex_lock): Likewise.
	(__pthread_mutex_cond_lock_adjust): Likewise.  Use
	internal_function.
	* nptl/pthread_mutex_timedlock.c (pthread_mutex_timedlock):
	Convert to prototype-style function definition.
	* nptl/pthread_mutex_trylock.c (__pthread_mutex_trylock):
	Likewise.
	* nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock_usercnt):
	Likewise.
	(__pthread_mutex_unlock): Likewise.
	* nptl_db/td_ta_clear_event.c (td_ta_clear_event): Likewise.
	* nptl_db/td_ta_set_event.c (td_ta_set_event): Likewise.
	* nptl_db/td_thr_clear_event.c (td_thr_clear_event): Likewise.
	* nptl_db/td_thr_event_enable.c (td_thr_event_enable): Likewise.
	* nptl_db/td_thr_set_event.c (td_thr_set_event): Likewise.
	* nss/makedb.c (process_input): Likewise.
	* posix/fnmatch.c (__strchrnul): Likewise.
	(__wcschrnul): Likewise.
	(fnmatch): Likewise.
	* posix/fnmatch_loop.c (FCT): Likewise.
	* posix/glob.c (globfree): Likewise.
	(__glob_pattern_type): Likewise.
	(__glob_pattern_p): Likewise.
	* posix/regcomp.c (re_compile_pattern): Likewise.
	(re_set_syntax): Likewise.
	(re_compile_fastmap): Likewise.
	(regcomp): Likewise.
	(regerror): Likewise.
	(regfree): Likewise.
	* posix/regexec.c (regexec): Likewise.
	(re_match): Likewise.
	(re_search): Likewise.
	(re_match_2): Likewise.
	(re_search_2): Likewise.
	(re_search_stub): Likewise.  Use internal_function
	(re_copy_regs): Likewise.
	(re_set_registers): Convert to prototype-style function
	definition.
	(prune_impossible_nodes): Likewise.  Use internal_function.
	* resolv/inet_net_pton.c (inet_net_pton): Convert to
	prototype-style function definition.
	(inet_net_pton_ipv4): Likewise.
	* stdlib/strtod_l.c (____STRTOF_INTERNAL): Likewise.
	* sysdeps/pthread/aio_cancel.c (aio_cancel): Likewise.
	* sysdeps/pthread/aio_suspend.c (aio_suspend): Likewise.
	* sysdeps/pthread/timer_delete.c (timer_delete): Likewise.
	* sysdeps/unix/sysv/linux/dl-openat64.c (openat64): Likewise.
	Make variadic.
	* time/strptime_l.c (localtime_r): Convert to prototype-style
	function definition.
	* wcsmbs/mbsnrtowcs.c (__mbsnrtowcs): Likewise.
	* wcsmbs/mbsrtowcs_l.c (__mbsrtowcs_l): Likewise.
	* wcsmbs/wcsnrtombs.c (__wcsnrtombs): Likewise.
	* wcsmbs/wcsrtombs.c (__wcsrtombs): Likewise.
2015-10-20 11:54:09 +00:00
Torvald Riegel a2f0363f81 Add and use new glibc-internal futex API.
This adds new functions for futex operations, starting with wait,
abstimed_wait, reltimed_wait, wake.  They add documentation and error
checking according to the current draft of the Linux kernel futex manpage.

Waiting with absolute or relative timeouts is split into separate functions.
This allows for removing a few cases of code duplication in pthreads code,
which uses absolute timeouts; also, it allows us to put platform-specific
code to go from an absolute to a relative timeout into the platform-specific
futex abstractions..

Futex operations that can be canceled are also split out into separate
functions suffixed by "_cancelable".

There are separate versions for both Linux and NaCl; while they currently
differ only slightly, my expectation is that the separate versions of
lowlevellock-futex.h will eventually be merged into futex-internal.h
when we get to move the lll_ functions over to the new futex API.
2015-07-10 13:47:09 +02:00
Joseph Myers b168057aaa Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
Roland McGrath 439c43f6ea Fix NPTL build for !__ASSUME_SET_ROBUST_LIST case. 2014-12-12 14:00:37 -08:00
Roland McGrath 33cd1f74b8 NPTL: Fix pthread_create regression from default-sched.h refactoring. 2014-11-21 14:16:47 -08:00
Roland McGrath f214ff74f4 NPTL: Refactor scheduler setup in pthread_create. 2014-11-20 10:56:20 -08:00
Roland McGrath d960211ff5 NPTL: Don't (re)validate sched_priority in pthread_create. 2014-11-19 17:34:25 -08:00
Roland McGrath 32fed10f0f NPTL: Refactor createthread.c 2014-11-18 11:03:00 -08:00
Roland McGrath 327ae25707 NPTL: Conditionalize more uses of SIGCANCEL and SIGSETXID. 2014-10-17 13:40:46 -07:00
Roland McGrath c0c6bac945 Get rid of lll_robust_dead. 2014-07-10 11:21:54 -07:00
Roland McGrath e0db65176f Clean up __exit_thread. 2014-05-13 09:49:20 -07:00
Roland McGrath d7329d4b4d Fix two stray cases using #ifdef vs #if for TLS_TCB_AT_TP. 2014-03-14 10:46:38 -07:00
Ondřej Bílka a1ffb40e32 Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
Allan McRae d4697bc93d Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
Siddhesh Poyarekar 61dd6208fb New API to set default thread attributes
This patch introduces two new convenience functions to set the default
thread attributes used for creating threads.  This allows a programmer
to set the default thread attributes just once in a process and then
run pthread_create without additional attributes.
2013-06-15 12:24:15 +05:30
Ryan S. Arnold e054f49430 Add #include <stdint.h> for uint[32|64]_t usage (except installed headers). 2013-05-16 11:32:54 -05:00
Roland McGrath e57b0c6100 Avoid unconditional __call_tls_dtors calls in static linking. 2013-03-28 16:52:57 -07:00
Siddhesh Poyarekar e903a7138b Move __default_stacksize into __default_pthread_attr
Make __default_pthread_attr object to store default attribute values
for threads.
2013-03-19 14:34:13 +05:30
Siddhesh Poyarekar ba384f6ed9 C++11 thread_local destructors support
This feature is specifically for the C++ compiler to offload calling
thread_local object destructors on thread program exit, to glibc.
This is to overcome the possible complication of destructors of
thread_local objects getting called after the DSO in which they're
defined is unloaded by the dynamic linker.  The DSO is marked as
'unloadable' if it has a constructed thread_local object and marked as
'unloadable' again when all the constructed thread_local objects
defined in it are destroyed.
2013-02-18 19:08:21 +05:30
Joseph Myers 568035b787 Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
Roland McGrath 9043e2288e Name space hygeine for madvise. 2012-10-04 16:31:43 -07:00
Siddhesh Poyarekar adcdc775e1 Fix clone flag name in comment to CLONE_CHILD_CLEARTID. 2012-10-02 08:52:55 +05:30
Roland McGrath 5acf7263d5 Add systemtap static probe points in generic and x86_64 pthread code. 2012-05-25 13:41:03 -07:00
Roland McGrath 3a097cc7a1 Add --enable-systemtap configuration to define static probe points. 2012-05-25 13:40:20 -07:00
H.J. Lu c252ec1579 Check __PTHREAD_MUTEX_HAVE_PREV for mutex prev 2012-05-11 10:08:57 -07:00
Paul Eggert 59ba27a63a Replace FSF snail mail address with URLs. 2012-02-09 23:18:22 +00:00
Jeff Law e988dba98d BZ #5245: pthread_create returns EAGAIN for stack allocation failure, not ENOMEM. 2011-12-14 13:14:56 -08:00
Ulrich Drepper fd5bdc0924 Optimize access to isXYZ and toXYZ tables
The functions to get the pointers can now depend on the TLS variable
be initialized.
2011-10-15 16:27:08 -04:00
Ulrich Drepper 1d78f2996d Fix a few more problem with the recent setxid changes. 2010-03-09 20:21:12 -08:00
Andreas Schwab 058e9ba9fd Revert to original version of setxid race fix 2010-03-08 17:02:46 +01:00
Ulrich Drepper 66f1b8eeb2 Fix setxid race with thread creation 2010-03-05 11:23:28 -08:00
Ulrich Drepper b42a214c18 Hint to kernel that thread stack memory can be removed. 2009-08-24 16:23:47 -07:00
Roland McGrath e965d5147e * Makeconfig (%.v.i): Depend on Makeconfig.
Exclude % lines from initial #-comment removal.
2009-02-28 02:26:51 +00:00
Ulrich Drepper 6c30d38fdd [BZ #5436]
2008-04-09  Ulrich Drepper  <drepper@redhat.com>
	* stdlib/tst-makecontext.c: Change parameter to cf to negative
	value to check for correct sign extension.

	[BZ #5436]
	* sysdeps/unix/sysv/linux/x86_64/makecontext.c (__makecontext):
	Copy 64-bit parameter values even though this is not required in
	the standard.

	* sysdeps/unix/sysv/linux/x86_64/vfork.S (__vfork): Record return
	PC save.
2008-04-09 18:30:12 +00:00
Ulrich Drepper f8de5057b9 * nscd/servicescache.c: Include kernel-features.h.
* nscd/gai.c: Likewise.
	* sysdeps/unix/sysv/linux/statfs64.c: Likewise.
	* sysdeps/unix/sysv/linux/fstatfs64.c: Likewise.
	* sysdeps/unix/sysv/linux/fxstatat.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/mmap.S: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/mmap64.S: Likewise.
	* sysdeps/unix/sysv/linux/xstatconv.c: Likewise.
	* sysdeps/unix/sysv/linux/if_index.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/xstat.c: Likewise.
	* sysdeps/unix/sysv/linux/ifaddrs.c: Likewise.
2007-08-13 18:33:31 +00:00
Ulrich Drepper e51deae7f6 * sysdeps/unix/sysv/linux/powerpc/sem_post.c (__new_sem_post):
Use __asm __volatile (__lll_acq_instr ::: "memory") instead of
	atomic_full_barrier.

2007-07-31  Jakub Jelinek  <jakub@redhat.com>

	* allocatestack.c (stack_cache_lock): Change type to int.
	(get_cached_stack, allocate_stack, __deallocate_stack,
	__make_stacks_executable, __find_thread_by_id, __nptl_setxid,
	__pthread_init_static_tls, __wait_lookup_done): Add LLL_PRIVATE
	as second argument to lll_lock and lll_unlock macros on
	stack_cache_lock.
	* pthread_create.c (__find_in_stack_list): Likewise.
	(start_thread): Similarly with pd->lock.  Use lll_robust_dead
	macro instead of lll_robust_mutex_dead, pass LLL_SHARED to it
	as second argument.
	* descr.h (struct pthread): Change lock and setxid_futex field
	type to int.
	* old_pthread_cond_broadcast.c (__pthread_cond_broadcast_2_0): Use
	LLL_LOCK_INITIALIZER instead of LLL_MUTEX_LOCK_INITIALIZER.
	* old_pthread_cond_signal.c (__pthread_cond_signal_2_0): Likewise.
	* old_pthread_cond_timedwait.c (__pthread_cond_timedwait_2_0):
	Likewise.
	* old_pthread_cond_wait.c (__pthread_cond_wait_2_0): Likewise.
	* pthread_cond_init.c (__pthread_cond_init): Likewise.
	* pthreadP.h (__attr_list_lock): Change type to int.
	* pthread_attr_init.c (__attr_list_lock): Likewise.
	* pthread_barrier_destroy.c (pthread_barrier_destroy): Pass
	ibarrier->private ^ FUTEX_PRIVATE_FLAG as second argument to
	lll_{,un}lock.
	* pthread_barrier_wait.c (pthread_barrier_wait): Likewise and
	also for lll_futex_{wake,wait}.
	* pthread_barrier_init.c (pthread_barrier_init): Make iattr
	a pointer to const.
	* pthread_cond_broadcast.c (__pthread_cond_broadcast): Pass
	LLL_SHARED as second argument to lll_{,un}lock.
	* pthread_cond_destroy.c (__pthread_cond_destroy): Likewise.
	* pthread_cond_signal.c (__pthread_cond_singal): Likewise.
	* pthread_cond_timedwait.c (__pthread_cond_timedwait): Likewise.
	* pthread_cond_wait.c (__condvar_cleanup, __pthread_cond_wait):
	Likewise.
	* pthread_getattr_np.c (pthread_getattr_np): Add LLL_PRIVATE
	as second argument to lll_{,un}lock macros on pd->lock.
	* pthread_getschedparam.c (__pthread_getschedparam): Likewise.
	* pthread_setschedparam.c (__pthread_setschedparam): Likewise.
	* pthread_setschedprio.c (pthread_setschedprio): Likewise.
	* tpp.c (__pthread_tpp_change_priority, __pthread_current_priority):
	Likewise.
	* sysdeps/pthread/createthread.c (do_clone, create_thread):
	Likewise.
	* pthread_once.c (once_lock): Change type to int.
	(__pthread_once): Pass LLL_PRIVATE as second argument to
	lll_{,un}lock macros on once_lock.
	* pthread_rwlock_rdlock.c (__pthread_rwlock_rdlock): Use
	lll_{,un}lock macros instead of lll_mutex_{,un}lock, pass
	rwlock->__data.__shared as second argument to them and similarly
	for lll_futex_w*.
	* pthread_rwlock_timedrdlock.c (pthread_rwlock_timedrdlock):
	Likewise.
	* pthread_rwlock_timedwrlock.c (pthread_rwlock_timedwrlock):
	Likewise.
	* pthread_rwlock_tryrdlock.c (__pthread_rwlock_tryrdlock): Likewise.
	* pthread_rwlock_trywrlock.c (__pthread_rwlock_trywrlock): Likewise.
	* pthread_rwlock_unlock.c (__pthread_rwlock_unlock): Likewise.
	* pthread_rwlock_wrlock.c (__pthread_rwlock_wrlock): Likewise.
	* sem_close.c (sem_close): Pass LLL_PRIVATE as second argument
	to lll_{,un}lock macros on __sem_mappings_lock.
	* sem_open.c (check_add_mapping): Likewise.
	(__sem_mappings_lock): Change type to int.
	* semaphoreP.h (__sem_mappings_lock): Likewise.
	* pthread_mutex_lock.c (LLL_MUTEX_LOCK, LLL_MUTEX_TRYLOCK,
	LLL_ROBUST_MUTEX_LOCK): Use lll_{,try,robust_}lock macros
	instead of lll_*mutex_*, pass LLL_SHARED as last
	argument.
	(__pthread_mutex_lock): Use lll_unlock instead of lll_mutex_unlock,
	pass LLL_SHARED as last argument.
	* sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c (LLL_MUTEX_LOCK,
	LLL_MUTEX_TRYLOCK, LLL_ROBUST_MUTEX_LOCK): Use
	lll_{cond_,cond_try,robust_cond}lock macros instead of lll_*mutex_*,
	pass LLL_SHARED as last argument.
	* pthread_mutex_timedlock.c (pthread_mutex_timedlock): Use
	lll_{timed,try,robust_timed,un}lock instead of lll_*mutex*, pass
	LLL_SHARED as last argument.
	* pthread_mutex_trylock.c (__pthread_mutex_trylock): Similarly.
	* pthread_mutex_unlock.c (__pthread_mutex_unlock_usercnt):
	Similarly.
	* sysdeps/pthread/bits/libc-lock.h (__libc_lock_lock,
	__libc_lock_lock_recursive, __libc_lock_unlock,
	__libc_lock_unlock_recursive): Pass LLL_PRIVATE as second
	argument to lll_{,un}lock.
	* sysdeps/pthread/bits/stdio-lock.h (_IO_lock_lock,
	_IO_lock_unlock): Likewise.
	* sysdeps/unix/sysv/linux/fork.c (__libc_fork): Don't use
	compound literal.
	* sysdeps/unix/sysv/linux/unregister-atfork.c (__unregister_atfork):
	Pass LLL_PRIVATE as second argument to lll_{,un}lock macros on
	__fork_lock.
	* sysdeps/unix/sysv/linux/register-atfork.c (__register_atfork,
	free_mem): Likewise.
	(__fork_lock): Change type to int.
	* sysdeps/unix/sysv/linux/fork.h (__fork_lock): Likewise.
	* sysdeps/unix/sysv/linux/sem_post.c (__new_sem_post): Pass
	isem->private ^ FUTEX_PRIVATE_FLAG as second argument to
	lll_futex_wake.
	* sysdeps/unix/sysv/linux/sem_timedwait.c (sem_timedwait): Likewise.
	* sysdeps/unix/sysv/linux/sem_wait.c (__new_sem_wait): Likewise.
	* sysdeps/unix/sysv/linux/lowlevellock.c (__lll_lock_wait_private):
	New function.
	(__lll_lock_wait, __lll_timedlock_wait): Add private argument and
	pass it through to lll_futex_*wait, only compile in when
	IS_IN_libpthread.
	* sysdeps/unix/sysv/linux/lowlevelrobustlock.c
	(__lll_robust_lock_wait, __lll_robust_timedlock_wait): Add private
	argument and pass it through to lll_futex_*wait.
	* sysdeps/unix/sysv/linux/alpha/lowlevellock.h: Renamed all
	lll_mutex_* resp. lll_robust_mutex_* macros to lll_* resp.
	lll_robust_*.  Renamed all __lll_mutex_* resp. __lll_robust_mutex_*
	inline functions to __lll_* resp. __lll_robust_*.
	(LLL_MUTEX_LOCK_INITIALIZER): Remove.
	(lll_mutex_dead): Add private argument.
	(__lll_lock_wait_private): New prototype.
	(__lll_lock_wait, __lll_robust_lock_wait, __lll_lock_timedwait,
	__lll_robust_lock_timedwait): Add private argument to prototypes.
	(__lll_lock): Add private argument, if it is constant LLL_PRIVATE,
	call __lll_lock_wait_private, otherwise pass private to
	__lll_lock_wait.
	(__lll_robust_lock, __lll_cond_lock, __lll_timedlock,
	__lll_robust_timedlock): Add private argument, pass it to
	__lll_*wait functions.
	(__lll_unlock): Add private argument, if it is constant LLL_PRIVATE,
	call __lll_unlock_wake_private, otherwise pass private to
	__lll_unlock_wake.
	(__lll_robust_unlock): Add private argument, pass it to
	__lll_robust_unlock_wake.
	(lll_lock, lll_robust_lock, lll_cond_lock, lll_timedlock,
	lll_robust_timedlock, lll_unlock, lll_robust_unlock): Add private
	argument, pass it through to __lll_* inline function.
	(__lll_mutex_unlock_force, lll_mutex_unlock_force): Remove.
	(lll_lock_t): Remove.
	(__lll_cond_wait, __lll_cond_timedwait, __lll_cond_wake,
	__lll_cond_broadcast, lll_cond_wait, lll_cond_timedwait,
	lll_cond_wake, lll_cond_broadcast): Remove.
	* sysdeps/unix/sysv/linux/ia64/lowlevellock.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/lowlevellock.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/lowlevellock.h: Likewise.
	* sysdeps/unix/sysv/linux/i386/lowlevellock.h: Allow including
	the header from assembler.  Renamed all lll_mutex_* resp.
	lll_robust_mutex_* macros to lll_* resp. lll_robust_*.
	(LOCK, FUTEX_CMP_REQUEUE, FUTEX_WAKE_OP,
	FUTEX_OP_CLEAR_WAKE_IF_GT_ONE): Define.
	(LLL_MUTEX_LOCK_INITIALIZER, LLL_MUTEX_LOCK_INITIALIZER_LOCKED,
	LLL_MUTEX_LOCK_INITIALIZER_WAITERS): Remove.
	(__lll_mutex_lock_wait, __lll_mutex_timedlock_wait,
	__lll_mutex_unlock_wake, __lll_lock_wait, __lll_unlock_wake):
	Remove prototype.
	(__lll_trylock_asm, __lll_lock_asm_start, __lll_unlock_asm): Define.
	(lll_robust_trylock, lll_cond_trylock): Use LLL_LOCK_INITIALIZER*
	rather than LLL_MUTEX_LOCK_INITIALIZER* macros.
	(lll_trylock): Likewise, use __lll_trylock_asm, pass
	MULTIPLE_THREADS_OFFSET as another asm operand.
	(lll_lock): Add private argument, use __lll_lock_asm_start, pass
	MULTIPLE_THREADS_OFFSET as last asm operand, call
	__lll_lock_wait_private if private is constant LLL_PRIVATE,
	otherwise pass private as another argument to __lll_lock_wait.
	(lll_robust_lock, lll_cond_lock, lll_robust_cond_lock,
	lll_timedlock, lll_robust_timedlock): Add private argument, pass
	private as another argument to __lll_*lock_wait call.
	(lll_unlock): Add private argument, use __lll_unlock_asm, pass
	MULTIPLE_THREADS_OFFSET as another asm operand, call
	__lll_unlock_wake_private if private is constant LLL_PRIVATE,
	otherwise pass private as another argument to __lll_unlock_wake.
	(lll_robust_unlock): Add private argument, pass private as another
	argument to __lll_unlock_wake.
	(lll_robust_dead): Add private argument, use __lll_private_flag
	macro.
	(lll_islocked): Use LLL_LOCK_INITIALIZER instead of
	LLL_MUTEX_LOCK_INITIALIZER.
	(lll_lock_t): Remove.
	(LLL_LOCK_INITIALIZER_WAITERS): Define.
	(__lll_cond_wait, __lll_cond_timedwait, __lll_cond_wake,
	__lll_cond_broadcast, lll_cond_wait, lll_cond_timedwait,
	lll_cond_wake, lll_cond_broadcast): Remove.
	* sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Likewise.
	* sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S: Revert
	2007-05-2{3,9} changes.
	* sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S: Include
	kernel-features.h and lowlevellock.h.
	(LOAD_PRIVATE_FUTEX_WAIT): Define.
	(LOAD_FUTEX_WAIT): Rewritten.
	(LOCK, SYS_gettimeofday, SYS_futex, FUTEX_WAIT, FUTEX_WAKE): Don't
	define.
	(__lll_lock_wait_private, __lll_unlock_wake_private): New functions.
	(__lll_mutex_lock_wait): Rename to ...
	(__lll_lock_wait): ... this.  Take futex addr from %edx instead of
	%ecx, %ecx is now private argument.  Don't compile in for libc.so.
	(__lll_mutex_timedlock_wait): Rename to ...
	(__lll_timedlock_wait): ... this.  Use __NR_gettimeofday.  %esi
	contains private argument.  Don't compile in for libc.so.
	(__lll_mutex_unlock_wake): Rename to ...
	(__lll_unlock_wake): ... this.  %ecx contains private argument.
	Don't compile in for libc.so.
	(__lll_timedwait_tid): Use __NR_gettimeofday.
	* sysdeps/unix/sysv/linux/i386/i486/lowlevelrobustlock.S: Include
	kernel-features.h and lowlevellock.h.
	(LOAD_FUTEX_WAIT): Define.
	(LOCK, SYS_gettimeofday, SYS_futex, FUTEX_WAIT, FUTEX_WAKE): Don't
	define.
	(__lll_robust_mutex_lock_wait): Rename to ...
	(__lll_robust_lock_wait): ... this.  Futex addr is now in %edx
	argument, %ecx argument contains private.  Use LOAD_FUTEX_WAIT
	macro.
	(__lll_robust_mutex_timedlock_wait): Rename to ...
	(__lll_robust_timedlock_wait): ... this.  Use __NR_gettimeofday.
	%esi argument contains private, use LOAD_FUTEX_WAIT macro.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S: Include
	lowlevellock.h.
	(SYS_futex, FUTEX_WAIT, FUTEX_WAKE, LOCK): Don't define.
	(pthread_barrier_wait): Rename __lll_mutex_* to __lll_*, pass
	PRIVATE(%ebx) ^ LLL_SHARED as private argument in %ecx to
	__lll_lock_wait and __lll_unlock_wake, pass MUTEX(%ebx) address
	to __lll_lock_wait in %edx.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S:
	Include lowlevellock.h and pthread-errnos.h.
	(SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_REQUEUE,
	FUTEX_CMP_REQUEUE, EINVAL, LOCK): Don't define.
	(__pthread_cond_broadcast): Rename __lll_mutex_* to __lll_*, pass
	cond_lock address in %edx rather than %ecx to __lll_lock_wait,
	pass LLL_SHARED in %ecx to both __lll_lock_wait and
	__lll_unlock_wake.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S:
	Include lowlevellock.h and pthread-errnos.h.
	(SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_WAKE_OP,
	FUTEX_OP_CLEAR_WAKE_IF_GT_ONE, EINVAL, LOCK): Don't define.
	(__pthread_cond_signal): Rename __lll_mutex_* to __lll_*, pass
	cond_lock address in %edx rather than %ecx to __lll_lock_wait,
	pass LLL_SHARED in %ecx to both __lll_lock_wait and
	__lll_unlock_wake.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S:
	Include lowlevellock.h.
	(SYS_futex, SYS_gettimeofday, FUTEX_WAIT, FUTEX_WAKE, LOCK):
	Don't define.
	(__pthread_cond_timedwait): Rename __lll_mutex_* to __lll_*, pass
	cond_lock address in %edx rather than %ecx to __lll_lock_wait,
	pass LLL_SHARED in %ecx to both __lll_lock_wait and
	__lll_unlock_wake.  Use __NR_gettimeofday.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S:
	Include lowlevellock.h.
	(SYS_futex, FUTEX_WAIT, FUTEX_WAKE, LOCK): Don't define.
	(__pthread_cond_wait, __condvar_w_cleanup): Rename __lll_mutex_*
	to __lll_*, pass cond_lock address in %edx rather than %ecx to
	__lll_lock_wait, pass LLL_SHARED in %ecx to both __lll_lock_wait
	and __lll_unlock_wake.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S:
	Include lowlevellock.h.
	(SYS_futex, FUTEX_WAIT, FUTEX_WAKE, LOCK): Don't define.
	(__pthread_rwlock_rdlock): Rename __lll_mutex_* to __lll_*, pass
	MUTEX(%ebx) address in %edx rather than %ecx to
	__lll_lock_wait, pass PSHARED(%ebx) in %ecx to both __lll_lock_wait
	and __lll_unlock_wake.  Move return value from %ecx to %edx
	register.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S:
	Include lowlevellock.h.
	(SYS_futex, SYS_gettimeofday, FUTEX_WAIT, FUTEX_WAKE, LOCK):
	Don't define.
	(__pthread_rwlock_wrlock): Rename __lll_mutex_* to __lll_*, pass
	MUTEX(%ebp) address in %edx rather than %ecx to
	__lll_lock_wait, pass PSHARED(%ebp) in %ecx to both __lll_lock_wait
	and __lll_unlock_wake.  Move return value from %ecx to %edx
	register.  Use __NR_gettimeofday.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S:
	Include lowlevellock.h.
	(SYS_futex, SYS_gettimeofday, FUTEX_WAIT, FUTEX_WAKE, LOCK):
	Don't define.
	(__pthread_rwlock_wrlock): Rename __lll_mutex_* to __lll_*, pass
	MUTEX(%ebp) address in %edx rather than %ecx to
	__lll_lock_wait, pass PSHARED(%ebp) in %ecx to both __lll_lock_wait
	and __lll_unlock_wake.  Move return value from %ecx to %edx
	register.  Use __NR_gettimeofday.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_unlock.S:
	Include lowlevellock.h.
	(SYS_futex, FUTEX_WAIT, FUTEX_WAKE, LOCK): Don't define.
	(__pthread_rwlock_unlock): Rename __lll_mutex_* to __lll_*, pass
	MUTEX(%edi) address in %edx rather than %ecx to
	__lll_lock_wait, pass PSHARED(%edi) in %ecx to both __lll_lock_wait
	and __lll_unlock_wake.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S:
	Include lowlevellock.h.
	(SYS_futex, FUTEX_WAIT, FUTEX_WAKE, LOCK): Don't define.
	(__pthread_rwlock_wrlock): Rename __lll_mutex_* to __lll_*, pass
	MUTEX(%ebx) address in %edx rather than %ecx to
	__lll_lock_wait, pass PSHARED(%ebx) in %ecx to both __lll_lock_wait
	and __lll_unlock_wake.  Move return value from %ecx to %edx
	register.
	* sysdeps/unix/sysv/linux/i386/pthread_once.S: Include
	lowlevellock.h.
	(LOCK, SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_PRIVATE_FLAG): Don't
	define.
	* sysdeps/unix/sysv/linux/i386/i486/sem_post.S: Include lowlevellock.h.
	(LOCK, SYS_futex, FUTEX_WAKE): Don't define.
	* sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S: Include
	lowlevellock.h.
	(LOCK, SYS_futex, SYS_gettimeofday, FUTEX_WAIT): Don't define.
	(sem_timedwait): Use __NR_gettimeofday.
	* sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S: Include
	lowlevellock.h.
	(LOCK): Don't define.
	* sysdeps/unix/sysv/linux/i386/i486/sem_wait.S: Include
	lowlevellock.h.
	(LOCK, SYS_futex, FUTEX_WAIT): Don't define.
	* sysdeps/unix/sysv/linux/powerpc/sem_post.c: Wake only when there
	are waiters.
	* sysdeps/unix/sysv/linux/x86_64/libc-lowlevellock.S: Revert
	2007-05-2{3,9} changes.
	* sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: Include
	kernel-features.h and lowlevellock.h.
	(LOAD_PRIVATE_FUTEX_WAIT): Define.
	(LOAD_FUTEX_WAIT): Rewritten.
	(LOCK, SYS_futex, FUTEX_WAIT, FUTEX_WAKE): Don't define.
	(__lll_lock_wait_private, __lll_unlock_wake_private): New functions.
	(__lll_mutex_lock_wait): Rename to ...
	(__lll_lock_wait): ... this.  %esi is now private argument.
	Don't compile in for libc.so.
	(__lll_mutex_timedlock_wait): Rename to ...
	(__lll_timedlock_wait): ... this.  %esi contains private argument.
	Don't compile in for libc.so.
	(__lll_mutex_unlock_wake): Rename to ...
	(__lll_unlock_wake): ... this.  %esi contains private argument.
	Don't compile in for libc.so.
	* sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S: Include
	kernel-features.h and lowlevellock.h.
	(LOAD_FUTEX_WAIT): Define.
	(LOCK, SYS_futex, FUTEX_WAIT, FUTEX_WAKE): Don't define.
	(__lll_robust_mutex_lock_wait): Rename to ...
	(__lll_robust_lock_wait): ... this.  %esi argument contains private.
	Use LOAD_FUTEX_WAIT macro.
	(__lll_robust_mutex_timedlock_wait): Rename to ...
	(__lll_robust_timedlock_wait): ... this. %esi argument contains
	private, use LOAD_FUTEX_WAIT macro.
	* sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S: Include
	lowlevellock.h.
	(SYS_futex, FUTEX_WAIT, FUTEX_WAKE, LOCK): Don't define.
	(pthread_barrier_wait): Rename __lll_mutex_* to __lll_*, pass
	PRIVATE(%rdi) ^ LLL_SHARED as private argument in %esi to
	__lll_lock_wait and __lll_unlock_wake.
	* sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S:
	Include lowlevellock.h and pthread-errnos.h.
	(SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_REQUEUE,
	FUTEX_CMP_REQUEUE, EINVAL, LOCK): Don't define.
	(__pthread_cond_broadcast): Rename __lll_mutex_* to __lll_*,
	pass LLL_SHARED in %esi to both __lll_lock_wait and
	__lll_unlock_wake.
	* sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S:
	Include lowlevellock.h and pthread-errnos.h.
	(SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_WAKE_OP,
	FUTEX_OP_CLEAR_WAKE_IF_GT_ONE, EINVAL, LOCK): Don't define.
	(__pthread_cond_signal): Rename __lll_mutex_* to __lll_*,
	pass LLL_SHARED in %esi to both __lll_lock_wait and
	__lll_unlock_wake.
	* sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:
	Include lowlevellock.h.
	(SYS_futex, FUTEX_WAIT, FUTEX_WAKE, LOCK): Don't define.
	(__pthread_cond_timedwait): Rename __lll_mutex_* to __lll_*,
	pass LLL_SHARED in %esi to both __lll_lock_wait and
	__lll_unlock_wake.
	* sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:
	Include lowlevellock.h.
	(SYS_futex, FUTEX_WAIT, FUTEX_WAKE, LOCK): Don't define.
	(__pthread_cond_wait, __condvar_cleanup): Rename __lll_mutex_*
	to __lll_*, pass LLL_SHARED in %esi to both __lll_lock_wait
	and __lll_unlock_wake.
	* sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S:
	Include lowlevellock.h.
	(SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_PRIVATE_FLAG, LOCK):
	Don't define.
	(__pthread_rwlock_rdlock): Rename __lll_mutex_* to __lll_*,
	pass PSHARED(%rdi) in %esi to both __lll_lock_wait
	and __lll_unlock_wake.
	* sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S:
	Include lowlevellock.h.
	(SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_PRIVATE_FLAG, LOCK):
	Don't define.
	(__pthread_rwlock_wrlock): Rename __lll_mutex_* to __lll_*,
	pass PSHARED(%rdi) in %esi to both __lll_lock_wait
	and __lll_unlock_wake.
	* sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S:
	Include lowlevellock.h.
	(SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_PRIVATE_FLAG, LOCK):
	Don't define.
	(__pthread_rwlock_wrlock): Rename __lll_mutex_* to __lll_*,
	pass PSHARED(%rdi) in %esi to both __lll_lock_wait
	and __lll_unlock_wake.
	* sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S:
	Include lowlevellock.h.
	(SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_PRIVATE_FLAG, LOCK):
	Don't define.
	(__pthread_rwlock_unlock): Rename __lll_mutex_* to __lll_*,
	pass PSHARED(%rdi) in %esi to both __lll_lock_wait
	and __lll_unlock_wake.
	* sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S:
	Include lowlevellock.h.
	(SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_PRIVATE_FLAG, LOCK):
	Don't define.
	(__pthread_rwlock_wrlock): Rename __lll_mutex_* to __lll_*,
	pass PSHARED(%rdi) in %ecx to both __lll_lock_wait
	and __lll_unlock_wake.
	* sysdeps/unix/sysv/linux/x86_64/pthread_once.S: Include
	lowlevellock.h.
	(LOCK, SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_PRIVATE_FLAG): Don't
	define.
	* sysdeps/unix/sysv/linux/x86_64/sem_post.S: Include lowlevellock.h.
	(LOCK, SYS_futex, FUTEX_WAKE): Don't define.
	* sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S: Include
	lowlevellock.h.
	(LOCK, SYS_futex, FUTEX_WAIT): Don't define.
	* sysdeps/unix/sysv/linux/x86_64/sem_trywait.S: Include
	lowlevellock.h.
	(LOCK): Don't define.
	* sysdeps/unix/sysv/linux/x86_64/sem_wait.S: Include
	lowlevellock.h.
	(LOCK, SYS_futex, FUTEX_WAIT): Don't define.
	* sysdeps/unix/sysv/linux/sparc/internaltypes.h: New file.
	* sysdeps/unix/sysv/linux/sparc/pthread_barrier_destroy.c: New file.
	* sysdeps/unix/sysv/linux/sparc/pthread_barrier_init.c: New file.
	* sysdeps/unix/sysv/linux/sparc/pthread_barrier_wait.c: New file.
	* sysdeps/unix/sysv/linux/sparc/sparc32/lowlevellock.c
	(__lll_lock_wait_private): New function.
	(__lll_lock_wait, __lll_timedlock_wait): Add private argument, pass
	it to lll_futex_*wait.  Don't compile in for libc.so.
	* sysdeps/unix/sysv/linux/sparc/sparc32/pthread_barrier_init.c:
	Remove.
	* sysdeps/unix/sysv/linux/sparc/sparc32/pthread_barrier_wait.c
	(struct sparc_pthread_barrier): Remove.
	(pthread_barrier_wait): Use union sparc_pthread_barrier instead of
	struct sparc_pthread_barrier.  Pass
	ibarrier->s.pshared ? LLL_SHARED : LLL_PRIVATE to lll_{,un}lock
	and lll_futex_wait macros.
	* sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_init.c:
	Remove.
	* sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_wait.c:
	Include sparc pthread_barrier_wait.c instead of generic one.
2007-08-01 04:47:26 +00:00