Commit Graph

22356 Commits

Author SHA1 Message Date
Samuel Thibault fa97d2ab5b hurd: Fix accessing errno from rtld
Letting rtld access errno through TLS can not work at early stages since
TLS will not be initialized yet.  When a private errno is not possible,
we thus have no other way than going through __errno_location.

	* include/errno.h [IS_IN(rtld) && !RTLD_PRIVATE_ERRNO]: Do not use the
	TLS declaration of errno.
2018-03-25 00:48:01 +01:00
H.J. Lu b8114edd3c Add $(tests-execstack-$(have-z-execstack)) after defined [BZ #22998]
When $(tests-execstack-$(have-z-execstack)) is added to tests before
it is defined, it is empty.  This patch adds it to tests after it is
defined.

	[BZ #22998]
	* elf/Makefile (tests): Add $(tests-execstack-$(have-z-execstack))
	after it is defined.
2018-03-24 08:25:55 -07:00
Andrew Senkevich cd66c0e584 Fix i386 memmove issue (bug 22644).
[BZ #22644]
	* sysdeps/i386/i686/multiarch/memcpy-sse2-unaligned.S: Fixed
	branch conditions.
	* string/test-memmove.c (do_test2): New testcase.
2018-03-23 16:19:45 +01:00
Joseph Myers a44061398c Remove unused frame.h header, sigcontextinfo.h macros.
The glibc-internal header frame.h was used in the old
debug/backtrace.c but is now unused.  Similarly, there are some
sigcontextinfo.h macros that are used nowhere in glibc -
ADVANCE_STACK_FRAME and FIRST_FRAME_POINTER were used in the old
debug/backtrace.c, while SIGCONTEXT_EXTRA_ARGS, GET_FRAME, GET_STACK
and CALL_SIGHANDLER were unused even before the removal of that old
implementation (beyond uses of SIGCONTEXT_EXTRA_ARGS in definitions of
CALL_SIGHANDLER).  This patch removes all the unused frame.h headers
and definitions of those macros.

Tested with build-many-glibcs.py.

	* sysdeps/generic/frame.h: Remove file.
	* sysdeps/arm/frame.h: Likewise.
	* sysdeps/hppa/frame.h: Likewise.
	* sysdeps/generic/sigcontextinfo.h (SIGCONTEXT_EXTRA_ARGS): Remove
	macro.
	(GET_FRAME): Likewise.
	(GET_STACK): Likewise.
	(CALL_SIGHANDLER): Likewise.
	* sysdeps/mach/hurd/i386/sigcontextinfo.h (SIGCONTEXT_EXTRA_ARGS):
	Likewise.
	(GET_FRAME): Likewise.
	(GET_STACK): Likewise.
	(CALL_SIGHANDLER): Likewise.
	* sysdeps/unix/sysv/linux/alpha/sigcontextinfo.h
	(SIGCONTEXT_EXTRA_ARGS): Likewise.
	(GET_FRAME): Likewise.
	(GET_STACK): Likewise.
	(CALL_SIGHANDLER): Likewise.
	* sysdeps/unix/sysv/linux/arm/sigcontextinfo.h
	(SIGCONTEXT_EXTRA_ARGS): Likewise.
	(GET_FRAME): Likewise.
	(GET_STACK): Likewise.
	(ADVANCE_STACK_FRAME): Likewise.
	(CALL_SIGHANDLER): Likewise.
	* sysdeps/unix/sysv/linux/i386/sigcontextinfo.h
	(SIGCONTEXT_EXTRA_ARGS): Likewise.
	(GET_FRAME): Likewise.
	(GET_STACK): Likewise.
	(CALL_SIGHANDLER): Likewise.
	* sysdeps/unix/sysv/linux/ia64/sigcontextinfo.h
	(SIGCONTEXT_EXTRA_ARGS): Likewise.
	(GET_FRAME): Likewise.
	(GET_STACK): Likewise.
	(CALL_SIGHANDLER): Likewise.
	* sysdeps/unix/sysv/linux/m68k/sigcontextinfo.h
	(SIGCONTEXT_EXTRA_ARGS): Likewise.
	(GET_FRAME): Likewise.
	(GET_STACK): Likewise.
	(CALL_SIGHANDLER): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/sigcontextinfo.h
	(SIGCONTEXT_EXTRA_ARGS): Likewise.
	(GET_FRAME): Likewise.
	(GET_STACK): Likewise.
	(CALL_SIGHANDLER): Likewise.
	* sysdeps/unix/sysv/linux/mips/sigcontextinfo.h
	(SIGCONTEXT_EXTRA_ARGS): Likewise.
	(GET_FRAME): Likewise.
	(GET_STACK): Likewise.
	(CALL_SIGHANDLER): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sigcontextinfo.h
	(SIGCONTEXT_EXTRA_ARGS): Likewise.
	(GET_FRAME): Likewise.
	(GET_STACK): Likewise.
	(CALL_SIGHANDLER): Likewise.
	* sysdeps/unix/sysv/linux/riscv/sigcontextinfo.h
	(SIGCONTEXT_EXTRA_ARGS): Likewise.
	(GET_FRAME): Likewise.
	(GET_STACK): Likewise.
	(CALL_SIGHANDLER): Likewise.
	* sysdeps/unix/sysv/linux/s390/sigcontextinfo.h
	(SIGCONTEXT_EXTRA_ARGS): Likewise.
	(GET_FRAME): Likewise.
	(GET_STACK): Likewise.
	(CALL_SIGHANDLER): Likewise.
	* sysdeps/unix/sysv/linux/sh/sigcontextinfo.h
	(SIGCONTEXT_EXTRA_ARGS): Likewise.
	(GET_FRAME): Likewise.
	(GET_STACK): Likewise.
	(CALL_SIGHANDLER): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/sigcontextinfo.h
	(SIGCONTEXT_EXTRA_ARGS): Likewise.
	(FIRST_FRAME_POINTER): Likewise.
	(ADVANCE_STACK_FRAME): Likewise.
	(GET_STACK): Likewise.
	(GET_FRAME): Likewise.
	(CALL_SIGHANDLER): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/sigcontextinfo.h
	(SIGCONTEXT_EXTRA_ARGS): Likewise.
	(ADVANCE_STACK_FRAME): Likewise.
	(GET_STACK): Likewise.
	(GET_FRAME): Likewise.
	(CALL_SIGHANDLER): Likewise.
	* sysdeps/unix/sysv/linux/tile/sigcontextinfo.h
	(SIGCONTEXT_EXTRA_ARGS): Likewise.
	(GET_FRAME): Likewise.
	(GET_STACK): Likewise.
	(CALL_SIGHANDLER): Likewise.
	* sysdeps/unix/sysv/linux/x86_64/sigcontextinfo.h
	(SIGCONTEXT_EXTRA_ARGS): Likewise.
	(GET_FRAME): Likewise.
	(GET_STACK): Likewise.
	(CALL_SIGHANDLER): Likewise.
2018-03-22 16:40:51 +00:00
Joseph Myers ffec7b2740 Use x86_64 backtrace as generic version.
No glibc configuration uses the present debug/backtrace.c, whereas
several #include the x86_64 version.  The x86_64 version is
effectively a generic one (using _Unwind_Backtrace from libgcc, which
works much more reliably than the built-in functions used by
debug/backtrace.c).  This patch moves it to debug/backtrace.c and
removes all the #includes of the x86_64 version from other
architectures which are no longer required.

I do not know whether all the other architecture-specific backtrace
implementations that are based on _Unwind_Backtrace are required, or
whether, where their differences from the generic version do something
useful, suitable hooks could be added to the generic version to reduce
the duplication involved.

Tested with build-many-glibcs.py that installed stripped shared
libraries are unchanged by this patch.

	* sysdeps/x86_64/backtrace.c: Move to ....
	* debug/backtrace.c: ... here.
	* sysdeps/aarch64/backtrace.c: Remove file.
	* sysdeps/alpha/backtrace.c: Likewise.
	* sysdeps/hppa/backtrace.c: Likewise.
	* sysdeps/ia64/backtrace.c: Likewise.
	* sysdeps/mips/backtrace.c: Likewise.
	* sysdeps/nios2/backtrace.c: Likewise.
	* sysdeps/riscv/backtrace.c: Likewise.
	* sysdeps/sh/backtrace.c: Likewise.
	* sysdeps/tile/backtrace.c: Likewise.
2018-03-21 17:25:30 +00:00
Joseph Myers d0c5d731af Remove powerpc, sparc fdim inlines (bug 22987).
The powerpc and sparc bits/mathinline.h include inlines of fdim and
fdimf.  These are not restricted to -fno-math-errno, but do not set
errno, and wrongly use ordered <= comparisons instead of the required
islessequal comparisons (this latter issue is latent on powerpc
because GCC wrongly uses unordered comparison instructions for
operations that should use ordered comparison instructions).

Since we wish to avoid such header inlines anyway, leaving it to the
compiler to inline such standard functions under appropriate
conditions, this patch fixes those issues by removing the inlines in
question (and thus removing the sparc bits/mathinline.h header which
had no other inlines left in it).  I've filed
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85003> for adding
correct fdim inlines to GCC, since the function is simple enough that
a correct inline is a perfectly reasonable architecture-independent
optimization with -fno-math-errno and in the absence of implicit
excess precision.

Tested with build-many-glibcs.py for all its powerpc and sparc
configurations.

	[BZ #22987]
	* sysdeps/powerpc/bits/mathinline.h (fdim): Remove inline
	function.
	(fdimf): Likewise.
	* sysdeps/sparc/fpu/bits/mathinline.h: Remove file.
2018-03-20 18:35:50 +00:00
Joseph Myers 8a07b0c43c Fix signed integer overflow in random_r (bug 17343).
Bug 17343 reports that stdlib/random_r.c has code with undefined
behavior because of signed integer overflow on int32_t.  This patch
changes the code so that the possibly overflowing computations use
unsigned arithmetic instead.

Note that the bug report refers to "Most code" in that file.  The
places changed in this patch are the only ones I found where I think
such overflow can occur.

Tested for x86_64 and x86.

	[BZ #17343]
	* stdlib/random_r.c (__random_r): Use unsigned arithmetic for
	possibly overflowing computations.
2018-03-20 18:25:24 +00:00
Samuel Thibault ceb54b9b4f Fix errno values
* manual/errno.texi (EOWNERDEAD, ENOTRECOVERABLE): Remove errno
	values from Linux-specific section now that it is in the GNU section.
	* sysdeps/gnu/errlist.c: Regenerate.
2018-03-20 03:10:57 +01:00
Joseph Myers 8d3f9e85cf Add narrowing subtract functions.
This patch adds the narrowing subtract functions from TS 18661-1 to
glibc's libm: fsub, fsubl, dsubl, f32subf64, f32subf32x, f32xsubf64
for all configurations; f32subf64x, f32subf128, f64subf64x,
f64subf128, f32xsubf64x, f32xsubf128, f64xsubf128 for configurations
with _Float64x and _Float128; __nldbl_dsubl for ldbl-opt.

The changes are essentially the same as for the narrowing add
functions, so the description of those generally applies to this patch
as well.

Tested for x86_64, x86, mips64 (all three ABIs, both hard and soft
float) and powerpc, and with build-many-glibcs.py.

	* math/Makefile (libm-narrow-fns): Add sub.
	(libm-test-funcs-narrow): Likewise.
	* math/Versions (GLIBC_2.28): Add narrowing subtract functions.
	* math/bits/mathcalls-narrow.h (sub): Use __MATHCALL_NARROW.
	* math/gen-auto-libm-tests.c (test_functions): Add sub.
	* math/math-narrow.h (CHECK_NARROW_SUB): New macro.
	(NARROW_SUB_ROUND_TO_ODD): Likewise.
	(NARROW_SUB_TRIVIAL): Likewise.
	* sysdeps/ieee754/float128/float128_private.h (__fsubl): New
	macro.
	(__dsubl): Likewise.
	* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add fsub and
	dsub.
	(CFLAGS-nldbl-dsub.c): New variable.
	(CFLAGS-nldbl-fsub.c): Likewise.
	* sysdeps/ieee754/ldbl-opt/Versions (GLIBC_2.28): Add
	__nldbl_dsubl.
	* sysdeps/ieee754/ldbl-opt/nldbl-compat.h (__nldbl_dsubl): New
	prototype.
	* manual/arith.texi (Misc FP Arithmetic): Document fsub, fsubl,
	dsubl, fMsubfN, fMsubfNx, fMxsubfN and fMxsubfNx.
	* math/auto-libm-test-in: Add tests of sub.
	* math/auto-libm-test-out-narrow-sub: New generated file.
	* math/libm-test-narrow-sub.inc: New file.
	* sysdeps/i386/fpu/s_f32xsubf64.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_f32xsubf64.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_fsub.c: Likewise.
	* sysdeps/ieee754/float128/s_f32subf128.c: Likewise.
	* sysdeps/ieee754/float128/s_f64subf128.c: Likewise.
	* sysdeps/ieee754/float128/s_f64xsubf128.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_dsubl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_f64xsubf128.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_fsubl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_dsubl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_fsubl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_dsubl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_fsubl.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/nldbl-dsub.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/nldbl-fsub.c: Likewise.
	* sysdeps/ieee754/soft-fp/s_dsubl.c: Likewise.
	* sysdeps/ieee754/soft-fp/s_fsub.c: Likewise.
	* sysdeps/ieee754/soft-fp/s_fsubl.c: Likewise.
	* sysdeps/powerpc/fpu/libm-test-ulps: Update.
	* sysdeps/mach/hurd/i386/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/riscv/rv64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
2018-03-20 00:34:52 +00:00
Joseph Myers d473f01520 Add SHT_X86_64_UNWIND to elf.h (bug 20079).
As requested in bug 20079, this patch adds SHT_X86_64_UNWIND (a
standard value from the x86_64 ABI) to elf.h.

Tested for x86_64.

	[BZ #20079]
	* elf/elf.h (SHT_X86_64_UNWIND): New macro.
2018-03-19 18:08:48 +00:00
Wilco Dijkstra fbce6f7260 Undefine attribute_hidden to fix benchtests
Add an undefine of attribute_hidden since it may be defined in some cases
(it must be defined since it is used by some hp-timing configurations).

	* benchtests/bench-timing.h (attribute_hidden): Undefine.
2018-03-19 10:53:14 +00:00
Richard Braun 72e7ffc37f Hurd: fix port leak in TLS
* sysdeps/mach/hurd/i386/tls.h (_hurd_tls_init): Use a temporary
	thread reference.
2018-03-18 20:43:59 +01:00
Samuel Thibault 20bc801b3d hurd: Add mlockall support
* sysdeps/mach/hurd/mlockall.c: New file.
	* sysdeps/mach/hurd/munlockall.c: New file.
2018-03-18 20:38:48 +01:00
Samuel Thibault aa2189295e hurd: Fix boot with statically-linked exec server
* sysdeps/mach/hurd/i386/init-first.c (init): Also find ELF headers by
	oneself when the pointer given in D is nul (as set by ext2fs).
2018-03-18 20:38:26 +01:00
Samuel Thibault 72103e73c9 hurd: Fix O_DIRECTORY | O_NOFOLLOW
Appending / to the path to be looked up would make us always follow a final
symlink, even with O_NOTRANS (since the final resolution is after the
'/').  In the O_DIRECTORY | O_NOFOLLOW case, we thus have to really open
the node and stat it, which we already do anyway, and check for
directory type.

	* hurd/hurdlookup.c (__hurd_file_name_lookup): Do not append '/' to
	path when flags contains O_NOFOLLOW.
	* hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Return ENOTDIR
	if flags contains O_DIRECTORY and the result is a directory.
2018-03-18 19:43:04 +01:00
Samuel Thibault 489999cc9c hurd: Fix O_NOFOLLOW
The error code documented by POSIX for opening a symlink with O_NOFOLLOW
is ELOOP.

Also, if the translator does not expose symlink as a symlink translator but
as a S_IFLNK file, O_NOFOLLOW needs to return ELOOP too.

	* hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Return ELOOP
	when opening a symlink with O_NOFOLLOW.
2018-03-18 19:42:17 +01:00
Agustina Arzille fb4cc8a0c2 hurd: Reimplement libc locks using mach's gsync
* hurd/Makefile (routines): Add hurdlock.
	* hurd/Versions (GLIBC_PRIVATE): Added new entry to export the above
	interface.
	(HURD_CTHREADS_0.3): Remove __libc_getspecific.
	* hurd/hurdpid.c: Include <lowlevellock.h>
	(_S_msg_proc_newids): Use lll_wait to synchronize.
	* hurd/hurdsig.c: (reauth_proc): Use __mutex_lock and __mutex_unlock.
	* hurd/setauth.c: Include <hurdlock.h>, use integer for synchronization.
	* mach/Makefile (lock-headers): Remove machine-lock.h.
	* mach/lock-intern.h: Include <lowlevellock.h> instead of
	<machine-lock.h>.
	(__spin_lock_t): New type.
	(__SPIN_LOCK_INITIALIZER): New macro.
	(__spin_lock, __spin_unlock, __spin_try_lock, __spin_lock_locked,
	__mutex_init, __mutex_lock_solid, __mutex_unlock_solid, __mutex_lock,
	__mutex_unlock, __mutex_trylock): Use lll to implement locks.
	* mach/mutex-init.c: Include <lowlevellock.h> instead of <cthreads.h>.
	(__mutex_init): Initialize with lll.
	* manual/errno.texi (EOWNERDEAD, ENOTRECOVERABLE): New errno values.
	* sysdeps/mach/Makefile: Add libmachuser as dependencies for libs
	needing lll.
	* sysdeps/mach/hurd/bits/errno.h: Regenerate.
	* sysdeps/mach/hurd/cthreads.c (__libc_getspecific): Remove function.
	* sysdeps/mach/hurd/bits/libc-lock.h: Remove file.
	* sysdeps/mach/hurd/setpgid.c: Include <lowlevellock.h>.
	(__setpgid): Use lll for synchronization.
	* sysdeps/mach/hurd/setsid.c: Likewise with __setsid.
	* sysdeps/mach/bits/libc-lock.h: Include <tls.h> and <lowlevellock.h>
	instead of <cthreads.h>.
	(_IO_lock_inexpensive): New macro
	(__libc_lock_recursive_t, __rtld_lock_recursive_t): New structures.
	(__libc_lock_self0): New declaration.
	(__libc_lock_owner_self): New macro.
	(__libc_key_t): Remove type.
	(_LIBC_LOCK_INITIALIZER): New macro.
	(__libc_lock_define_initialized, __libc_lock_init, __libc_lock_fini,
	__libc_lock_fini_recursive, __rtld_lock_fini_recursive,
	__libc_lock_lock, __libc_lock_trylock, __libc_lock_unlock,
	__libc_lock_define_initialized_recursive,
	__rtld_lock_define_initialized_recursive,
	__libc_lock_init_recursive, __libc_lock_trylock_recursive,
	__libc_lock_lock_recursive, __libc_lock_unlock_recursive,
	__rtld_lock_initialize, __rtld_lock_trylock_recursive,
	__rtld_lock_lock_recursive, __rtld_lock_unlock_recursive
	__libc_once_define, __libc_mutex_unlock): Reimplement with lll.
	(__libc_lock_define_recursive, __rtld_lock_define_recursive,
	_LIBC_LOCK_RECURSIVE_INITIALIZER, _RTLD_LOCK_RECURSIVE_INITIALIZER):
	New macros.
	Include <libc-lockP.h> to reimplement libc_key* with pthread_key*.
	* hurd/hurdlock.c: New file.
	* hurd/hurdlock.h: New file.
	* mach/lowlevellock.h: New file
2018-03-18 18:23:45 +01:00
Agustina Arzille 542c20a171 hurd: Rewrite __libc_cleanup_*
This makes it notably safe against 'return' and such, and used for
__libc_cleanup_push/pop.

	* sysdeps/mach/libc-lock.h (__libc_cleanup_frame): Define structure.
	(__libc_cleanup_fct): Define function.
	(__libc_cleanup_region_start, __libc_cleanup_region_end,
	__libc_cleanup_end): Rewrite implementation using
	__attribute__ ((__cleanup__)).
	(__libc_cleanup_push, __libc_cleanup_pop): New macros.
2018-03-18 17:27:00 +01:00
Samuel Thibault 9a37922ee0 hurd: Add missing include
* sysdeps/mach/hurd/cthreads.c: Include <cthreads.h>.
2018-03-18 16:38:26 +01:00
Samuel Thibault dd28d4ba97 x86_64: Fix build with RTLD_PRIVATE_ERRNO defined to 1
* sysdeps/unix/sysv/linux/x86_64/sysdep.h: Always include
	<dl-sysdep.h>.  Test for value of RTLD_PRIVATE_ERRNO instead of
	testing whether it is defined.
2018-03-18 02:11:56 +01:00
Samuel Thibault c2fb08c78a hurd: Fix link cthread/pthread symbol exposition.
* hurd/Versions (HURD_CTHREADS_0.3): Rename weak refs cthread_fork,
	cthread_detach, pthread_getattr_np, pthread_attr_getstack,
	cthread_keycreate, cthread_getspecific, cthread_setspecific to
	__cthread_fork, __cthread_detach, __pthread_getattr_np,
	__pthread_attr_getstack, __cthread_keycreate, __cthread_getspecific,
	__cthread_setspecific.
	* hurd/hurdsig.c (_hurdsig_init): Use __cthread_fork,
	__cthread_detach, __pthread_getattr_np, __pthread_attr_getstack,
	__cthread_t instead of cthread_fork, cthread_detach,
	pthread_getattr_np, pthread_attr_getstack.
	* sysdeps/mach/hurd/cthreads.c (cthread_keycreate): Rename to
	__cthread_keycreate.
	(cthread_getspecific): Rename to __cthread_getspecific.
	(cthread_setspecific): Rename to __cthread_setspecific.
	(__libc_getspecific): Use __cthread_getspecific instead of
	cthread_getspecific.
	* sysdeps/mach/hurd/libc-lock.h (__libc_key_create): Use
	__cthread_keycreate instead of cthread_keycreate.
	(__libc_setspecific): Use __cthread_setspecific instead of
	cthread_setspecific.
	* sysdeps/mach/libc-lock.h (__libc_key_create, __libc_setspecific):
	Likewise.
2018-03-17 23:53:39 +01:00
Samuel Thibault dc33bef307 hurd: Replace threadvars with TLS
This gets rid of a lot of kludge and gets closer to other ports.

	* hurd/Makefile (headers): Remove threadvar.h.
	(inline-headers): Remove threadvar.h.
	* hurd/Versions (GLIBC_2.0: Remove __hurd_sigthread_stack_base,
	__hurd_sigthread_stack_end, __hurd_sigthread_variables,
	__hurd_threadvar_max, __hurd_errno_location.
	(HURD_CTHREADS_0.3): Add pthread_getattr_np, pthread_attr_getstack.
	* hurd/hurd/signal.h: Do not include <hurd/threadvar.h>.
	(_hurd_self_sigstate): Use THREAD_SELF to get _hurd_sigstate.
	(_HURD_SIGNAL_H_EXTERN_INLINE): Use THREAD_SELF to get _hurd_sigstate,
	unless TLS is not initialized yet, in which case we do not need a
	critical section yet anyway.
	* hurd/hurd/threadvar.h: Include <tls.h>, do not include
	<machine-sp.h>.
	(__hurd_sigthread_variables, __hurd_threadvar_max): Remove variables
	declarations.
	(__hurd_threadvar_index): Remove enum.
	(_HURD_THREADVAR_H_EXTERN_INLINE): Remove macro.
	(__hurd_threadvar_location_from_sp,__hurd_threadvar_location): Remove
	inlines.
	(__hurd_reply_port0): New variable declaration.
	(__hurd_local_reply_port): New macro.
	* hurd/hurdsig.c (__hurd_sigthread_variables): Remove variable.
	(interrupted_reply_port_location): Add thread_t parameter.  Use it
	with THREAD_TCB to access thread-local variables.
	(_hurdsig_abort_rpcs): Pass ss->thread to
	interrupted_reply_port_location.
	(_hurd_internal_post_signal): Likewise.
	(_hurdsig_init): Use presence of cthread_fork instead of
	__hurd_threadvar_stack_mask to start signal thread by hand.
	Remove signal thread threadvar initialization.
	* hurd/hurdstartup.c: Do not include <hurd/threadvar.h>
	* hurd/sigunwind.c: Include <hurd/threadvar.h>
	(_hurdsig_longjmp_from_handler): Use __hurd_local_reply_port instead
	of threadvar.
	* sysdeps/mach/hurd/Versions (libc.GLIBC_PRIVATE): Add
	__libc_lock_self0.
	(ld.GLIBC_2.0): Remove __hurd_sigthread_stack_base,
	__hurd_sigthread_stack_end, __hurd_sigthread_variables.
	(ld.GLIBC_PRIVATE): Add __libc_lock_self0.
	* sysdeps/mach/hurd/cthreads.c: Add __libc_lock_self0.
	* sysdeps/mach/hurd/dl-sysdep.c (errno, __hurd_sigthread_stack_base,
	__hurd_sigthread_stack_end, __hurd_sigthread_variables, threadvars,
	__hurd_threadvar_stack_offset, __hurd_threadvar_stack_mask): Do not
	define variables.
	* sysdeps/mach/hurd/errno-loc.c: Do not include <errno.h> and
	<hurd/threadvar.h>.
	[IS_IN(rtld)] (rtld_errno): New variable.
	[IS_IN(rtld)] (__errno_location): New weak function.
	[!IS_IN(rtld)]: Include "../../../csu/errno-loc.c".
	* sysdeps/mach/hurd/errno.c: Remove file.
	* sysdeps/mach/hurd/fork.c: Include <hurd/threadvar.h>
	(__fork): Remove THREADVAR_SPACE macro and its use.
	* sysdeps/mach/hurd/i386/init-first.c (__hurd_threadvar_max): Remove
	variable.
	(init): Do not initialize threadvar.
	* sysdeps/mach/hurd/i386/libc.abilist (__hurd_threadvar_max): Remove
	symbol.
	* sysdeps/mach/hurd/i386/sigreturn.c (__sigreturn): Use
	__hurd_local_reply_port instead of threadvar.
	* sysdeps/mach/hurd/i386/tls.h (tcbhead_t): Add reply_port and
	_hurd_sigstate fields.
	(HURD_DESC_TLS, __LIBC_NO_TLS, THREAD_TCB): New macro.
	* sysdeps/mach/hurd/i386/trampoline.c: Remove outdated comment.
	* sysdeps/mach/hurd/libc-lock.h: Do not include <hurd/threadvar.h>.
	(__libc_lock_owner_self): Use &__libc_lock_self0 and THREAD_SELF
	instead of threadvar.
	* sysdeps/mach/hurd/libc-tsd.h: Remove file.
	* sysdeps/mach/hurd/mig-reply.c (GETPORT, reply_port): Remove macros.
	(use_threadvar, global_reply_port): Remove variables.
	(__hurd_reply_port0): New variable.
	(__mig_get_reply_port): Use __hurd_local_reply_port and
	__hurd_reply_port0 instead of threadvar.
	(__mig_dealloc_reply_port): Likewise.
	(__mig_init): Do not initialize threadvar.
	* sysdeps/mach/hurd/profil.c: Fix comment.
2018-03-17 23:29:57 +01:00
Samuel Thibault 34e6a8694d hurd: Fix getting signal thread stack layout for fork
* hurd/hurdsig.c: Include <pthread.h>.
(_hurdsig_init): Call pthread_getattr_np and pthread_attr_getstack to
get the signal thread stack layout.
2018-03-17 22:53:01 +01:00
Samuel Thibault f8baf2a224 hurd: add TLS support
* sysdeps/generic/thread_state.h (MACHINE_NEW_THREAD_STATE_FLAVOR):
	Define macro.
	* sysdeps/mach/thread_state.h (MACHINE_THREAD_STATE_FIX_NEW): New macro.
	* sysdeps/mach/i386/thread_state.h
	(MACHINE_NEW_THREAD_STATE_FLAVOR): New macro, defined to
	i386_THREAD_STATE.
	(MACHINE_THREAD_STATE_FLAVOR): Define to i386_REGS_SEGS_STATE instead of
	i386_THREAD_STATE.
	(MACHINE_THREAD_STATE_FIX_NEW): New macro, reads segments.

	* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler): Use
	i386_REGS_SEGS_STATE instead of i386_THREAD_STATE.

	* sysdeps/mach/hurd/i386/tls.h (TCB_ALIGNMENT, HURD_SEL_LDT): New
	macros.
	(_hurd_tls_fork): Add original thread parameter, Duplicate existing LDT
	descriptor instead of creating a new one.
	(_hurd_tls_new): New function, creates a new descriptor and updates tcb.

	* mach/setup-thread.c: Include <ldsodefs.h>.
	(__mach_setup_thread): Call _dl_allocate_tls, pass
	MACHINE_NEW_THREAD_STATE_FLAVOR to __thread_set_state instead of
	MACHINE_THREAD_STATE_FLAVOR, before getting
	MACHINE_THREAD_STATE_FLAVOR, calling _hurd_tls_new, and setting
	MACHINE_THREAD_STATE_FLAVOR with the result.
	* hurd/hurdfault.c (_hurdsig_fault_init): Call
	MACHINE_THREAD_STATE_FIX_NEW.
	* sysdeps/mach/hurd/fork.c (__fork): Call _hurd_tls_fork for sigthread
	too.  Add original thread parameter.
2018-03-17 03:17:36 +01:00
Joseph Myers 5d75b75fb7 Remove sysdeps/x86/fpu/bits/mathinline.h __finite inline.
Continuing the removals of inline functions from the x86
bits/mathinline.h, this patch removes an inline of __finite (which was
not actually architecture-specific at all beyond its
endianness-dependence).

This inline is not normally used with GCC 4.4 or later, because
isfinite now uses __builtin_isfinite except for -fsignaling-nans.
Allowing __builtin_isfinite etc. to work properly even for
-fsignaling-nans, by implementing versions of those built-in functions
that use integer arithmetic in GCC, is
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66462> (a patch was
committed but had to be reverted because it caused problems, and that
patch didn't address all formats for all architectures, only some, so
by itself would not have been sufficient to allow glibc to use
__builtin_isfinite unconditionally for new-enough GCC).

Tested for x86_64 and x86.

	* sysdeps/x86/fpu/bits/mathinline.h [__USE_MISC] (__finite):
	Remove inline function.
2018-03-16 18:36:53 +00:00
Joseph Myers 34ba96b89c Update i386 libm-test-ulps.
I found the i386 libm-test-ulps files needed updating (probably the
sqrt changes perturbed exactly when excess precision was used by the
compiler).

	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/i386/i686/fpu/multiarch/libm-test-ulps: Likewise.
2018-03-16 17:43:38 +00:00
Wilco Dijkstra 22679b2c33 Revert m68k __ieee754_sqrt change
Revert m68k __ieee754_sqrt change as it causes a build failure in one
m68k configuration.  m68k-linux-gnu now passes again.

	* sysdeps/m68k/m680x0/fpu/mathimpl.h (__ieee754_sqrt): Revert previous
	commit.
2018-03-16 14:25:41 +00:00
Wilco Dijkstra 700593fdd7 Remove all target specific __ieee754_sqrt(f/l) inlines
Remove the now unused target specific__ieee754_sqrt(f/l) inlines.
Also remove inlines of sqrt which are for really old GCC versions.
Removing these is desirable, under the general principle of leaving
such inlining to the compiler rather than trying to do it in installed
headers, especially when only very old compilers are affected.

Note that removing inlines for __ieee754_sqrt disables inlining in the
sqrt wrapper functions.  Given the sqrt function will typically only be
called for negative arguments, it doesn't matter whether the inlining
happens or not.

	* sysdeps/aarch64/fpu/math_private.h (__ieee754_sqrt): Remove.
	(__ieee754_sqrtf): Remove.
	* sysdeps/alpha/fpu/math_private.h (__ieee754_sqrt): Remove.
	(__ieee754_sqrtf): Remove.
	* sysdeps/generic/math-type-macros.h (M_SQRT): Use sqrt.
	* sysdeps/m68k/m680x0/fpu/mathimpl.h (__ieee754_sqrt): Remove.
	* sysdeps/powerpc/fpu/math_private.h (__ieee754_sqrt): Remove.
	(__ieee754_sqrtf): Remove.
	* sysdeps/s390/fpu/bits/mathinline.h: Remove file.
	* sysdeps/sparc/fpu/bits/mathinline.h (sqrt) Remove.
	(sqrtf): Remove.
	(sqrtl): Remove.
	(__ieee754_sqrt): Remove.
	(__ieee754_sqrtf): Remove.
	(__ieee754_sqrtl): Remove.
	* sysdeps/m68k/m680x0/fpu/mathimpl.h (__ieee754_sqrt): Remove.
	* sysdeps/x86/fpu/math_private.h (__ieee754_sqrt): Remove.
	* sysdeps/x86_64/fpu/math_private.h (__ieee754_sqrt): Remove.
	(__ieee754_sqrtf): Remove.
	(__ieee754_sqrtl): Remove.
2018-03-15 19:21:36 +00:00
Wilco Dijkstra f67a8147b0 Rename all __ieee754_sqrt(f/l) calls to sqrt(f/l)
Use sqrt(f/l) to enable inlining by GCC - if inlining doesn't happen,
the asm redirect ensures we will still call __ieee754_sqrt(f/l).

	* sysdeps/ieee754/dbl-64/e_acosh.c (__ieee754_acosh): Use sqrt.
	* sysdeps/ieee754/dbl-64/e_gamma_r.c (gamma_positive): Likewise.
	* sysdeps/ieee754/dbl-64/e_hypot.c (__ieee754_hypot): Likewise.
	* sysdeps/ieee754/dbl-64/e_j0.c (__ieee754_j0): Likewise.
	* sysdeps/ieee754/dbl-64/e_j1.c (__ieee754_j1): Likewise.
	* sysdeps/ieee754/dbl-64/e_jn.c (__ieee754_jn): Likewise.
	* sysdeps/ieee754/dbl-64/s_asinh.c (__asinh): Likewise.
	* sysdeps/ieee754/dbl-64/wordsize-64/e_acosh.c (__ieee754_acosh): Likewise.
	* sysdeps/ieee754/flt-32/e_acosf.c (__ieee754_acosf): Likewise.
	* sysdeps/ieee754/flt-32/e_acoshf.c (__ieee754_acoshf): Likewise.
	* sysdeps/ieee754/flt-32/e_asinf.c (__ieee754_asinf): Likewise.
	* sysdeps/ieee754/flt-32/e_gammaf_r.c (gammaf_positive): Likewise.
	* sysdeps/ieee754/flt-32/e_hypotf.c (__ieee754_hypotf): Likewise.
	* sysdeps/ieee754/flt-32/e_j0f.c (__ieee754_j0f): Likewise.
	* sysdeps/ieee754/flt-32/e_j1f.c (__ieee754_j1f): Likewise.
	* sysdeps/ieee754/flt-32/e_powf.c (__ieee754_powf): Likewise.
	* sysdeps/ieee754/flt-32/s_asinhf.c (__asinhf): Likewise.
	* sysdeps/ieee754/ldbl-128/e_acoshl.c (__ieee754_acoshl): Use sqrtl.
	* sysdeps/ieee754/ldbl-128/e_acosl.c (__ieee754_acosl): Likewise.
	* sysdeps/ieee754/ldbl-128/e_asinl.c (__ieee754_asinl): Likewise.
	* sysdeps/ieee754/ldbl-128/e_gammal_r.c (gammal_positive): Likewise.
	* sysdeps/ieee754/ldbl-128/e_hypotl.c (__ieee754_hypotl): Likewise.
	* sysdeps/ieee754/ldbl-128/e_j0l.c (__ieee754_j0l): Likewise.
	* sysdeps/ieee754/ldbl-128/e_j1l.c (__ieee754_j1l): Likewise.
	* sysdeps/ieee754/ldbl-128/e_jnl.c (__ieee754_jnl): Likewise.
	* sysdeps/ieee754/ldbl-128/e_powl.c (__ieee754_powl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_asinhl.c (__ieee754_asinhl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_acoshl.c (__ieee754_acoshl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_acosl.c (__ieee754_acosl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_asinl.c (__ieee754_asinl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c (gammal_positive): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_hypotl.c (__ieee754_hypotl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_j0l.c (__ieee754_j0l): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_j1l.c (__ieee754_j1l): Likewise
	* sysdeps/ieee754/ldbl-128ibm/e_jnl.c (__ieee754_jnl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_powl.c (__ieee754_powl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_asinhl.c (__ieee754_asinhl): Likewise.
	* sysdeps/ieee754/ldbl-96/e_acoshl.c (__ieee754_acoshl): Use sqrtl.
	* sysdeps/ieee754/ldbl-96/e_asinl.c (__ieee754_asinl): Likewise.
	* sysdeps/ieee754/ldbl-96/e_gammal_r.c (gammal_positive): Likewise.
	* sysdeps/ieee754/ldbl-96/e_hypotl.c (__ieee754_hypotl): Likewise.
	* sysdeps/ieee754/ldbl-96/e_j0l.c (__ieee754_j0l): Likewise.
	* sysdeps/ieee754/ldbl-96/e_j1l.c (__ieee754_j1l): Likewise.
	* sysdeps/ieee754/ldbl-96/e_jnl.c (__ieee754_jnl): Likewise.
	* sysdeps/ieee754/ldbl-96/s_asinhl.c (__ieee754_asinhl): Likewise.
	* sysdeps/m68k/m680x0/fpu/e_pow.c (__ieee754_pow): Likewise.
	* sysdeps/powerpc/fpu/e_hypot.c (__ieee754_hypot): Likewise.
	* sysdeps/powerpc/fpu/e_hypotf.c (__ieee754_hypotf): Likewise.
2018-03-15 19:21:36 +00:00
Wilco Dijkstra 1294b1892e Add support for sqrt asm redirects
This patch series cleans up the many uses of  __ieee754_sqrt(f/l) in GLIBC.
The goal is to enable GCC to do the inlining, and if this fails call the
__ieee754_sqrt function.  This is done by internally declaring sqrt with asm
redirects.  The compat symbols and sqrt wrappers need to disable the redirect.
The redirect is also disabled if there are already redirects defined when
using -ffinite-math-only.

All math functions (but not math tests, non-library code and libnldbl) are
built with -fno-math-errno which means GCC will typically inline sqrt as a
single instruction.  This means targets are no longer forced to add a special
inline for sqrt.

	* include/math.h (sqrt): Declare with asm redirect.
	(sqrtf): Likewise.
	(sqrtl): Likewise.
	(sqrtf128): Likewise.
	* Makeconfig: Add -fno-math-errno for libc/libm, but build testsuite,
	nonlib and libnldbl with -fmath-errno.
	* math/w_sqrt_compat.c: Define NO_MATH_REDIRECT.
	* math/w_sqrt_template.c: Likewise.
	* math/w_sqrtf_compat.c: Likewise.
	* math/w_sqrtl_compat.c: Likewise.
	* sysdeps/i386/fpu/w_sqrt.c: Likewise.
	* sysdeps/i386/fpu/w_sqrt_compat.c: Likewise.
	* sysdeps/generic/math-type-macros-float128.h: Remove math.h and
	complex.h.
2018-03-15 19:21:35 +00:00
Joseph Myers c429a8d8d6 Remove more old-compilers parts of sysdeps/x86/fpu/bits/mathinline.h.
This patch removes further parts of sysdeps/x86/fpu/bits/mathinline.h
that are only of value for optimization with older compiler versions,
in accordance with general principles of preferring the let the
compiler deal with such inlining through built-in functions.

In general, GCC supports inlining all these functions as of version
4.3 or earlier.  However, some inlines in GCC may have had excessively
restrictive conditions in past GCC versions (e.g. requiring
-ffast-math when the inline is valid under broader conditions).  (In
particular, GCC had, before GCC 7, unnecessarily restrictive
conditions on when it could apply floor and ceil inlines corresponding
to the ones removed here.  The same was true for rint, but
bits/mathinline.h *also* was excessively restrictive there.)

The removed sincos inlines are for __sincos etc. functions (not a
public interface and not currently used in this header either; not in
a part of the header ever used for building glibc itself).  Likewise,
the atan2 inlines included one for __atan2l, also not a public
interface and not used for building glibc itself (calls inside glibc
generally use __ieee754_atan2l, for which there is a separate
__LIBC_INTERNAL_MATH_INLINES case in this header).

Tested for x86_64 and x86.

	* sysdeps/x86/fpu/bits/mathinline.h [__FAST_MATH__]
	(__sincos_code): Remove define and undefine.
	[__FAST_MATH__] (__sincos): Remove inline function.
	[__FAST_MATH__] (__sincosf): Remove inline function.
	[__FAST_MATH__] (__sincosl): Remove inline function.
	(__atan2l): Remove inline functions.
	[!__GNUC_PREREQ (3, 4)] (__atan2_code): Remove macro.
	[!__GNUC_PREREQ (3, 4) && __FAST_MATH__] (atan2): Remove inline
	function.
	(floor): Remove inline function.
	(ceil): Likewise.
	[__FAST_MATH__] (__ldexp_code): Remove macro.
	[__FAST_MATH__] (ldexp): Remove inline function.
	[__FAST_MATH__ && __USE_ISOC99] (ldexpf): Likewise.
	[__FAST_MATH__ && __USE_ISOC99] (ldexpl): Likewise.
	[__FAST_MATH__ && __USE_ISOC99] (rint): Likewise.
	[__USE_ISOC99] (__lrint_code): Remove macro.
	[__USE_ISOC99] (__llrint_code): Likewise.
	[__USE_ISOC99] (lrintf): Remove inline function.
	[__USE_ISOC99] (lrint): Likewise.
	[__USE_ISOC99] (lrintl): Likewise.
	[__USE_ISOC99] (llrint): Likewise.
	[__USE_ISOC99] (llrintf): Likewise.
	[__USE_ISOC99] (llrintl): Likewise.
2018-03-15 18:26:35 +00:00
Wilco Dijkstra f1c8185d34 Use correct includes in benchtests
Currently the benchtests are run with internal GLIBC headers, which is incorrect.
Defining _ISOMAC in the makefile ensures the internal headers are bypassed.
Fix all tests which were relying on internal defines or includes.

	* benchtests/Makefile: Define _ISOMAC.
	* benchtests/bench-strcoll.c: Add missing sys/stat.h include.
	* benchtests/bench-string.h: Define inhibit_loop_to_libcall macro.
	* benchtests/bench-strstr.c: Define empty libc_hidden_builtin_def.
	* benchtests/bench-strtok.c (oldstrtok): Use rawmemchr.
	* benchtests/bench-timing.h: Define attribute_hidden.
2018-03-15 15:44:58 +00:00
Siddhesh Poyarekar b47c3e7637 aarch64/strncmp: Use lsr instead of mov+lsr
A lsr can do what the mov and lsr did.
2018-03-15 08:06:21 +05:30
Rafal Luzynski 807fee29d2 cs_CZ locale: Add alternative month names (bug 22963).
Add alternative month names, primary month names are genitive now.

	[BZ #22963]
	* localedata/locales/cs_CZ (mon): Rename to...
	(alt_mon): This.
	(mon): Import from CLDR (genitive case).
2018-03-15 01:21:02 +01:00
Rafal Luzynski e7155a28ef Greek (el_CY, el_GR) locales: Introduce ab_alt_mon (bug 22937).
As spotted by GNOME translation team, Greek language has the actually
visible difference between the abbreviated nominative and the abbreviated
genitive case for some month names.  Examples:

May:

abbreviated nominative: "Μάι" -> abbreviated genitive: "Μαΐ"

July:

abbreviated nominative: "Ιούν" -> abbreviated genitive: "Ιουλ"

and more month names with similar differences.

Original discussion: https://bugzilla.gnome.org/show_bug.cgi?id=793645#c21

	[BZ #22937]
	* localedata/locales/el_CY (abmon): Rename to...
	(ab_alt_mon): This.
	(abmon): Import from CLDR (abbreviated genitive case).
	* localedata/locales/el_GR (abmon): Rename to...
	(ab_alt_mon): This.
	(abmon): Import from CLDR (abbreviated genitive case).
2018-03-15 01:11:05 +01:00
Rafal Luzynski 71d7b12168 lt_LT locale: Update abbreviated month names (bug 22932).
A GNOME translator asked to use the same abbreviated month names
as provided by CLDR.  This sounds reasonable.  See the discussion:
https://bugzilla.gnome.org/show_bug.cgi?id=793645#c27

	[BZ #22932]
	* localedata/locales/lt_LT (abmon): Synchronize with CLDR.
2018-03-15 01:08:49 +01:00
Robert Buj a00bffe8b5 ca_ES locale: Update LC_TIME (bug 22848).
Add/fix alternative month names, long & short formats, am_pm,
abday settings, and improve indentation for Catalan.

	[BZ #22848]
	* localedata/locales/ca_ES (abmon): Rename to...
	(ab_alt_mon): This, then synchronize with CLDR (nominative case).
	(mon): Rename to...
	(alt_mon): This.
	(abmon): Import from CLDR (genitive case, month names preceded by
	"de" or "d’").
	(mon): Likewise.
	(abday): Synchronize with CLDR.
	(d_t_fmt): Likewise.
	(d_fmt): Likewise.
	(am_pm): Likewise.

	(LC_TIME): Improve indentation.
	(LC_TELEPHONE): Likewise.
	(LC_NAME): Likewise.
	(LC_ADDRESS): Likewise.
2018-03-15 01:05:19 +01:00
Joseph Myers f9555d7312 Remove old-GCC parts of x86 bits/mathinline.h.
In accordance with the general principle of preferring to let the
compiler optimize function calls based on their standard semantics
rather than putting inline definitions of such functions in installed
headers, this patch removes various such inline definitions in the x86
bits/mathinline.h that were already disabled for GCC 3.5 or later and
so were only used with very old compilers (for which good optimization
is particularly unimportant); along with those inlines, a definition
of __M_SQRT2, which was only used in such inline functions, is also
removed.  This is similar to an early step in removing the string.h
inlines; I intend to follow up with further removals of
bits/mathinline.h inline definitions in appropriate logical groups
(with GCC bugs filed in cases where GCC doesn't already support
corresponding optimizations).

Tested for x86_64 and x86.

	* sysdeps/x86/fpu/bits/mathinline.h [!__GNUC_PREREQ (3, 4)]
	(lrintf): Remove definitions used only with old GCC.
	[!__GNUC_PREREQ (3, 4)] (lrint): Likewise.
	[!__GNUC_PREREQ (3, 4)] (llrintf): Likewise.
	[!__GNUC_PREREQ (3, 4)] (llrint): Likewise.
	[!__GNUC_PREREQ (3, 4)] (fmaxf): Likewise.
	[!__GNUC_PREREQ (3, 4)] (fmax): Likewise.
	[!__GNUC_PREREQ (3, 4)] (fminf): Likewise.
	[!__GNUC_PREREQ (3, 4)] (fmin): Likewise.
	[!__GNUC_PREREQ (3, 4)] (rint): Likewise.
	[!__GNUC_PREREQ (3, 4)] (rintf): Likewise.
	[!__GNUC_PREREQ (3, 4)] (nearbyint): Likewise.
	[!__GNUC_PREREQ (3, 4)] (nearbyintf): Likewise.
	[!__GNUC_PREREQ (3, 4)] (ceil): Likewise.
	[!__GNUC_PREREQ (3, 4)] (ceilf): Likewise.
	[!__GNUC_PREREQ (3, 4)] (floor): Likewise.
	[!__GNUC_PREREQ (3, 4)] (floorf): Likewise.
	[__FAST_MATH__ && !__GNUC_PREREQ (3, 5)] (tan): Likewise.
	[__FAST_MATH__ && !__GNUC_PREREQ (3, 5)] (fmod): Likewise.
	[__FAST_MATH__ && !__GNUC_PREREQ (3, 4)] (sin): Likewise.
	[__FAST_MATH__ && !__GNUC_PREREQ (3, 4)] (cos): Likewise.
	[__FAST_MATH__ && !__GNUC_PREREQ (3, 5)] (log10): Likewise.
	[__FAST_MATH__ && !__GNUC_PREREQ (3, 5)] (asin): Likewise.
	[__FAST_MATH__ && !__GNUC_PREREQ (3, 5)] (acos): Likewise.
	[__FAST_MATH__ && !__GNUC_PREREQ (3, 4)] (atan): Likewise.
	[__FAST_MATH__ && !__GNUC_PREREQ (3, 5)] (log1p): Likewise.
	[__FAST_MATH__ && !__GNUC_PREREQ (3, 5)] (logb): Likewise.
	[__FAST_MATH__ && !__GNUC_PREREQ (3, 5)] (log2): Likewise.
	[__FAST_MATH__ && !__GNUC_PREREQ (3, 5)] (drem): Likewise.
	[__FAST_MATH__] (__M_SQRT2): Remove macro.
2018-03-14 18:26:03 +00:00
Siddhesh Poyarekar d46f84de74 aarch64/strncmp: Unbreak builds with old binutils
Binutils 2.26.* and older do not support moves with shifted registers,
so use a separate shift instruction instead.
2018-03-14 18:51:05 +05:30
Siddhesh Poyarekar 7108f1f944 aarch64: Improve strncmp for mutually misaligned inputs
The mutually misaligned inputs on aarch64 are compared with a simple
byte copy, which is not very efficient.  Enhance the comparison
similar to strcmp by loading a double-word at a time.  The peak
performance improvement (i.e. 4k maxlen comparisons) due to this on
the strncmp microbenchmark is as follows:

falkor: 3.5x (up to 72% time reduction)
cortex-a73: 3.5x (up to 71% time reduction)
cortex-a53: 3.5x (up to 71% time reduction)

All mutually misaligned inputs from 16 bytes maxlen onwards show
upwards of 15% improvement and there is no measurable effect on the
performance of aligned/mutually aligned inputs.

	* sysdeps/aarch64/strncmp.S (count): New macro.
	(strncmp): Store misaligned length in SRC1 in COUNT.
	(mutual_align): Adjust.
	(misaligned8): Load dword at a time when it is safe.
2018-03-13 23:57:04 +05:30
Zack Weinberg 2cc7bad0ae [BZ 1190] Make EOF sticky in stdio.
C99 specifies that the EOF condition on a file is "sticky": once EOF
has been encountered, all subsequent reads should continue to return
EOF until the file is closed or something clears the "end-of-file
indicator" (e.g. fseek, clearerr).  This is arguably a change from
C89, where the wording was ambiguous; the BSDs always had sticky EOF,
but the System V lineage would attempt to read from the underlying fd
again.  GNU libc has followed System V for as long as we've been
using libio, but nowadays C99 conformance and BSD compatibility are
more important than System V compatibility.

You might wonder if changing the _underflow impls is sufficient to
apply the C99 semantics to all of the many stdio functions that
perform input.  It should be enough to cover all paths to _IO_SYSREAD,
and the only other functions that call _IO_SYSREAD are the _seekoff
impls, which is OK because seeking clears EOF, and the _xsgetn impls,
which, as far as I can tell, are unused within glibc.

The test programs in this patch use a pseudoterminal to set up the
necessary conditions.  To facilitate this I added a new test-support
function that sets up a pair of pty file descriptors for you; it's
almost the same as BSD openpty, the only differences are that it
allocates the optionally-returned tty pathname with malloc, and that
it crashes if anything goes wrong.

	[BZ #1190]
        [BZ #19476]
	* libio/fileops.c (_IO_new_file_underflow): Return EOF immediately
	if the _IO_EOF_SEEN bit is already set; update commentary.
	* libio/oldfileops.c (_IO_old_file_underflow): Likewise.
	* libio/wfileops.c (_IO_wfile_underflow): Likewise.

	* support/support_openpty.c, support/tty.h: New files.
	* support/Makefile (libsupport-routines): Add support_openpty.

	* libio/tst-fgetc-after-eof.c, wcsmbs/test-fgetwc-after-eof.c:
	New test cases.
	* libio/Makefile (tests): Add tst-fgetc-after-eof.
	* wcsmbs/Makefile (tests): Add tst-fgetwc-after-eof.
2018-03-13 08:31:56 -04:00
Dmitry V. Levin 778f197486 Update translations from the Translation Project
* po/pt_BR.po: Update translations.
2018-03-12 13:24:46 +00:00
David Michael da6d4404ec Lookup the startup server through /servers/startup
* sysdeps/mach/hurd/reboot.c: Include <hurd/paths.h>
(reboot): Lookup _SERVERS_STARTUP instead of calling proc_getmsgport to get a
port to the startup server.
2018-03-12 00:24:31 +01:00
Zack Weinberg d3da750d01 nldbl-compat.c: Include math.h before nldbl-compat.h.
Jeff Law noticed that native PowerPC builds were broken by my having
made math_ldbl_opt.h not include math.h.  nldbl-compat.c formerly got
math.h via libioP.h and math_ldbl_opt.h, *without* __NO_LONG_DOUBLE_MATH;
after my change it got it via nldbl-compat.h *with* __NO_LONG_DOUBLE_MATH,
but __NO_LONG_DOUBLE_MATH mode is forbidden on hosts that define
__HAVE_DISTINCT_FLOAT128, so the build breaks.  This is the quick fix.

	* sysdeps/ieee754/ldbl-opt/nldbl-compat.c: Include math.h
	before nldbl-compat.h.
2018-03-11 14:20:13 -04:00
Zack Weinberg 0d13dfa17b Don't include math.h/math_private.h in math_ldbl_opt.h.
The sysdeps/ieee754/ldbl-opt version of math_ldbl_opt.h includes
math.h and math_private.h, despite not having any need for those
headers itself; the sysdeps/generic version doesn't.  About 20 files
are relying on math_ldbl_opt.h to include math.h and/or math_private.h
for them, even though none of them necessarily used on a platform that
needs ldbl-opt support.

	* sysdeps/ieee754/ldbl-opt/math_ldbl_opt.h: Don't include
	math.h or math_private.h.

	* sysdeps/alpha/fpu/s_isnan.c
	* sysdeps/ieee754/ldbl-128ibm/s_ceill.c
	* sysdeps/ieee754/ldbl-128ibm/s_floorl.c
	* sysdeps/ieee754/ldbl-128ibm/s_llrintl.c
	* sysdeps/ieee754/ldbl-128ibm/s_llroundl.c
	* sysdeps/ieee754/ldbl-128ibm/s_lrintl.c
	* sysdeps/ieee754/ldbl-128ibm/s_lroundl.c
	* sysdeps/ieee754/ldbl-128ibm/s_rintl.c
	* sysdeps/ieee754/ldbl-128ibm/s_roundl.c
	* sysdeps/ieee754/ldbl-128ibm/s_truncl.c
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/e_hypot.c
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/e_hypotf.c:
	* sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf.c
	* sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot.c
	* sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf.c:
	Include math_private.h.

	* sysdeps/ieee754/ldbl-64-128/s_finitel.c
	* sysdeps/ieee754/ldbl-64-128/s_fpclassifyl.c
	* sysdeps/ieee754/ldbl-64-128/s_isinfl.c
	* sysdeps/ieee754/ldbl-64-128/s_isnanl.c
	* sysdeps/ieee754/ldbl-64-128/s_signbitl.c
	* sysdeps/powerpc/power7/fpu/s_logb.c:
	Include math.h and math_private.h.
2018-03-10 15:18:08 -05:00
Zack Weinberg 054b72cc97 alpha/clone.S: Invoke .set noat/.set at around explicit uses of $at
On Alpha, the register $at is, by default, reserved for use by the
assembler, in the expansion of pseudo-instructions.  It's also used
by the special calling convention for _mcount.  We get warnings from
Alpha clone.S because the code to call _mcount isn't properly marked
up to tell the assembler not to use $at itself.

	* sysdeps/unix/sysv/linux/alpha/clone.s (__clone): Wrap manual
	uses of $at in .set noat / .set at.
2018-03-10 15:17:18 -05:00
H.J. Lu 6253bacdc0 Remove hidden __libc_longjmp
Since __libc_longjmp is a private interface for cancellation implementation
in libpthread, there is no need to provide hidden __libc_longjmp in libc.

Tested with build-many-glibcs.py.

	* include/setjmp.h (__libc_longjmp): Remove libc_hidden_proto.
	* setjmp/longjmp.c (__libc_longjmp): Remove libc_hidden_def.
	* sysdeps/s390/longjmp.c (__libc_longjmp): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/longjmp.S (__libc_longjmp):
	Likewise.
2018-03-10 09:27:20 -08:00
Florian Weimer 229855e598 malloc: Revert sense of prev_inuse in comments
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-03-09 16:21:22 +01:00
H.J. Lu d9f26dab2c Fix a typo in ChangeLog: auch_fork -> arch_fork 2018-03-08 20:06:30 -08:00
Aurelien Jarno 9aa5c222b9 sparc32: Add nop before __startcontext to stop unwinding [BZ #22919]
On sparc32 tst-makecontext fails, as backtrace called within a context
created by makecontext to yield infinite backtrace.

Fix that the same way than nios2 by adding a nop just before
__startcontext. This is needed as otherwise FDE lookup just repeatedly
finds __setcontext's FDE in an infinite loop, due to the convention of
using 'address - 1' for FDE lookup.

Changelog:
	[BZ #22919]
	* sysdeps/unix/sysv/linux/sparc/sparc32/setcontext.S (__startcontext):
	Add nop before __startcontext, add explaining comments.
2018-03-09 00:14:27 +01:00
Adhemerval Zanella e921c89e01 powerpc: Fix TLE build for SPE (BZ #22926)
Some SPE opcodes clashes with some recent PowerISA opcodes and
until recently gas did not complain about it.  However binutils
recently changed it and now VLE configured gas does not support to
assembler some instruction that might class with VLE (HTM for
instance).  It also does not help that glibc build hardware lock
elision support as default (regardless of assembler support).

Although runtime will not actually enables TLE on SPE hardware
(since kernel will not advertise it), I see little advantage on
adding HTM support on SPE built glibc.  SPE uses an incompatible
ABI which does not allow share the same build with default
powerpc and HTM code slows down SPE without any benefict.

This patch fixes it by only building HTM when SPE configuration
is not used.

Checked with a powerpc-linux-gnuspe build. I also did some sniff
tests on a e500 hardware without any issue.

	[BZ #22926]
	* sysdeps/powerpc/powerpc32/sysdep.h (ABORT_TRANSACTION_IMPL): Define
	empty for __SPE__.
	* sysdeps/powerpc/sysdep.h (ABORT_TRANSACTION): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/elision-lock.c (__lll_lock_elision):
	Do not build hardware transactional code for __SPE__.
	* sysdeps/unix/sysv/linux/powerpc/elision-trylock.c
	(__lll_trylock_elision): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/elision-unlock.c
	(__lll_unlock_elision): Likewise.
2018-03-07 17:39:44 -03:00
Adhemerval Zanella 3dc214977b Refactor Linux ARCH_FORK implementation
This patch refactors the ARCH_FORK macro and the required architecture
specific header to simplify the required architecture definitions
to provide the fork syscall semantic and proper document current
Linux clone ABI variant.

Instead of require the reimplementation of arch-fork.h header, this
patch changes the ARCH_FORK to an inline function with clone ABI
defined by kernel-features.h define.  The generic kernel ABI meant
for newer ports is used as default and redefine if the architecture
requires.

Checked on x86_64-linux-gnu and i686-linux-gnu.  Also with a build
for all the afected ABIs.

	* sysdeps/nptl/fork.c (ARCH_FORK): Replace by auch_fork.
	* sysdeps/unix/sysv/linux/alpha/arch-fork.h: Remove file.
	* sysdeps/unix/sysv/linux/riscv/arch-fork.h: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/arch-fork.h: Likewise.
	* sysdeps/unix/sysv/linux/arm/arch-fork.h: Likewise.
	* sysdeps/unix/sysv/linux/hppa/arch-fork.h: Likewise.
	* sysdeps/unix/sysv/linux/i386/arch-fork.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/arch-fork.h: Likewise.
	* sysdeps/unix/sysv/linux/m68k/arch-fork.h: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/arch-fork.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/arch-fork.h: Likewise.
	* sysdeps/unix/sysv/linux/nios2/arch-fork.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/arch-fork.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/arch-fork.h: Likewise.
	* sysdeps/unix/sysv/linux/sh/arch-fork.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/arch-fork.h: Likewise.
	* sysdeps/unix/sysv/linux/tile/arch-fork.h: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/arch-fork.h: Likewise.
	* sysdeps/unix/sysv/linux/arch-fork.h (arch_fork): New function.
	* sysdeps/unix/sysv/linux/aarch64/kernel-features.h: New file.
	* sysdeps/unix/sysv/linux/riscv/kernel-features.h: Likewise.
	* sysdeps/unix/sysv/linux/arm/kernel-features.h
	(__ASSUME_CLONE_BACKWARDS): Define.
	* sysdeps/unix/sysv/linux/createthread.c (ARCH_CLONE): Define to
	__clone2 if __NR_clone2 is defined.
	* sysdeps/unix/sysv/linux/hppa/kernel-features.h
	(__ASSUME_CLONE_BACKWARDS): Likewise.
	* sysdeps/unix/sysv/linux/i386/kernel-features.h
	(__ASSUME_CLONE_BACKWARDS): Likewise.
	* sysdeps/unix/sysv/linux/ia64/kernel-features.h
	(__ASSUME_CLONE2): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
	(__ASSUME_CLONE_BACKWARDS3): Likewise.
	* sysdeps/unix/sysv/linux/kernel-features.h: Document possible clone
	variants and the define architecture can use.
	(__ASSUME_CLONE_DEFAULT): Define as default.
	* sysdeps/unix/sysv/linux/mips/kernel-features.h
	(__ASSUME_CLONE_BACKWARDS): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/kernel-features.h
	(__ASSUME_CLONE_BACKWARDS): Likewise.
	* sysdeps/unix/sysv/linux/s390/kernel-features.h
	(__ASSUME_CLONE_BACKWARDS2): Likewise.
2018-03-07 17:39:40 -03:00
Siddhesh Poyarekar 4e54d91863 aarch64: Fix branch target to loop16
I goofed up when changing the loop8 name to loop16 and missed on out
the branch instance.  Fixed and actually build tested this time.

	* sysdeps/aarch64/memcmp.S (more16): Fix branch target loop16.
2018-03-06 23:01:02 +05:30
Siddhesh Poyarekar 30a81dae5b aarch64: Optimized memcmp for medium to large sizes
This improved memcmp provides a fast path for compares up to 16 bytes
and then compares 16 bytes at a time, thus optimizing loads from both
sources.  The glibc memcmp microbenchmark retains performance (with an
error of ~1ns) for smaller compare sizes and reduces up to 31% of
execution time for compares up to 4K on the APM Mustang.  On Qualcomm
Falkor this improves to almost 48%, i.e. it is almost 2x improvement
for sizes of 2K and above.

	* sysdeps/aarch64/memcmp.S: Widen comparison to 16 bytes at a
	time.
2018-03-06 19:22:40 +05:30
Siddhesh Poyarekar adc95fb06a Add ChangeLog entry for last 3 commits
Apparently I've forgotten how to commit to glibc.
2018-03-06 19:15:02 +05:30
Samuel Thibault 4e9066bc88 Add missing start-of-file descriptive comment.
* io/futimens.c: Add missing start-of-file descriptive comment.
	* io/utime.c: Likewise.
	* misc/futimesat.c: Likewise.
	* misc/utimes.c: Likewise.
	* sysdeps/mach/hurd/futimesat.c: Likewise.
	* sysdeps/mach/hurd/utimes.c: Likewise.
	* sysdeps/posix/utime.c: Likewise.
	* sysdeps/posix/utimes.c: Likewise.
	* sysdeps/unix/sysv/linux/futimesat.c: Likewise.
	* sysdeps/unix/sysv/linux/generic/futimesat.c: Likewise.
	* sysdeps/unix/sysv/linux/generic/utimes.c: Likewise.
	* sysdeps/unix/sysv/linux/utimes.c: Likewise.
2018-03-06 09:21:04 +01:00
Samuel Thibault ec1300cfc8 hurd: Add futimesat and utimensat support
* sysdeps/mach/hurd/utime-helper.c (hurd_futimens): Rename function to
	hurd_futimes.
	* sysdeps/mach/hurd/utimes.c (__utimes): Update call accordingly.
	* sysdeps/mach/hurd/lutimes.c (__lutimes): Likewise.
	* sysdeps/mach/hurd/futimens.c: Include "utime-helper.c".
	(__futimens): Move implementation to...
	* sysdeps/mach/hurd/utime-helper.c (utime_ts_from_tspec,
	utime_tvalue_from_tspec): ... new helper functions.
	(hurd_futimens): New function.
	* sysdeps/mach/hurd/futimesat.c: New file.
	* sysdeps/mach/hurd/utimensat.c: New file.
2018-03-06 00:14:26 +01:00
Flávio Cruz bbe762d1e5 hurd: Define and pass UTIME_NOW and UTIME_OMIT to new file_utimens RPC
* sysdeps/mach/hurd/bits/stat.h [__USE_ATFILE] (UTIME_NOW,
	UTIME_OMIT): New macros.
	* sysdeps/mach/hurd/futimens.c (__futimens): Try to use __file_utimens
	before reverting to converting time spec to time value and calling
	__file_utimes.
	* sysdeps/mach/hurd/utime-helper.c: New file.
	* sysdeps/mach/hurd/futimes.c: Include "utime-helper.c".
	(__futimes): Try to use utime_ts_from_tval and __file_utimens before
	reverting to utime_tvalue_from_tval and __file_utimes.
	* sysdeps/mach/hurd/lutimes.c: Include "utime-helper.c".
	(__lutimes): Just call hurd_futimens after lookup.
	* sysdeps/mach/hurd/utimes.c: Likewise.
2018-03-05 23:30:50 +01:00
Samuel Thibault a1ede3a402 hurd: Fix includability of <hurd/signal.h> in all standards
* bits/sigaction.h: Add include guard.
* sysdeps/unix/sysv/linux/alpha/bits/sigaction.h: Likewise.
* sysdeps/unix/sysv/linux/bits/sigaction.h: Likewise.
* sysdeps/unix/sysv/linux/hppa/bits/sigaction.h: Likewise.
* sysdeps/unix/sysv/linux/ia64/bits/sigaction.h: Likewise.
* sysdeps/unix/sysv/linux/mips/bits/sigaction.h: Likewise.
* sysdeps/unix/sysv/linux/s390/bits/sigaction.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/sigaction.h: Likewise.
* sysdeps/unix/sysv/linux/tile/bits/sigaction.h: Likewise.
* hurd/hurd/signal.h: Include <bits/sigaction.h>.
2018-03-05 22:50:29 +01:00
Joseph Myers 6900d2ca74 Fix s390 -Os iconv build.
Building glibc for s390 with -Os (32-bit only, with GCC 7) fails with:

In file included from ../sysdeps/s390/multiarch/8bit-generic.c:370:0,
                 from ebcdic-at-de.c:28:
../iconv/loop.c: In function '__to_generic_vx':
../iconv/loop.c:264:22: error: 'ch' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     if (((Character) >> 7) == (0xe0000 >> 7))          \
                      ^~
In file included from ebcdic-at-de.c:28:0:
../sysdeps/s390/multiarch/8bit-generic.c:340:15: note: 'ch' was declared here
      uint32_t ch;      \
               ^
../iconv/loop.c:325:7: note: in expansion of macro 'BODY'
       BODY
       ^~~~

It's fairly easy to see, looking at the (long) expansion of the BODY
macro, that this is a false positive and the relevant variable 'ch' is
always initialized before use, in one of two possible places.  As
such, disabling the warning for -Os with the DIAG_* macros is the
natural approach to fix this build failure.  However, because of the
location at which the warning is reported, the disabling needs to go
in iconv/loop.c, around the definition of UNICODE_TAG_HANDLER (not
inside the definition), as that macro definition is where the
uninitialized use is reported, whereas the code that needs to be
reasoned about to see that the warning is a false positive is in the
definition of BODY elsewhere.

Thus, the patch adds such disabling in iconv/loop.c, with a comment
pointing to the s390-specific code and a comment in the s390-specific
code pointing to the generic file to alert people to the possible need
to update one place when changing the other.  It would be possible if
desired to use #ifdef __s390__ around the disabling, though in general
we try to avoid that sort of thing in generic files.  (Or some
extremely specialized macros for "disable -Wmaybe-uninitialized in
this particular place" could be specified, defined to 0 in a lot of
different files that include iconv/loop.c and to 1 in that particular
s390 file.)

Tested that this fixed -Os compilation for s390-linux-gnu with
build-many-glibcs.py.

	* iconv/loop.c (UNICODE_TAG_HANDLER): Disable
	-Wmaybe-uninitialized for -Os.
	* sysdeps/s390/multiarch/8bit-generic.c (BODY): Add comment about
	this disabling.
2018-03-05 21:46:55 +00:00
Adhemerval Zanella 5226a81f55 Define _DIRENT_MATCHES_DIRENT64 regardless
This patch defines _DIRENT_MATCHES_DIRENT64 to either 0 or 1 and adjust its
usage from checking its definition to its value.

Checked on a build for major Linux abis.

	* bits/dirent.h (__INO_T_MATCHES_INO64_T): Define regardless whether
	__INO_T_MATCHES_INO64_T is defined.
	* sysdeps/unix/sysv/linux/bits/dirent.h: Likewise.
	* dirent/alphasort.c: Check _DIRENT_MATCHES_DIRENT64 value instead
	of definition.
	* dirent/alphasort64.c: Likewise.
	* dirent/scandir.c: Likewise.
	* dirent/scandir64-tail.c: Likewise.
	* dirent/scandir64.c: Likewise.
	* dirent/scandirat.c: Likewise.
	* dirent/scandirat64.c: Likewise.
	* dirent/versionsort.c: Likewise.
	* dirent/versionsort64.c: Likewise.
	* include/dirent.h: Likewise.
2018-03-05 18:10:04 -03:00
Adhemerval Zanella fbd01e6c44 nptl: Fix tst-cancel4 sendto tests
Now that send might be implemented calling sendto syscall on Linux,
I am seeing some issue in some kernel configurations where tst-cancel4
sendto do not block as expected.

The socket used to force the syscall blocking is used with default
system configuration for buffer sending size, which might not be
suffice to force blocking.  This patch fixes it by explicit setting
buffer socket lower than the buffer size used.  It also enables sendto
cancellation tests to work in both ways (since internally send is
implemented routing to sendto on Linux kernel).

The patch also removes unrequired make rules on some archictures
for send/recv. The generic nptl Makefile already set the compiler flags
required on some architectures for correct unwinding and libc object
are not strictly required to support unwind (since pthread_cancel
requires linking against libpthread).

Checked on aarch64-linux-gnu and x86_64-linux-gnu. I also did a
sniff test with tst-cancel{4,5} on a simulated mips64-linux-gnu.

	* nptl/tst-cancel4-common.h (set_socket_buffer): New function.
	* nptl/tst-cancel4-common.c (do_test): Call set_socket_buffer
	for socketpair endpoint.
	* nptl/tst-cancel4.c (tf_send): Call set_socket_buffer and use
	WRITE_BUFFER_SIZE as buffer size for sending socket.
	(tf_sendto): Use SOCK_STREAM instead of SOCK_DGRAM and fix an
	issue on system where send is implemented with sendto syscall.
	* sysdeps/unix/sysv/linux/mips/mips64/Makefile [$(subdir) = socket]
	(CFLAGS-recv.c, CFLAGS-send.c): Remove rules.
	[$(subdir) = nptl] (CFLAGS-recv.c, CFLAGS-send.c): Likewise.
	* sysdeps/unix/sysv/linux/riscv/rv64/Makefile: Remove file.
2018-03-05 18:09:08 -03:00
Adhemerval Zanella 68448be208 i386: Fix i386 sigaction sa_restorer initialization (BZ#21269)
This patch fixes the i386 sa_restorer field initialization for sigaction
syscall for kernel with vDSO.  As described in bug report, i386 Linux
(and compat on x86_64) interprets SA_RESTORER clear with nonzero
sa_restorer as a request for stack switching if the SS segment is 'funny'.
This means that anything that tries to mix glibc's signal handling with
segmentation (for instance through modify_ldt syscall) is randomly broken
depending on what values lands in sa_restorer.

The testcase added  is based on Linux test tools/testing/selftests/x86/ldt_gdt.c,
more specifically in do_multicpu_tests function.  The main changes are:

  - C11 atomics instead of plain access.

  - Remove x86_64 support which simplifies the syscall handling and fallbacks.

  - Replicate only the test required to trigger the issue.

Checked on i686-linux-gnu.

	[BZ #21269]
	* sysdeps/unix/sysv/linux/i386/Makefile (tests): Add tst-bz21269.
	* sysdeps/unix/sysv/linux/i386/sigaction.c (SET_SA_RESTORER): Clear
	sa_restorer for vDSO case.
	* sysdeps/unix/sysv/linux/i386/tst-bz21269.c: New file.
2018-03-05 18:08:27 -03:00
Samuel Thibault 8d965cde7a hurd: Add futimens support
* sysdeps/mach/hurd/futimens.c: New file.
2018-03-04 22:39:47 +01:00
Samuel Thibault 974393ea43 Separate out error_t definition
so interfaces needing it can get it.

	* stdlib/errno.h (error_t): Move definition to...
	* bits/types/error_t.h: ... new header.
	* stdlib/Makefile (headers): Add bits/types/error_t.h.
	* sysdeps/mach/hurd/bits/errno.h (error_t): Move definition to...
	* sysdeps/mach/hurd/bits/types/error_t.h: ... new header.
	* sysdeps/mach/hurd/errnos.awk (error_t): Likewise.
	* hurd/hurd.h: Include <bits/types/error_t.h>
	* hurd/hurd/fd.h: Include <bits/types/error_t.h>
	* hurd/hurd/id.h: Include <errno.h> and <bits/types/error_t.h>
	* hurd/hurd/lookup.h: Include <errno.h> and <bits/types/error_t.h>
	* hurd/hurd/resource.h: Include <bits/types/error_t.h>
	* hurd/hurd/signal.h: Include <bits/types/error_t.h>
	* hurd/hurd/sigpreempt.h: Include <bits/types/error_t.h>
2018-03-04 17:27:58 +01:00
Samuel Thibault ba89615dab hurd: Make almost all hurd headers includable in all standards
* hurd/hurd.h: Include <bits/types/sigset_t.h>
	* hurd/hurd/fd.h: Include <sys/select.h> and <bits/types/sigset_t.h>
	(_hurd_fd_read, _hurd_fd_write): Use __loff_t instead of loff_t.
	* hurd/hurd/signal.h: Include <bits/types/stack_t.h> and
	<bits/types/sigset_t.h>.
	[!defined __USE_GNU]: Do not #error out.
	(struct hurd_sigstate): Use _NSIG instead of NSIG.
	* hurd/hurd/sigpreempt.h (__need_size_t): Define.
	Include <stddef.h> and <bits/types/sigset_t.h>
	(struct hurd_signal_preemptor, hurd_catch_signal): Use __sighandler_t
	instead of sighandler_t.
2018-03-04 04:03:13 +01:00
Samuel Thibault a726c87a14 hurd: Fix inclusion of mach headers in all standards
mig_support does not actually inline the stpncpy any more.

	* mach/mach/mig_support.h [defined __USE_GNU]: Do not #error out.
	* scripts/check-installed-headers.sh: Do not ignore Hurd and Mach
	headers.
2018-03-04 02:53:09 +01:00
Samuel Thibault 95dfdbd28c hurd: Avoid using ino64_t and loff_t in headers
* mach/Machrules ($(patsubst %,$(objpfx)%.h,$(user-interfaces)):
	Process mig output through $(migheaderpipe).
	* hurd/Makefile (migheaderpipe): Define variable.
2018-03-04 02:13:56 +01:00
Samuel Thibault 44c6376ca3 hurd: Add missing include
* sysdeps/mach/hurd/dl-sysdep.c: Include <mach/machine/vm_param.h>.
2018-03-04 01:59:30 +01:00
Samuel Thibault 48d34cbc23 hurd: fix header conformity
* hurd/hurd/fd.h (_hurd_fd_error): Fix struct initializer to be
	trivial, for C++ conformity.
2018-03-04 01:35:38 +01:00
Samuel Thibault 3403cb7dd4 hurd: avoid including hurd/signal.h when not needed
thus making <hurd/port.h> and <hurd/userlink.h> includable without
_GNU_SOURCE.

	* hurd/hurd/port.h: Do not include <hurd/signal.h>.
	* hurd/hurd/userlink.h [!defined __USE_EXTERN_INLINES ||
	!defined _LIBC || !IS_IN (libc)]: Do not include <hurd/signal.h>.
2018-03-04 01:28:55 +01:00
Samuel Thibault 430fd94599 hurd: Move mach/param.h to bits/mach/param.h
* mach/Makefile (headers): Move mach/param.h to bits/mach/param.h.
	* sysdeps/mach/i386/mach/param.h: Move file to ...
	* sysdeps/mach/i386/bits/mach/param.h: ... here.  Update path in #error.
	* sysdeps/mach/hurd/bits/param.h: Include <bits/mach/param.h> instead
	of <mach/param.h>.
2018-03-04 00:42:20 +01:00
Samuel Thibault f4bff843cd hurd: Add missing includes
* mach/Makefile ($(objpfx)mach-shortcuts.h): Make it include
	<mach/mach_types.h> and <mach/message.h>.
2018-03-04 00:14:12 +01:00
Samuel Thibault e30c291a6d hurd: Add missing includes
* hurd/hurd/id.h: Include <hurd/hurd_types.h>
	* hurd/hurd/ioctl.h: Include <mach/port.h>
	* hurd/hurd/lookup.h: Include <hurd/hurd_types.h>
2018-03-03 23:58:51 +01:00
Samuel Thibault eb1ca47e55 hurd: do not check Mach and Hurd headers
as they are not standard.

	* scripts/check-installed-headers.sh: Ignore Hurd and Mach headers.
2018-03-03 20:18:12 +01:00
Andreas Schwab eaf6753f8a Fix multiple definitions of __nss_*_database (bug 22918) 2018-03-03 17:44:24 +01:00
Joseph Myers 4dc23804a2 Fix powerpc ifunc-sel.h build for -Os.
Compiling the testsuite for powerpc (multi-arch configurations) with
-Os with GCC 7 fails with:

In file included from ifuncmod1.c:7:0,
                 from ifuncdep1.c:3:
../sysdeps/powerpc/ifunc-sel.h: In function 'ifunc_sel':
../sysdeps/powerpc/ifunc-sel.h:12:3: error: asm operand 2 probably doesn't match constraints [-Werror]
   __asm__ ("mflr 12\n\t"
   ^~~~~~~
../sysdeps/powerpc/ifunc-sel.h:12:3: error: asm operand 3 probably doesn't match constraints [-Werror]
../sysdeps/powerpc/ifunc-sel.h:12:3: error: asm operand 4 probably doesn't match constraints [-Werror]
../sysdeps/powerpc/ifunc-sel.h:12:3: error: impossible constraint in 'asm'

The "i" constraints on function pointers require the function call to
be inlined so the compiler can see the constant function pointer
arguments passed to the asm.  This patch marks the relevant functions
as always_inline accordingly.

Tested that this fixes the -Os testsuite build for
powerpc-linux-gnu-power4, powerpc64-linux-gnu, powerpc64le-linux-gnu
with build-many-glibcs.py.

	* sysdeps/powerpc/ifunc-sel.h (ifunc_sel): Make always_inline.
	(ifunc_one): Likewise.
2018-03-02 22:27:56 +00:00
DJ Delorie 1c81d55fc4 [BZ #22342] Fix netgroup cache keys.
Unlike other nscd caches, the netgroup cache contains two types of
records - those for "iterate through a netgroup" (i.e. setnetgrent())
and those for "is this user in this netgroup" (i.e. innetgr()),
i.e. full and partial records.  The timeout code assumes these records
have the same key for the group name, so that the collection of records
that is "this netgroup" can be expired as a unit.

However, the keys are not the same, as the in-netgroup key is generated
by nscd rather than being passed to it from elsewhere, and is generated
without the trailing NUL.  All other keys have the trailing NUL, and as
noted in the linked BZ, debug statements confirm that two keys for the
same netgroup are added to the cache with two different lengths.

The result of this is that as records in the cache expire, the purge
code only cleans out one of the two types of entries, resulting in
stale, possibly incorrect, and possibly inconsistent cache data.

The patch simply includes the existing NUL in the computation for the
key length ('key' points to the char after the NUL, and 'group' to the
first char of the group, so 'key-group' includes the first char to the
NUL, inclusive).

	[BZ #22342]
	* nscd/netgroupcache.c (addinnetgrX): Include trailing NUL in
	key value.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-03-01 23:23:24 -05:00
Maciej W. Rozycki b717c14fb1 nptl_db: Remove stale `match_pid' parameter from `iterate_thread_list'
Complement commit c579f48edb ("Remove cached PID/TID in clone") and
remove the `match_pid' parameter not used by `iterate_thread_list' any
longer.  Update call sites accordingly.

	* nptl_db/td_ta_thr_iter.c (iterate_thread_list): Remove
	`match_pid' parameter.
	(td_ta_thr_iter): Update accordingly.
2018-03-01 16:10:05 +00:00
Florian Weimer 1efe135861 nptl: Turn libpthread.so into a symbolic link to the real DSO
The linker script is no longer needed.
2018-03-01 16:14:47 +01:00
Mike FABIAN a527f09cd1 an_ES locale: update some locale data [BZ #22896]
[BZ #22896]
	* localedata/locales/an_ES: update month and day names,
	improve d_fmt, improve postal_fmt, add country_post,
	add country_isbn
2018-03-01 15:06:24 +01:00
Mike FABIAN 35d660b01e bg_BG locale: Fix a typo in a comment
* localedata/locales/bg_BG (LC_COLLATE): The comment mentioned
	Ukrainian instead of Bulgarian.
2018-03-01 14:52:26 +01:00
Florian Weimer 1a2f44a848 nptl: Drop libpthread_nonshared.a from libpthread.so
Fixes commit bd60ce8652 (nptl: Move
pthread_atfork to libc_nonshared.a).
2018-03-01 12:53:09 +01:00
Florian Weimer bd60ce8652 nptl: Move pthread_atfork to libc_nonshared.a
libpthread_nonshared.a is unused after this, so remove it from the
build.

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

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

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-03-01 08:18:48 +01:00
Joseph Myers e2bcf6a855 Fix i386 fenv_private.h float128 for 32-bit --with-fpmath=sse (bug 22902).
As discussed in bug 22902, the i386 fenv_private.h implementation has
problems for float128 for the case of 32-bit glibc built with libgcc
from GCC configured using --with-fpmath=sse.

The optimized floating-point state handling in fenv_private.h needs to
know which floating-point state - x87 or SSE - is used for each
floating-point type, so that only one state needs updating / testing
for libm code using that state internally.  On 32-bit x86, the x87
rounding mode is always used for float128, but the x87 exception flags
are only used when libgcc is built using x87 floating-point
arithmetic; if libgcc is built for SSE arithmetic, the SSE exception
flags are used.

The choice of arithmetic with which libgcc is built is independent of
that with which glibc is built.  Thus, since glibc cannot tell the
choice used in libgcc, the default implementations of
libc_feholdexcept_setroundf128 and libc_feupdateenv_testf128 (which
use the <fenv.h> functions, thus using both x87 and SSE state on
processors that have both) need to be used; this patch updates the
code accordingly.

Tested for 32-bit x86; HJ reports testing in the --with-fpmath=sse
case.

	[BZ #22902]
	* sysdeps/i386/fpu/fenv_private.h [!__x86_64__]
	(libc_feholdexcept_setroundf128): New macro.
	[!__x86_64__] (libc_feupdateenv_testf128): Likewise.
2018-02-28 21:55:51 +00:00
Joseph Myers 000f290ff1 Use libc_hidden_* for strtoumax (bug 15105).
On sparc, localplt test failures appear when building with -Os because
of a call to strtoumax from
sysdeps/unix/sysv/linux/sparc/sparc64/get_clockfreq.c, and strtoumax
is not inlined when building with -Os.  This patch fixes those
failures by using libc_hidden_proto and libc_hidden_def for strtoumax.

Tested with build-many-glibcs.py for
sparc64-linux-gnu-disable-multi-arch, sparc64-linux-gnu,
sparcv9-linux-gnu-disable-multi-arch, sparcv9-linux-gnu that this
fixes that test failure with -Os.

	[BZ #15105]
	* sysdeps/wordsize-32/strtoumax.c (strtoumax): Use
	libc_hidden_def.
	* sysdeps/wordsize-64/strtoumax.c (strtoumax): Likewise.
	* include/inttypes.h: New file.
2018-02-28 14:16:21 +00:00
Joseph Myers 02f2fead8f Fix two more -Os strcoll / wcscoll build failures.
Continuing fixes for -Os build issues shown with build-many-glibcs.py,
this patch adds uses of DIAG_* to disable -Wmaybe-uninitialized in two
more places where code inlined from strcoll / wcscoll is wrongly
diagnosed as possibly using uninitialized structure fields.  (All
these warnings in different places for these functions are I think
essentially the same bug.)

Tested with build-many-glibcs.py for alpha-linux-gnu and
mips-linux-gnu that this fixes the -Os build failures for those
configurations with GCC 7.

	* locale/weightwc.h (findidx): Ignore -Wmaybe-uninitialized for
	-Os in two more places.
2018-02-27 16:55:42 +00:00
Mike FABIAN 874c56d797 Remove the lines from cmn_TW.UTF-8.in which cannot work at the moment.
See this bug https://sourceware.org/bugzilla/show_bug.cgi?id=22898

These lines don’t yet work because of a glibc bug, not because of
problems in the locale data. No matter what sorting rules one uses,
these characters cannot be sorted at all at the moment.

As soon as that bug is fixed, these lines should be added back to the
test file.

	* localedata/cmn_TW.UTF-8.in: Remove the lines which cannot
        be sorted correctly at the moment because of a bug.
2018-02-27 17:47:51 +01:00
Mike FABIAN 1597385481 Adapt collation in several locales to the new iso14651_t1_common file
[BZ #22550] - es_ES locale (and other es_* locales): collation should
treat ñ as a primary different character, sync the collation
for Spanish with CLDR
[BZ #21547] - Tibetan script collation broken (Dzongkha and Tibetan)

	* localedata/Makefile: Add new test files.
	* localedata/lv_LV.UTF-8.in: Adapt test file to new collation order.
	* localedata/sv_SE.ISO-8859-1.in: Adapt test file to new collation order.
	* localedata/uk_UA.UTF-8.in: Adapt test file to new collation order.
	* localedata/am_ET.UTF-8.in: New test file.
	* localedata/az_AZ.UTF-8.in: Likewise.
	* localedata/be_BY.UTF-8.in: Likewise.
	* localedata/ber_DZ.UTF-8.in: Likewise.
	* localedata/ber_MA.UTF-8.in: Likewise.
	* localedata/bg_BG.UTF-8.in: Likewise.
	* localedata/br_FR.UTF-8.in: Likewise.
	* localedata/cmn_TW.UTF-8.in: Likewise.
	* localedata/crh_UA.UTF-8.in: Likewise.
	* localedata/csb_PL.UTF-8.in: Likewise.
	* localedata/cv_RU.UTF-8.in: Likewise.
	* localedata/cy_GB.UTF-8.in: Likewise.
	* localedata/dz_BT.UTF-8.in: Likewise.
	* localedata/eo.UTF-8.in: Likewise.
	* localedata/es_ES.UTF-8.in: Likewise.
	* localedata/fa_IR.UTF-8.in: Likewise.
	* localedata/fi_FI.UTF-8.in: Likewise.
	* localedata/fil_PH.UTF-8.in: Likewise.
	* localedata/fur_IT.UTF-8.in: Likewise.
	* localedata/gez_ER.UTF-8@abegede.in: Likewise.
	* localedata/ha_NG.UTF-8.in: Likewise.
	* localedata/ig_NG.UTF-8.in: Likewise.
	* localedata/ik_CA.UTF-8.in: Likewise.
	* localedata/kk_KZ.UTF-8.in: Likewise.
	* localedata/ku_TR.UTF-8.in: Likewise.
	* localedata/ky_KG.UTF-8.in: Likewise.
	* localedata/ln_CD.UTF-8.in: Likewise.
	* localedata/mi_NZ.UTF-8.in: Likewise.
	* localedata/ml_IN.UTF-8.in: Likewise.
	* localedata/mn_MN.UTF-8.in: Likewise.
	* localedata/mr_IN.UTF-8.in: Likewise.
	* localedata/mt_MT.UTF-8.in: Likewise.
	* localedata/nb_NO.UTF-8.in: Likewise.
	* localedata/om_KE.UTF-8.in: Likewise.
	* localedata/os_RU.UTF-8.in: Likewise.
	* localedata/ps_AF.UTF-8.in: Likewise.
	* localedata/ro_RO.UTF-8.in: Likewise.
	* localedata/ru_RU.UTF-8.in: Likewise.
	* localedata/sc_IT.UTF-8.in: Likewise.
	* localedata/se_NO.UTF-8.in: Likewise.
	* localedata/sq_AL.UTF-8.in: Likewise.
	* localedata/sv_SE.UTF-8.in: Likewise.
	* localedata/szl_PL.UTF-8.in: Likewise.
	* localedata/tg_TJ.UTF-8.in: Likewise.
	* localedata/tk_TM.UTF-8.in: Likewise.
	* localedata/tt_RU.UTF-8.in: Likewise.
	* localedata/tt_RU.UTF-8@iqtelif.in: Likewise.
	* localedata/ug_CN.UTF-8.in: Likewise.
	* localedata/uz_UZ.UTF-8.in: Likewise.
	* localedata/vi_VN.UTF-8.in: Likewise.
	* localedata/yi_US.UTF-8.in: Likewise.
	* localedata/yo_NG.UTF-8.in: Likewise.
	* localedata/zh_CN.UTF-8.in: Likewise.
	* localedata/locales/am_ET: Adapt collation rules to new iso14651_t1_common
        file and fix bugs in the collation.
	* localedata/locales/az_AZ: Likewise.
	* localedata/locales/be_BY: Likewise.
	* localedata/locales/ber_DZ: Likewise.
	* localedata/locales/ber_MA: Likewise.
	* localedata/locales/bg_BG: Likewise.
	* localedata/locales/br_FR: Likewise.
	* localedata/locales/br_FR@euro: Likewise.
	* localedata/locales/ca_ES: Likewise.
	* localedata/locales/cns11643_stroke: Likewise.
	* localedata/locales/crh_UA: Likewise.
	* localedata/locales/cs_CZ: Likewise.
	* localedata/locales/csb_PL: Likewise.
	* localedata/locales/cv_RU: Likewise.
	* localedata/locales/cy_GB: Likewise.
	* localedata/locales/da_DK: Likewise.
	* localedata/locales/dz_BT: Likewise.
	* localedata/locales/en_CA: Likewise.
	* localedata/locales/eo: Likewise.
	* localedata/locales/es_CU: Likewise.
	* localedata/locales/es_EC: Likewise.
	* localedata/locales/es_ES: Likewise.
	* localedata/locales/es_US: Likewise.
	* localedata/locales/et_EE: Likewise.
	* localedata/locales/fa_IR: Likewise.
	* localedata/locales/fi_FI: Likewise.
	* localedata/locales/fil_PH: Likewise.
	* localedata/locales/fur_IT: Likewise.
	* localedata/locales/gez_ER@abegede: Likewise.
	* localedata/locales/ha_NG: Likewise.
	* localedata/locales/hr_HR: Likewise.
	* localedata/locales/hsb_DE: Likewise.
	* localedata/locales/hu_HU: Likewise.
	* localedata/locales/ig_NG: Likewise.
	* localedata/locales/ik_CA: Likewise.
	* localedata/locales/is_IS: Likewise.
	* localedata/locales/iso14651_t1_pinyin: Likewise.
	* localedata/locales/kk_KZ: Likewise.
	* localedata/locales/ku_TR: Likewise.
	* localedata/locales/ky_KG: Likewise.
	* localedata/locales/ln_CD: Likewise.
	* localedata/locales/lt_LT: Likewise.
	* localedata/locales/lv_LV: Likewise.
	* localedata/locales/mi_NZ: Likewise.
	* localedata/locales/ml_IN: Likewise.
	* localedata/locales/mn_MN: Likewise.
	* localedata/locales/mr_IN: Likewise.
	* localedata/locales/mt_MT: Likewise.
	* localedata/locales/nb_NO: Likewise.
	* localedata/locales/om_KE: Likewise.
	* localedata/locales/os_RU: Likewise.
	* localedata/locales/pl_PL: Likewise.
	* localedata/locales/ps_AF: Likewise.
	* localedata/locales/ro_RO: Likewise.
	* localedata/locales/ru_RU: Likewise.
	* localedata/locales/ru_UA: Likewise.
	* localedata/locales/sc_IT: Likewise.
	* localedata/locales/se_NO: Likewise.
	* localedata/locales/si_LK: Likewise.
	* localedata/locales/sq_AL: Likewise.
	* localedata/locales/sv_FI: Likewise.
	* localedata/locales/sv_FI@euro: Likewise.
	* localedata/locales/sv_SE: Likewise.
	* localedata/locales/szl_PL: Likewise.
	* localedata/locales/tg_TJ: Likewise.
	* localedata/locales/ti_ER: Likewise.
	* localedata/locales/tk_TM: Likewise.
	* localedata/locales/tl_PH: Likewise.
	* localedata/locales/tr_TR: Likewise.
	* localedata/locales/tt_RU: Likewise.
	* localedata/locales/tt_RU@iqtelif: Likewise.
	* localedata/locales/ug_CN: Likewise.
	* localedata/locales/uk_UA: Likewise.
	* localedata/locales/uz_UZ: Likewise.
	* localedata/locales/uz_UZ@cyrillic: Likewise.
	* localedata/locales/vi_VN: Likewise.
	* localedata/locales/yi_US: Likewise.
	* localedata/locales/yo_NG: Likewise.
2018-02-27 17:47:50 +01:00
Mike FABIAN ce6636b06b Improve gen-locales.mk and gen-locale.sh to make test files with @ options work
With out this, adding collation test files like localedata/gez_ER.UTF-8@abegede.in
does not work for locales which contain @ modifiers.

	* gen-locales.mk: Make test files which contain @ modifiers in their
        name work.
	* localedata/gen-locale.sh: Likewise.
2018-02-27 17:01:57 +01:00
Mike FABIAN ac3a3b4b0d Fix test cases tst-fnmatch and tst-regexloc for the new iso14651_t1_common file.
See:

http://pubs.opengroup.org/onlinepubs/7908799/xbd/re.html

> A range expression represents the set of collating elements that fall
> between two elements in the current collation sequence,
> inclusively. It is expressed as the starting point and the ending
> point separated by a hyphen (-).
>
> Range expressions must not be used in portable applications because
> their behaviour is dependent on the collating sequence. Ranges will be
> treated according to the current collating sequence, and include such
> characters that fall within the range based on that collating
> sequence, regardless of character values. This, however, means that
> the interpretation will differ depending on collating sequence. If,
> for instance, one collating sequence defines ä as a variant of a,
> while another defines it as a letter following z, then the expression
> [ä-z] is valid in the first language and invalid in the second.

Therefore, using [a-z] does not make much sense except in the C/POSIX locale.
The new iso14651_t1_common lists upper case and  lower case Latin characters
in a different order than the old one which causes surprising results
for example in the de_DE locale: [a-z] now includes A because A comes
after a in iso14651_t1_common but does not include Z because that comes
after z in iso14651_t1_common.

	* posix/tst-fnmatch.input: Fix results for range expressions
        for non C locales.
	* posix/tst-regexloc.c: Do not use a range expression for
        de_DE.ISO-8859-1 locale.
2018-02-27 17:00:21 +01:00
Mike FABIAN 770cbe147c Fix posix/bug-regex5.c test case, adapt to iso14651_t1_common upate
This test case tests how many collating elements are defined in
da_DK.ISO-8859-1 locale. The da_DK locale source defines 4:

collating-element <A-A> from "<U0041><U0041>"
collating-element <A-a> from "<U0041><U0061>"
collating-element <a-A> from "<U0061><U0041>"
collating-element <a-a> from "<U0061><U0061>"

The new iso14651_t1_common file defines more collating elements, two
of them are in the ISO-8859-1 range:

collating-element <U004C_00B7> from "<U004C><U00B7>" % decomposition of LATIN CAPITAL LETTER L WITH MIDDLE DOT
collating-element <U006C_00B7> from "<U006C><U00B7>" % decomposition of LATIN SMALL LETTER L WITH MIDDLE DOT

So the total count is now 6 instead of 4.

	* posix/bug-regex5.c: Fix test case because with the new
        iso14651_t1_common file, the da_DK locale now has 6 collating elements
        in the ISO-8859-1 range instead of 4 with the old iso14651_t1_common
        file.
2018-02-27 16:58:44 +01:00
Mike FABIAN 0fc355d9a7 Collation order of @-. and space has changed in new iso14651_t1_common file, adapt test files
* localedata/da_DK.ISO-8859-1.in: In the new iso14651_t1_common file
        downloaded from ISO, the collation order of @-. and space has changed.
        Therefore, this test file needed to be adapted.
	* localedata/fr_CA.UTF-8.in: Likewise.
	* localedata/fr_FR.UTF-8.in: Likewise.
	* localedata/uk_UA.UTF-8.in: Likewise.
2018-02-27 16:56:25 +01:00
Mike FABIAN 43f3893f4b Collation order of ȥ has changed in new iso14651_t1_common file, adapt test files
* localedata/cs_CZ.UTF-8.in: adapt this test file to the collation
        order of ȥ in the new iso14651_t1_common file.
	* localedata/pl_PL.UTF-8.in: Likewise.
2018-02-27 16:54:31 +01:00
Mike FABIAN df74ef786f Add sections for various scripts to the iso14651_t1_common file
* localedata/locales/iso14651_t1_common: Add sections for various
	scripts to the iso14651_t1_common file.
2018-02-27 16:52:54 +01:00
Mike FABIAN d5adfbadd4 iso14651_t1_common: make the fourth level the codepoint for characters which are ignorable on all 4 levels
Entries for characters which have “IGNORE” on all 4 levels like:

 <U0001> IGNORE;IGNORE;IGNORE;IGNORE % START OF HEADING (in ISO 6429)

are changed into:

 <U0001> IGNORE;IGNORE;IGNORE;<U0001> % START OF HEADING (in ISO 6429)

i.e. putting the code point of the character into the fourth level
instead of “IGNORE”. Without that change, all such characters
would compare equal which would make a wcscoll test case fail.
It is better to have a clearly defined sort order even for characters
like this so it is good to use the code point as a tie-break.

	* localedata/locales/iso14651_t1_common: Use the code point of a
        character in the fourth collation level instead of IGNORE for all
        entries which have IGNORE on all 4 levels.
2018-02-27 16:50:30 +01:00
Mike FABIAN 5f5a961091 Add convenience symbols like <AFTER-A>, <BEFORE-A> to iso14651_t1_common
* localedata/locales/iso14651_t1_common: Add some convenient collation
	symbols like <AFTER-A>, <BEFORE-A> to make tailoring easier using
	rules similar to those in CLDR.
2018-02-27 16:47:22 +01:00
Mike FABIAN 8a97e9002f Fixing syntax errors after updating the iso14651_t1_common file
* localedata/locales/iso14651_t1_common: The new version of this
	file downloaded from ISO contained several syntax errors which
	are fixed by this patch.
2018-02-27 16:45:30 +01:00
Mike FABIAN bbdd2fba7d iso14651_t1_common: <U\([0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F]\)> → <U000\1>
* localedata/locales/iso14651_t1_common: replace all <U.....>
	with <U000.....> because glibc understands only 4 digit or 8 digit
2018-02-27 16:44:03 +01:00
Mike FABIAN 1569e551af Necessary changes after updating the iso14651_t1_common file
* localedata/locales/iso14651_t1_common: Necessary changes
	to make the file downloaded from ISO usable by glibc.
2018-02-27 16:42:14 +01:00
Mike FABIAN 9479b6d5e0 Update iso14651_t1_common file to ISO14651_2016_TABLE1_en.txt [BZ #14095]
[BZ #14095] - Review / update collation data from Unicode / ISO 14651

File downloaded from:
http://standards.iso.org/iso-iec/14651/ed-4/ISO14651_2016_TABLE1_en.txt

Updating this file alone is not enough, there are problems in the new
file which need to be fixed and the collation rules for many locales
need to be adapted. This is done by the following patches.

This update also fixes the problem that many characters are treated as
identical when sorting because they were not yet in the old
iso14651_t1_common file, see:

https://bugzilla.redhat.com/show_bug.cgi?id=1336308
- Infinite (∞) and empty set (∅) are treated as if they were the same character by sort and uniq

	[BZ #14095]
	* localedata/locales/iso14651_t1_common: Update file to
	latest version from ISO (ISO14651_2016_TABLE1_en.txt).
2018-02-27 16:36:31 +01:00
Samuel Thibault 7211eba676 hurd: fix gai_misc build
* sysdeps/mach/hurd/gai_misc.h: New file.
2018-02-27 01:11:08 +01:00
Samuel Thibault eb937a5285 hurd: fix timer_routines.c build
* sysdeps/pthread/timer_routines.c: [!defined DELAYTIMER_MAX]
        (DELAYTIMER_MAX): Define to INT_MAX.
2018-02-27 00:55:59 +01:00
Samuel Thibault 03b540b368 Move NPTL-specific code to NPTL-specific header
* sysdeps/pthread/timer_routines.c: Include <timer_routines.h> instead
	of <nptl/pthreadP.h>
	(thread_attr_compare): Move function to...
	* sysdeps/nptl/timer_routines.h: ... new header.
2018-02-27 00:48:24 +01:00
Joseph Myers f54d8f735a Fix another -Os strcoll build issue.
While there are now clean -Os build and test results on x86_64 (given
my patch <https://sourceware.org/ml/libc-alpha/2018-02/msg00602.html>,
pending review), testing with -Os with build-many-glibcs.py shows the
build is still failing with -Os everywhere except for x86_64, x86 and
s390x.

There are a variety of different build failures, but the most common
seem to be in strcoll / wcscoll, similar to existing such cases where
DIAG_* are used to disable -Wmaybe-uninitialized.  There are various
different failures even within those functions.  This patch fixes one
particular case that seems quite common, where the warning appears at
the declarations of seq1 and seq2.

Tested with build-many-glibcs.py that this fixes the -Os build for
aarch64-linux-gnu with GCC 7.

	* string/strcoll_l.c: Include <libc-diag.h>.
	(STRCOLL): Ignore -Wmaybe-uninitialized for -Os around
	declarations of seq1 and seq2.
2018-02-26 18:38:01 +00:00
Joseph Myers 20602c72fa Use libc_hidden_* for atoi (bug 15105).
Continuing the fixes for localplt test failures with -Os arising from
functions not being inlined in that case, this patch fixes such
failures for atoi by using libc_hidden_proto and libc_hidden_def.

Tested for x86_64 (both that it removes this particular localplt
failure for -Os, and that the testsuite continues to pass without
-Os).

	[BZ #15105]
	* stdlib/atoi.c (atoi): Use libc_hidden_def.
	* include/stdlib.h [!_ISOMAC] (atoi): Use libc_hidden_proto.
2018-02-26 18:17:47 +00:00
Dmitry V. Levin f5f473a9d0 linux/powerpc: sync sys/ptrace.h with Linux 4.15 [BZ #22433, #22807]
Tested with strace.

* sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h (__ptrace_request): Add
PTRACE_GETREGS, PTRACE_SETREGS, PTRACE_GETFPREGS, PTRACE_SETFPREGS,
PTRACE_GETVRREGS, PTRACE_SETVRREGS, PTRACE_GETEVRREGS,
PTRACE_SETEVRREGS, PTRACE_GETREGS64, PTRACE_SETREGS64,
PTRACE_GET_DEBUGREG, PTRACE_SET_DEBUGREG, PTRACE_GETVSRREGS,
PTRACE_SETVSRREGS, and PTRACE_SINGLEBLOCK.
2018-02-26 13:46:31 +00:00
Tulio Magno Quites Machado Filho 398c6fddaf powerpc: Undefine Linux ptrace macros that conflict with __ptrace_request
Linux ptrace headers define macros whose tokens conflict with the
constants of enum __ptrace_request causing build errors when
asm/ptrace.h or linux/ptrace.h are included before sys/ptrace.h.

	* sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h: Undefine Linux
	macros used in __ptrace_request.

Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
2018-02-26 10:40:34 -03:00
H.J. Lu d863cd712e Fix a typo in ChangeLog (bit_cpu_BIT -> bit_cpu_IBT) 2018-02-26 04:54:14 -08:00
DJ Delorie 7e04eb2932 Update ChangeLog for BZ 22884 - riscv fmax/fmin 2018-02-23 16:08:08 -05:00
H.J. Lu f5d1f629c6 Define GEN_AS_CONST_HEADERS when generating header files [BZ #22792]
Glibc build generates header files to define constants from special .sym
files.  If a .sym file includes the same header file which it generates,
it leads to circular dependency which may lead to build hang on a
many-core machine.  Define GEN_AS_CONST_HEADERS when generating header
files to avoid circular dependency.

<tcb-offsets.h> is needed for i686 and it isn't needed for x86-64 at
least since glibc 2.23.

Tested on i686 and x86-64.

	[BZ #22792]
	* Makerules ($(common-objpfx)%.h): Pass -DGEN_AS_CONST_HEADERS
	to $(CC).
	* sysdeps/unix/sysv/linux/i386/lowlevellock.h: Include
	<tcb-offsets.h> only if GEN_AS_CONST_HEADERS isn't defined.
	* sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Don't include
	<tcb-offsets.h>.
2018-02-23 11:29:39 -08:00
Joseph Myers 54412d2061 Use libc_hidden_* for tolower, toupper (bug 15105).
Continuing the fixes for localplt test failures with -Os arising from
functions not being inlined in that case, this patch fixes such
failures for tolower and toupper by using libc_hidden_proto and
libc_hidden_def.

Tested for x86_64 (both that it removes this particular localplt
failure for -Os, and that the testsuite continues to pass without
-Os).

2018-02-22  Joseph Myers  <joseph@codesourcery.com>

	[BZ #15105]
	* ctype/ctype.c (tolower): Use libc_hidden_def.
	(toupper): Likewise.
	* include/ctype.h [!_ISOMAC] (tolower): Use libc_hidden_proto.
	[!_ISOMAC] (toupper): Likewise.
2018-02-23 13:54:53 +00:00
Mike FABIAN 81be4b5e38 Remove --quiet argument when installing locales
Using this argument hides problems. I would like to see when something fails.

	* localedata/Makefile: Remove --quiet argument when
	installing locales
2018-02-23 09:51:56 +01:00
Mike FABIAN 9d5cfd8e83 Use / instead of - in d_fmt for pt_BR and pt_PT [BZ #17438]
[BZ #17438]
	* localedata/locales/pt_BR (LC_TIME): use / instead of -
	in d_fmt.
	* localedata/locales/pt_PT (LC_TIME): likewise
2018-02-23 09:50:29 +01:00
Mike FABIAN 6c7269f31d Use “copy "es_BO"” in LC_TIME of es_CU, es_CL, and es_EC
LC_TIME in these 4 locales is identical, using “copy "es_BO"” makes
that more obvious.

	[BZ #22646]
	* localedata/locales/es_CL (LC_TIME): copy "es_BO".
	* localedata/locales/es_CU (LC_TIME): copy "es_BO".
	* localedata/locales/es_EC (LC_TIME): copy "es_BO".
2018-02-23 09:49:03 +01:00
Adhemerval Zanella 4cdc25a4a1 Update sparc ulps
* sysdeps/sparc/fpu/libm-test-ulps: Update.
2018-02-22 16:44:58 -03:00
Adhemerval Zanella 27761a1042 Refactor atfork handlers
Current implementation (sysdeps/nptl/fork.c) replicates the atfork
handlers list backward to invoke the child handlers after fork/clone
syscall.

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

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

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

Checked on x86_64-linux-gnu.

	* nptl/Makefile (routines): Remove unregister-atfork.
	* nptl/register-atfork.c (fork_handler_pool): Remove variable.
	(fork_handler_alloc): Remove function.
	(fork_handlers, fork_handler_init): New variables.
	(__fork_lock): Rename to atfork_lock.
	(__register_atfork, __unregister_atfork, libc_freeres_fn): Rewrite
	to use a dynamic array to add/remove atfork handlers.
	* sysdeps/nptl/fork.c (__libc_fork): Likewise.
	* sysdeps/nptl/fork.h (__fork_lock, __fork_handlers, __linkin_atfork):
	Remove declaration.
	(fork_handler): Remove next, refcntr, and need_signal member.
	(__run_fork_handler_type): New enum.
	(__run_fork_handlers): New prototype.
	* sysdeps/nptl/libc-lockP.h (__libc_atfork): Remove declaration.
2018-02-22 16:43:59 -03:00
Adhemerval Zanella 92aabad9b2 Rename nptl-signals.h to internal-signals.h
This patch renames the nptl-signals.h header to internal-signals.h.
On Linux the definitions and functions are not only NPTL related, but
used for other POSIX definitions as well (for instance SIGTIMER for
posix times, SIGSETXID for id functions, and signal block/restore
helpers) and since generic functions will be places and used in generic
implementation it makes more sense to decouple it from NPTL.

Checked on x86_64-linux-gnu.

	* sysdeps/nptl/nptl-signals.h: Move to ...
	* sysdeps/generic/internal-signals.h: ... here.  Adjust internal
	comments.
	* sysdeps/unix/sysv/linux/internal-signals.h: Add include guards.
	(__nptl_is_internal_signal): Rename to __is_internal_signal.
	(__nptl_clear_internal_signals): Rename to __clear_internal_signals.
	* sysdeps/unix/sysv/linux/raise.c: Adjust nptl-signal.h to
	include-signals.h rename.
	* nptl/pthreadP.h: Likewise.
	* sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Call
	__is_internal_signal instead of __nptl_is_internal_signal.
2018-02-22 16:43:59 -03:00
Andrew Waterman fdcc625376 RISC-V: fmax/fmin: Handle signalling NaNs correctly.
RISC-V's fmax(sNAN,4) returns 4 but glibc expects it to return qNAN.

	* sysdeps/riscv/rvd/s_fmax.c (__fmax): Handle sNaNs correctly.
	* sysdeps/riscv/rvd/s_fmin.c (__fmin): Likewise.
	* sysdeps/riscv/rvf/s_fmaxf.c (__fmaxf): Likewise.
	* sysdeps/riscv/rvf/s_fminf.c (__fminf): Likewise.
2018-02-22 14:31:54 -05:00
DJ Delorie 8090720a87 RISC-V: Do not initialize $gp in TLS macros.
RISC-V TLS doesn't require GP to be initialized, and doing so breaks
TLS in a shared object.
2018-02-22 14:28:47 -05:00
Siddhesh Poyarekar 6ca24c4348 aarch64/strcmp: fix misaligned loop jump target
I accidentally set the loop jump back label as misaligned8 instead of
do_misaligned.  The typo is harmless but it's always nice to not have
to unnecessarily execute those two instructions.

	* sysdeps/aarch64/strcmp.S (do_misaligned): Jump back to
	do_misaligned, not misaligned8.
2018-02-22 23:48:14 +05:30
Steve Ellcey e9537dddc7 IFUNC for Cavium ThunderX2
* sysdeps/aarch64/multiarch/Makefile (sysdep_routines):
	Add memcpy_thunderx2.
	* sysdeps/aarch64/multiarch/ifunc-impl-list.c (MAX_IFUNC):
	Increment to 4.
	(__libc_ifunc_impl_list): Add __memcpy_thunderx2.
	* sysdeps/aarch64/multiarch/memcpy.c (libc_ifunc): Add IS_THUNDERX2
	and IS_THUNDERX2PA checks.
	* sysdeps/aarch64/multiarch/memcpy_thunderx.S (USE_THUNDERX2):
	Use macro to set name appropriately.
	(memcpy): Use USE_THUNDERX2 macro to modify prefetches.
	* sysdeps/aarch64/multiarch/memcpy_thunderx2.S: New file.
	* sysdeps/unix/sysv/linux/aarch64/cpu-features.h (IS_THUNDERX2PA):
	New macro.
	(IS_THUNDERX2): New macro.
2018-02-22 08:38:47 -08:00
Rical Jasan da81ae645d Add [BZ #16335] annotation to ChangeLog entry.
Commit 6a3962c4a4 unwittingly fixed a
bug, so update the ChangeLog entry accordingly.
2018-02-22 06:15:32 -08:00
Stefan Liebler 6e33647646 S390: Regenerate ULPs.
After regenerating ULPs from scratch in
commit 8e7196c875, I've missed
to test it with multiple gcc versions.  Hence, here is a further update.

ChangeLog:

	* sysdeps/s390/fpu/libm-test-ulps: Regenerated.
2018-02-22 09:19:49 +01:00
Samuel Thibault 315304d24a hurd: Add sysdep-cancel.h 2018-02-21 23:32:59 +01:00
Zack Weinberg 30bfee2630 Remove miscellaneous debris from libio.
This patch eliminates a number of #if 0 and #ifdef TODO blocks, macros
that are never used, macros that provide portability to substrates that
lack basic things like EINVAL and off_t, and other such debris.

I preserved IO_DEBUG and CHECK_FILE, even though as far as I can tell
IO_DEBUG is never defined and therefore CHECK_FILE never does
anything, because it seems like we might actually want to turn it _on_.

Installed stripped libraries and executables are unchanged, except,
again, that the line number of an assertion changes (this time it's
somewhere in fileops.c).

	* libio/libio.h (_IO_pos_BAD, _IO_pos_0, _IO_pos_adjust):
	Define here, unconditionally.
	* libio/iolibio.h (_IO_pos_BAD): Don't define here.
	* libio/libioP.h: Remove #if 0 blocks.
	(_IO_pos_BAD, _IO_pos_0, _IO_pos_adjust): Don't define here.
	(_IO_va_start, COERCE_FILE, MAYBE_SET_EINVAL): Don't define.
	(CHECK_FILE): Don't use MAYBE_SET_EINVAL or COERCE_FILE.  Fix style.

	* libio/clearerr.c, libio/fputc.c, libio/getchar.c:
	Assume weak_alias is always defined.

	* libio/fileops.c, libio/genops.c, libio/oldfileops.c
	* libio/oldpclose.c, libio/pclose.c, libio/wfileops.c:
	Remove #if 0 and #ifdef TODO blocks.
	Assume text_set_element is always defined.

	* libio/iofdopen.c, libio/iogetdelim.c, libio/oldiofdopen.c
	Use __set_errno (EINVAL) instead of MAYBE_SET_EINVAL.
	* libio/tst-mmap-eofsync.c: Make #if 1 block unconditional.
2018-02-21 14:39:54 -05:00
Zack Weinberg df6c012b99 Remove _IO_file_flags define.
This entirely mechanical (except for some indentation fixups) patch
replaces all uses of _IO_file_flags with _flags and removes the #define.

Installed stripped libraries and executables are unchanged by this patch.

	* libio/libio.h (_IO_file_flags): Remove macro.
	All uses changed to _flags.
2018-02-21 14:22:50 -05:00
Zack Weinberg 177aad3ff6 Remove legacy configuration knobs from libio.
This patch eliminates the "compatibility defines"
_IO_UNIFIED_JUMPTABLES (always defined to 1, used in a number of #ifs
which are therefore always false), _STDIO_USES_IOSTREAM (unused),
__HAVE_COLUMN (unused), _IO_BE (replaced with __glibc_unlikely), and
yet another redundant definition of EOF.

Installed stripped libraries are unchanged by this patch.

	* libio/libio.h (_IO_UNIFIED_JUMPTABLES, _STDIO_USES_IOSTREAM)
	(__HAVE_COLUMN, _IO_BE): Don't define.
	(_IO_peekc_unlocked, _IO_getwc_unlocked, _IO_putwc_unlocked)
	(_IO_fwide_maybe_incompatible): Use __glibc_unlikely.
	* libio/libioP.h (EOF): Don't define.
	* libio/iofdopen.c, libio/iofopen.c, libio/iopopen.c
	* libio/iovdprintf.c, libio/oldiofdopen.c, libio/oldiofopen.c
	* libio/oldiopopen.c, debug/vdprintf_chk.c: Remove #if block
	testing _IO_UNIFIED_JUMPTABLES.
2018-02-21 14:13:21 -05:00
Zack Weinberg 9964a14579 Mechanically remove _IO_ name aliases for types and constants.
This patch mechanically removes all remaining uses, and the
definitions, of the following libio name aliases:

 name                         replaced with
 ----                         -------------
 _IO_FILE                     FILE
 _IO_fpos_t                   __fpos_t
 _IO_fpos64_t                 __fpos64_t
 _IO_size_t                   size_t
 _IO_ssize_t                  ssize_t or __ssize_t
 _IO_off_t                    off_t
 _IO_off64_t                  off64_t
 _IO_pid_t                    pid_t
 _IO_uid_t                    uid_t
 _IO_wint_t                   wint_t
 _IO_va_list                  va_list or __gnuc_va_list
 _IO_BUFSIZ                   BUFSIZ
 _IO_cookie_io_functions_t    cookie_io_functions_t
 __io_read_fn                 cookie_read_function_t
 __io_write_fn                cookie_write_function_t
 __io_seek_fn                 cookie_seek_function_t
 __io_close_fn                cookie_close_function_t

I used __fpos_t and __fpos64_t instead of fpos_t and fpos64_t because
the definitions of fpos_t and fpos64_t depend on the largefile mode.
I used __ssize_t and __gnuc_va_list in a handful of headers where
namespace cleanliness might be relevant even though they're
internal-use-only.  In all other cases, I used the public-namespace
name.

There are a tiny handful of places where I left a use of 'struct _IO_FILE'
alone, because it was being used together with 'struct _IO_FILE_plus'
or 'struct _IO_FILE_complete' in the same arithmetic expression.

Because this patch was almost entirely done with search and replace, I
may have introduced indentation botches.  I did proofread the diff,
but I may have missed something.

The ChangeLog below calls out all of the places where this was not a
pure search-and-replace change.

Installed stripped libraries and executables are unchanged by this patch,
except that some assertions in vfscanf.c change line numbers.

	* libio/libio.h (_IO_FILE): Delete; all uses changed to FILE.
	(_IO_fpos_t): Delete; all uses changed to __fpos_t.
	(_IO_fpos64_t): Delete; all uses changed to __fpos64_t.
	(_IO_size_t): Delete; all uses changed to size_t.
	(_IO_ssize_t): Delete; all uses changed to ssize_t or __ssize_t.
	(_IO_off_t): Delete; all uses changed to off_t.
	(_IO_off64_t): Delete; all uses changed to off64_t.
	(_IO_pid_t): Delete; all uses changed to pid_t.
	(_IO_uid_t): Delete; all uses changed to uid_t.
	(_IO_wint_t): Delete; all uses changed to wint_t.
	(_IO_va_list): Delete; all uses changed to va_list or __gnuc_va_list.
	(_IO_BUFSIZ): Delete; all uses changed to BUFSIZ.
	(_IO_cookie_io_functions_t): Delete; all uses changed to
	cookie_io_functions_t.
	(__io_read_fn): Delete; all uses changed to cookie_read_function_t.
	(__io_write_fn): Delete; all uses changed to cookie_write_function_t.
	(__io_seek_fn): Delete; all uses changed to cookie_seek_function_t.
	(__io_close_fn): Delete: all uses changed to cookie_close_function_t.

	* libio/iofopncook.c: Remove unnecessary forward declarations.
	* libio/iolibio.h: Correct outdated commentary.
	* malloc/malloc.c (__malloc_stats): Remove unnecessary casts.
	* stdio-common/fxprintf.c (__fxprintf_nocancel):
	Remove unnecessary casts.
	* stdio-common/getline.c: Use _IO_getdelim directly.
	Don't redefine ssize_t.
	* stdio-common/printf_fp.c, stdio_common/printf_fphex.c
	* stdio-common/printf_size.c: Don't redefine size_t or FILE.
	Remove outdated comments.
	* stdio-common/vfscanf.c: Don't redefine va_list.
2018-02-21 14:11:05 -05:00
Zack Weinberg 349579047d Remove vestiges of external build support from libio headers.
As requested by Adhemerval, this patch removes some preprocessor
conditionals from the libio headers that were only relevant when
building libio outside glibc.

Installed stripped libraries and executables are unchanged by this
patch.

	* libio/iolibio.h, libio/libioP.h: Remove extern "C".
	* libio/libio.h: Remove __BEGIN_DECLS and __END_DECLS.
	Remove preprocessor conditionals on _LIBC and __USE_GNU,
	which are always true, and __cplusplus, which is always false.
2018-02-21 14:04:18 -05:00
Joseph Myers 039c721a30 Fix -Os putc_unlocked, fputc_unlocked linknamespace, localplt issues (bug 15105, bug 19463).
Continuing the fixes for linknamespace and localplt test failures with
-Os that arise from functions not being inlined in that case, this
patch fixes such failures for putc_unlocked and fputc_unlocked.

libc_hidden_* are used for both functions, while namespace issues are
addressed by making putc_unlocked a weak alias of hidden
__putc_unlocked, which is called in the one place where namespace
issues arise (and defined as an inline function in include/stdio.h).

Tested for x86_64 (both without -Os to make sure that case continues
to work, and with -Os to make sure all the relevant linknamespace and
localplt test failures are resolved).  This completes fixing the -Os
linknamespace failures (at least for x86_64); localplt failures remain
after this patch.

2018-02-19  Joseph Myers  <joseph@codesourcery.com>

	[BZ #15105]
	[BZ #19463]
	* libio/fputc_u.c (fputc_unlocked): Use libc_hidden_def.
	* libio/putc_u.c (putc_unlocked): Rename to __putc_unlocked and
	define as weak alias of __putc_unlocked.  Use libc_hidden_weak.
	* include/stdio.h [!_ISOMAC] (fputc_unlocked): Use
	libc_hidden_proto.
	[!_ISOMAC] (putc_unlocked): Likewise.
	[!_ISOMAC] (__putc_unlocked): Declare as hidden function, and
	define inline if [__USE_EXTERN_INLINES].
	* misc/syslog.c (__vsyslog_chk): Call __putc_unlocked instead of
	putc_unlocked.
2018-02-21 18:02:24 +00:00
Joseph Myers 30ac923dbe Fix -Os getc_unlocked linknamespace, localplt issues (bug 15105, bug 19463).
Continuing the fixes for linknamespace and localplt test failures with
-Os that arise from functions not being inlined in that case, this
patch fixes such failures for getc_unlocked.

__getc_unlocked already exists; this patch makes it explicitly hidden,
calls it where needed for namespace reasons, adds an inline function
for it when inline functions are used and adds libc_hidden_proto /
libc_hidden_weak for getc_unlocked.

Tested for x86_64 (both without -Os to make sure that case continues
to work, and with -Os to make sure all the relevant linknamespace and
localplt test failures are resolved).  Because of other such failures
that remain after this patch, neither of the bugs can yet be closed.

	[BZ #15105]
	[BZ #19463]
	* libio/getc_u.c (getc_unlocked): Use libc_hidden_weak.
	* include/stdio.h [!_ISOMAC] (__getc_unlocked): Use
	attribute_hidden, and define inline if [__USE_EXTERN_INLINES].
	[!_ISOMAC] (getc_unlocked): Use libc_hidden_proto.
	* misc/getttyent.c (__getttyent): Call __getc_unlocked instead of
	getc_unlocked.
	* time/tzfile.c (__tzfile_read): Likewise.
2018-02-21 18:01:11 +00:00
Mike FABIAN 7ec5f9465e Add missing “reorder-end” in LC_COLLATE of et_EE [BZ #22517]
[BZ #22517]
	* localedata/locales/et_EE (LC_COLLATE): add missing “reorder-end”
2018-02-21 16:36:39 +01:00
Rical Jasan 0d217f4082 Fix a typo in a comment.
* io/fcntl.h: Fix a typo in a comment.
2018-02-21 04:00:03 -08:00
Rical Jasan 862b45026f manual: Update _DEFAULT_SOURCE. [BZ #22862]
The description of the interplay between feature test macros and
compiler options in the description of _DEFAULT_SOURCE is a little
confusing, and dated, so clarify the situation, and don't assume a
specific value for _DEFAULT_SOURCE.

Also, _DEFAULT_SOURCE is supposed to be defined if none of the C/POSIX
feature test macros are defined, but the condition was lacking a test
for _ISOC11_SOURCE, so that is also addressed.

	[BZ #22862]
	* include/features.h: Add _ISOC11_SOURCE to test for whether
	to define _DEFAULT_SOURCE.
	* manual/creature.texi (_DEFAULT_SOURCE): Improve
	documentation.
2018-02-21 02:38:42 -08:00
Florian Weimer 999a6dab3e ldconfig: Sync temporary files to disk before renaming them [BZ #20890]
If the system crashes before the file data has been written to disk, the
file system recovery upon the next mount may restore a partially
rewritten temporary file under the non-temporary (final) name (after the
rename operation).
2018-02-21 10:42:48 +01:00
Florian Weimer 52a01100ad elf: Remove ad-hoc restrictions on dlopen callers [BZ #22787]
This looks like a post-exploitation hardening measure: If an attacker is
able to redirect execution flow, they could use that to load a DSO which
contains additional code (or perhaps make the stack executable).

However, the checks are not in the correct place to be effective: If
they are performed before the critical operation, an attacker with
sufficient control over execution flow could simply jump directly to
the code which performs the operation, bypassing the check.  The check
would have to be executed unconditionally after the operation and
terminate the process in case a caller violation was detected.

Furthermore, in _dl_check_caller, there was a fallback reading global
writable data (GL(dl_rtld_map).l_map_start and
GL(dl_rtld_map).l_text_end), which could conceivably be targeted by an
attacker to disable the check, too.

Other critical functions (such as system) remain completely
unprotected, so the value of these additional checks does not appear
that large.  Therefore this commit removes this functionality.
2018-02-21 10:37:22 +01:00
Samuel Thibault b5bf62e40c hurd: fix build
* sysdeps/mach/hurd/dl-sysdep.c (_dl_random): New variable.
2018-02-21 01:17:29 +01:00
Rical Jasan e8d190b9ed manual: Update the _ISOC99_SOURCE description.
The current description refers to ISO C99 not being widely adopted,
which it is believed to be now.

	* manual/creature.texi (_ISOC99_SOURCE): Update the dated
	description.
2018-02-20 00:04:46 -08:00
Rical Jasan 6a3962c4a4 manual: Document missing feature test macros.
Several feature test macros are documented in features.h but absent in
the manual, and some documented macros accept undocumented values.
This commit updates the manual to mention all the accepted macros,
along with any values that hold special meaning.

	* manual/creature.texi (_POSIX_C_SOURCE): Document special
	values of 199606L, 200112L, and 200809L.
	(_XOPEN_SOURCE): Document special values of 600 and 700.
	(_ISOC11_SOURCE): Document macro.
	(_ATFILE_SOURCE): Likewise.
	(_FORTIFY_SOURCE): Likewise.
2018-02-20 00:01:26 -08:00
Joseph Myers ec481ad81b Fix -Os ferror_unlocked linknamespace, localplt issues (bug 15105, bug 19463).
Continuing the fixes for linknamespace and localplt test failures with
-Os that arise from functions not being inlined in that case, this
patch fixes such failures for ferror_unlocked.

The usual approach is followed of adding __ferror_unlocked (inlined
when ferror_unlocked is), making calls use it when required for
namespace reasons (only one such call), and using libc_hidden_proto /
libc_hidden_weak for the ferror_unlocked weak alias when only localplt
but not namespace issues are involved.

Tested for x86_64 (both without -Os to make sure that case continues
to work, and with -Os to make sure all the relevant linknamespace and
localplt test failures are resolved).  Because of other such failures
that remain after this patch, neither of the bugs can yet be closed.

	[BZ #15105]
	[BZ #19463]
	* libio/ferror_u.c (ferror_unlocked): Rename to __ferror_unlocked
	and define as weak alias of __ferror_unlocked.  Use
	libc_hidden_weak.
	* include/stdio.h [!_ISOMAC] (ferror_unlocked): Use
	libc_hidden_proto.
	[!_ISOMAC] (__ferror_unlocked) New declaration, and inline
	function if [__USE_EXTERN_INLINES].
	* time/getdate.c (__getdate_r): Call __ferror_unlocked instead of
	ferror_unlocked.
2018-02-19 17:32:34 +00:00
Rical Jasan 7d15ef84f5 manual: Improve documentation of get_current_dir_name. [BZ #6889]
This is a minor rewording to clarify the behaviour of
get_current_dir_name.  Additionally, the @vindex is moved above the
@deftypefun so that following links give a better result with regard
to context.

	[BZ #6889]
	* manual/filesys.texi (get_current_dir_name): Clarify
	behaviour.
2018-02-19 01:59:52 -08:00
Aurelien Jarno f8d7958289 Fix posix/tst-glob_lstat_compat on alpha [BZ #22818]
The tst-glob_lstat_compat test needs to run tests on the previous
version of glob. On alpha, there are three versions of glob, GLIBC_2.0,
GLIBC_2.1 and GLIBC_2.27, while on other architectures there are only
the GLIBC_2.0 and GLIBC_2.27 version. Therefore on alpha the previous
version is GLIBC_2.1 and not GLIBC_2.0.

Changelog:
	[BZ #22818]
	* posix/tst-glob_lstat_compat.c [__alpha__] (glob): Access
	the GLIBC_2.1 version.
2018-02-18 18:23:47 +01:00
Aurelien Jarno 56456a2aad intl/tst-gettext: fix failure with newest msgfmt
Since upstream gettext commit d13f165b83 (msgfmt: Remove
POT-Creation-Date field from the header in the output.), msgfmt does not
copy the POT-Creation-Date field in the header entry from the po file to
the mo file anymore. This breaks the assumption that we can test gettext
by comparing each message in the po files with the corresponding string
return by gettext. This makes the intl/tst-gettext to fail.

While it would have been possible to modify the po2test.awk script to
also strip the line POT-Creation-Date field when creating the msgs.h
file, it would not work with both the old and new msgfmt.

Instead create a tst-gettext-de.po file from de.po by removing the
POT-Creation-Date line. Another alternative would be to use a static
tst-gettext-de.po file, but I guess the reason for using de.po is to
also catch issues caused by newly added strings.

As tst-catgets also uses msg.h, it should also be updated. Instead of
using the new tst-gettext-de.po file, the patch modifies xopen-msg.awk
to avoid creating a second catgets->intl dependency.

Changelog:
	[BZ #21508]
	* catgets/xopen-msg.awk: Ignore POT-Creation-Date line.
	* intl/Makefile ($(objpfx)tst-gettext-de.po): Generate
	intl/tst-gettext-de.po from po/de.po by removing the
	POT-Creation-Date line.
	($(objpfx)msgs.h): Depend on $(objpfx)tst-gettext-de.po instead of
	../po/de.po.
	* intl/tst-gettext.sh: Use ${objpfx}tst-gettext-de.po instead of
	../po/de.po.
2018-02-18 18:16:05 +01:00
Samuel Thibault dd1efd8c56 hurd: Fix build on missing __ptsname_internal function
* sysdeps/mach/hurd/ptsname.c: Include <sys/stat.h>.
	(__ptsname_r): Move implementation to...
	(__ptsname_internal): ... new function.  Add filling the STP
	structure.
2018-02-17 23:26:45 +01:00
Samuel Thibault 13768813bc hurd: Define EXEC_PAGESIZE
* mach/Makefile (headers): Add mach/param.h.
* sysdeps/mach/hurd/bits/param.h: Include <mach/param.h>.
* sysdeps/mach/i386/mach/param.h: New file, defines EXEC_PAGESIZE
2018-02-17 22:57:26 +01:00
John David Anglin 6aca1b6102 Fix ulps for pow on hppa.
* sysdeps/hppa/fpu/libm-test-ulps (pow): Increase double and
	idouble to 1 ULP.
2018-02-17 13:46:50 -05:00
Rical Jasan 16efad5171 manual: Fix a syntax error.
The opening parenthesis for function arguments in an @deftypefun need
to be separated from the function name.  This isn't just a matter of
the GNU coding style---it causes the "(void" (in this case) to be
rendered as a part of the function name, causing a visual defect, and
also results in a warning to the following effect during `make pdf':

  Warning: unbalanced parentheses in @def...)

	* manual/platform.texi (__riscv_flush_icache): Fix @deftypefun
	syntax.
2018-02-16 08:21:47 -08:00
Stefan Liebler 8724507385 Add runtime check if mutex will be elided in tst-mutex8 testcases.
An elided mutex don't fail destroy. Elision was disabled for the
test nptl/tst-mutex8 in nptl/Makefile. Thus we can run tests which
destroy a locked mutex.

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

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

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

ChangeLog:

	* nptl/Makefile (tst-mutex8-ENV): Delete.
	* nptl/tst-mutex8.c (check_type):
	Add runtime check if mutex will be elided.
2018-02-16 09:57:30 +01:00
Joseph Myers db9881ecd7 Document use of CC and CFLAGS in more detail (bug 20980, bug 21234).
There are some bug reports from people setting CFLAGS not including a
-O option and then being confused when the build fails.  This patch
addresses this by documenting the proper use of CC and CFLAGS in more
detail - saying what options should go where and specifying the
requirement to compile with optimization.

The previous text incorrectly used @var markup with CC and CFLAGS.
The correct markup for environment variables is @env, but it's also
the case that passing such variables explicitly on the configure
command line is preferred to passing them in the environment, so this
patch changes the documentation to describe passing them on the
command line (and uses @code).

In many cases putting options in the wrong place may in fact work, but
I believe what I've specified is the correct rule for which options to
put where.

	[BZ #20980]
	[BZ #21234]
	* manual/install.texi (Configuring and compiling): Describe
	passing CC and CFLAGS on configure command line, not as
	environment variables.  Use @code markup on those variables.
	Specify what options go in CC and what go in CFLAGS.  Note the
	requirement to compile with optimization.
	* INSTALL: Regenerated.
2018-02-15 23:48:47 +00:00