Commit Graph

22525 Commits

Author SHA1 Message Date
Adhemerval Zanella 743b9c2a98 arm: Remove ununsed ARM code in optimized implementation
This patch removes the ununsed ARM code path for armv6t2 memchr and
strlen and armv7 memch and strcmp.  In all implementation, the ARM
code is not used in any possible build (unless glibc is explicit
build with the non-documented NO_THUMB compiler flag) and for armv7
the resulting code either produces wrong results (memchr) and throw
build error (strcmp).

Checked on arm-linux-gnueabihf built targeting both armv6 and
armv7.

	* sysdeps/arm/armv6t2/memchr.S (memchr): Remove ARM code path.
	* sysdeps/arm/armv6t2/strlen.S (memchr): Likewise.
	* sysdeps/arm/armv7/multiarch/memchr_neon.S (memchr): Likewise.
	* sysdeps/arm/armv7/strcmp.S (strcmp): Likewise.
2018-04-16 17:24:31 -03:00
Andreas Schwab 326e74e7c1 Add aliases to recognize normalized charset names (bug 19527) 2018-04-16 17:30:56 +02:00
Patrick McGehearty a14d8acd32 Improves __ieee754_exp(x) performance by 18-37% when |x| < 1.0397
Adds a fast path to e_exp.c when |x| < 1.03972053527832.
When values are tested in isolation, reduction in execution
time is: aarch 30%, sparc 18%, x86 37%.
When comparing benchtests/bench.out which includes values
outside that range, the gains are:
aarch 8%, sparc 5%, x86 9%.

make check is clean (no increase in ulp for any math test).
Testing 20M values for each rounding mode in that range shows
approximately one in 200 values is off by 1 ulp. No value tested
for exp(x) changed by 2 or more ulp.

No observed change in performance or accuracy for x outside
fast path range.

These changes will be active for all platforms that don't provide
their own exp() routines. They will also be active for ieee754
versions of ccos, ccosh, cosh, csin, csinh, sinh, exp10, gamma, and
erf.
2018-04-15 18:46:37 -04:00
DJ Delorie a700e7cb37 Update kernel version in syscall-names.list to 4.16.
Linux 4.16 does not add any new syscalls; this patch updates the
version number in syscall-names.list to reflect that it's still
current for 4.16.

Tested for x86_64 (compilation with build-many-glibcs.py, using Linux
4.16).

	* sysdeps/unix/sysv/linux/syscall-names.list: Update kernel
	version to 4.16.
2018-04-12 15:25:50 -04:00
Stefan Liebler d8abfab7d4 S390: Fix struct sigaction for 31bit in kernel_sigaction.h.
The recent commit b4a5d26d88
"linux: Consolidate sigaction implementation" changed the definition
of struct sigaction for s390 (31bit). Unfortunately the order of the
fields were wrong.

This leads to blocking testcases e.g. nptl/tst-sem11.
A thread which blocks due to sem_wait() is cancelled via pthread_cancel()
and the signal-handler sigcancel_handler (see <glibc-src>/nptl/nptl-init.c
is called.
But it just returns as the siginfo_t argument is not setup by the kernel.
Then the main-thread is blocking due to pthread_join().

The flag SA_SIGINFO is set in sa_flags in struct sigaction and
is copied to the "kernel_sigaction.h" struct by the sigaction() call,
but due to the wrong ordering of the struct fields,
the kernel does not recognize it.
2018-04-12 09:37:26 +02:00
Florian Weimer 583a27d525 resolv: Fully initialize struct mmsghdr in send_dg [BZ #23037] 2018-04-09 10:08:16 +02:00
Adhemerval Zanella 942de61a89 Consolidate Linux readdir{64}{_r} implementation
This patch consolidates Linux readdir{64}{_r} implementation on just
the default sysdeps/unix/sysv/linux/readdir{64}{_r}.c ones.  The
default implementation handle the Linux requirements:

  * readdir{_r} is only built for _DIRENT_MATCHES_DIRENT64 being 0.

  * readdir64{_r} is always built and aliased to readdir{_r} for
    ABI that define _DIRENT_MATCHES_DIRENT64.

  * A compat symbol is added for readdir64{_r} for ABI that used to
    export the old non-LFS version.

Checked on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
sparcv9-linux-gnu, sparc64-linux-gnu, powerpc-linux-gnu, and
powerpc64le-linux-gnu.

	* sysdeps/posix/readdir.c (__READDIR, __GETDENTS, DIRENTY_TYPE,
	__READDIR_ALIAS): Undefine after usage.
	* sysdeps/posix/readdir_r.c (__READDIR_R, __GETDENTS, DIRENT_TYPE,
	__READDIR_R_ALIAS): Likewise.
	* sysdeps/unix/sysv/linux/arm/readdir64.c: Remove file.
	* sysdeps/unix/sysv/linux/arm/readdir64_r.c: Likewise.
	* sysdeps/unix/sysv/linux/m68k/readdir64.c: Likewise.
	* sysdeps/unix/sysv/linux/m68k/readdir64_r.c: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/readdir64.c: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/readdir64_r.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/readdir64.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/readdir64_r.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/readdir64.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/readdir64_r.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/readdir64.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/readdir64_r.c: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/readdir.c: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/readdir64.c: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/readdir64_r.c: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/readdir_r.c: Likewise.
	* sysdeps/unix/sysv/linux/readdir.c: New file.
	* sysdeps/unix/sysv/linux/readdir_r.c: Likewise.
	* sysdeps/unix/sysv/linux/readdir64.c: Add compat symbol if required.
	* sysdeps/unix/sysv/linux/readdir64_r.c: Likewise.
2018-04-06 17:49:02 -03:00
Adhemerval Zanella 243f59e5aa Update i386 libm-test-ulps.
Updated ulps after recent commit "[PATCH 1/7] sin/cos slow paths:
avoid slow paths for small inputs"
(19a8b9a300).

	* sysdeps/i386/i686/fpu/multiarch/libm-test-ulps: Update.
2018-04-06 17:24:15 -03:00
Andreas Schwab 690c3475f1 Fix missing @ before texinfo command 2018-04-06 08:56:24 +02:00
Adhemerval Zanella bbc2062a75 Update SPARC libm-test-ulps.
* sysdeps/sparc/fpu/libm-test-ulps: Update.
2018-04-05 17:10:03 -03:00
Adhemerval Zanella fa7c619978 Update ARM libm-test-ulps.
* sysdeps/arm/libm-test-ulps: Update.
2018-04-05 17:10:03 -03:00
Adhemerval Zanella b4a5d26d88 linux: Consolidate sigaction implementation
This patch consolidates all Linux sigaction implementations on the default
sysdeps/unix/sysv/linux/sigaction.c.  The idea is remove redundant code
and simplify new ports addition by following the current generic
Linux User API (UAPI).

The UAPI for new ports defines a generic extensible sigaction struct as:

  struct sigaction
  {
    __sighandler_t sa_handler;
    unsigned long sa_flags;
  #ifdef SA_RESTORER
    void (*sa_restorer) (void);
  #endif
    sigset_t sa_mask;
  };

Where SA_RESTORER is just placed for compatibility reasons (news ports
should not add it).  A similar definition is used on generic
kernel_sigaction.h.

The user exported sigaction definition is not changed, so for most
architectures it requires an adjustment to kernel expected one for the
syscall.

The main changes are:

  - All architectures now define and use a kernel_sigaction struct meant
    for the syscall, even for the architectures where the user sigaction
    has the same layout of the kernel expected one (s390-64 and ia64).
    Although it requires more work for these architectures, it simplifies
    the generic implementation. Also, sigaction is hardly a hotspot where
    micro optimization would play an important role.

  - The generic kernel_sigaction definition is now aligned with expected
    UAPI one for newer ports, where SA_RESTORER and sa_restorer are not
    expected to be defined.  This means adding kernel_sigaction for
    current architectures that does define it (m68k, nios2, powerpc, s390,
    sh, sparc, and tile) and which rely on previous generic definition.

  - Remove old MIPS usage of sa_restorer.  This was removed since 2.6.27
    (2957c9e61ee9c - "[MIPS] IRIX: Goodbye and thanks for all the fish").

  - The remaining arch-specific sigaction.c are to handle ABI idiosyncrasies
    (like SPARC kernel ABI for rt_sigaction that requires an additional
    stub argument).

So for new ports the generic implementation should work if its uses
Linux UAPI.  If SA_RESTORER is still required (due some architecture
limitation), it should define its own kernel_sigaction.h, define it and
include generic header (assuming it still uses the default generic kernel
layout).

Checked on x86_64-linux-gnu, i686-linux-gnu, arm-linux-gnueabihf,
aarch64-linux-gnu, sparc64-linux-gnu, sparcv9-linux-gnu, powerpc-linux-gnu,
powerpc64-linux-gnu, ia64-linux-gnu and alpha-linux-gnu.  I also checked the
build on all remaining affected ABIs.

	* sysdeps/unix/sysv/linux/aarch64/sigaction.c: Use default Linux version
	as base implementation.
	* sysdeps/unix/sysv/linux/arm/sigaction.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/sigaction.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/sigaction.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/sigaction.c: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/sigaction.c: Likewise.
	* sysdeps/unix/sysv/linux/alpha/kernel_sigaction.h: Add include guards,
	remove unrequired definitions and update comments.
	* sysdeps/unix/sysv/linux/kernel_sigaction.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/kernel_sigaction.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/kernel_sigaction.h: New file.
	* sysdeps/unix/sysv/linux/m68k/kernel_sigaction.h: Likewise.
	* sysdeps/unix/sysv/linux/nios2/kernel_sigaction.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/kernel_sigaction: Likewise.
	* sysdeps/unix/sysv/linux/s390/kernel_sigaction.h: Likewise.
	* sysdeps/unix/sysv/linux/sh/kernel_sigaction.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/kernel_sigaction.h: Likewise.
	* sysdeps/unix/sysv/linux/tile/kernel_sigaction.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/sigaction.c: Remove file.
	* sysdeps/unix/sysv/linux/mips/sigaction.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/sigaction.c: Likewise.
	* sysdeps/unix/sysv/linux/sigaction.c: Add STUB, SET_SA_RESTORER,
	and RESET_SA_RESTORER hooks.
2018-04-05 17:09:50 -03:00
Stefan Liebler db9e55ff36 S390: Regenerate ULPs.
Updated ulps after recent commit
"[PATCH 1/7] sin/cos slow paths: avoid slow paths for small inputs"
(19a8b9a300).

ChangeLog:

	* sysdeps/s390/fpu/libm-test-ulps: Regenerated.
2018-04-05 16:24:06 +02:00
Florian Weimer cf138b0c83 manual: Various fixes to the mbstouwcs example, and mbrtowc update
The example did not work because the null byte was not converted, and
mbrtowc was called with a zero-length input string.  This results in a
(size_t) -2 return value, so the function always returns NULL.

The size computation for the heap allocation of the result was
incorrect because it did not deal with integer overflow.

Error checking was missing, and the allocated memory was not freed on
error paths.  All error returns now set errno.  (Note that there is an
assumption that free does not clobber errno.)

The slightly unportable comparision against (size_t) -2 to catch both
(size_t) -1 and (size_t) -2 return values is gone as well.

A null wide character needs to be stored in the result explicitly, to
terminate it.

The description in the manual is updated to deal with these finer
points.  The (size_t) -2 behavior (consuming the input bytes) matches
what is specified in ISO C11.
2018-04-05 12:52:19 +02:00
Florian Weimer 0f33925269 manual: Move mbstouwcs to an example C file 2018-04-05 12:50:58 +02:00
Samuel Thibault 08e92e2443 Revert "hurd: Avoid PLTs for longjmp & siglongjmp"
This reverts commit e5f9508a32.
2018-04-05 09:38:58 +02:00
Samuel Thibault c120981d72 hurd: Avoid PLT for dirfd
* include/dirent.h (dirfd): Add hidden proto.
	* dirent/dirfd.c (dirfd): Add hidden def.
	* sysdeps/mach/hurd/dirfd.c (dirfd): Add hidden def.
	* sysdeps/posix/dirfd.c (dirfd): Add hidden def.
2018-04-05 01:52:29 +02:00
Samuel Thibault e5f9508a32 hurd: Avoid PLTs for longjmp & siglongjmp
* include/setjmp.h (longjmp, siglongjmp): Add hidden protos.
	* setjmp/longjmp.c (longjmp, siglongjmp): Add hidden defs.
	* sysdeps/s390/longjmp.c (longjmp, siglongjmp): Add hidden defs.
2018-04-04 23:19:18 +00:00
Tulio Magno Quites Machado Filho b2fd61ca9b powerpc: Update sin, cos and sincos ULPs
* sysdeps/powerpc/fpu/libm-test-ulps: Increase double-precision
	sin, cos and sincos to 1 ULP.

Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2018-04-04 19:17:13 -03:00
Maciej W. Rozycki e7feec374c elf: Correct absolute (SHN_ABS) symbol run-time calculation [BZ #19818]
Do not relocate absolute symbols by the base address.  Such symbols have
SHN_ABS as the section index and their value is not supposed to be
affected by relocation as per the ELF gABI[1]:

"SHN_ABS
    The symbol has an absolute value that will not change because of
    relocation."

The reason for our non-conformance here seems to be an old SysV linker
bug causing symbols like _DYNAMIC to be incorrectly emitted as absolute
symbols[2].  However in a previous discussion it was pointed that this
is seriously flawed by preventing the lone purpose of the existence of
absolute symbols from being used[3]:

"On the contrary, the only interpretation that makes sense to me is that
it will not change because of relocation at link time or at load time.
Absolute symbols, from the days of the earliest linking loaders, have
been used to represent addresses that are outside the address space of
the module (e.g., memory-mapped addresses or kernel gateway pages).
They've even been used to represent true symbolic constants (e.g.,
system entry point numbers, sizes, version numbers).  There's no other
way to represent a true absolute symbol, while the meaning you seek is
easily represented by giving the symbol a non-negative st_shndx value."

and we ought to stop supporting our current broken interpretation.

Update processing for dladdr(3) and dladdr1(3) so that SHN_ABS symbols
are ignored, because under the corrected interpretation they do not
represent addresses within a mapped file and therefore are not supposed
to be considered.

References:

[1] "System V Application Binary Interface - DRAFT - 19 October 2010",
    The SCO Group, Section "Symbol Table",
    <http://www.sco.com/developers/gabi/2012-12-31/ch4.symtab.html>

[2] Alan Modra, "Absolute symbols"
    <https://sourceware.org/ml/binutils/2012-05/msg00019.html>

[3] Cary Coutant, "Re: Absolute symbols"
    <https://sourceware.org/ml/binutils/2012-05/msg00020.html>

	[BZ #19818]
	* sysdeps/generic/ldsodefs.h (SYMBOL_ADDRESS): Handle SHN_ABS
	symbols.
	* elf/dl-addr.c (determine_info): Ignore SHN_ABS symbols.
	* elf/tst-absolute-sym.c: New file.
	* elf/tst-absolute-sym-lib.c: New file.
	* elf/tst-absolute-sym-lib.lds: New file.
	* elf/Makefile (tests): Add `tst-absolute-sym'.
	(modules-names): Add `tst-absolute-sym-lib'.
	(LDLIBS-tst-absolute-sym-lib.so): New variable.
	($(objpfx)tst-absolute-sym-lib.so): New dependency.
	($(objpfx)tst-absolute-sym): New dependency.
2018-04-04 23:09:37 +01:00
Maciej W. Rozycki 10a446ddcc elf: Unify symbol address run-time calculation [BZ #19818]
Wrap symbol address run-time calculation into a macro and use it
throughout, replacing inline calculations.

There are a couple of variants, most of them different in a functionally
insignificant way.  Most calculations are right following RESOLVE_MAP,
at which point either the map or the symbol returned can be checked for
validity as the macro sets either both or neither.  In some places both
the symbol and the map has to be checked however.

My initial implementation therefore always checked both, however that
resulted in code larger by as much as 0.3%, as many places know from
elsewhere that no check is needed.  I have decided the size growth was
unacceptable.

Having looked closer I realized that it's the map that is the culprit.
Therefore I have modified LOOKUP_VALUE_ADDRESS to accept an additional
boolean argument telling it to access the map without checking it for
validity.  This in turn has brought quite nice results, with new code
actually being smaller for i686, and MIPS o32, n32 and little-endian n64
targets, unchanged in size for x86-64 and, unusually, marginally larger
for big-endian MIPS n64, as follows:

i686:
   text    data     bss     dec     hex filename
 152255    4052     192  156499   26353 ld-2.27.9000-base.so
 152159    4052     192  156403   262f3 ld-2.27.9000-elf-symbol-value.so
MIPS/o32/el:
   text    data     bss     dec     hex filename
 142906    4396     260  147562   2406a ld-2.27.9000-base.so
 142890    4396     260  147546   2405a ld-2.27.9000-elf-symbol-value.so
MIPS/n32/el:
   text    data     bss     dec     hex filename
 142267    4404     260  146931   23df3 ld-2.27.9000-base.so
 142171    4404     260  146835   23d93 ld-2.27.9000-elf-symbol-value.so
MIPS/n64/el:
   text    data     bss     dec     hex filename
 149835    7376     408  157619   267b3 ld-2.27.9000-base.so
 149787    7376     408  157571   26783 ld-2.27.9000-elf-symbol-value.so
MIPS/o32/eb:
   text    data     bss     dec     hex filename
 142870    4396     260  147526   24046 ld-2.27.9000-base.so
 142854    4396     260  147510   24036 ld-2.27.9000-elf-symbol-value.so
MIPS/n32/eb:
   text    data     bss     dec     hex filename
 142019    4404     260  146683   23cfb ld-2.27.9000-base.so
 141923    4404     260  146587   23c9b ld-2.27.9000-elf-symbol-value.so
MIPS/n64/eb:
   text    data     bss     dec     hex filename
 149763    7376     408  157547   2676b ld-2.27.9000-base.so
 149779    7376     408  157563   2677b ld-2.27.9000-elf-symbol-value.so
x86-64:
   text    data     bss     dec     hex filename
 148462    6452     400  155314   25eb2 ld-2.27.9000-base.so
 148462    6452     400  155314   25eb2 ld-2.27.9000-elf-symbol-value.so

	[BZ #19818]
	* sysdeps/generic/ldsodefs.h (LOOKUP_VALUE_ADDRESS): Add `set'
	parameter.
	(SYMBOL_ADDRESS): New macro.
	[!ELF_FUNCTION_PTR_IS_SPECIAL] (DL_SYMBOL_ADDRESS): Use
	SYMBOL_ADDRESS for symbol address calculation.
	* elf/dl-runtime.c (_dl_fixup): Likewise.
	(_dl_profile_fixup): Likewise.
	* elf/dl-symaddr.c (_dl_symbol_address): Likewise.
	* elf/rtld.c (dl_main): Likewise.
	* sysdeps/aarch64/dl-machine.h (elf_machine_rela): Likewise.
	* sysdeps/alpha/dl-machine.h (elf_machine_rela): Likewise.
	* sysdeps/arm/dl-machine.h (elf_machine_rel): Likewise.
	(elf_machine_rela): Likewise.
	* sysdeps/hppa/dl-machine.h (elf_machine_rela): Likewise.
	* sysdeps/hppa/dl-symaddr.c (_dl_symbol_address): Likewise.
	* sysdeps/i386/dl-machine.h (elf_machine_rel): Likewise.
	(elf_machine_rela): Likewise.
	* sysdeps/ia64/dl-machine.h (elf_machine_rela): Likewise.
	* sysdeps/m68k/dl-machine.h (elf_machine_rela): Likewise.
	* sysdeps/microblaze/dl-machine.h (elf_machine_rela): Likewise.
	* sysdeps/mips/dl-machine.h (ELF_MACHINE_BEFORE_RTLD_RELOC):
	Likewise.
	(elf_machine_reloc): Likewise.
	(elf_machine_got_rel): Likewise.
	* sysdeps/mips/dl-trampoline.c (__dl_runtime_resolve): Likewise.
	* sysdeps/nios2/dl-machine.h (elf_machine_rela): Likewise.
	* sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_rela):
	Likewise.
	* sysdeps/powerpc/powerpc64/dl-machine.h (elf_machine_rela):
	Likewise.
	* sysdeps/riscv/dl-machine.h (elf_machine_rela): Likewise.
	* sysdeps/s390/s390-32/dl-machine.h (elf_machine_rela):
	Likewise.
	* sysdeps/s390/s390-64/dl-machine.h (elf_machine_rela):
	Likewise.
	* sysdeps/sh/dl-machine.h (elf_machine_rela): Likewise.
	* sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela):
	Likewise.
	* sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela):
	Likewise.
	* sysdeps/tile/dl-machine.h (elf_machine_rela): Likewise.
	* sysdeps/x86_64/dl-machine.h (elf_machine_rela): Likewise.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2018-04-04 23:09:37 +01:00
Zack Weinberg 9185f86d8f Make sysdeps/generic/internal-signals.h less stubby.
Three of the functions defined by internal-signals.h were not actually
fulfilling their contracts when the sysdeps/generic version of that
file was used.  Also, the Linux version included several more headers
than the generic version, which is the root cause of a build failure
on Hurd (already addressed in another way, but I think it is proper to
make the headers match).

	* sysdeps/generic/internal-signals.h: Include signal.h,
	sigsetops.h, and stdbool.h.
	(__libc_signal_block_all): Actually block all signals.
	(__libc_signal_block_app): Likewise.
	(__libc_signal_restore_set): Actually restore the signal mask.
2018-04-04 12:37:23 -04:00
Florian Weimer b07367bcf8 inet: Actually build and run tst-deadline 2018-04-04 16:08:18 +02:00
Samuel Thibault d8440a2147 hurd: fix build
* signal/sigaddset.c: Include <sigsetopts.h>.
	* signal/sigdelset.c: Likewise.
2018-04-04 02:28:20 +02:00
Samuel Thibault ff297b70b5 hurd: Add missing symbols
* sysdeps/mach/hurd/i386/exc2signal.c (_hurd_exception2signal): Add
	hidden def.
	* mach/spin-lock.c (__mutex_unlock): Add hidden def.
2018-04-04 02:17:49 +02:00
Samuel Thibault e8ef51b171 hurd: Silence warning
* hurd/hurdsig.c (interrupted_reply_port_location): Use
	DIAG_IGNORE_NEEDS_COMMENT to silence warning with GCC 6 and before.
2018-04-04 02:06:16 +02:00
Samuel Thibault 92846492dc hurd: Make __if_nametoindex return ENODEV if ifname is too long
rather than truncating it.

	* sysdeps/mach/hurd/if_index.c (__if_nametoindex): Return ENODEV if
	ifname is too long.
2018-04-03 23:14:11 +02:00
Samuel Thibault 5e17a480f8 Revert parts of "hurd: Avoid more libc.so local PLTs"
This reverts parts of commit 82dbf555a4.
2018-04-03 23:06:00 +02:00
Samuel Thibault 51722f4dc7 Revert "s390x: Fix hidden aliases"
This reverts commit 811836a411.
2018-04-03 22:59:25 +02:00
H.J. Lu f2652643d7 Update RWF_SUPPORTED for Linux kernel 4.16 [BZ #22947]
Add RWF_APPEND to RWF_SUPPORTED to support Linux kernel 4.16.

	[BZ #22947]
	* bits/uio-ext.h (RWF_APPEND): New.
	* sysdeps/unix/sysv/linux/bits/uio-ext.h (RWF_APPEND): Likewise.
	* manual/llio.texi: Document RWF_APPEND.
	* misc/tst-preadvwritev2-common.c (RWF_APPEND): New.
	(RWF_SUPPORTED): Add RWF_APPEND.
2018-04-03 12:19:29 -07:00
Adhemerval Zanella d2dc5467c6 Filter out NPTL internal signals (BZ #22391)
This patch filters out the internal NPTL signals (SIGCANCEL/SIGTIMER and
SIGSETXID) from signal functions.  GLIBC on Linux requires both signals to
proper implement pthread cancellation, posix timers, and set*id posix
thread synchronization.

And not filtering out the internal signal is troublesome:

  - A conformant program on a architecture that does not filter out the
    signals might inadvertently disable pthread asynchronous cancellation,
    set*id synchronization or posix timers.

  - It might also to security issues if SIGSETXID is masked and set*id
    functions are called (some threads might have effective user or group
    id different from the rest).

The changes are basically:

  - Change __is_internal_signal to bool and used on all signal function
    that has a signal number as input.  Also for signal function which accepts
    signals sets (sigset_t) it assumes that canonical function were used to
    add/remove signals which lead to some input simplification.

  - Fix tst-sigset.c to avoid check for SIGCANCEL/SIGTIMER and SIGSETXID.
    It is rewritten to check each signal indidually and to check realtime
    signals using canonical macros.

  - Add generic __clear_internal_signals and __is_internal_signal
    version since both symbols are used on generic implementations.

  - Remove superflous sysdeps/nptl/sigfillset.c.

  - Remove superflous SIGTIMER handling on Linux __is_internal_signal
    since it is the same of SIGCANCEL.

  - Remove dangling define and obvious comment on nptl/sigaction.c.

Checked on x86_64-linux-gnu.

	[BZ #22391]
	* nptl/sigaction.c (__sigaction): Use __is_internal_signal to
	check for internal nptl signals.
	* nptl/sigaction.c (__sigaction): Likewise.
	* signal/sigaddset.c (sigaddset): Likewise.
	* signal/sigdelset.c (sigdelset): Likewise.
	* sysdeps/posix/signal.c (__bsd_signal): Likewise.
	* sysdeps/posix/sigset.c (sigset): Call and check sigaddset return
	value.
	* signal/sigfillset.c (sigfillset): User __clear_internal_signals
	to filter out internal nptl signals.
	* signal/tst-sigset.c (do_test): Check ech signal indidually and
	also check realtime signals using standard macros.
	* sysdeps/generic/internal-signals.h (__clear_internal_signals,
	__is_internal_signal, __libc_signal_block_all,
	__libc_signal_block_app, __libc_signal_restore_set): New functions.
	* sysdeps/nptl/sigfillset.c: Remove file.
	* sysdeps/unix/sysv/linux/internal-signals.h (__is_internal_signal):
	Change return to bool.
	(__clear_internal_signals): Remove SIGTIMER clean since it is
	equal to SIGCANEL on Linux.
	* sysdeps/unix/sysv/linux/sigtimedwait.c (__sigtimedwait): Assume
	signal set was constructed using standard functions.

Reported-by: Yury Norov <ynorov@caviumnetworks.com>
2018-04-03 13:30:49 -03:00
Samuel Thibault 511ed56f2e hurd: Fix buffer overrun in __if_nametoindex
and building with mainline GCC which reports it.

	* sysdeps/mach/hurd/if_index.c (__if_nametoindex): Always end
	ifr.fr_name with a NUL caracter.
2018-04-03 18:06:15 +02:00
Wilco Dijkstra e88ecbbfe8 [PATCH 7/7] sin/cos slow paths: refactor sincos implementation
Refactor the sincos implementation - rather than rely on odd partial inlining
of preprocessed portions from sin and cos, explicitly write out the cases.
This makes sincos much easier to maintain and provides an additional 16-20%
speedup between 0 and 2^27.  The overall speedup of sincos is 48% over this range.
Between 0 and PI it is 66% faster.

	* sysdeps/ieee754/dbl-64/s_sin.c (__sin): Cleanup ifdefs.
	(__cos): Likewise.
	* sysdeps/ieee754/dbl-64/s_sin.c (__sincos): Refactor using the same
	logic as sin and cos.
2018-04-03 16:52:18 +01:00
Wilco Dijkstra aef3e2558a [PATCH 6/7] sin/cos slow paths: refactor duplicated code into dosin
Refactor duplicated code into do_sin.  Since all calls to do_sin use copysign to
set the sign of the result, move it inside do_sin.  Small inputs use a separate
polynomial, so move this into do_sin as well (the check is based on the more
conservative case when doing large range reduction, but could be relaxed).

	* sysdeps/ieee754/dbl-64/s_sin.c (do_sin): Use TAYLOR_SIN for small
	inputs.  Return correct sign.
	(do_sincos): Remove small input check before do_sin, let do_sin set
	the sign.
	(__sin): Likewise.
	(__cos): Likewise.
2018-04-03 16:52:17 +01:00
Wilco Dijkstra 72f6e9a3e3 [PATCH 5/7] sin/cos slow paths: remove unused slowpath functions
Remove all unused slowpath functions.

	* sysdeps/ieee754/dbl-64/s_sin.c (TAYLOR_SLOW): Remove.
	(do_cos_slow): Likewise.
	(do_sin_slow): Likewise.
	(reduce_and_compute): Likewise.
	(slow): Likewise.
	(slow1): Likewise.
	(slow2): Likewise.
	(sloww): Likewise.
	(sloww1): Likewise.
	(sloww2): Likewise.
	(bslow): Likewise.
	(bslow1): Likewise.
	(bslow2): Likewise.
	(cslow2): Likewise.
2018-04-03 16:52:17 +01:00
Wilco Dijkstra 649095838b [PATCH 4/7] sin/cos slow paths: remove slow paths from huge range reduction
For huge inputs use the improved do_sincos function as well.  Now no cases use
the correction factor returned by do_sin, do_cos and TAYLOR_SIN, so remove it.

	* sysdeps/ieee754/dbl-64/s_sin.c (TAYLOR_SIN): Remove cor parameter.
	(do_cos): Remove corp parameter and calculations.
	(do_sin): Likewise.
	(do_sincos): Remove cor variable.
	(__sin): Use do_sincos for huge inputs.
	(__cos): Likewise.
	* sysdeps/ieee754/dbl-64/s_sincos.c (__sincos): Likewise.
	(reduce_and_compute_sincos): Remove unused function.
2018-04-03 16:52:17 +01:00
Wilco Dijkstra d9469deb14 [PATCH 3/7] sin/cos slow paths: remove slow paths from small range reduction
This patch improves the accuracy of the range reduction.  When the input is
large (2^27) and very close to a multiple of PI/2, using 110 bits of PI is not
enough.  Improve range reduction accuracy to 136 bits.  As a result the special
checks for results close to zero can be removed.  The ULP of the polynomials is
at worst 0.55ULP, so there is no reason for the slow functions, and they can be
removed.

	* sysdeps/ieee754/dbl-64/s_sin.c (reduce_sincos_1): Rename to
	reduce_sincos, improve accuracy to 136 bits.
	(do_sincos_1): Rename to do_sincos, remove fallbacks to slow functions.
	(__sin): Use improved reduction and simplified do_sincos calculation.
	(__cos): Likewise.
	* sysdeps/ieee754/dbl-64/s_sincos.c (__sincos): Likewise.
2018-04-03 16:52:17 +01:00
Wilco Dijkstra 7a5640f23a [PATCH 2/7] sin/cos slow paths: remove large range reduction
This patch removes the large range reduction code and defers to the huge range
reduction code.  The first level range reducer supports inputs up to 2^27,
which is way too large given that inputs for sin/cos are typically small
(< 10), and optimizing for a smaller range would give a significant speedup.

Input values above 2^27 are practically never used, so there is no reason for
supporting range reduction between 2^27 and 2^48.  Removing it significantly
simplifies code and enables further speedups.  There is about a 2.3x slowdown
in this range due to __branred being extremely slow  (a better algorithm could
easily more than double performance).

	* sysdeps/ieee754/dbl-64/s_sin.c (reduce_sincos_2): Remove function.
	(do_sincos_2): Likewise.
	(__sin): Remove middle range reduction case.
	(__cos): Likewise.
	* sysdeps/ieee754/dbl-64/s_sincos.c (__sincos): Remove middle range
	reduction case.
2018-04-03 16:52:17 +01:00
Wilco Dijkstra 19a8b9a300 [PATCH 1/7] sin/cos slow paths: avoid slow paths for small inputs
This series of patches removes the slow patchs from sin, cos and sincos.
Besides greatly simplifying the implementation, the new version is also much
faster for inputs up to PI (41% faster) and for large inputs needing range
reduction (27% faster).

ULP is ~0.55 with no errors found after testing 1.6 billion inputs across most
of the range with mpsin and mpcos.  The number of incorrectly rounded results
(ie. ULP >0.5) is at most ~2750 per million inputs between 0.125 and 0.5,
the average is ~850 per million between 0 and PI.

Tested on AArch64 and x86_64 with no regressions.

The first patch removes the slow paths for the cases where the input is small
and doesn't require range reduction.  Update ULP tables for sin, cos and sincos
on AArch64 and x86_64.

	* sysdeps/aarch64/libm-test-ulps: Update ULP for sin, cos, sincos.
	* sysdeps/ieee754/dbl-64/s_sin.c (__sin): Remove slow paths for small
	inputs.
	(__cos): Likewise.
	* sysdeps/x86_64/fpu/libm-test-ulps: Update ULP for sin, cos, sincos.
2018-04-03 16:52:16 +01:00
Joseph Myers f72aa11d7e Use Linux 4.16 in build-many-glibcs.py.
* scripts/build-many-glibcs.py (Context.checkout): Default Linux
	version to 4.16.
2018-04-03 15:41:08 +00:00
Adhemerval Zanella 8e4754ed7e Assume O_DIRECTORY for opendir
This patch assumes O_DIRECTORY works as defined by POSIX on opendir
implementation (aligning with other glibc code, for instance pwd).  This
allows remove both the fallback code to handle system with missing or
broken O_DIRECTORY along with the Linux specific opendir.c which just
advertise the working flag.

Checked on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
sparcv9-linux-gnu, sparc64-linux-gnu, powerpc-linux-gnu, and
powerpc64le-linux-gnu.

	* sysdeps/posix/opendir.c (o_directory_works, tryopen_o_directory):
	Remove definitions.
	(opendir_oflags): Use O_DIRECTORY regardless.
	(__opendir, __opendirat): Remove need_isdir_precheck usage.
	* sysdeps/unix/sysv/linux/opendir.c: Remove file.
2018-04-03 08:57:17 -03:00
Adhemerval Zanella 57408435ad Add Changelog reference to BZ#23024 2018-04-03 08:54:32 -03:00
Samuel Thibault 811836a411 s390x: Fix hidden aliases
* sysdeps/s390/longjmp.c (__libc_longjmp, __libc_siglongjmp): New
	hidden defs.
2018-04-03 13:52:29 +02:00
Samuel Thibault fe9748cca3 hurd: Avoid local PLT in libpthread
* htl/pt-exit.c: Include <pthreadP.h>.
	(__pthread_exit): Call ___pthread_get_cleanup_stack instead of
	__pthread_get_cleanup_stack.
2018-04-03 02:56:35 +02:00
Samuel Thibault 82dbf555a4 hurd: Avoid more libc.so local PLTs
* hurd/catch-signal.c (__hurd_catch_signal): Call __libc_siglongjmp
	instead if siglongjmp.
	(hurd_safe_memmove): Call __libc_longjmp instead of longjmp.
	* hurd/hurdfault.c (faulted): Call __libc_longjmp instead of longjmp.
	* include/setjmp.h (__libc_siglongjmp, __libc_longjmp): New hidden
	prototypes.
	* libio/iolibio.h (_IO_puts): New hidden prototype.
	* libio/ioputs.c (_IO_puts): New hidden def.
	* setjmp/longjmp.c (__libc_longjmp, __libc_siglongjmp): New hidden
	defs.
	* sysdeps/mach/hurd/sigwait.c (__sigwait): Call __libc_longjmp instead
	of longjmp.
2018-04-03 00:36:33 +00:00
Samuel Thibault a758c29399 hurd: Avoid more libc.so PLTs
* sysdeps/hurd/include/hurd/signal.h (_hurd_raise_signal): Add hidden
	prototype.
	* hurd/hurd-raise.c (_hurd_raise_signal): Add hidden def.
	* hurd/Makefile ($(inlines:%=$(objpfx)%.c): Define
	_HEADER_H_HIDDEN_DEF macro.
	* sysdeps/hurd/include/hurd/fd.h (_hurd_fd_error,
	_hurd_fd_error_signal): Add hidden prototype.
	[_HURD_FD_H_HIDDEN_DEF] (_hurd_fd_error, _hurd_fd_error_signal): Add
	hidden def.
2018-04-02 23:40:26 +00:00
Samuel Thibault 7a8f45e302 hurd: Avoid some libc.so PLTs
* hurd/catch-signal.c (hurd_catch_signal): Rename to
	__hurd_catch_signal.
	(hurd_catch_signal): New strong alias.
	(hurd_safe_memset, hurd_safe_copyout, hurd_safe_copyin): Call
	__hurd_catch_signal instead of hurd_catch_signal.
	* hurd/exc2signal.c (_hurd_exception2signal): Add hidden def.
	* hurd/hurdexec.c (_hurd_init): Add hidden def.
	* hurd/hurdinit.c (_hurd_init): Add hidden def.
	* hurd/hurdsig.c: Include <mach/mig_support.h>.
	(_hurd_thread_sigstate): Add hidden def.
	(_hurd_internal_post_signal): Use __mutex_unlock instead of
	mutex_unlock.
	* hurd/intern-fd.c (_hurd_intern_fd): Add hidden def.
	* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Add hidden def.
	* hurd/path-lookup.c (hurd_file_name_path_lookup): Rename to
	__hurd_file_name_path_lookup.
	(hurd_file_name_path_lookup): New strong alias.
	(file_name_path_lookup): Call __hurd_file_name_path_lookup instead of
	hurd_file_name_path_lookup.
	* mach/errstring.c (mach_error_type): Add hidden def.
	* mach/msg-destroy.c (__mach_msg_destroy): Add hidden def.
	* mach/mutex-init.c (__mutex_init): Add hidden def.
	* mach/spin-lock.c (__spin_lock_locked, __spin_lock, __spin_unlock,
	__spin_try_lock, __mutex_lock, __mutex_trylock): Add hidden defs.
	* mach/spin-solid.c (__spin_lock_solid): Add hidden def.
	* sysdeps/mach/hurd/getcwd.c
	(_hurd_canonicalize_directory_name_internal): Rename to
	__hurd_canonicalize_directory_name_internal.
	(_hurd_canonicalize_directory_name_internal): New strong alias.
	(__canonicalize_directory_name_internal, __getcwd): Call
	__hurd_canonicalize_directory_name_internal instead of
	_hurd_canonicalize_directory_name_internal.
	* sysdeps/mach/hurd/mig-reply.c: Include <mach/mig_support.h>.
	(__mig_get_reply_port, __mig_dealloc_reply_port, __mig_init): Add
	hidden defs.
	* sysdeps/hurd/include/hurd.h: New file.
	* sysdeps/hurd/include/hurd/fd.h: New file.
	* sysdeps/hurd/include/hurd/signal.h: New file.
	* sysdeps/mach/include/lock-intern.h: New file.
	* sysdeps/mach/include/mach.h: New file.
	* sysdeps/mach/include/mach/mig_support.h: New file.
	* sysdeps/mach/include/mach_error.h: New file.
2018-04-02 22:08:55 +00:00
Samuel Thibault 171488a2de hurd: whitelist rtld symbols expected to be overridable
* sysdeps/mach/hurd/localplt.data: New file.
2018-04-02 23:02:02 +02:00
Samuel Thibault 97c7a6a68b Revert __dirfd PLT avoidance for now
* io/fts.c (fts_build): Call dirfd instead of __dirfd.
2018-04-02 21:45:38 +02:00
Samuel Thibault dba2bdbe75 hurd: Avoid some PLTs in libc and librt
* hurd/hurdauth.c (_S_msg_add_auth): Call __vm_allocate and
	__vm_deallocate instead of vm_allocate and vm_deallocate.
	* hurd/hurdmsg.c (_S_msg_set_env_variable): Call __setenv instead of
	setenv.
	* hurd/hurdprio.c (_hurd_priority_which_map): Call __geteuid instead
	of geteuid.
	* hurd/path-lookup.c (file_name_path_scan): Call __strdup instead of
	strdup.
	* hurd/siginfo.c: Include <libioP.h>.
	(_hurd_siginfo_handler): Call _IO_puts instead of puts.
	* hurd/xattr.c (_hurd_xattr_get, _hurd_xattr_set): Call __munmap instead of
	munmap.
	* io/fts.c (fts_build): Call __dirfd instead of dirfd.
	* mach/devstream.c: Include <libioP.h>.
	(dealloc_ref): Call __mach_port_deallocate instead of
	mach_port_deallocate.
	(mach_open_devstream): Call _IO_fopencookie instead of fopencookie.
	Call __mach_port_deallocate instead of mach_port_deallocate.
	* stdlib/canonicalize.c (__realpath): Call __pathconf instead of
	pathconf.
	* sysdeps/mach/hurd/ifreq.c (__ifreq): Call __munmap instead of
	munmap.
	* sysdeps/mach/hurd/ifreq.h (__if_freereq): Likewise.
	* sysdeps/mach/hurd/ptrace.c (ptrace): Call __kill instead of kill.
	* sysdeps/mach/hurd/sendfile64.c (sendfile64): Call __munmap instead
	of munmap.
	* sysdeps/mach/hurd/socketpair.c (__socketpair): Call __close instead
	of close.
	* sysdeps/posix/clock_getres.c (realtime_getres): Call __sysconf
	instead of sysconf.
	* sysdeps/pthread/timer_gettime.c (timer_gettime): Call
	__clock_gettime instead of clock_gettime.
	* sysdeps/pthread/timer_routines.c (thread_func): Likewise.
	* sysdeps/pthread/timer_settime.c (timer_settime): Likewise.
	* sysdeps/unix/bsd/gtty.c (gtty): Call __ioctl instead of ioctl.
	* sysdeps/unix/bsd/stty.c (stty): Likewise.
	* sysdeps/unix/bsd/tcflow.c (tcflow): Call __tcgetattr instead of
	tcgetattr.
	* sysdeps/unix/clock_nanosleep.c (__clock_nanosleep): Call
	__clock_gettime and __nanosleep instead of clock_gettime and
	nanosleep.
2018-04-02 19:07:52 +00:00
Samuel Thibault f6fb29d22e hurd: Avoid local PLTs in libpthread.
* htl/cthreads-compat.c (__cthread_detach): Call __pthread_detach
	instead of pthread_detach.
	(__cthread_fork): Call __pthread_create instead of pthread_create.
	(__cthread_keycreate): Call __pthread_key_create instead of
	pthread_key_create.
	(__cthread_getspecific): Call __pthread_getspecific instead of
	pthread_getspecific.
	(__cthread_setspecific): Call __pthread_setspecific instead of
	pthread_setspecific.
	* htl/pt-alloc.c (__pthread_alloc): Call __pthread_mutex_lock and
	__pthread_mutex_unlock instead of pthread_mutex_lock and
	pthread_mutex_unlock.
	* htl/pt-cleanup.c (__pthread_get_cleanup_stack): Rename to
	___pthread_get_cleanup_stack.
	(__pthread_get_cleanup_stack): New strong alias.
	* htl/pt-create.c: Include <pthreadP.h>.
	(entry_point): Call __pthread_exit instead of pthread_exit.
	(pthread_create): Rename to __pthread_create.
	(pthread_create): New strong alias.
	* htl/pt-detach.c (pthread_detach): Rename to __pthread_detach.
	(pthread_detach): New strong alias.
	(__pthread_detach): Call __pthread_cond_broadcast instead of
	pthread_cond_broadcast.
	* htl/pt-exit.c (__pthread_exit): Call __pthread_setcancelstate
	instead of pthread_setcancelstate.
	* htl/pt-testcancel.c: Include <pthreadP.h>.
	(pthread_testcancel): Call __pthread_exit instead of pthread_exit.
	* sysdeps/htl/pt-attr-getstack.c: Include <pthreadP.h>
	(__pthread_attr_getstack): Call __pthread_attr_getstackaddr and
	__pthread_attr_getstacksize instead of pthread_attr_getstackaddr and
	pthread_attr_getstacksize.
	* sysdeps/htl/pt-attr-getstackaddr.c (pthread_attr_getstackaddr):
	Rename to __pthread_attr_getstackaddr.
	(pthread_attr_getstackaddr): New strong alias.
	* sysdeps/htl/pt-attr-getstacksize.c (pthread_attr_getstacksize):
	Rename to __pthread_attr_getstacksize.
	(pthread_attr_getstacksize): New strong alias.
	* sysdeps/htl/pt-attr-setstack.c: Include <pthreadP.h>.
	(pthread_attr_setstack): Rename to __pthread_attr_setstack.
	(pthread_attr_setstack): New strong alias.
	(__pthread_attr_setstack): Call __pthread_attr_getstacksize,
	__pthread_attr_setstacksize and __pthread_attr_setstackaddr instead of
	pthread_attr_getstacksize, pthread_attr_setstacksize and
	pthread_attr_setstackaddr.
	* sysdeps/htl/pt-attr-setstackaddr.c (pthread_attr_setstackaddr):
	Rename to __pthread_attr_setstackaddr.
	(pthread_attr_setstackaddr): New strong alias.
	* sysdeps/htl/pt-attr-setstacksize.c (pthread_attr_setstacksize):
	Rename to __pthread_attr_setstacksize.
	(pthread_attr_setstacksize): New strong alias.
	* sysdeps/htl/pt-cond-timedwait.c: Include <pthreadP.h>.
	(__pthread_cond_timedwait_internal): Use __pthread_exit instead of
	pthread_exit.
	* sysdeps/htl/pt-key-create.c: Include <pthreadP.h>.
	(__pthread_key_create): New hidden def.
	* sysdeps/htl/pt-key.h: Include <pthreadP.h>.
	* sysdeps/htl/pthreadP.h (_pthread_mutex_init,
	__pthread_cond_broadcast, __pthread_create, __pthread_detach,
	__pthread_exit, __pthread_key_create, __pthread_getspecific,
	__pthread_setspecific, __pthread_setcancelstate,
	__pthread_attr_getstackaddr, __pthread_attr_setstackaddr,
	__pthread_attr_getstacksize, __pthread_attr_setstacksize,
	__pthread_attr_setstack, ___pthread_get_cleanup_stack): New
	declarations.
	(__pthread_key_create, _pthread_mutex_init): New hidden declarations.
	* sysdeps/mach/hurd/htl/pt-attr-setstackaddr.c
	(pthread_attr_setstackaddr): Rename to __pthread_attr_setstackaddr.
	(pthread_attr_setstackaddr): New strong alias.
	* sysdeps/mach/hurd/htl/pt-attr-setstacksize.c
	(pthread_attr_setstacksize): Rename to __pthread_attr_setstacksize.
	(pthread_attr_setstacksize): New strong alias.
	* sysdeps/mach/hurd/htl/pt-docancel.c: Include <pthreadP.h>.
	(call_exit): Call __pthread_exit instead of pthread_exit.
	* sysdeps/mach/hurd/htl/pt-mutex-init.c: Include <pthreadP.h>.
	(_pthread_mutex_init): New hidden definition.
	* sysdeps/mach/hurd/htl/pt-sysdep.c: Include <pthreadP.h>.
	(_init_routine): Call __pthread_attr_init and __pthread_attr_setstack
	instead of pthread_attr_init and pthread_attr_setstack.
2018-04-02 18:08:37 +00:00
Samuel Thibault fa9e15558d hurd: Fix exposition of UTIME_NOW, UTIME_OMIT
* sysdeps/mach/hurd/bits/stat.h [!__USE_MISC && __USE_ATFILE]
	(UTIME_NOW, UTIME_OMIT): Define macros.
2018-04-02 17:07:11 +02:00
Samuel Thibault fb03b04b7f hurd: Announce that glibc now builds unpatched
* NEWS: Announce that glibc now builds unpatched on GNU/Hurd.
	* README: Remove the mention of out-of-tree patches needed for
	GNU/Hurd.
2018-04-02 16:45:44 +02:00
Samuel Thibault ad2b41bfd8 hurd: Bump remaining LGPL2+ htl licences to LGPL 2.1+
* htl/Makefile: Bump licence to LGPL 2.1+.
	* htl/alloca_cutoff.c: Likewise.
	* htl/cthreads-compat.c: Likewise.
	* htl/lockfile.c: Likewise.
	* htl/pt-alloc.c: Likewise.
	* htl/pt-cancel.c: Likewise.
	* htl/pt-cleanup.c: Likewise.
	* htl/pt-create.c: Likewise.
	* htl/pt-dealloc.c: Likewise.
	* htl/pt-detach.c: Likewise.
	* htl/pt-exit.c: Likewise.
	* htl/pt-getattr.c: Likewise.
	* htl/pt-initialize.c: Likewise.
	* htl/pt-internal.h: Likewise.
	* htl/pt-join.c: Likewise.
	* htl/pt-self.c: Likewise.
	* htl/pt-setcancelstate.c: Likewise.
	* htl/pt-setcanceltype.c: Likewise.
	* htl/pt-sigmask.c: Likewise.
	* htl/pt-spin-inlines.c: Likewise.
	* htl/pt-testcancel.c: Likewise.
	* htl/pt-yield.c: Likewise.
	* htl/tests/test-1.c: Likewise.
	* htl/tests/test-10.c: Likewise.
	* htl/tests/test-11.c: Likewise.
	* htl/tests/test-12.c: Likewise.
	* htl/tests/test-13.c: Likewise.
	* htl/tests/test-14.c: Likewise.
	* htl/tests/test-15.c: Likewise.
	* htl/tests/test-16.c: Likewise.
	* htl/tests/test-17.c: Likewise.
	* htl/tests/test-2.c: Likewise.
	* htl/tests/test-3.c: Likewise.
	* htl/tests/test-4.c: Likewise.
	* htl/tests/test-5.c: Likewise.
	* htl/tests/test-6.c: Likewise.
	* htl/tests/test-7.c: Likewise.
	* htl/tests/test-8.c: Likewise.
	* htl/tests/test-9.c: Likewise.
	* htl/tests/test-__pthread_destroy_specific-skip.c: Likewise.
	* sysdeps/htl/bits/cancelation.h: Likewise.
	* sysdeps/htl/bits/pthread-np.h: Likewise.
	* sysdeps/htl/bits/pthread.h: Likewise.
	* sysdeps/htl/bits/pthreadtypes.h: Likewise.
	* sysdeps/htl/bits/semaphore.h: Likewise.
	* sysdeps/htl/bits/types/__pthread_key.h: Likewise.
	* sysdeps/htl/bits/types/struct___pthread_attr.h: Likewise.
	* sysdeps/htl/bits/types/struct___pthread_barrier.h: Likewise.
	* sysdeps/htl/bits/types/struct___pthread_barrierattr.h: Likewise.
	* sysdeps/htl/bits/types/struct___pthread_cond.h: Likewise.
	* sysdeps/htl/bits/types/struct___pthread_condattr.h: Likewise.
	* sysdeps/htl/bits/types/struct___pthread_mutex.h: Likewise.
	* sysdeps/htl/bits/types/struct___pthread_mutexattr.h: Likewise.
	* sysdeps/htl/bits/types/struct___pthread_once.h: Likewise.
	* sysdeps/htl/bits/types/struct___pthread_rwlock.h: Likewise.
	* sysdeps/htl/bits/types/struct___pthread_rwlockattr.h: Likewise.
	* sysdeps/htl/old_pt-atfork.c: Likewise.
	* sysdeps/htl/pt-atfork.c: Likewise.
	* sysdeps/htl/pt-attr-destroy.c: Likewise.
	* sysdeps/htl/pt-attr-getdetachstate.c: Likewise.
	* sysdeps/htl/pt-attr-getguardsize.c: Likewise.
	* sysdeps/htl/pt-attr-getinheritsched.c: Likewise.
	* sysdeps/htl/pt-attr-getschedparam.c: Likewise.
	* sysdeps/htl/pt-attr-getschedpolicy.c: Likewise.
	* sysdeps/htl/pt-attr-getscope.c: Likewise.
	* sysdeps/htl/pt-attr-getstack.c: Likewise.
	* sysdeps/htl/pt-attr-getstackaddr.c: Likewise.
	* sysdeps/htl/pt-attr-getstacksize.c: Likewise.
	* sysdeps/htl/pt-attr-init.c: Likewise.
	* sysdeps/htl/pt-attr-setdetachstate.c: Likewise.
	* sysdeps/htl/pt-attr-setguardsize.c: Likewise.
	* sysdeps/htl/pt-attr-setinheritsched.c: Likewise.
	* sysdeps/htl/pt-attr-setschedparam.c: Likewise.
	* sysdeps/htl/pt-attr-setschedpolicy.c: Likewise.
	* sysdeps/htl/pt-attr-setscope.c: Likewise.
	* sysdeps/htl/pt-attr-setstack.c: Likewise.
	* sysdeps/htl/pt-attr-setstackaddr.c: Likewise.
	* sysdeps/htl/pt-attr-setstacksize.c: Likewise.
	* sysdeps/htl/pt-attr.c: Likewise.
	* sysdeps/htl/pt-barrier-destroy.c: Likewise.
	* sysdeps/htl/pt-barrier-init.c: Likewise.
	* sysdeps/htl/pt-barrier-wait.c: Likewise.
	* sysdeps/htl/pt-barrier.c: Likewise.
	* sysdeps/htl/pt-barrierattr-destroy.c: Likewise.
	* sysdeps/htl/pt-barrierattr-getpshared.c: Likewise.
	* sysdeps/htl/pt-barrierattr-init.c: Likewise.
	* sysdeps/htl/pt-barrierattr-setpshared.c: Likewise.
	* sysdeps/htl/pt-cond-brdcast.c: Likewise.
	* sysdeps/htl/pt-cond-destroy.c: Likewise.
	* sysdeps/htl/pt-cond-init.c: Likewise.
	* sysdeps/htl/pt-cond-signal.c: Likewise.
	* sysdeps/htl/pt-cond-timedwait.c: Likewise.
	* sysdeps/htl/pt-cond-wait.c: Likewise.
	* sysdeps/htl/pt-cond.c: Likewise.
	* sysdeps/htl/pt-condattr-destroy.c: Likewise.
	* sysdeps/htl/pt-condattr-getclock.c: Likewise.
	* sysdeps/htl/pt-condattr-getpshared.c: Likewise.
	* sysdeps/htl/pt-condattr-init.c: Likewise.
	* sysdeps/htl/pt-condattr-setclock.c: Likewise.
	* sysdeps/htl/pt-condattr-setpshared.c: Likewise.
	* sysdeps/htl/pt-destroy-specific.c: Likewise.
	* sysdeps/htl/pt-equal.c: Likewise.
	* sysdeps/htl/pt-getconcurrency.c: Likewise.
	* sysdeps/htl/pt-getcpuclockid.c: Likewise.
	* sysdeps/htl/pt-getschedparam.c: Likewise.
	* sysdeps/htl/pt-getspecific.c: Likewise.
	* sysdeps/htl/pt-init-specific.c: Likewise.
	* sysdeps/htl/pt-key-create.c: Likewise.
	* sysdeps/htl/pt-key-delete.c: Likewise.
	* sysdeps/htl/pt-key.h: Likewise.
	* sysdeps/htl/pt-mutex-destroy.c: Likewise.
	* sysdeps/htl/pt-mutex-getprioceiling.c: Likewise.
	* sysdeps/htl/pt-mutex-init.c: Likewise.
	* sysdeps/htl/pt-mutex-lock.c: Likewise.
	* sysdeps/htl/pt-mutex-setprioceiling.c: Likewise.
	* sysdeps/htl/pt-mutex-timedlock.c: Likewise.
	* sysdeps/htl/pt-mutex-trylock.c: Likewise.
	* sysdeps/htl/pt-mutex-unlock.c: Likewise.
	* sysdeps/htl/pt-mutexattr-destroy.c: Likewise.
	* sysdeps/htl/pt-mutexattr-getprioceiling.c: Likewise.
	* sysdeps/htl/pt-mutexattr-getprotocol.c: Likewise.
	* sysdeps/htl/pt-mutexattr-getpshared.c: Likewise.
	* sysdeps/htl/pt-mutexattr-gettype.c: Likewise.
	* sysdeps/htl/pt-mutexattr-init.c: Likewise.
	* sysdeps/htl/pt-mutexattr-setprioceiling.c: Likewise.
	* sysdeps/htl/pt-mutexattr-setprotocol.c: Likewise.
	* sysdeps/htl/pt-mutexattr-setpshared.c: Likewise.
	* sysdeps/htl/pt-mutexattr-settype.c: Likewise.
	* sysdeps/htl/pt-mutexattr.c: Likewise.
	* sysdeps/htl/pt-once.c: Likewise.
	* sysdeps/htl/pt-rwlock-attr.c: Likewise.
	* sysdeps/htl/pt-rwlock-destroy.c: Likewise.
	* sysdeps/htl/pt-rwlock-init.c: Likewise.
	* sysdeps/htl/pt-rwlock-rdlock.c: Likewise.
	* sysdeps/htl/pt-rwlock-timedrdlock.c: Likewise.
	* sysdeps/htl/pt-rwlock-timedwrlock.c: Likewise.
	* sysdeps/htl/pt-rwlock-tryrdlock.c: Likewise.
	* sysdeps/htl/pt-rwlock-trywrlock.c: Likewise.
	* sysdeps/htl/pt-rwlock-unlock.c: Likewise.
	* sysdeps/htl/pt-rwlock-wrlock.c: Likewise.
	* sysdeps/htl/pt-rwlockattr-destroy.c: Likewise.
	* sysdeps/htl/pt-rwlockattr-getpshared.c: Likewise.
	* sysdeps/htl/pt-rwlockattr-init.c: Likewise.
	* sysdeps/htl/pt-rwlockattr-setpshared.c: Likewise.
	* sysdeps/htl/pt-setconcurrency.c: Likewise.
	* sysdeps/htl/pt-setschedparam.c: Likewise.
	* sysdeps/htl/pt-setschedprio.c: Likewise.
	* sysdeps/htl/pt-setspecific.c: Likewise.
	* sysdeps/htl/pt-spin.c: Likewise.
	* sysdeps/htl/pt-startup.c: Likewise.
	* sysdeps/htl/pthread.h: Likewise.
	* sysdeps/htl/sem-close.c: Likewise.
	* sysdeps/htl/sem-destroy.c: Likewise.
	* sysdeps/htl/sem-getvalue.c: Likewise.
	* sysdeps/htl/sem-init.c: Likewise.
	* sysdeps/htl/sem-open.c: Likewise.
	* sysdeps/htl/sem-post.c: Likewise.
	* sysdeps/htl/sem-timedwait.c: Likewise.
	* sysdeps/htl/sem-trywait.c: Likewise.
	* sysdeps/htl/sem-unlink.c: Likewise.
	* sysdeps/htl/sem-wait.c: Likewise.
	* sysdeps/hurd/htl/pt-kill.c: Likewise.
	* sysdeps/i386/htl/pt-machdep.h: Likewise.
	* sysdeps/mach/htl/pt-block.c: Likewise.
	* sysdeps/mach/htl/pt-spin.c: Likewise.
	* sysdeps/mach/htl/pt-stack-alloc.c: Likewise.
	* sysdeps/mach/htl/pt-thread-alloc.c: Likewise.
	* sysdeps/mach/htl/pt-thread-start.c: Likewise.
	* sysdeps/mach/htl/pt-thread-terminate.c: Likewise.
	* sysdeps/mach/htl/pt-timedblock.c: Likewise.
	* sysdeps/mach/htl/pt-wakeup.c: Likewise.
	* sysdeps/mach/hurd/htl/bits/pthread-np.h: Likewise.
	* sysdeps/mach/hurd/htl/bits/types/struct___pthread_mutex.h: Likewise.
	* sysdeps/mach/hurd/htl/pt-attr-setstackaddr.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-attr-setstacksize.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-docancel.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-hurd-cond-timedwait.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-hurd-cond-wait.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-mutex-consistent.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-mutex-destroy.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-mutex-getprioceiling.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-mutex-init.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-mutex-lock.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-mutex-setprioceiling.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-mutex-timedlock.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-mutex-transfer-np.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-mutex-trylock.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-mutex-unlock.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-mutex.h: Likewise.
	* sysdeps/mach/hurd/htl/pt-mutexattr-destroy.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-mutexattr-getprioceiling.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-mutexattr-getprotocol.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-mutexattr-getpshared.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-mutexattr-getrobust.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-mutexattr-gettype.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-mutexattr-init.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-mutexattr-setprioceiling.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-mutexattr-setprotocol.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-mutexattr-setpshared.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-mutexattr-setrobust.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-mutexattr-settype.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-sigstate-destroy.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-sigstate-init.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-sigstate.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-sysdep.c: Likewise.
	* sysdeps/mach/hurd/htl/pt-sysdep.h: Likewise.
	* sysdeps/mach/hurd/i386/htl/pt-machdep.c: Likewise.
	* sysdeps/mach/hurd/i386/htl/pt-setup.c: Likewise.
2018-04-02 16:37:36 +02:00
Samuel Thibault deed72f6b0 hurd: Remove bogus net/if_ppp.h
It was not even compilable anyway.

	* sysdeps/mach/hurd/net/if_ppp.h: Remove file.
	* sysdeps/mach/hurd/Makefile (sysdep_headers): Remove net/if_ppp.h.
2018-04-02 02:07:33 +02:00
Samuel Thibault 8e2666ea9a hurd: Advertise libpthread
* sysdeps/mach/hurd/bits/local_lim.h (_POSIX_THREAD_KEYS_MAX,
_POSIX_THREAD_DESTRUCTOR_ITERATIONS, _POSIX_THREAD_THREADS_MAX): Define
macros.
* sysdeps/mach/hurd/bits/posix_opt.h (_POSIX_THREADS,
_POSIX_THREAD_ATTR_STACKSIZE, _POSIX_THREAD_ATTR_STACKADDR,
_POSIX_SEMAPHORES, _POSIX_READER_WRITER_LOCKS, _POSIX_TIMEOUTS,
_POSIX_SPIN_LOCKS, _POSIX_BARRIERS): Define macros to 200809L.
2018-04-02 01:57:47 +02:00
Samuel Thibault 33574c17ee hurd: Add hurd thread library
Contributed by

Agustina Arzille <avarzille@riseup.net>
Amos Jeffries <squid3@treenet.co.nz>
David Michael <fedora.dm0@gmail.com>
Marco Gerards <marco@gnu.org>
Marcus Brinkmann <marcus@gnu.org>
Neal H. Walfield <neal@gnu.org>
Pino Toscano <toscano.pino@tiscali.it>
Richard Braun <rbraun@sceen.net>
Roland McGrath <roland@gnu.org>
Samuel Thibault <samuel.thibault@ens-lyon.org>
Thomas DiModica <ricinwich@yahoo.com>
Thomas Schwinge <tschwinge@gnu.org>

	* htl: New directory.
	* sysdeps/htl: New directory.
	* sysdeps/hurd/htl: New directory.
	* sysdeps/i386/htl: New directory.
	* sysdeps/mach/htl: New directory.
	* sysdeps/mach/hurd/htl: New directory.
	* sysdeps/mach/hurd/i386/htl: New directory.
	* nscd/Depend, resolv/Depend, rt/Depend: Add htl dependency.
	* sysdeps/mach/hurd/i386/Implies: Add mach/hurd/i386/htl imply.
	* sysdeps/mach/hurd/i386/libpthread.abilist: New file.
2018-04-02 01:44:14 +02:00
Samuel Thibault 03e2aa50fd hurd: avoid letting signals go to thread created by timer_create
* sysdeps/pthread/timer_routines.c (__timer_thread_start): Block all
signals in thread created for runing timers.
2018-04-02 01:32:11 +02:00
Florian Weimer 1aa52ced5d support_format_addrinfo: Include unknown error number in result 2018-04-01 19:41:01 +02:00
Florian Weimer 4d76d3e59d Linux i386: tst-bz21269 triggers SIGBUS on some kernels
In addition to SIGSEGV and SIGILL, SIGBUS is also a possible signal
generated by the kernel.
2018-03-29 11:42:24 +02:00
Adhemerval Zanella d39c0a459e sparc: Fix arch_fork definition
This patch fixes 3dc214977 for sparc.  Different than other architectures
SPARC kernel Kconfig does not define CONFIG_CLONE_BACKWARDS, however it
has the same ABI as if it did, implemented by sparc-specific code
(sparc_do_fork).

It also has a unique return value convention for clone:

   Parent -->  %o0 == child's  pid, %o1 == 0
   Child  -->  %o0 == parent's pid, %o1 == 1

Which required a special macro to correct issue the syscall
(INLINE_CLONE_SYSCALL).

Checked on sparc64-linux-gnu and sparcv9-linux-gnu.

	* sysdeps/unix/sysv/linux/arch-fork.h [__ASSUME_CLONE_BACKWARDS]
	(arch_fork): Issue INLINE_CLONE_SYSCALL if defined.
	* sysdeps/unix/sysv/linux/sparc/kernel-features.h
	(__ASSUME_CLONE_BACKWARDS): Define.
2018-03-27 21:28:58 -03:00
Jesse Hathaway cc8a1620eb getlogin_r: return early when linux sentinel value is set
When there is no login uid Linux sets /proc/self/loginid to the sentinel
value of, (uid_t) -1. If this is set we can return early and avoid
needlessly looking up the sentinel value in any configured nss
databases.

Checked on aarch64-linux-gnu.

	* sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid): Return
	early when linux sentinel value is set.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2018-03-27 21:28:36 -03:00
Samuel Thibault 8bfd94d0dc hurd: advertise process memory locking option
mlock/unlockall were already implemented.

* sysdeps/mach/hurd/bits/posix_opt.h (_POSIX_MEMLOCK): Define.
2018-03-27 23:20:07 +02:00
Andreas Schwab f178e59fa5 Fix crash in resolver on memory allocation failure (bug 23005) 2018-03-27 17:26:32 +02:00
Joseph Myers 5f45f96ad0 Unify umount function implementations (bug 16552).
Linux kernel architectures have various arrangements for umount
syscalls.  There is a syscall that takes flags, and an older one that
does not.  Newer architectures have only the one taking flags, under
the name umount2 (or under the name umount, in the ia64 case).  Older
architectures may have both, under the names umount2 and umount (or
under the names umount and oldumount, in the alpha case).  glibc then
has several similar implementations of the umount function (no flags)
in terms of either the __umount2 function, or the corresponding
syscall, or in terms of the old syscall under either of its names.

This patch simplifies the implementations in glibc by always using the
__umount2 function to implement the umount function on all systems
using the Linux kernel.  The linux/generic implementation is moved to
sysdeps/unix/sysv/linux (without any changes to code or comments) and
all the other variants are removed.  (This will have the effect of
causing the new syscall to be used in some cases that previously used
the old one, but as discussed for previous changes, such a change to
the underlying syscalls used is OK.)

There remain two variants of how the __umount2 function is
implemented, either in umount2.S, or, for ia64, in syscalls.list.

Tested with build-many-glibcs.py.

	[BZ #16552]
	* sysdeps/unix/sysv/linux/generic/umount.c: Move to ....
	* sysdeps/unix/sysv/linux/umount.c: ... here.
	* sysdeps/unix/sysv/linux/arm/umount.c: Remove file.
	* sysdeps/unix/sysv/linux/hppa/umount.c: Likewise.
	* sysdeps/unix/sysv/linux/ia64/umount.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/umount.c: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/umount.c: Likewise.
	* sysdeps/unix/sysv/linux/umount.S: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/umount.c: Likewise.
2018-03-26 21:18:28 +00:00
Andreas Schwab 3dfd23eb4b RISC-V: add remaining relocations 2018-03-26 12:08:21 +02:00
Samuel Thibault 2d813d7b77 hurd: Regenerate errno.h header
* sysdeps/mach/hurd/bits/errno.h: Regenerate.
2018-03-25 20:17:35 +00:00
Samuel Thibault 978a6803e2 hurd: Fix calling __pthread_initialize_minimal in shared case
* sysdeps/generic/ldsodefs.h [SHARED] (__pthread_initialize_minimal):
	Declare function.
2018-03-25 00:59:18 +01:00
Samuel Thibault 37be82a03f Add missing changelog from previous commit 2018-03-25 00:54:55 +01:00
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
Joseph Myers 3785b31c16 Fix hppa local PLT entries for sigprocmask (bug 18124).
When adding/updating localplt.data for various architectures to get
the compilation tests passing everywhere, I generally made it reflect
the existing state of what local PLT entries were actually seen,
rather than an ideal state with as few as possible such entries,
mainly for functions that are intended to be interposable.

This patch eliminates some local PLT entries for hppa by using
__sigprocmask instead of sigprocmask in getcontext and setcontext.
The specific case of sigprocmask called by setcontext is the third of
four items in bug 18124 (the other three have already been fixed for
2.26 or earlier releases).  Note that hppa-specific localplt.data
entries for __sigsetjmp, _IO_funlockfile and __errno_location remain,
but the causes / fixes are less immediately obvious from source
inspection.

Tested (compilation tests only) with build-many-glibcs.py for
hppa-linux-gnu.

	[BZ #18124]
	* sysdeps/hppa/bsd-setjmp.S: Include <sysdep.h>.
	(setjmp): Use HIDDEN_JUMPTARGET with __sigsetjmp.
	* sysdeps/unix/sysv/linux/hppa/getcontext.S (__getcontext): Call
	__sigprocmask instead of sigprocmask.
	* sysdeps/unix/sysv/linux/hppa/setcontext.S (__setcontext):
	Likewise.
	* sysdeps/unix/sysv/linux/hppa/localplt.data: Remove entries for
	__sigsetjmp and sigprocmask.
2018-02-15 21:01:25 +00:00
Joseph Myers 055ac2a7ee Use libc_hidden_* for argz_next, __argz_next (bug 15105).
Among other localplt test failures when building with -Os, there are
libc.so PLT references for argz_next and __argz_next.  This is a
simple case of functions that are inlined for -O2 but not for -Os;
this patch adds libc_hidden_proto / libc_hidden_def for them to avoid
localplt failures even when not inlined.

Tested for x86_64 (both that it removes these particular localplt
failures for -Os - but other such failures remain so the bug can't yet
be closed - and that the testsuite continues to pass without -Os).

	[BZ #15105]
	* include/argz.h (argz_next): Use libc_hidden_proto.
	(__argz_next): Likewise.
	* string-argz-next.c (__argz_next): Use libc_hidden_def.
	(argz_next): Use libc_hidden_weak.
2018-02-15 21:00:02 +00:00
Joseph Myers e4452a2d19 Use libc_hidden_* for __cmsg_nxthdr (bug 15105).
Among other localplt test failures when building with -Os, there are
libc.so PLT references for __cmsg_nxthdr.  This is a simple case of a
function that is inlined for -O2 but not for -Os; this patch adds
libc_hidden_proto / libc_hidden_def for it to avoid a localplt failure
even when it is not inlined.

Tested for x86_64 (both that it removes this particular localplt
failure for -Os - but other such failures remain so the bug can't yet
be closed - and that the testsuite continues to pass without -Os).

	[BZ #15105]
	* include/sys/socket.h [!_ISOMAC] (__cmsg_nxthdr): Use
	libc_hidden_proto.
	* sysdeps/unix/sysv/linux/cmsg_nxthdr.c (__cmsg_nxthdr): Use
	libc_hidden_def.
2018-02-15 20:59:12 +00:00
Joseph Myers 499b315324 Use libc_hidden_* for fputs (bug 15105).
Among other localplt test failures when building with -Os, there are
libc.so PLT references for fputs.  fputs calls normally get redirected
to _IO_fputs by a macro in include/stdio.h (and _IO_fputs in turn uses
libc_hidden_proto), but GCC can convert an fprintf call with a
constant string argument into an fputs call, which of course is then
unaffected by the macro redirection.  (I don't know why this issue
only appears with -Os.)

This patch duly adds a use of libc_hidden_proto for fputs.  I see no
obvious reason why the fputs macro redirection is needed at all, but
this patch does not change it.

Tested for x86_64 (both that it removes this particular localplt
failure for -Os - but other such failures remain so the bug can't yet
be closed - and that the testsuite continues to pass without -Os).

	[BZ #15105]
	* include/stdio.h [!_ISOMAC && IS_IN (libc)] (fputs): Use
	libc_hidden_proto.
	* libio/iofputs.c (fputs): Use libc_hidden_weak.
2018-02-15 20:58:16 +00:00
Joseph Myers 7fc03cf320 Fix -Os feof_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 feof_unlocked.

The usual approach is followed of adding __feof_unlocked (inlined when
feof_unlocked is), making calls use it when required for namespace
reasons, and using libc_hidden_proto / libc_hidden_weak for the
feof_unlocked weak alias when only localplt but not namespace issues
are involved.  In the case of getaddrinfo.c, use of __feof_unlocked
needs to be conditional since that code is also used in nscd (where
__feof_unlocked is not available).

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/feof_u.c (feof_unlocked): Rename to __feof_unlocked and
	define as weak alias of __feof_unlocked.  Use libc_hidden_weak.
	* include/stdio.h (feof_unlocked): Use libc_hidden_proto.
	(__feof_unlocked): New declaration, and inline function if
	[__USE_EXTERN_INLINES].
	* iconv/gconv_conf.c (read_conf_file): Call __feof_unlocked
	instead of feof_unlocked.
	* intl/localealias.c [_LIBC] (FEOF): Likewise.
	* nss/nsswitch.c (nss_parse_file): Likewise.
	* sysdeps/unix/sysv/linux/readonly-area.c (__readonly_area):
	Likewise.
	* time/getdate.c (__getdate_r): Likewise.
	* sysdeps/posix/getaddrinfo.c [IS_IN (libc)] (feof_unlocked):
	Define as macro to call __feof_unlocked.
2018-02-15 20:57:15 +00:00
Wilco Dijkstra 0c8a67a573 [AArch64] Fix include.
Fix include to use <>.

	* sysdeps/aarch64/fpu/fpu_control.h: Use <> in include.
2018-02-15 12:41:06 +00:00
Wilco Dijkstra 610ee1fc93 Remove mplog and mpexp
Remove the now unused mplog and mpexp files.

	* math/Makefile: Remove mpexp.c and mplog.c
	* sysdeps/i386/fpu/mpexp.c: Delete file.
	* sysdeps/i386/fpu/mplog.c: Likewise.
	* sysdeps/ia64/fpu/mpexp.c: Likewise.
	* sysdeps/ia64/fpu/mplog.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_exp.c: Remove mention of mpexp and mplog.
	* sysdeps/ieee754/dbl-64/mpa.h (__pow_mp): Remove unused function.
	* sysdeps/ieee754/dbl-64/mpexp.c: Delete file.
	* sysdeps/ieee754/dbl-64/mplog.c: Likewise.
	* sysdeps/m68k/m680x0/fpu/mpexp.c: Likewise.
	* sysdeps/m68k/m680x0/fpu/mplog.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/Makefile: Remove mpexp* and mplog*.
	* sysdeps/x86_64/fpu/multiarch/e_log-avx.c: Remove unused defines.
	* sysdeps/x86_64/fpu/multiarch/e_log-fma.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/e_log-fma4.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/mpexp-avx.c: Delete file.
	* sysdeps/x86_64/fpu/multiarch/mpexp-fma.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/mpexp-fma4.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/mplog-avx.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/mplog-fma.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/mplog-fma4.c: Likewise.
2018-02-15 12:41:05 +00:00
Stefan Liebler 8e7196c875 S390: Regenerate ULPs.
Regenerated ulps file from scratch due to recent pow changes.

ChangeLog:

	* sysdeps/s390/fpu/libm-test-ulps: Regenerated.
2018-02-15 09:06:18 +01:00
Adhemerval Zanella 4f55ad0bc9 Update SH libm-tests-ulps
* sysdeps/sh/libm-test-ulps: Update.

Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2018-02-14 14:03:40 -02:00
Tulio Magno Quites Machado Filho 261a851c22 powerpc: Update pow() ULPs
* sysdeps/powerpc/fpu/libm-test-ulps (pow): Increase double and
	idouble to 1 ULP.

Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
2018-02-12 13:23:03 -02:00
Zack Weinberg e16deca62e [BZ #19239] Don't include sys/sysmacros.h from sys/types.h.
This completes the deprecation and removal of this inclusion, which
was begun in the 2.25 release.

	* posix/sys/types.h: Don't include sys/sysmacros.h.
	* misc/sys/sysmacros.h: Remove the conditional deprecation
	warnings for the macros defined by this header.
2018-02-12 07:34:50 -05:00
Szabolcs Nagy de800d8305 Remove slow paths from exp
Remove the __slowexp code, so exp is no longer correctly rounded.  The
result is computed to about 70 bits precision so the worst case ulp
error is about 0.500007 in nearest rounding mode.

	* manual/probes.texi: Remove slowexp probes.
	* math/Makefile: Remove slowexp.
	* sysdeps/generic/math_private.h (__slowexp): Remove.
	* sysdeps/ieee754/dbl-64/e_exp.c (__ieee754_exp): Remove __slowexp and
	document error bounds.
	* sysdeps/i386/fpu/slowexp.c: Remove.
	* sysdeps/ia64/fpu/slowexp.c: Remove.
	* sysdeps/ieee754/dbl-64/slowexp.c: Remove.
	* sysdeps/ieee754/dbl-64/uexp.h (err_0): Remove.
	* sysdeps/m68k/m680x0/fpu/slowexp.c: Remove.
	* sysdeps/powerpc/power4/fpu/Makefile (CPPFLAGS-slowexp.c): Remove.
	* sysdeps/x86_64/fpu/multiarch/Makefile: Remove slowexp-fma.
	* sysdeps/x86_64/fpu/multiarch/e_exp-avx.c (__slowexp): Remove.
	* sysdeps/x86_64/fpu/multiarch/e_exp-fma.c (__slowexp): Remove.
	* sysdeps/x86_64/fpu/multiarch/e_exp-fma4.c (__slowexp): Remove.
	* sysdeps/x86_64/fpu/multiarch/slowexp-avx.c: Remove.
	* sysdeps/x86_64/fpu/multiarch/slowexp-fma.c: Remove.
	* sysdeps/x86_64/fpu/multiarch/slowexp-fma4.c: Remove.
2018-02-12 11:33:33 +00:00
Wilco Dijkstra c3d466cba1 Remove slow paths from pow
Remove the slow paths from pow.  Like several other double precision math
functions, pow is exactly rounded.  This is not required from math functions
and causes major overheads as it requires multiple fallbacks using higher
precision arithmetic if a result is close to 0.5ULP.  Ridiculous slowdowns
of up to 100000x have been reported when the highest precision path triggers.

All GLIBC math tests pass on AArch64 and x64 (with ULP of pow set to 1).
The worst case error is ~0.506ULP.  A simple test over a few hundred million
values shows pow is 10% faster on average.  This fixes BZ #13932.

	[BZ #13932]
	* sysdeps/ieee754/dbl-64/uexp.h (err_1): Remove.
	* benchtests/pow-inputs: Update comment for slow path cases.
	* manual/probes.texi (slowpow_p10): Delete removed probe.
	(slowpow_p10): Likewise.
	* math/Makefile: Remove halfulp.c and slowpow.c.
	* sysdeps/aarch64/libm-test-ulps: Set ULP of pow to 1.
	* sysdeps/generic/math_private.h (__exp1): Remove error argument.
	(__halfulp): Remove.
	(__slowpow): Remove.
	* sysdeps/i386/fpu/halfulp.c: Delete file.
	* sysdeps/i386/fpu/slowpow.c: Likewise.
	* sysdeps/ia64/fpu/halfulp.c: Likewise.
	* sysdeps/ia64/fpu/slowpow.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_exp.c (__exp1): Remove error argument,
	improve comments and add error analysis.
	* sysdeps/ieee754/dbl-64/e_pow.c (__ieee754_pow): Add error analysis.
	(power1): Remove function:
	(log1): Remove error argument, add error analysis.
	(my_log2): Remove function.
	* sysdeps/ieee754/dbl-64/halfulp.c: Delete file.
	* sysdeps/ieee754/dbl-64/slowpow.c: Likewise.
	* sysdeps/m68k/m680x0/fpu/halfulp.c: Likewise.
	* sysdeps/m68k/m680x0/fpu/slowpow.c: Likewise.
	* sysdeps/powerpc/power4/fpu/Makefile: Remove CPPFLAGS-slowpow.c.
	* sysdeps/x86_64/fpu/libm-test-ulps: Set ULP of pow to 1.
	* sysdeps/x86_64/fpu/multiarch/Makefile: Remove slowpow-fma.c,
	slowpow-fma4.c, halfulp-fma.c, halfulp-fma4.c.
	* sysdeps/x86_64/fpu/multiarch/e_pow-fma.c (__slowpow): Remove define.
	* sysdeps/x86_64/fpu/multiarch/e_pow-fma4.c (__slowpow): Likewise.
	* sysdeps/x86_64/fpu/multiarch/halfulp-fma.c: Delete file.
	* sysdeps/x86_64/fpu/multiarch/halfulp-fma4.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/slowpow-fma.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/slowpow-fma4.c: Likewise.
2018-02-12 10:47:09 +00:00
Samuel Thibault 7bb087bd7b nscd: don't unconditionally use PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP
PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP is Linux-only.

* nscd/connections.c (RWLOCK_INITIALIZER): Define to
PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP or
PTHREAD_RWLOCK_INITIALIZER if that is not available.
(dbs): Use RWLOCK_INITIALIZER instead of
PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP.
2018-02-11 18:22:11 +01:00
Dmitry V. Levin 2fd4bbaa14 linux/aarch64: sync sys/ptrace.h with Linux 4.15 [BZ #22433]
Remove compat-specific constants that were never exported by kernel
headers under these names.  Before linux commit v3.7-rc1~16^2~1 they
were exported with COMPAT_ prefix, and since that commit they are not
exported at all.

* sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h (__ptrace_request):
Remove arm-specific PTRACE_GET_THREAD_AREA, PTRACE_GETHBPREGS,
and PTRACE_SETHBPREGS.
2018-02-10 22:12:12 +00:00
Zack Weinberg 402ecba487 [BZ #22830] malloc_stats: restore cancellation for stderr correctly.
malloc_stats means to disable cancellation for writes to stderr while
it runs, but it restores stderr->_flags2 with |= instead of =, so what
it actually does is disable cancellation on stderr permanently.

	[BZ #22830]
	* malloc/malloc.c (__malloc_stats): Restore stderr->_flags2
        correctly.
        * malloc/tst-malloc-stats-cancellation.c: New test case.
        * malloc/Makefile: Add new test case.
2018-02-10 16:24:17 -05:00
Wilco Dijkstra 4f5b921eb9 [AArch64] Fix testsuite error due to fpsr/fscr change
Add features.h include for __GNUC_PREREQ.

	* sysdeps/aarch64/fpu/fpu_control.h: Add features.h to fix build error.
2018-02-10 15:02:51 +00:00
Joseph Myers d8742dd82f Add narrowing add functions.
This patch adds the narrowing add functions from TS 18661-1 to glibc's
libm: fadd, faddl, daddl, f32addf64, f32addf32x, f32xaddf64 for all
configurations; f32addf64x, f32addf128, f64addf64x, f64addf128,
f32xaddf64x, f32xaddf128, f64xaddf128 for configurations with
_Float64x and _Float128; __nldbl_daddl for ldbl-opt.  As discussed for
the build infrastructure patch, tgmath.h support is deliberately
deferred, and FP_FAST_* macros are not applicable without optimized
function implementations.

Function implementations are added for all relevant pairs of formats
(including certain cases of a format and itself where more than one
type has that format).  The main implementations use round-to-odd, or
a trivial computation in the case where both formats are the same or
where the wider format is IBM long double (in which case we don't
attempt to be correctly rounding).  The sysdeps/ieee754/soft-fp
implementations use soft-fp, and are used automatically for
configurations without exceptions and rounding modes by virtue of
existing Implies files.  As previously discussed, optimized versions
for particular architectures are possible, but not included.

i386 gets a special version of f32xaddf64 to avoid problems with
double rounding (similar to the existing fdim version), since this
function must round just once without an intermediate rounding to long
double.  (No such special version is needed for any other function,
because the nontrivial functions use round-to-odd, which does the
intermediate computation with the rounding mode set to round-to-zero,
and double rounding is OK except in round-to-nearest mode, so is OK
for that intermediate round-to-zero computation.)  mul and div will
need slightly different special versions for i386 (using round-to-odd
on long double instead of precision control) because of the
possibility of inexact intermediate results in the subnormal range for
double.

To reduce duplication among the different function implementations,
math-narrow.h gets macros CHECK_NARROW_ADD, NARROW_ADD_ROUND_TO_ODD
and NARROW_ADD_TRIVIAL.

In the trivial cases and for any architecture-specific optimized
implementations, the overhead of the errno setting might be
significant, but I think that's best handled through compiler built-in
functions rather than providing separate no-errno versions in glibc
(and likewise there are no __*_finite entry points for these function
provided, __*_finite effectively being no-errno versions at present in
most cases).

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

	* math/Makefile (libm-narrow-fns): Add add.
	(libm-test-funcs-narrow): Likewise.
	* math/Versions (GLIBC_2.28): Add narrowing add functions.
	* math/bits/mathcalls-narrow.h (add): Use __MATHCALL_NARROW .
	* math/gen-auto-libm-tests.c (test_functions): Add add.
	* math/math-narrow.h (CHECK_NARROW_ADD): New macro.
	(NARROW_ADD_ROUND_TO_ODD): Likewise.
	(NARROW_ADD_TRIVIAL): Likewise.
	* sysdeps/ieee754/float128/float128_private.h (__faddl): New
	macro.
	(__daddl): Likewise.
	* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add fadd and
	dadd.
	(CFLAGS-nldbl-dadd.c): New variable.
	(CFLAGS-nldbl-fadd.c): Likewise.
	* sysdeps/ieee754/ldbl-opt/Versions (GLIBC_2.28): Add
	__nldbl_daddl.
	* sysdeps/ieee754/ldbl-opt/nldbl-compat.h (__nldbl_daddl): New
	prototype.
	* manual/arith.texi (Misc FP Arithmetic): Document fadd, faddl,
	daddl, fMaddfN, fMaddfNx, fMxaddfN and fMxaddfNx.
	* math/auto-libm-test-in: Add tests of add.
	* math/auto-libm-test-out-narrow-add: New generated file.
	* math/libm-test-narrow-add.inc: New file.
	* sysdeps/i386/fpu/s_f32xaddf64.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_f32xaddf64.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_fadd.c: Likewise.
	* sysdeps/ieee754/float128/s_f32addf128.c: Likewise.
	* sysdeps/ieee754/float128/s_f64addf128.c: Likewise.
	* sysdeps/ieee754/float128/s_f64xaddf128.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_daddl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_f64xaddf128.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_faddl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_daddl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_faddl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_daddl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_faddl.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/nldbl-dadd.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/nldbl-fadd.c: Likewise.
	* sysdeps/ieee754/soft-fp/s_daddl.c: Likewise.
	* sysdeps/ieee754/soft-fp/s_fadd.c: Likewise.
	* sysdeps/ieee754/soft-fp/s_faddl.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-02-10 02:08:43 +00:00
Joseph Myers a85b70dbd2 Fix narrowing function tests build for powerpc64le.
Testing narrowing functions with build-many-glibcs.py showed up a
further testsuite fix needed to enable building such functions for
powerpc64le: tests test-<narrower-type>-float128-<function> (and
likewise for float64x) needed the same special handling for
powerpc64le as test-float128-* and test-float64x-*.  This patch adds
that special handling.

Tested with build-many-glibcs.py for powerpc64le in conjunction with
the main patch adding narrowing add functions.

	* sysdeps/powerpc/powerpc64le/Makefile [$(subdir) = math]
	(f128-pairs): New variable.
	[$(subdir) = math] ($(foreach suf,$(all-object-suffixes),$(foreach
	pair,$(f128-pairs),$(objpfx)test-$(pair)%$(suf)))): Add -mfloat128
	to CFLAGS.
	[$(subdir) = math] ($(foreach pair,$(f128-pairs),test-$(pair)%)):
	Also make tests add $(f128-loader-link) to gnulib-tests.
2018-02-10 01:52:33 +00:00
DJ Delorie 6a1ff640dc [RISC-V] Fix parsing flags in ELF64 files.
When ldconfig reads Elf64 files to determine the ABI, it used the
Elf32 type, so read the wrong location, and stored the wrong ABI
type in the cache, making the cache useless.  This patch uses
an Elf64 type for Elf64 objects instead.

Note that pre-patch caches might need to be manually removed and
regenerated to get the correct ABIs stored.

	[BZ #22827]
	* sysdeps/unix/sysv/linux/riscv/readelflib.c (process_elf_file): Use
	64-bit ELF type for 64-bit ELF objects.
2018-02-09 18:51:32 -05:00
Joseph Myers 3195833899 Handle narrowing function sNaN test disabling based on argument format.
Testing narrowing functions for x86_64 with GCC 6 showed up a further
testsuite fix needed: there is no _Float128 sNaN support before GCC 7
on x86_64 / x86, and the existing tests of SNAN_TESTS only checked it
for the return type, not for the argument type.  This patch fixes the
code to check SNAN_TESTS (ARG_FLOAT) as well (in a variable set in
libm-test-driver.c, since libm-test-support.c is compiled only once
for each choice of FLOAT).

Tested for x86_64 and x86 with GCC 6 in conjunction with the main
patch adding narrowing add functions.

	* math/libm-test-driver.c (snan_tests_arg): New variable.
	* math/libm-test-support.h (snan_tests_arg): New declaration.
	* math/libm-test-support.c (enable_test): Check snan_tests_arg.
2018-02-09 22:56:35 +00:00
Joseph Myers 8e554659ad Add test infrastructure for narrowing libm functions.
This patch continues preparations for adding TS 18661-1 narrowing libm
functions by adding the required testsuite infrastructure to test such
functions through the libm-test infrastructure.

That infrastructure is based around testing for a single type, FLOAT.
For the narrowing functions, FLOAT, the "main" type for testing, is
the function return type; the argument type is ARG_FLOAT.  This is
consistent with how the code built once for each type,
libm-test-support.c, depends on FLOAT for such things as calculating
ulps errors in results but can already handle different argument types
(pointers, integers, long double for nexttoward).

Makefile machinery is added to handle building tests for all pairs of
types for which there are narrowing functions (as with non-narrowing
functions, aliases are tested just the same as the functions they
alias).  gen-auto-libm-tests gains a --narrow option for building
outputs for narrowing functions (so narrowing sqrt and fma will share
the same inputs as non-narrowing, but gen-auto-libm-tests will be run
with and without that option to generate different output files).  In
the narrowing case, the auto-libm-test-out-narrow-* files include
annotations for each test about what properties ARG_FLOAT must have to
be able to represent all the inputs for that test; those annotations
result in calls to the TEST_COND_arg_fmt macro.

gen-libm-test.pl has some minor updates to handle narrowing tests (for
example, arguments in such tests must be surrounded by ARG_LIT calls
instead of LIT calls).  Various new macros are added to the C test
support code (for example, sNaN initializers need to be properly
typed, so arg_snan_value is added; other such arg_* macros are added
as it seems cleanest to do so, though some are not strictly required).
Special-casing of the ibm128 format to allow for its limitations is
adjusted to handle it as the argument format as well as as the result
format; thus, the tests of the new functions allow nonzero ulps only
in the case where ibm128 is the argument format, as otherwise the
functions correspond to fully-defined IEEE operations.  The ulps in
question appear as e.g. 'Function: "add_ldouble"' in libm-test-ulps
(with 1ulp errors then listed for double and float for that function
in powerpc); no support is added to generate corresponding faddl /
daddl ulps listings in the ulps table in the manual.

For the previous patch, I noted the need to avoid spurious macro
expansions of identifiers such as "add".  A test test-narrow-macros.c
is added to verify such macro expansions are successfully avoided, and
there is also a -mlong-double-64 version of that test for ldbl-opt.
This test is set up to cover the full set of relevant identifiers from
the start rather than adding functions one at a time as each function
group is added.

Tested for x86_64 (this patch in isolation, as well as testing for
various configurations in conjunction with the actual addition of
"add" functions).

	* math/Makefile (test-type-pairs): New variable.
	(test-type-pairs-f64xf128-yes): Likewise.
	(tests): Add test-narrow-macros.
	(libm-test-funcs-narrow): New variable.
	(libm-test-c-narrow): Likewise.
	(generated): Add $(libm-test-c-narrow).
	(libm-tests-base-narrow): New variable.
	(libm-tests-narrow): Likewise.
	(libm-tests): Add $(libm-tests-narrow).
	(libm-tests-for-type): Handle $(libm-tests-narrow).
	(libm-test-c-narrow-obj): New variable.
	($(libm-test-c-narrow-obj)): New rule.
	($(foreach t,$(libm-tests-narrow),$(objpfx)$(t).c)): Likewise.
	($(foreach f,$(libm-test-funcs-narrow),$(objpfx)$(o)-$(f).o)): Use
	$(o-iterator) to set dependencies and CFLAGS.
	* math/gen-auto-libm-tests.c: Document use for narrowing
	functions.
	(output_for_one_input_case): Take argument NARROW.
	(generate_output): Likewise.  Update call to
	output_for_one_input_case.
	(main): Take --narrow option.  Update call to generate_output.
	* math/gen-libm-test.pl (_apply_lit): Take macro name as argument.
	(apply_lit): Update call to _apply_lit.
	(apply_arglit): New function.
	(parse_args): Handle "a" arguments.
	(parse_auto_input): Handle format names using ":".
	* math/README.libm-test: Document "a" parameter type.
	* math/libm-test-support.h (ARG_TYPE_MIN): New macro.
	(ARG_TYPE_TRUE_MIN): Likewise.
	(ARG_TYPE_MAX): Likwise.
	(ARG_MIN_EXP): Likewise.
	(ARG_MAX_EXP): Likewise.
	(ARG_MANT_DIG): Likewise.
	(TEST_COND_arg_ibm128): Likewise.
	(TEST_COND_ibm128_libgcc): Define conditional on [ARG_FLOAT].
	(TEST_COND_arg_fmt): New macro.
	(init_max_error): Update prototype.
	* math/libm-test-support.c (test_ibm128): New variable.
	(init_max_error): Take argument testing_ibm128 and set test_ibm128
	instead of using [TEST_COND_ibm128] conditional.
	(test_exceptions): Use test_ibm128 instead of TEST_COND_ibm128.
	* math/libm-test-driver.c (STR_ARG_FLOAT): New macro.
	[TEST_NARROW] (TEST_MSG): New definition.
	(arg_plus_zero): New macro.
	(arg_minus_zero): Likewise.
	(arg_plus_infty): Likewise.
	(arg_minus_infty): Likewise.
	(arg_qnan_value_pl): Likewise.
	(arg_qnan_value): Likewise.
	(arg_snan_value_pl): Likewise.
	(arg_snan_value): Likewise.
	(arg_max_value): Likewise.
	(arg_min_value): Likewise.
	(arg_min_subnorm_value): Likewise.
	[ARG_FLOAT] (struct test_aa_f_data): New struct type.
	(RUN_TEST_LOOP_aa_f): New macro.
	(TEST_SUFF): New macro.
	(TEST_SUFF_STR): Likewise.
	[!TEST_MATHVEC] (VEC_SUFF): Don't define.
	(TEST_COND_any_ibm128): New macro.
	(START): Use TEST_SUFF and TEST_SUFF_STR in initializer for
	this_func.  Update call to init_max_error.
	* math/test-double.h (FUNC_NARROW_PREFIX): New macro.
	* math/test-float.h (FUNC_NARROW_PREFIX): Likewise.
	* math/test-float128.h (FUNC_NARROW_PREFIX): Likewise.
	* math/test-float32.h (FUNC_NARROW_PREFIX): Likewise.
	* math/test-float32x.h (FUNC_NARROW_PREFIX): Likewise.
	* math/test-float64.h (FUNC_NARROW_PREFIX): Likewise.
	* math/test-float64x.h (FUNC_NARROW_PREFIX): Likewise.
	* math/test-math-scalar.h (TEST_NARROW): Likewise.
	* math/test-math-vector.h (TEST_NARROW): Likewise.
	* math/test-arg-double.h: New file.
	* math/test-arg-float128.h: Likewise.
	* math/test-arg-float32x.h: Likewise.
	* math/test-arg-float64.h: Likewise.
	* math/test-arg-float64x.h: Likewise.
	* math/test-arg-ldouble.h: Likewise.
	* math/test-math-narrow.h: Likewise.
	* math/test-narrow-macros.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/test-narrow-macros-ldbl-64.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/Makefile (tests): Add
	test-narrow-macros-ldbl-64.
	(CFLAGS-test-narrow-macros-ldbl-64.c): New variable.
2018-02-09 21:55:48 +00:00
Joseph Myers 63716ab270 Add build infrastructure for narrowing libm functions.
TS 18661-1 defines libm functions that carry out an operation (+ - * /
sqrt fma) on their arguments and return a result rounded to a
(usually) narrower type, as if the original result were computed to
infinite precision and then rounded directly to the result type
without any intermediate rounding to the argument type.  For example,
fadd, faddl and daddl for addition.  These are the last remaining TS
18661-1 functions left to be added to glibc.  TS 18661-3 extends this
to corresponding functions for _FloatN and _FloatNx types.

As functions parametrized by two rather than one varying
floating-point types, these functions require infrastructure in glibc
that was not required for previous libm functions.  This patch
provides such infrastructure - excluding test support, and actual
function implementations, which will be in subsequent patches.

Declaring the functions uses a header bits/mathcalls-narrow.h, which
is included many times, for each relevant pair of types.  This will
end up containing macro calls of the form

__MATHCALL_NARROW (__MATHCALL_NAME (add), __MATHCALL_REDIR_NAME (add), 2);

for each family of narrowing functions.  (The structure of this macro
call, with the calls to __MATHCALL_NAME and __MATHCALL_REDIR_NAME
there rather than in the definition of __MATHCALL_NARROW, arises from
the names such as "add" *not* themselves being reserved identifiers -
meaning it's necessary to avoid any indirection that would result in a
user-defined "add" macro being expanded.)  Whereas for existing
functions declaring long double functions is disabled if _LIBC in the
case where they alias double functions, to facilitate defining the
long double functions as aliases of the double ones, there is no such
logic for the narrowing functions in this patch.  Rather, the files
defining such functions are expected to use #define to hide the
original declarations of the alias names, to avoid errors about
defining aliases with incompatible types.

math/Makefile support is added for building the functions (listed in
libm-narrow-fns, currently empty) for all relevant pairs of types.  An
internal header math-narrow.h is added for macros shared between
multiple function implementations - currently a ROUND_TO_ODD macro to
facilitate writing functions using the round-to-odd implementation
approach, and alias macros to create all the required function
aliases.  libc_feholdexcept_setroundf128 and libc_feupdateenv_testf128
are added for use when required (only for x86_64).  float128_private.h
support is added for ldbl-128 narrowing functions to be used for
_Float128.

Certain things are specifically omitted from this patch and the
immediate followups.  tgmath.h support is deferred; there remain
unresolved questions about how the type-generic macros for these
functions are supposed to work, especially in the case of arguments of
integer type.  The math.h / bits/mathcalls-narrow.h logic, and the
logic for determining what functions / aliases to define, will need
some adjustments to support the sqrt and fma functions, where
e.g. f32xsqrtf64 can just be an alias for sqrt rather than a separate
function.  TS 18661-1 defines FP_FAST_* macros but no support is
included for defining them (they won't in general be true without
architecture-specific optimized function versions).

For each of the function groups (add sub mul div sqrt fma) there are
always six functions present (e.g. fadd, faddl, daddl, f32addf64,
f32addf32x, f32xaddf64).  When _Float64x and _Float128 are supported,
there are seven more (e.g. f32addf64x, f32addf128, f64addf64x,
f64addf128, f32xaddf64x, f32xaddf128, f64xaddf128).  In addition, in
the ldbl-opt case there are function names such as __nldbl_daddl (an
alias for f32xaddf64, which is not a reserved name in TS 18661-1, only
in TS 18661-3), for calls to daddl to be mapped to in the
-mlong-double-64 case.  (Calls to faddl just get mapped to fadd, and
for sqrt and fma there won't be __nldbl_* functions because dsqrtl and
dfmal can just be mapped to sqrt and fma with -mlong-double-64.)

While there are six or thirteen functions present in each group (plus
__nldbl_* names only as an ABI, not an API), not all are distinct;
they fall in various groups of aliases.  There are two distinct
versions built if long double has the same format as double; four if
they have distinct formats but there is no _Float64x or _Float128
support; five if long double has binary128 format; seven when
_Float128 is distinct from long double.

Architecture-specific optimized versions are possible, but not
included in my patches.  For example, IA64 generally supports
narrowing the result of most floating-point instructions; Power ISA
2.07 (POWER8) supports double values as arguments to float
instructions, with the results narrowed as expected; Power ISA 3
(POWER9) supports round-to-odd for float128 instructions, so meaning
that approach can be used without needing to set and restore the
rounding mode and test "inexact".  I intend to leave any such
optimized versions to the architecture maintainers.  Generally in such
cases it would also make sense for calls to these functions to be
expanded inline (given -fno-math-errno); I put a suggestion for TS
18661-1 built-in functions at <https://gcc.gnu.org/wiki/SummerOfCode>.

Tested for x86_64 (this patch in isolation, as well as testing for
various configurations in conjunction with further patches).

	* math/bits/mathcalls-narrow.h: New file.
	* include/bits/mathcalls-narrow.h: Likewise.
	* math/math-narrow.h: Likewise.
	* math/math.h (__MATHCALL_NARROW_ARGS_1): New macro.
	(__MATHCALL_NARROW_ARGS_2): Likewise.
	(__MATHCALL_NARROW_ARGS_3): Likewise.
	(__MATHCALL_NARROW_NORMAL): Likewise.
	(__MATHCALL_NARROW_REDIR): Likewise.
	(__MATHCALL_NARROW): Likewise.
	[__GLIBC_USE (IEC_60559_BFP_EXT)]: Repeatedly include
	<bits/mathcalls-narrow.h> with _Mret_, _Marg_ and __MATHCALL_NAME
	defined.
	[__GLIBC_USE (IEC_60559_TYPES_EXT)]: Likewise.
	* math/Makefile (headers): Add bits/mathcalls-narrow.h.
	(libm-narrow-fns): New variable.
	(libm-narrow-types-basic): Likewise.
	(libm-narrow-types-ldouble-yes): Likewise.
	(libm-narrow-types-float128-yes): Likewise.
	(libm-narrow-types-float128-alias-yes): Likewise.
	(libm-narrow-types): Likewise.
	(libm-routines): Add narrowing functions.
	* sysdeps/i386/fpu/fenv_private.h [__x86_64__]
	(libc_feholdexcept_setroundf128): New macro.
	[__x86_64__] (libc_feupdateenv_testf128): Likewise.
	* sysdeps/ieee754/float128/float128_private.h: Include
	<math/math-narrow.h>.
	[libc_feholdexcept_setroundf128] (libc_feholdexcept_setroundl):
	Undefine and redefine.
	[libc_feupdateenv_testf128] (libc_feupdateenv_testl): Likewise.
	(libm_alias_float_ldouble): Undefine and redefine.
	(libm_alias_double_ldouble): Likewise.
2018-02-09 21:18:52 +00:00
Joseph Myers bfd475876f Remove unused math/Makefile variable libm-test-incs.
The math/Makefile variable libm-test-incs was formerly used, but no
longer is.  This patch removes it.

Tested for x86_64.

	* math/Makefile [$(PERL) != no] (libm-test-incs): Remove variable.
2018-02-09 18:15:32 +00:00
Wilco Dijkstra 3f8d9d58c5 [AArch64] Use builtins for fpcr/fpsr
Since GCC has support for accessing FPSR/FPCR, use them when possible
so that the asm instructions can be removed eventually.  Although GCC 5
supports the builtins, it has an optimization bug, so use them from GCC 6
onwards.

	* sysdeps/aarch64/fpu/fpu_control.h: Use builtins for accessing
	FPCR/FPSR.
2018-02-09 16:59:23 +00:00
Rical Jasan 1f6676d7da manual: Fix Texinfo warnings about improper node names.
A number of cross-references to the GCC info manual cause Texinfo
warnings; e.g.:

  ./creature.texi:11: warning: @xref node name should not contain `.'

This is due to "gcc.info" being used in the INFO-FILE-NAME (fourth)
argument.  Changing it to "gcc" removes these warnings.  (Manually
confirmed equivalent behaviour for make info, html, and pdf.)

	* manual/creature.texi: Convert references to gcc.info to gcc.
	* manual/stdio.texi: Likewise.
	* manual/string.texi: Likewise.
2018-02-09 04:40:48 -08:00
Joseph Myers 15081be993 Define char16_t, char32_t consistently with uint_least16_t, uint_least32_t (bug 17979).
As noted in bug 17979 (and as I noted earlier in
<https://sourceware.org/ml/libc-alpha/2012-02/msg00647.html>), uchar.h
has gratuitously complicated code to determine the types for char16_t
and char32_t, and to reject including that header for pre-C11
compilers not defining __CHAR16_TYPE__ and __CHAR32_TYPE__.  Since
those types are always required to match uint_least16_t and
uint_least32_t, which glibc knows how to define without reference to
such predefined macros, it's safe just to define those types the same
as the *least* types are defined in stdint.h, so allowing the header
to work with (for example) GCC 4.3.

This patch implements that.  bits/types.h is made to define
__int_leastN_t and __uint_leastN_t so the logic for those types can
stay in a single place, and stdint.h is made to use those __*_t to
define the public *_t types.  uchar.h is then made to use
__uint_least16_t and __uint_least32_t to define char16_t and char32_t,
so simplifying the logic there.  A new test is added that verifies the
types chosen for char16_t and char32_t do indeed match the types the
compiler uses for u"" and U"" string literals.

Tested for x86_64.  (I have not tested with any of the older compilers
for which this would actually make a difference to whether you can
include uchar.h.)

	[BZ #17979]
	* posix/bits/types.h (__int_least8_t): New typedef.
	(__uint_least8_t): Likewise.
	(__int_least16_t): Likewise.
	(__uint_least16_t): Likewise.
	(__int_least32_t): Likewise.
	(__uint_least32_t): Likewise.
	(__int_least64_t): Likewise.
	(__uint_least64_t): Likewise.
	* sysdeps/generic/stdint.h (int_least8_t): Define using
	__int_least8_t.
	(int_least16_t): Define using __int_least16_t.
	(int_least32_t): Define using __int_least32_t.
	(int_least64_t): Define using __int_least64_t.
	(uint_least8_t): Define using __uint_least8_t.
	(uint_least16_t): Define using __uint_least16_t.
	(uint_least32_t): Define using __uint_least32_t.
	(uint_least64_t): Define using __uint_least64_t.
	* wcsmbs/uchar.h: Include <bits/types.h>.
	(char16_t): Define using __uint_least16_t conditional only on
	[!__USE_ISOCXX11].
	(char32_t): Define using __uint_least32_t conditional only on
	[!__USE_ISOCXX11].
	* wcsmbs/test-char-types.c: New file.
	* wcsmbs/Makefile (tests): Add test-char-types.
2018-02-07 20:33:55 +00:00
Joseph Myers d80441dde6 Use MPFR 4.0.1 in build-many-glibcs.py.
* scripts/build-many-glibcs.py (Context.checkout): Default MPFR
	version to 4.0.1.
2018-02-07 17:38:13 +00:00
Zack Weinberg 63fb8f9aa9 Post-cleanup 2: minimize _G_config.h.
Nearly everything in _G_config.h is either junk or more appropriately
defined elsewhere:

 * _G_fpos_t, _G_fpos64_t, and _G_BUFSIZ are already completely unused.
 * All remaining uses of _G_va_list have been changed to __gnuc_va_list.
 * The definition of _G_HAVE_ST_BLKSIZE/_IO_HAVE_ST_BLKSIZE has
   been inlined into its sole use.
 * The complete definition of _G_iconv_t has been moved to libio.h and
   renamed _IO_iconv_t (all actual users used that name).
 * _G_IO_IO_FILE_VERSION is vestigial; some code cares whether
   _IO_stdin_used exists, but nothing looks at its value.  I've
   preserved the value as a hardwired constant in csu/init.c.
   This means csu/init.c no longer needs to include anything.
 * Many of the headers included by _G_config.h were already being
   included directly by either either libio.h or stdio.h; the
   remaining ones were moved to libio.h.
 * _G_HAVE_MREMAP is still relevant, because mremap genuinely is a
   Linux extension; it's not in POSIX and as far as I can tell it's
   not available on the Hurd either.  I also preserved _G_HAVE_MMAP,
   since it's conceivable someone would want to port glibc to a
   MMU-less, mmap-less environment in the future.  Both are now always
   defined to 1/0 as is the current convention, instead of the older
   1/undef convention.  These are the only symbols still defined in
   _G_config.h.
 * The actual inclusion of _G_config.h moves from libio.h to libioP.h,
   as this is where a potential override of _G_HAVE_MMAP happens.
 * The #ifdef logic in libioP.h controlling _IO_JUMPS_OFFSET has been
   simplified.

After this patch, the only surviving _G_ symbols are the struct tag
names _G_fpos_t and _G_fpos64_t, which are preserved for the sake of
C++ mangled names in applications, and _G_HAVE_MMAP and _G_HAVE_MREMAP,
which do not seem worth renaming.

Installed stripped libraries are unchanged by this patch.

	* bits/_G_config.h: Move back to sysdeps/generic/_G_config.h.
	Delete all contents except for definitions of _G_HAVE_MMAP and
	_G_HAVE_MREMAP.  Add commentary explaining those two symbols.
	* sysdeps/unix/sysv/linux/bits/_G_config.h: Move back to
	sysdeps/unix/sysv/linux/_G_config.h.  Make same content
	change as above.

	* libio/libio.h: Don't include bits/_G_config.h here.
	Include stddef.h with __need_wchar_t defined.  Include
	bits/types/__mbstate_t.h, bits/types/wint_t.h, and gconv.h.
	Define _IO_iconv_t here, directly.
	Don't define _IO_HAVE_ST_BLKSIZE.
	* libio/libioP.h: Include _G_config.h here.  Move include of
	shlib-compat.h up with rest of includes.  Simplify conditionals
	controlling definition of _IO_JUMPS_OFFSET.

	* csu/init.c: Remove always-true #if around entire file.
	Don't include stdio.h.  Set _IO_stdin_used to hardwired
	constant 0x20001, and update commentary.
	* include/stdio.h, sysdeps/ieee754/ldbl-opt/nldbl-compat.h:
	Replace all uses of _G_va_list with __gnuc_va_list.
	* libio/filedoalloc.c: Use #if defined _STATBUF_ST_BLKSIZE
	instead of #if _IO_HAVE_ST_BLKSIZE.
	* libio/fileops.c: Test _G_HAVE_MREMAP with #if, not #ifdef.
	* libio/iofdopen.c, libio/iofopen.c: Test _G_HAVE_MMAP with #if,
	not #ifdef.
2018-02-07 10:10:32 -05:00
Zack Weinberg 6c6c962a20 Post-cleanup 1: move libio.h back out of bits/.
We can't go very far with libio cleanups as long as we still have
_IO_MTSAFE_IO, and I am not tackling that in this patch series,
but we can at least make the maze of stdio-related headers a
little less complicated.

In this patch, libio.h moves back out of bits/ into the top level of
the libio subdirectory, and is merged with libio/bits/libio-ldbl.h
(which also used to be installed) and include/libio.h.  Since almost
no files include libio.h directly, this is quite straightforward.

libio.h is now always used with _LIBC defined, so all of the _LIBC ||
_GLIBCPP_USE_WCHAR_T conditionals are unnecessary.  Similarly, the
ifdef nest surrounding the definition of _IO_fwide_maybe_incompatible
can collapse down to a single SHLIB_COMPAT check.  I also took the
opportunity to add some checks for configuration botches to libio.h.

Installed stripped libraries are unchanged by this patch.

        * libio/bits/libio.h: Move back to libio/libio.h and adjust
        multiple-include guard to match.
        Merge contents of libio/bits/libio-ldbl.h and include/libio.h
        into this file.
        Remove preprocessor conditionals that are always true and/or
        redundant to other preprocessor conditionals in the same nest.
        Include shlib-compat.h unconditionally.
        Error out if _LIBC is not defined, or if _ISOMAC is defined,
        or if _IO_MTSAFE_IO is defined but _IO_lock_t_defined is not
        defined after including stdio.h.
        Use __BEGIN_DECLS/__END_DECLS.

        * libio/bits/libio-ldbl.h, include/bits/libio.h: Delete file.
        * include/stdio.h, libio/iolibio.h, libio/libioP.h: Include
        libio.h as <libio/libio.h> rather than as <bits/libio.h>.
2018-02-07 10:09:47 -05:00
Zack Weinberg a4fea3f2c3 Don't install libio.h or _G_config.h.
We shipped 2.27 with libio.h and _G_config.h still installed but
issuing warnings when used.  Let's stop installing them early in 2.28
so that we have plenty of time to think of another plan if there are
problems.

The public stdio.h had a genuine dependency on libio.h for the
complete definitions of FILE and cookie_io_functions_t, and a genuine
dependency on _G_config.h for the complete definitions of fpos_t and
fpos64_t; these are moved to single-type headers.
bits/types/struct_FILE.h also provides a handful of accessor and
bitflags macros so that code is not duplicated between bits/stdio.h
and libio.h.  All the other _IO_ and _G_ names used by the public
stdio.h can be replaced with either public names or __-names.

In order to minimize the risk of breaking our own compatibility code,
bits/types/struct_FILE.h preserves the _IO_USE_OLD_IO_FILE mechanism
exactly as it was in libio.h, but you have to define _LIBC to use it,
or it'll error out.  Similarly, _IO_lock_t_defined is preserved
exactly, but will error out if used without defining _LIBC.

Internally, include/stdio.h continues to include libio.h, and libio.h
scrupulously provides every _IO_* and _G_* name that it always did,
perhaps now defined in terms of the public names.  This is how this
patch avoids touching dozens of files throughout glibc and becoming
entangled with the _IO_MTSAFE_IO mess.  The remaining patches in this
series eliminate most of the _G_ names.

Tested on x86_64-linux; in addition to the test suite, I installed the
library in a sysroot and verified that a simple program that uses
stdio.h could be compiled against the installed library, and I also
verified that installed stripped libraries are unchanged.

	* libio/bits/types/__fpos_t.h, libio/bits/types/__fpos64_t.h:
	New single-type headers split from _G_config.h.
	* libio/bits/types/cookie_io_functions_t.h
	* libio/bits/types/struct_FILE.h
	New single-type headers split from libio.h.

	* libio/Makefile: Install the above new headers.  Don't install
	libio.h, _G_config.h, bits/libio.h, bits/_G_config.h, or
	bits/libio-ldbl.h.
	* libio/_G_config.h, libio/libio.h: Delete file.

	* libio/bits/libio.h: Remove improper-inclusion guard.
	Include stdio.h and don't repeat anything that it does.
	Define _IO_fpos_t as __fpos_t, _IO_fpos64_t as __fpos64_t,
	_IO_BUFSIZ as BUFSIZ, _IO_va_list as __gnuc_va_list,
	__io_read_fn as cookie_read_function_t,
	__io_write_fn as cookie_write_function_t,
	__io_seek_fn as cookie_seek_function_t,
	__io_close_fn as cookie_close_function_t,
	and _IO_cookie_io_functions_t as cookie_io_functions_t.
	Define _STDIO_USES_IOSTREAM, __HAVE_COLUMN, and _IO_file_flags
	here, in the "compatibility defines" section.  Remove an #if 0
	block.  Use the "body" macros from bits/types/struct_FILE.h to
	define _IO_getc_unlocked, _IO_putc_unlocked, _IO_feof_unlocked,
	and _IO_ferror_unlocked.
	Move prototypes of __uflow and __overflow...

	* libio/stdio.h: ...here.  Don't include bits/libio.h.
	Don't define _STDIO_USES_IOSTREAM.  Get __gnuc_va_list
	directly from stdarg.h.  Include bits/types/__fpos_t.h,
	bits/types/__fpos64_t.h, bits/types/struct_FILE.h,
	and, when __USE_GNU, bits/types/cookie_io_functions_t.h.
	Use __gnuc_va_list, not _G_va_list; __fpos_t, not _G_fpos_t;
	__fpos64_t, not _G_fpos64_t; FILE, not struct _IO_FILE;
	cookie_io_functions_t, not _IO_cookie_io_functions_t;
	__ssize_t, not _IO_ssize_t.  Unconditionally define
	BUFSIZ as 8192 and EOF as (-1).

	* libio/bits/stdio.h: Add multiple-include guard.  Use the "body"
	macros from bits/types/struct_FILE.h instead of _IO_* macros
	from libio.h; use __gnuc_va_list instead of va_list and __ssize_t
	instead of _IO_ssize_t.
	* libio/bits/stdio2.h: Similarly.

	* libio/iolibio.h: Add multiple-include guard.
	Include bits/libio.h after stdio.h.
	* libio/libioP.h: Add multiple-include guard.
	Include stdio.h and bits/libio.h before iolibio.h.

        * include/bits/types/__fpos_t.h, include/bits/types/__fpos64_t.h
	* include/bits/types/cookie_io_functions_t.h
	* include/bits/types/struct_FILE.h: New wrappers.

	* bits/_G_config.h, sysdeps/unix/sysv/linux/_G_config.h:
        Get definitions of _G_fpos_t and _G_fpos64_t from
        bits/types/__fpos_t.h and bits/types/__fpos64_t.h
        respectively.  Remove improper-inclusion guards.

        * conform/data/stdio.h-data: Update expectations of va_list.
	* scripts/check-installed-headers.sh: Remove special case for
        libio.h and _G_config.h.
2018-02-07 10:07:31 -05:00