Commit Graph

92 Commits

Author SHA1 Message Date
Joseph Myers 0d40d0ecba Unify and simplify bits/byteswap.h, bits/byteswap-16.h headers (bug 14508, bug 15512, bug 17082, bug 20530).
We have a general principle of preferring optimizations for library
facilities to use compiler built-in functions rather than being
located in library headers, where the compiler can reasonably optimize
code without needing to know glibc implementation details.

This patch applies this principle to bits/byteswap.h, eliminating all
the architecture-specific variants and bits/byteswap-16.h.  The
__bswap_16, __bswap_32 and __bswap_64 interfaces all become inline
functions, never macros, using the GCC built-in functions where
available and otherwise a single architecture-independent definition
using shifts and masking (which compilers may well be able to detect
and optimize; GCC has detection of various byte-swapping idioms).

The __bswap_constant_32 macro needs to stay around because of uses in
static initializers within glibc and its tests, and so for consistency
all __bswap_constant_* are kept rather than just being inlined into
the old-GCC-or-non-GCC parts of the __bswap_* inline function
definitions.

Various open bugs are addressed by this cleanup, with caveats about
exactly what is covered by those bugs and when the bugs applied at
all.

Bug 14508 reports -Wformat warnings building glibc because __bswap_*
sometimes returned the wrong types.  Obviously we already don't have
such warnings any more or the build would be failing, given -Werror,
and I suspect that bug was originally for wrong types for x86_64, as
fixed by commit d394eb742a (glibc 2.17).
The only case I saw removed by this patch where the types would still
have been wrong was the non-__GNUC__ case of __bswap_64 in the s390
header (using unsigned long long int, but uint64_t would be unsigned
long int for 64-bit).  In any case, the single header consistently
uses __uintN_t types after this patch, thereby eliminating all such
bugs.  The existing string/test-endian-types.c test already suffices
to verify that the types are correct with the compiler used to build
glibc and its tests.

Bug 15512 reports an error from __bswap_constant_16 with -Werror
-Wsign-conversion.  I am unable to reproduce this with any GCC version
supporting -Wsign-conversion - all seem to be able to avoid warning
for ((x) >> 8) & 0xffu, where x is uint16_t, which while it formally
does involve an implicit conversion from int to unsigned int, is also
a case where it should be easy for the compiler to see that the value
converted is never negative.  But in this patch __bswap_constant_16 is
changed to use signed 0xff so that no such implicit conversion occurs
at all, and a test with -Werror -Wsign-conversion is added.

Bug 17082 objects to the use of ({}) statement expressions in these
macros preventing use at file scope (in C, that's in sizeof etc.; in
C++, more generally in static initializers).  The particular case of
these interfaces is fixed by this patch as it changes them to inline
functions, eliminating all uses of ({}) in bits/byteswap.h, and a
corresponding testcase is added.  The bug tries to raise a more
general policy question about use of ({}) in macros in installed
headers, referring to "many other libc functions" (unspecified which
functions are being considered).

Since such policy questions belong on libc-alpha, and since there
*are* macros in installed headers which can't really avoid using ({})
(where they are type-generic, so can't use an inline function, but
need a temporary variable, and a few where the interface involves
returning memory from alloca so can't use an inline function either),
I propose to consider that bug fixed with this change.  That is
without prejudice to any other new bugs anyone wishes to file *for
precisely defined sets of macros* requesting moving away from ({})
*where it is clearly possible for those interfaces*.  Where ({}) can
be avoided, typically by use of an inline function, I think that's a
good idea - that inline functions are typically to be preferred to
({}) for header interfaces where such optimizations are useful but the
interface is suited to being defined using an inline function.

Bug 20530 requests use of __builtin_bswap16 when available (GCC 4.8
and later), which this patch implements.

Tested for x86_64, and with build-many-glibcs.py.  Also did an x86_64
test with the __GNUC_PREREQ conditionals changed to "#if 0" to verify
the old-GCC/non-GCC case in the headers.  (There are already existing
tests for correctness of results of these interfaces.)

	[BZ #14508]
	[BZ #15512]
	[BZ #17082]
	[BZ #20530]
	* bits/byteswap.h: Update file comment.  Do not include
	<bits/byteswap-16.h>.
	(__bswap_constant_16): Cast result to __uint16_t.  Use signed 0xff
	constant.
	(__bswap_16): Define as inline function.
	(__bswap_constant_32): Reformat definition.
	(__bswap_32): Always define as inline function, not macro, using
	__uint32_t.  Use __builtin_bswap32 if [__GNUC_PREREQ (4, 3)],
	otherwise __bswap_constant_32.
	(__bswap_constant_64): Reformat definition.  Do not use
	__extension__ here.
	(__bswap_64): Always define as inline function, not macro.  Use
	__extension__ on function definition.  Use __builtin_bswap64 if
	[__GNUC_PREREQ (4, 3)], otherwise __bswap_constant_64.
	* string/test-endian-file-scope.c: New file.
	* string/test-endian-sign-conversion.c: Likewise.
	* string/Makefile (headers): Remove bits/byteswap-16.h.
	(tests): Add test-endian-file-scope and
	test-endian-sign-conversion.
	(CFLAGS-test-endian-sign-conversion.c): New variable.
	* bits/byteswap-16.h: Remove file.
	* sysdeps/ia64/bits/byteswap-16.h: Likewise.
	* sysdeps/ia64/bits/byteswap.h: Likewise.
	* sysdeps/m68k/bits/byteswap.h: Likewise.
	* sysdeps/s390/bits/byteswap-16.h: Likewise.
	* sysdeps/s390/bits/byteswap.h: Likewise.
	* sysdeps/tile/bits/byteswap.h: Likewise.
	* sysdeps/x86/bits/byteswap-16.h: Likewise.
	* sysdeps/x86/bits/byteswap.h: Likewise.
2018-02-06 21:55:08 +00:00
Joseph Myers eb65a3d545 Remove some math_private.h libc_feholdexcept_setround overrides.
math_private.h headers for configurations lacking support for
floating-point exceptions and rounding modes define
libc_feholdexcept_setround to override the default version with one
that discards its rounding mode argument.

Unlike other such libc_fe* macros that I removed, this one is actually
used for such configurations (in dbl-64/e_sqrt.c).  However, this does
not make the macro required.  It's only used for such configurations
with FE_TONEAREST as the rounding mode (anything needing another mode
should not be used when that mode is unavailable), and the default
definition just calls __feholdexcept and __fesetround.  Since we now
have suitable inline do-nothing definitions of __feholdexcept and
__fesetround for the cases of no exceptions and rounding modes, we can
just rely on those inlines to achieve the same optimization as this
macro definition.  Thus, this patch removes those macro definitions
(and the math_private.h headers containing them, when no longer needed
after that removal).

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

	* sysdeps/m68k/coldfire/fpu/math_private.h: Move to ....
	* sysdeps/m68k/coldfire/math_private.h: ... here.
	* sysdeps/m68k/coldfire/nofpu/math_private.h: Remove file.
	* sysdeps/tile/math_private.h: Likewise.
	* sysdeps/microblaze/math_private.h (libc_feholdexcept_setround):
	Remove macro.
	* sysdeps/nios2/math_private.h (libc_feholdexcept_setround):
	Likewise.
2018-02-01 20:58:57 +00:00
Joseph Myers 8a6bb1d086 Remove some math_private.h libc_fe* overrides.
math_private.h headers for configurations lacking support for
floating-point exceptions and rounding modes define various libc_fe*
macros to override the default versions with ones that discard any
exception or rounding mode arguments.

Three of the four macros defined in these headers are no longer needed
there: those macros are only used in fma implementations that are not
used for such configurations, now all those configurations properly
use soft-fp fma implementations instead.  (Effectively, those macros
were a workaround to allow glibc to build in the absence of a proper
fma implementation for this case - now there is such an
implementation, there is no need to support building the wrong
implementation for those configurations.)  Thus, this patch removes
the unnecessary macros.

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

	* sysdeps/m68k/coldfire/nofpu/math_private.h (libc_fesetround):
	Remove macro.
	(libc_fetestexcept): Likewise.
	(libc_feupdateenv_test): Likewise.
	* sysdeps/microblaze/math_private.h (libc_fesetround): Likewise.
	(libc_fetestexcept): Likewise.
	(libc_feupdateenv_test): Likewise.
	* sysdeps/nios2/math_private.h (libc_fesetround): Likewise.
	(libc_fetestexcept): Likewise.
	(libc_feupdateenv_test): Likewise.
	* sysdeps/tile/math_private.h (libc_fesetround): Likewise.
	(libc_fetestexcept): Likewise.
	(libc_feupdateenv_test): Likewise.
2018-02-01 20:57:22 +00:00
Joseph Myers b1c347e2cd Move fenv.h override inline functions to generic math_private.h.
The tile version of math_private.h defines some inline functions for
fenv.h functions, to optimize away internal calls to these functions
that do nothing given no support for floating-point exceptions and
rounding modes.  (Some functions may have error cases for invalid
arguments, but those aren't applicable to the internal calls from
within glibc.)  Other configurations lacking support for exceptions
and rounding modes lack such inline functions.  This patch moves them
to the generic math_private.h, appropriately conditioned, so that all
such configurations can benefit from the.

include/fenv.h is made to check whether there are any non-default
rounding modes; that needs to be done there, rather than later,
because get-rounding-mode.h defines values for otherwise unsupported
FE_* rounding modes.  It also gives an error for FE_TONEAREST
undefined, a case that already did not work for building the glibc
testsuite; the convention has by now been established that all
architectures need to provide a version of bits/fenv.h that at least
defines FE_TONEAREST.

Tested with build-many-glibcs.py.  As expected, installed stripped
shared libraries are unchanged for tile and for architectures
supporting exceptions and rounding modes, but changed for non-tile
architectures not supporting exceptions and rounding modes that
previously lacked this optimization (e.g. Nios II libm.so is about 1kB
smaller).

The optimization is not in fact complete (does not cover feholdexcept
/ __feholdexcept, so a few calls to those remain unnecessarily within
libm even after this patch), but that can be dealt with separately.

	* include/fenv.h [!_ISOMAC && !FE_TONEAREST]: Give #error.
	[!_ISOMAC] (FE_HAVE_ROUNDING_MODES): New macro.
	* sysdeps/generic/math_private.h
	[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (fegetenv): New
	inline function.
	[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (__fegetenv):
	Likewise.
	[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (fesetenv):
	Likewise.
	[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (__fesetenv):
	Likewise.
	[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (feupdateenv):
	Likewise.
	[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (__feupdateenv):
	Likewise.
	[!FE_HAVE_ROUNDING_MODES] (fegetround): Likewise.
	[!FE_HAVE_ROUNDING_MODES] (__fegetround): Likewise.
	[!FE_HAVE_ROUNDING_MODES] (fesetround): Likewise.
	[!FE_HAVE_ROUNDING_MODES] (__fesetround): Likewise.
	* sysdeps/tile/math_private.h (fegetenv): Remove inline function.
	(__fegetenv): Likewise.
	(fesetenv): Likewise.
	(__fesetenv): Likewise.
	(feupdateenv): Likewise.
	(__feupdateenv): Likewise.
	(fegetround): Likewise.
	(__fegetround): Likewise.
	(fesetround): Likewise.
	(__fesetround): Likewise.
2018-02-01 20:54:44 +00:00
Joseph Myers d23a4962bb Move some fenv.h override macros to generic math_private.h.
Various configurations lacking support for floating-point exceptions
and rounding modes have a math_private.h that overrides certain
functions and macros, internal and external, to avoid references to
FE_* constants that are undefined in those configurations.  For
example, there are unconditional feraiseexcept (FE_INVALID) calls in
generic libm code, and these macro definitions duly define
feraiseexcept to ignore its argument to avoid an error from FE_INVALID
being undefined.

In fact it is easy to tell in an architecture-independent way whether
this is needed, by testing whether FE_ALL_EXCEPT == 0.  Thus, this
patch puts such a test, and feraiseexcept and __feraiseexcept macros,
in the generic math_private.h, so reducing the duplication between
architecture versions of this header.  The feclearexcept macro present
in several versions of this header, and fetestexcept in the tile
version, are not needed; they would have been needed before there were
proper soft-fp fma implementations (when generic versions, that depend
on FE_TOWARDZERO and FE_INEXACT, were being used for configurations
not supporting those features), but aren't needed any more, and so are
removed.

The tile version of this header has several inline functions for
fenv.h functions to optimize calls to them away in such configurations
where they do nothing useful, and all these header versions also have
definitions of some of the libc_fe* internal macros.  I intend to make
those generic in subsequent patches.

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

	* sysdeps/generic/math_private.h [FE_ALL_EXCEPT == 0]
	(feraiseexcept): New macro.
	[FE_ALL_EXCEPT == 0] (__feraiseexcept): Likewise.
	* sysdeps/m68k/coldfire/nofpu/math_private.h (feraiseexcept):
	Remove macro.
	(__feraiseexcept): Likewise.
	(feclearexcept): Likewise.
	* sysdeps/microblaze/math_private.h (feraiseexcept): Likewise.
	(__feraiseexcept): Likewise.
	(feclearexcept): Likewise.
	* sysdeps/nios2/math_private.h (feraiseexcept): Likewise.
	(__feraiseexcept): Likewise.
	(feclearexcept): Likewise.
	* sysdeps/tile/math_private.h (feraiseexcept): Likewise.
	(__feraiseexcept): Likewise.
	(feclearexcept): Likewise.
	(fetestexcept): Likewise.
2018-02-01 20:52:59 +00:00
Joseph Myers 688903eb3e Update copyright dates with scripts/update-copyrights.
* All files with FSF copyright notices: Update copyright dates
	using scripts/update-copyrights.
	* locale/programs/charmap-kw.h: Regenerated.
	* locale/programs/locfile-kw.h: Likewise.
2018-01-01 00:32:25 +00:00
Adhemerval Zanella 8d2d239cb7 Simplify tile assembly definitions
With tilepro removal, the uppercase instruction are not anymore
required to be defines as potentially macros.  This is a
mechanical change done by the following shell script:

---
INSNS="LD LD4U ST ST4 BNEZ BEQZ BEQZT BGTZ CMPEQI CMPEQ CMOVEQZ CMOVNEZ"

FILES=$(find sysdeps/tile sysdeps/unix/sysv/linux/tile -iname *.S)

for insn in $INSNS; do
  repl=$(echo $insn | tr '[:upper:]' '[:lower:]')
  sed -i 's/\b'$insn'\b/'$repl'/g' $FILES
done
---

Checked with a build for tilegx-linux-gnu and tilegx-linux-gnu-32 with
and without the patch, there is no difference in generated binary with
a dissassemble.

	* sysdeps/tile/__longjmp.S (__longjmp): Use lowercase instructions.
	* sysdeps/tile/__tls_get_addr.S (__tls_get_addr): Likewise.
	* sysdeps/tile/_mcount.S (__mcount): Likewise.
	* sysdeps/tile/crti.S (_init, _fini): Likewise.
	* sysdeps/tile/crtn.S: Likewise.
	* sysdeps/tile/dl-start.S (_start): Likewise.
	* sysdeps/tile/dl-trampoline.S: Likewise.
	* sysdeps/tile/setjmp.S (__sigsetjmp): Likewise.
	* sysdeps/tile/start.S (_start): Likewise.
	* sysdeps/unix/sysv/linux/tile/clone.S (_clone): Likewise.
	* sysdeps/unix/sysv/linux/tile/getcontext.S (__getcontext): Likewise.
	* sysdeps/unix/sysv/linux/tile/ioctl.S (__ioctl): Likewise.
	* sysdeps/unix/sysv/linux/tile/setcontext.S (__setcontext): Likewise.
	* sysdeps/unix/sysv/linux/tile/swapcontext.S (__swapcontext): Likewise.
	* sysdeps/unix/sysv/linux/tile/syscall.S (syscall): Likewise.
	* sysdeps/unix/sysv/linux/tile/vfork.S (__vfork): Likewise.
2017-12-20 16:55:26 -02:00
Adhemerval Zanella 24d1d8ec9e Simplify tilegx sysdeps folder
With tilepro support removal we can now simplify internal tile support by
moving the directory structure to avoid the unnecessary directory levels
in tile/tilegx both on generic and linux folders.

Checked with a build for tilegx-linux-gnu and tilegx-linux-gnu-32 with
and without the patch, there is no difference in generated binary with
a dissassemble.

	* stdlib/bug-getcontext.c (do_test): Remove tilepro mention in
	comment.
	* sysdeps/tile/preconfigure: Remove tilegx folder.
	* sysdeps/tile/tilegx/Implies: Move definitions to ...
	* sysdeps/tile/Implies: ... here.
	* sysdeps/tile/tilegx/Makefile: Move rules to ...
	* sysdeps/tile/Makefile: ... here.
	* sysdeps/tile/tilegx/atomic-machine.h: Move definitions to ...
	* sysdeps/tile/atomic-machine.h: ... here.  Add include guards.
	* sysdeps/tile/tilegx/bits/wordsize.h: Move to ...
	* sysdeps/tile/bits/wordsize.h: ... here.
	* sysdeps/tile/tilegx/*: Move to ...
	* sysdeps/tile/*: ... here.
	* sysdeps/tile/tilegx/tilegx32/Implies: Move to ...
	* sysdeps/tile/tilegx32/Implies: ... here.
	* sysdeps/tile/tilegx/tilegx64/Implies: Move to ...
	* sysdeps/tile/tilegx64/Implies: ... here.
	* sysdeps/unix/sysv/linux/tile/tilegx/Makefile: Move definitions
	to ...
	* sysdeps/unix/sysv/linux/tile/Makefile: ... here.
	* sysdeps/unix/sysv/linux/tile/tilegx/*: Move to ...
	* sysdeps/unix/sysv/linux/tile/*: ... here.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/*: Move to ...
	* sysdeps/unix/sysv/linux/tile/tilegx32/*: ... here.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/*: Move to ...
	* sysdeps/unix/sysv/linux/tile/tilegx64/*: ... here.
2017-12-20 16:55:26 -02:00
Adhemerval Zanella ed95f61149 Remove tilepro-*-linux-gnu support
As from previous discussions [1] this patch removes tileprox-*-linux-gnu
support from GLIBC.  This patch is a straigthfoward one, which just remove
tilepro specific implementation and configurations (no sysdep simplfication
or reorganization is done).

	* README: Remove tilepro-*-linux-gnu from supported architecture.
	* scripts/build-many-glibcs.py: Likewise.
	* sysdeps/tile/__tls_get_addr.S (__tls_get_addr): Likewise.
	* sysdeps/tile/crti.S (PREINIT_FUNCTION): Likewise.
	* sysdeps/tile/dl-machine.h (ELF_MACHINE_NAME,
	elf_machine_matches_host, elf_machine_dynamic,
	elf_machine_load_address, elf_machine_runtime_setup, reloc_howto
	howto, elf_machine_rela): Likewise
	* sysdeps/tile/dl-start.S (_start): Likewise.
	* sysdeps/tile/memcmp.c (DBLALIGN, REVBYTES): Likewise.
	* sysdeps/tile/memcopy.h (MEMCPY_OK_FOR_FWD_MEMMOVE,
	MEMCPY_OK_FOR_FWD_MEMMOVE, op_t): Likewise.
	* sysdeps/tile/nptl/pthread_spin_lock.c (TNS, CMPTNS): Likewise.
	* sysdeps/tile/nptl/pthread_spin_trylock.c (TNS): Likewise.
	* sysdeps/tile/nptl/pthread_spin_unlock.c (pthread_spin_unlock):
	Likewise.
	* sysdeps/tile/nptl/tls.h (DB_THREAD_SELF): Likewise.
	* sysdeps/tile/preconfigure: Likewise.
	* sysdeps/tile/stackguard-macros.h (STACK_CHK_GUARD,
	POINTER_CHK_GUARD): Likewise.
	* sysdeps/tile/stackinfo.h (__stackinfo_sub): Likewise.
	* sysdeps/tile/start.S (_start): Likewise.
	* sysdeps/tile/tls-macros.h (TLS_GD_OFFSET, TLS_IE_OFFSET, _TLS_LE):
	Likewise.
	* sysdeps/tile/sysdep.h (REGSIZE): Likewise.
	(LD, LD4U, ST, ST4, BNEZ, BEQZ, BEQZT, BGTZ, CMPEQI, CMPEQ, CMOVEQZ,
	CMOVNEZ): Remove.
	* sysdeps/unix/sysv/linux/tile/bits/environments.h
	(__ILP32_OFF32_CFLAGS, __ILP32_OFFBIG_CFLAGS, __ILP32_OFF32_LDFLAGS,
	__ILP32_OFFBIG_LDFLAGS, __LP64_OFF64_CFLAGS, __LP64_OFF64_LDFLAGS):
	Likewise.
	* sysdeps/tile/wordcopy.c (DBLALIGN): Likewise.
	* sysdeps/tile/tilepro/Implies: Remove file.
	* sysdeps/tile/tilepro/atomic-machine.h: Likewise.
	* sysdeps/tile/tilepro/bits/wordsize.h: Likewise.
	* sysdeps/tile/tilepro/memchr.c: Likewise.
	* sysdeps/tile/tilepro/memcpy.S: Likewise.
	* sysdeps/tile/tilepro/memset.c: Likewise.
	* sysdeps/tile/tilepro/memusage.h: Likewise.
	* sysdeps/tile/tilepro/rawmemchr.c: Likewise.
	* sysdeps/tile/tilepro/strchr.c: Likewise.
	* sysdeps/tile/tilepro/strchrnul.c: Likewise.
	* sysdeps/tile/tilepro/strlen.c: Likewise.
	* sysdeps/tile/tilepro/strrchr.c: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/Implies: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/c++-types.data: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/ld.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/ldconfig.h: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libBrokenLocale.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libanl.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libcrypt.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libdl.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libnsl.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libresolv.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/librt.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libthread_db.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libutil.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/register-dump.h: Likewise.
	* sysdeps/unix/sysv/linux/tile/sysconf.c (linux_sysconf): Remove
	tilepro mention in comment.

[1] https://sourceware.org/ml/libc-alpha/2017-12/msg00038.html
2017-12-20 16:55:24 -02:00
Joseph Myers 6f7c009282 Add sysdeps/ieee754/soft-fp.
The default sysdeps/ieee754 fma implementations rely on exceptions and
rounding modes to achieve correct results through internal use of
round-to-odd.  Thus, glibc configurations without support for
exceptions and rounding modes instead need to use implementations of
fma based on soft-fp.

At present, this is achieved via having implementation files in
soft-fp/ that are #included by sysdeps files for each glibc
configuration that needs them.  In general this means such a
configuration has its own s_fma.c and s_fmaf.c.

TS 18661-1 adds functions that do an operation (+ - * / sqrt fma) on
arguments wider than the return type, with a single rounding of the
infinite-precision result to that return type.  These are also
naturally implemented using round-to-odd on platforms with hardware
support for rounding modes and exceptions but lacking hardware support
for these narrowing operations themselves.  (Platforms that have
direct hardware support for such narrowing operations include at least
ia64, and Power ISA 2.07 or later, which I think means POWER8 or
later.)

So adding the remaining TS 18661-1 functions would mean at least six
narrowing function implementations (fadd fsub fmul fdiv ffma fsqrt),
with aliases for other types and further implementations in some
configurations, that need to be overridden for configurations lacking
hardware exceptions and rounding modes.  Requiring all such
configurations (currently seven of them) to have their own source
files for all those functions seems undesirable.

Thus, this patch adds a directory sysdeps/ieee754/soft-fp to contain
libm function implementations based on soft-fp.  This directory is
then used via Implies from all the configurations that need it, so no
more files need adding to every such configuration when adding more
functions with soft-fp implementations.  A configuration can still
selectively #include a particular file from this directory if desired;
thus, the MIPS #include of the fmal implementation is retained, since
that's appropriate even for hard float (because long double is always
implementated in software for MIPS64, so the soft-fp implementation of
fmal is better than the ldbl-128 one).

This also provides additional motivation for my recent patch removing
--with-fp / --without-fp: previously there was no need for correct use
of --without-fp for no-FPU ARM or SH3, and now we have autodetection
nofpu/ sysdeps directories can be used by this patch for those
configurations without imposing any new requirements on how glibc is
configured.

(The mips64/*/fpu/s_fma.c files added by this patch are needed to keep
the dbl-64 version of fma for double, rather than the ldbl-128 one,
used in that case.)

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

	* soft-fp/fmadf4.c: Move to ....
	* sysdeps/ieee754/soft-fp/s_fma.c: ... here.
	* soft-fp/fmasf4.c: Move to ....
	* sysdeps/ieee754/soft-fp/s_fmaf.c: ... here.
	* soft-fp/fmatf4.c: Move to ....
	* sysdeps/ieee754/soft-fp/s_fmal.c: ... here.
	* sysdeps/ieee754/soft-fp/Makefile: New file.
	* sysdeps/arm/preconfigure.ac: Define with_fp_cond.
	* sysdeps/arm/preconfigure: Regenerated.
	* sysdeps/arm/nofpu/Implies: New file.
	* sysdeps/arm/s_fma.c: Remove file.
	* sysdeps/arm/s_fmaf.c: Likewise.
	* sysdeps/m68k/coldfire/nofpu/Implies: New file.
	* sysdeps/m68k/coldfire/nofpu/s_fma.c: Remove file.
	* sysdeps/m68k/coldfire/nofpu/s_fmaf.c: Likewise.
	* sysdeps/microblaze/Implies: Add ieee754/soft-fp.
	* sysdeps/microblaze/s_fma.c: Remove file.
	* sysdeps/microblaze/s_fmaf.c: Likewise.
	* sysdeps/mips/mips32/nofpu/Implies: New file.
	* sysdeps/mips/mips64/n32/fpu/s_fma.c: Likewise.
	* sysdeps/mips/mips64/n32/nofpu/Implies: Likewise.
	* sysdeps/mips/mips64/n64/fpu/s_fma.c: Likewise.
	* sysdeps/mips/mips64/n64/nofpu/Implies: Likewise.
	* sysdeps/mips/ieee754/s_fma.c: Remove file.
	* sysdeps/mips/ieee754/s_fmaf.c: Likewise.
	* sysdeps/mips/ieee754/s_fmal.c: Update include for move of fmal
	implementation.
	* sysdeps/nios2/Implies: Add ieee754/soft-fp.
	* sysdeps/nios2/s_fma.c: Remove file.
	* sysdeps/nios2/s_fmaf.c: Likewise.
	* sysdeps/sh/nofpu/Implies: New file.
	* sysdeps/sh/s_fma.c: Remove file.
	* sysdeps/sh/s_fmaf.c: Likewise.
	* sysdeps/tile/Implies: Add ieee754/soft-fp.
	* sysdeps/tile/s_fma.c: Remove file.
	* sysdeps/tile/s_fmaf.c: Likewise.
2017-12-12 23:35:21 +00:00
Chris Metcalf c7e882b705 tilegx: tag __insn_OP builtin issue with gcc bugzilla # 2017-12-05 11:36:26 -05:00
Chris Metcalf f18b8dc7d7 tilegx: work around vector insn bug in gcc
Avoid an issue in gcc where some of the vector (aka SIMD) ops will
sometimes end up getting wrongly optimized out.  We use these
instructions in many of the string implementations.  If/when we
have an upstreamed fix for this problem in gcc we can conditionalize
the use of the extended assembly workaround in glibc.
2017-12-05 10:24:56 -05:00
Chris Metcalf 2e49fed84c tile: update ca{cos,sin,tan}{,h} double ULPs 2017-12-04 12:31:20 -05:00
Adhemerval Zanella 06be6368da nptl: Define __PTHREAD_MUTEX_{NUSERS_AFTER_KIND,USE_UNION}
This patch adds two new internal defines to set the internal
pthread_mutex_t layout required by the supported ABIS:

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

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

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

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

Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2017-11-07 09:48:41 -02:00
Adhemerval Zanella dff91cd45e nptl: Add tests for internal pthread_mutex_t offsets
This patch adds a new build test to check for internal fields
offsets for user visible internal field.  Although currently
the only field which is statically initialized to a non zero value
is pthread_mutex_t.__data.__kind value, the tests also check the
offset of __kind, __spins, __elision (if supported), and __list
internal member.  A internal header (pthread-offset.h) is added
to each major ABI with the reference value.

Checked on x86_64-linux-gnu and with a build check for all affected
ABIs (aarch64-linux-gnu, alpha-linux-gnu, arm-linux-gnueabihf,
hppa-linux-gnu, i686-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,
microblaze-linux-gnu, mips64-linux-gnu, mips64-n32-linux-gnu,
mips-linux-gnu, powerpc64le-linux-gnu, powerpc-linux-gnu,
s390-linux-gnu, s390x-linux-gnu, sh4-linux-gnu, sparc64-linux-gnu,
sparcv9-linux-gnu, tilegx-linux-gnu, tilegx-linux-gnu-x32,
tilepro-linux-gnu, x86_64-linux-gnu, and x86_64-linux-x32).

	* nptl/pthreadP.h (ASSERT_PTHREAD_STRING,
	ASSERT_PTHREAD_INTERNAL_OFFSET): New macro.
	* nptl/pthread_mutex_init.c (__pthread_mutex_init): Add build time
	checks for internal pthread_mutex_t offsets.
	* sysdeps/aarch64/nptl/pthread-offsets.h
	(__PTHREAD_MUTEX_NUSERS_OFFSET, __PTHREAD_MUTEX_KIND_OFFSET,
	__PTHREAD_MUTEX_SPINS_OFFSET, __PTHREAD_MUTEX_ELISION_OFFSET,
	__PTHREAD_MUTEX_LIST_OFFSET): New macro.
	* sysdeps/alpha/nptl/pthread-offsets.h: Likewise.
	* sysdeps/arm/nptl/pthread-offsets.h: Likewise.
	* sysdeps/hppa/nptl/pthread-offsets.h: Likewise.
	* sysdeps/i386/nptl/pthread-offsets.h: Likewise.
	* sysdeps/ia64/nptl/pthread-offsets.h: Likewise.
	* sysdeps/m68k/nptl/pthread-offsets.h: Likewise.
	* sysdeps/microblaze/nptl/pthread-offsets.h: Likewise.
	* sysdeps/mips/nptl/pthread-offsets.h: Likewise.
	* sysdeps/nios2/nptl/pthread-offsets.h: Likewise.
	* sysdeps/powerpc/nptl/pthread-offsets.h: Likewise.
	* sysdeps/s390/nptl/pthread-offsets.h: Likewise.
	* sysdeps/sh/nptl/pthread-offsets.h: Likewise.
	* sysdeps/sparc/nptl/pthread-offsets.h: Likewise.
	* sysdeps/tile/nptl/pthread-offsets.h: Likewise.
	* sysdeps/x86_64/nptl/pthread-offsets.h: Likewise.

Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2017-11-07 09:48:28 -02:00
Wilco Dijkstra 4d3693ec1c Remove ancient __signbit inlines
Remove __signbit inlines from mathinline.h.  Math.h already uses
the builtin when supported, so additional inlines are only used
on pre 4.0 GCCs.  Similarly remove ancient copysign and fabs
inlines.

	* sysdeps/alpha/fpu/bits/mathinline.h: Delete file.
	* sysdeps/ia64/fpu/bits/mathinline.h: Delete file.
	* sysdeps/m68k/coldfire/fpu/bits/mathinline.h: Delete file.
	* sysdeps/m68k/m680x0/fpu/bits/mathinline.h: (__signbitf): Remove.
	(__signbit): Remove.
	(__signbitl): Remove.
	* sysdeps/powerpc/bits/mathinline.h (__signbitf): Remove.
	(__signbit): Remove.
	(__signbitl): Remove.
	* sysdeps/s390/fpu/bits/mathinline.h: (__signbitf): Remove.
	(__signbit): Remove.
	(__signbitl): Remove
	* sysdeps/sparc/fpu/bits/mathinline.h (__signbitf): Remove.
	(__signbit): Remove.
	(__signbitl): Remove.
	* sysdeps/tile/bits/mathinline.h: Delete file.
	* sysdeps/x86/fpu/bits/mathinline.h (__signbitf): Remove.
	(__signbit): Remove.
	(__signbitl): Remove.
2017-09-28 19:52:13 +01:00
Joseph Myers 5a80d39d0d Obsolete pow10 functions.
This patch obsoletes the pow10, pow10f and pow10l functions (makes
them into compat symbols, not available for new ports or static
linking).  The exp10 names for these functions are standardized (in TS
18661-4) and were added in the same glibc version (2.1) as pow10 so
source code can change to use them without any loss of portability.
Since pow10 is deliberately not provided for _Float128, only exp10,
this slightly simplifies moving to the new wrapper templates in the
!LIBM_SVID_COMPAT case, by avoiding needing to arrange for pow10,
pow10f and pow10l to be defined by those templates.

Tested for x86_64, and with build-many-glibcs.py.

	* manual/math.texi (pow10): Do not document.
	(pow10f): Likewise.
	(pow10l): Likewise.
	* math/bits/mathcalls.h [__USE_GNU] (pow10): Do not declare.
	* math/bits/math-finite.h [__USE_GNU] (pow10): Likewise.
	* math/libm-test-exp10.inc (pow10_test): Remove.
	(do_test): Do not call pow10.
	* math/w_exp10_compat.c (pow10): Make into compat symbol.
	[NO_LONG_DOUBLE] (pow10l): Likewise.
	* math/w_exp10f_compat.c (pow10f): Likewise.
	* math/w_exp10l_compat.c (pow10l): Likewise.
	* sysdeps/ia64/fpu/e_exp10.S: Include <shlib-compat.h>.
	(pow10): Make into compat symbol.
	* sysdeps/ia64/fpu/e_exp10f.S: Include <shlib-compat.h>.
	(pow10f): Make into compat symbol.
	* sysdeps/ia64/fpu/e_exp10l.S: Include <shlib-compat.h>.
	(pow10l): Make into compat symbol.
	* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Remove
	pow10.
	(CFLAGS-nldbl-pow10.c): Remove variable..
	* sysdeps/ieee754/ldbl-opt/nldbl-pow10.c: Remove file.
	* sysdeps/ieee754/ldbl-opt/w_exp10_compat.c (pow10l): Condition on
	[SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_27)].
	* sysdeps/ieee754/ldbl-opt/w_exp10l_compat.c (compat_symbol):
	Undefine and redefine.
	(pow10l): Make into compat symbol.
	* sysdeps/aarch64/libm-test-ulps: Remove pow10 ulps.
	* sysdeps/alpha/fpu/libm-test-ulps: Likewise.
	* sysdeps/arm/libm-test-ulps: Likewise.
	* sysdeps/hppa/fpu/libm-test-ulps: Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Likewise.
	* sysdeps/i386/i686/fpu/multiarch/libm-test-ulps: Likewise.
	* sysdeps/microblaze/libm-test-ulps: Likewise.
	* sysdeps/mips/mips32/libm-test-ulps: Likewise.
	* sysdeps/mips/mips64/libm-test-ulps: Likewise.
	* sysdeps/nios2/libm-test-ulps: Likewise.
	* sysdeps/powerpc/fpu/libm-test-ulps: Likewise.
	* sysdeps/powerpc/nofpu/libm-test-ulps: Likewise.
	* sysdeps/s390/fpu/libm-test-ulps: Likewise.
	* sysdeps/sh/libm-test-ulps: Likewise.
	* sysdeps/sparc/fpu/libm-test-ulps: Likewise.
	* sysdeps/tile/libm-test-ulps: Likewise.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2017-09-01 21:13:18 +00:00
Florian Weimer 17e00cc69e elf: Remove internal_function attribute 2017-08-31 16:59:37 +02:00
Joseph Myers f17a42333f Do not use __ptr_t.
sys/cdefs.h has a macro __ptr_t, which a few places in glibc use
instead of void *.  void * is a well-understood standard type for that
purpose and in a post-C89 context there is no need for a macro for it;
this patch changes those places to use void * directly instead.

Unlike __long_double_t, __ptr_t is widely used outside glibc (or at
least has many hits on codesearch.debian.net).  I don't know how many
of those uses would break if sys/cdefs.h ceased to define the macro,
but there's enough risk that this patch leaves the definition and just
removes the uses within glibc; removal of the definition can be
considered separately if desired.

Tested for x86_64, and with build-many-glibcs.py.

	* malloc/mcheck.c (old_free_hook): Use void * instead of __ptr_t.
	(old_malloc_hook): Likewise.
	(old_memalign_hook): Likewise.
	(old_realloc_hook): Likewise.
	(struct hdr): Likewise.
	(flood): Likewise.
	(freehook): Likewise.
	(mallochook): Likewise.
	(memalignhook): Likewise.
	(reallochook): Likewise.
	(mprobe): Likewise.
	* malloc/mtrace.c (mallwatch): Likewise.
	(tr_old_free_hook): Likewise.
	(tr_old_malloc_hook): Likewise.
	(tr_old_realloc_hook): Likewise.
	(tr_old_memalign_hook): Likewise.
	(tr_where): Likewise.
	(lock_and_info): Likewise.
	(tr_freehook): Likewise.
	(tr_mallochook): Likewise.
	(tr_reallochook): Likewise.
	(tr_memalignhook): Likewise.
	* misc/err.h [!__GNUC_VA_LIST] (__gnuc_va_list): Likewise.
	* misc/mmap.c (__mmap): Likewise.
	* misc/mmap64.c (__mmap64): Likewise.
	* misc/mprotect.c (__mprotect): Likewise.
	* misc/msync.c (msync): Likewise.
	* misc/munmap.c (__munmap): Likewise.
	* posix/posix_madvise.c (posix_madvise): Likewise.
	* socket/send.c (__send): Likewise.
	* socket/sendto.c (__sendto): Likewise.
	* socket/setsockopt.c (__setsockopt): Likewise.
	* string/memcmp.c (__ptr_t): Remove macro.
	(MEMCMP): Use void * instead of ptr_t.
	* string/memrchr.c (__ptr_t): Remove macro.
	(__memrchr): Use void * instead of ptr_t.
	* sysdeps/mach/hurd/dl-sysdep.c (__mmap): Likewise.
	* sysdeps/mach/hurd/mmap.c (__mmap): Likewise.
	* sysdeps/mach/hurd/mmap64.c (__mmap64): Likewise.
	* sysdeps/mach/mprotect.c (__mprotect): Likewise.
	* sysdeps/mach/msync.c (msync): Likewise.
	* sysdeps/mach/munmap.c (__munmap): Likewise.
	* sysdeps/mips/bits/setjmp.h (struct __jmp_buf_internal_tag):
	Likewise.
	* sysdeps/posix/getcwd.c (__getcwd): Likewise.
	* sysdeps/powerpc/powerpc32/memset.S (memset): Likewise.
	* sysdeps/powerpc/powerpc32/power4/memcpy.S (memcpy): Likewise.
	* sysdeps/powerpc/powerpc32/power4/memset.S (memset): Likewise.
	* sysdeps/powerpc/powerpc32/power6/memcpy.S (memcpy): Likewise.
	* sysdeps/powerpc/powerpc32/power6/memset.S (memset): Likewise.
	* sysdeps/powerpc/powerpc32/power7/memcpy.S (memcpy): Likewise.
	* sysdeps/powerpc/powerpc32/power7/mempcpy.S (__mempcpy):
	Likewise.
	* sysdeps/powerpc/powerpc32/power7/memset.S (memset): Likewise.
	* sysdeps/powerpc/powerpc64/memcpy.S (memcpy): Likewise.
	* sysdeps/powerpc/powerpc64/memset.S (memset): Likewise.
	* sysdeps/powerpc/powerpc64/power4/memcpy.S (memcpy): Likewise.
	* sysdeps/powerpc/powerpc64/power4/memset.S (memset): Likewise.
	* sysdeps/powerpc/powerpc64/power6/memcpy.S (memcpy): Likewise.
	* sysdeps/powerpc/powerpc64/power6/memset.S (memset): Likewise.
	* sysdeps/powerpc/powerpc64/power7/memcpy.S (memcpy): Likewise.
	* sysdeps/powerpc/powerpc64/power7/mempcpy.S (__mempcpy):
	Likewise.
	* sysdeps/powerpc/powerpc64/power7/memset.S (memset): Likewise.
	* sysdeps/powerpc/powerpc64/power8/memset.S (memset): Likewise.
	* sysdeps/tile/memcmp.c (__ptr_t): Remove macro.
	(MEMCMP): Use void * instead of ptr_t.
	* sysdeps/unix/sysv/linux/alpha/oldglob.c (old_glob_t): Likewise.
	* sysdeps/unix/sysv/linux/mmap.c (__mmap): Likewise.
2017-08-08 17:14:49 +00:00
Alan Modra 0572433b5b PowerPC64 ELFv2 PPC64_OPT_LOCALENTRY
ELFv2 functions with localentry:0 are those with a single entry point,
ie. global entry == local entry, that have no requirement on r2 or
r12 and guarantee r2 is unchanged on return.  Such an external
function can be called via the PLT without saving r2 or restoring it
on return, avoiding a common load-hit-store for small functions.

This patch implements the ld.so changes necessary for this
optimization.  ld.so needs to check that an optimized plt call
sequence is in fact calling a function implemented with localentry:0,
end emit a fatal error otherwise.

The elf/testobj6.c change is to stop "error while loading shared
libraries: expected localentry:0 `preload'" when running
elf/preloadtest, which we'd get otherwise.

	* elf/elf.h (PPC64_OPT_LOCALENTRY): Define.
	* sysdeps/alpha/dl-machine.h (elf_machine_fixup_plt): Add
	refsym and sym parameters.  Adjust callers.
	* sysdeps/aarch64/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/arm/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/generic/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/hppa/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/i386/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/ia64/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/m68k/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/microblaze/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/mips/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/nios2/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_fixup_plt):
	Likewise.
	* sysdeps/s390/s390-32/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/s390/s390-64/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/sh/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/sparc/sparc32/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/sparc/sparc64/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/tile/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/x86_64/dl-machine.h (elf_machine_fixup_plt): Likewise.
	* sysdeps/powerpc/powerpc64/dl-machine.c (_dl_error_localentry): New.
	(_dl_reloc_overflow): Increase buffser size.  Formatting.
	* sysdeps/powerpc/powerpc64/dl-machine.h (ppc64_local_entry_offset):
	Delete reloc param, add refsym and sym.  Check optimized plt
	call stubs for localentry:0 functions.  Adjust callers.
	(elf_machine_fixup_plt, elf_machine_plt_conflict): Add refsym
	and sym parameters.  Adjust callers.
	(_dl_reloc_overflow): Move attribute.
	(_dl_error_localentry): Declare.
	* elf/dl-runtime.c (_dl_fixup): Save original sym.  Pass
	refsym and sym to elf_machine_fixup_plt.
	* elf/testobj6.c (preload): Call printf.
2017-06-14 10:47:25 +09:30
Stefan Liebler 12d2dd7060 Optimize generic spinlock code and use C11 like atomic macros.
This patch optimizes the generic spinlock code.

The type pthread_spinlock_t is a typedef to volatile int on all archs.
Passing a volatile pointer to the atomic macros which are not mapped to the
C11 atomic builtins can lead to extra stores and loads to stack if such
a macro creates a temporary variable by using "__typeof (*(mem)) tmp;".
Thus, those macros which are used by spinlock code - atomic_exchange_acquire,
atomic_load_relaxed, atomic_compare_exchange_weak - have to be adjusted.
According to the comment from  Szabolcs Nagy, the type of a cast expression is
unqualified (see http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_423.htm):
__typeof ((__typeof (*(mem)) *(mem)) tmp;
Thus from spinlock perspective the variable tmp is of type int instead of
type volatile int.  This patch adjusts those macros in include/atomic.h.
With this construct GCC >= 5 omits the extra stores and loads.

The atomic macros are replaced by the C11 like atomic macros and thus
the code is aligned to it.  The pthread_spin_unlock implementation is now
using release memory order instead of sequentially consistent memory order.
The issue with passed volatile int pointers applies to the C11 like atomic
macros as well as the ones used before.

I've added a glibc_likely hint to the first atomic exchange in
pthread_spin_lock in order to return immediately to the caller if the lock is
free.  Without the hint, there is an additional jump if the lock is free.

I've added the atomic_spin_nop macro within the loop of plain reads.
The plain reads are also realized by C11 like atomic_load_relaxed macro.

The new define ATOMIC_EXCHANGE_USES_CAS determines if the first try to acquire
the spinlock in pthread_spin_lock or pthread_spin_trylock is an exchange
or a CAS.  This is defined in atomic-machine.h for all architectures.

The define SPIN_LOCK_READS_BETWEEN_CMPXCHG is now removed.
There is no technical reason for throwing in a CAS every now and then,
and so far we have no evidence that it can improve performance.
If that would be the case, we have to adjust other spin-waiting loops
elsewhere, too!  Using a CAS loop without plain reads is not a good idea
on many targets and wasn't used by one.  Thus there is now no option to
do so.

Architectures are now using the generic spinlock automatically if they
do not provide an own implementation.  Thus the pthread_spin_lock.c files
in sysdeps folder are deleted.

ChangeLog:

	* NEWS: Mention new spinlock implementation.
	* include/atomic.h:
	(__atomic_val_bysize): Cast type to omit volatile qualifier.
	(atomic_exchange_acq): Likewise.
	(atomic_load_relaxed): Likewise.
	(ATOMIC_EXCHANGE_USES_CAS): Check definition.
	* nptl/pthread_spin_init.c (pthread_spin_init):
	Use atomic_store_relaxed.
	* nptl/pthread_spin_lock.c (pthread_spin_lock):
	Use C11-like atomic macros.
	* nptl/pthread_spin_trylock.c (pthread_spin_trylock):
	Likewise.
	* nptl/pthread_spin_unlock.c (pthread_spin_unlock):
	Use atomic_store_release.
	* sysdeps/aarch64/nptl/pthread_spin_lock.c: Delete File.
	* sysdeps/arm/nptl/pthread_spin_lock.c: Likewise.
	* sysdeps/hppa/nptl/pthread_spin_lock.c: Likewise.
	* sysdeps/m68k/nptl/pthread_spin_lock.c: Likewise.
	* sysdeps/microblaze/nptl/pthread_spin_lock.c: Likewise.
	* sysdeps/mips/nptl/pthread_spin_lock.c: Likewise.
	* sysdeps/nios2/nptl/pthread_spin_lock.c: Likewise.
	* sysdeps/aarch64/atomic-machine.h (ATOMIC_EXCHANGE_USES_CAS): Define.
	* sysdeps/alpha/atomic-machine.h: Likewise.
	* sysdeps/arm/atomic-machine.h: Likewise.
	* sysdeps/i386/atomic-machine.h: Likewise.
	* sysdeps/ia64/atomic-machine.h: Likewise.
	* sysdeps/m68k/coldfire/atomic-machine.h: Likewise.
	* sysdeps/m68k/m680x0/m68020/atomic-machine.h: Likewise.
	* sysdeps/microblaze/atomic-machine.h: Likewise.
	* sysdeps/mips/atomic-machine.h: Likewise.
	* sysdeps/powerpc/powerpc32/atomic-machine.h: Likewise.
	* sysdeps/powerpc/powerpc64/atomic-machine.h: Likewise.
	* sysdeps/s390/atomic-machine.h: Likewise.
	* sysdeps/sparc/sparc32/atomic-machine.h: Likewise.
	* sysdeps/sparc/sparc32/sparcv9/atomic-machine.h: Likewise.
	* sysdeps/sparc/sparc64/atomic-machine.h: Likewise.
	* sysdeps/tile/tilegx/atomic-machine.h: Likewise.
	* sysdeps/tile/tilepro/atomic-machine.h: Likewise.
	* sysdeps/unix/sysv/linux/hppa/atomic-machine.h: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h: Likewise.
	* sysdeps/unix/sysv/linux/nios2/atomic-machine.h: Likewise.
	* sysdeps/unix/sysv/linux/sh/atomic-machine.h: Likewise.
	* sysdeps/x86_64/atomic-machine.h: Likewise.
2017-06-06 09:41:56 +02:00
Adhemerval Zanella eab380d8ec Move shared pthread definitions to common headers
This patch removes all the replicated pthread definition accross the
architectures and consolidates it on shared headers.  The new
organization is as follow:

  * Architecture specific definition (such as pthread types sizes) are
    place in the new pthreadtypes-arch.h header in arch specific path.

  * All shared structure definition are moved to a common NPTL header
    at sysdeps/nptl/bits/pthreadtypes.h (with now includes the arch
    specific one for internal definitions).

  * Also, for C11 future thread support, both mutex and condition
    definition are placed in a common header at
    sysdeps/nptl/bits/thread-shared-types.h.

It is also a refactor patch without expected functional changes.
Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu,
m68k-linux-gnu, microblaze-linux-gnu, mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
tile{pro,gx}-linux-gnu, and x86_64-linux-gnu).

	* posix/Makefile (headers): Add pthreadtypes-arch.h and
	thread-shared-types.h.
	* sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h: New file: arch
	specific thread definition.
	* sysdeps/alpha/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/arm/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/hppa/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/ia64/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/m68k/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/mips/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/nios2/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/powerpc/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/s390/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/sh/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/sparc/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/tile/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/x86/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/nptl/bits/thread-shared-types.h: New file: shared
	thread definition between POSIX and C11.
	* sysdeps/aarch64/nptl/bits/pthreadtypes.h.: Remove file.
	* sysdeps/alpha/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/arm/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/hppa/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/m68k/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/microblaze/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/mips/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/nios2/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/ia64/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/powerpc/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/s390/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/sh/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/sparc/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/tile/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/x86/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/nptl/bits/pthreadtypes.h: New file: common thread
	definitions shared across all architectures.
2017-05-09 17:49:17 -03:00
Chris Metcalf 502697713f tile: Check for pointer add overflow in memchr
As was done in b224637928, check for large size causing an overflow
in the loop that walks over the array.

Branching out of line here is the fastest approach for handling this
problem, since tile can bundle the instructions to compute the branch
test in parallel with doing the required memchr loop setup computation.

Unfortunately, the existing saturated ops (e.g. tilegx addxsc) are
all signed saturing ops, so don't help with unsigned saturation.
2017-01-16 15:44:48 -05:00
Torvald Riegel cc25c8b4c1 New pthread rwlock that is more scalable.
This replaces the pthread rwlock with a new implementation that uses a
more scalable algorithm (primarily through not using a critical section
anymore to make state changes).  The fast path for rdlock acquisition and
release is now basically a single atomic read-modify write or CAS and a few
branches.  See nptl/pthread_rwlock_common.c for details.

	* nptl/DESIGN-rwlock.txt: Remove.
	* nptl/lowlevelrwlock.sym: Remove.
	* nptl/Makefile: Add new tests.
	* nptl/pthread_rwlock_common.c: New file.  Contains the new rwlock.
	* nptl/pthreadP.h (PTHREAD_RWLOCK_PREFER_READER_P): Remove.
	(PTHREAD_RWLOCK_WRPHASE, PTHREAD_RWLOCK_WRLOCKED,
	PTHREAD_RWLOCK_RWAITING, PTHREAD_RWLOCK_READER_SHIFT,
	PTHREAD_RWLOCK_READER_OVERFLOW, PTHREAD_RWLOCK_WRHANDOVER,
	PTHREAD_RWLOCK_FUTEX_USED): New.
	* nptl/pthread_rwlock_init.c (__pthread_rwlock_init): Adapt to new
	implementation.
	* nptl/pthread_rwlock_rdlock.c (__pthread_rwlock_rdlock_slow): Remove.
	(__pthread_rwlock_rdlock): Adapt.
	* nptl/pthread_rwlock_timedrdlock.c
	(pthread_rwlock_timedrdlock): Adapt.
	* nptl/pthread_rwlock_timedwrlock.c
	(pthread_rwlock_timedwrlock): Adapt.
	* nptl/pthread_rwlock_trywrlock.c (pthread_rwlock_trywrlock): Adapt.
	* nptl/pthread_rwlock_tryrdlock.c (pthread_rwlock_tryrdlock): Adapt.
	* nptl/pthread_rwlock_unlock.c (pthread_rwlock_unlock): Adapt.
	* nptl/pthread_rwlock_wrlock.c (__pthread_rwlock_wrlock_slow): Remove.
	(__pthread_rwlock_wrlock): Adapt.
	* nptl/tst-rwlock10.c: Adapt.
	* nptl/tst-rwlock11.c: Adapt.
	* nptl/tst-rwlock17.c: New file.
	* nptl/tst-rwlock18.c: New file.
	* nptl/tst-rwlock19.c: New file.
	* nptl/tst-rwlock2b.c: New file.
	* nptl/tst-rwlock8.c: Adapt.
	* nptl/tst-rwlock9.c: Adapt.
	* sysdeps/aarch64/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* sysdeps/arm/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* sysdeps/hppa/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* sysdeps/ia64/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* sysdeps/m68k/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* sysdeps/microblaze/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* sysdeps/mips/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* sysdeps/nios2/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* sysdeps/s390/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* sysdeps/sh/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* sysdeps/sparc/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* sysdeps/tile/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h
	(pthread_rwlock_t): Adapt.
	* sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h
	(pthread_rwlock_t): Adapt.
	* sysdeps/x86/bits/pthreadtypes.h (pthread_rwlock_t): Adapt.
	* nptl/nptl-printers.py (): Adapt.
	* nptl/nptl_lock_constants.pysym: Adapt.
	* nptl/test-rwlock-printers.py: Adapt.
	* nptl/test-rwlockattr-printers.c: Adapt.
	* nptl/test-rwlockattr-printers.py: Adapt.
2017-01-10 11:50:17 +01:00
Joseph Myers bfff8b1bec Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
Torvald Riegel ed19993b5b New condvar implementation that provides stronger ordering guarantees.
This is a new implementation for condition variables, required
after http://austingroupbugs.net/view.php?id=609 to fix bug 13165.  In
essence, we need to be stricter in which waiters a signal or broadcast
is required to wake up; this couldn't be solved using the old algorithm.
ISO C++ made a similar clarification, so this also fixes a bug in
current libstdc++, for example.

We can't use the old algorithm anymore because futexes do not guarantee
to wake in FIFO order.  Thus, when we wake, we can't simply let any
waiter grab a signal, but we need to ensure that one of the waiters
happening before the signal is woken up.  This is something the previous
algorithm violated (see bug 13165).

There's another issue specific to condvars: ABA issues on the underlying
futexes.  Unlike mutexes that have just three states, or semaphores that
have no tokens or a limited number of them, the state of a condvar is
the *order* of the waiters.  A waiter on a semaphore can grab a token
whenever one is available; a condvar waiter must only consume a signal
if it is eligible to do so as determined by the relative order of the
waiter and the signal.
Therefore, this new algorithm maintains two groups of waiters: Those
eligible to consume signals (G1), and those that have to wait until
previous waiters have consumed signals (G2).  Once G1 is empty, G2
becomes the new G1.  64b counters are used to avoid ABA issues.

This condvar doesn't yet use a requeue optimization (ie, on a broadcast,
waking just one thread and requeueing all others on the futex of the
mutex supplied by the program).  I don't think doing the requeue is
necessarily the right approach (but I haven't done real measurements
yet):
* If a program expects to wake many threads at the same time and make
that scalable, a condvar isn't great anyway because of how it requires
waiters to operate mutually exclusive (due to the mutex usage).  Thus, a
thundering herd problem is a scalability problem with or without the
optimization.  Using something like a semaphore might be more
appropriate in such a case.
* The scalability problem is actually at the mutex side; the condvar
could help (and it tries to with the requeue optimization), but it
should be the mutex who decides how that is done, and whether it is done
at all.
* Forcing all but one waiter into the kernel-side wait queue of the
mutex prevents/avoids the use of lock elision on the mutex.  Thus, it
prevents the only cure against the underlying scalability problem
inherent to condvars.
* If condvars use short critical sections (ie, hold the mutex just to
check a binary flag or such), which they should do ideally, then forcing
all those waiter to proceed serially with kernel-based hand-off (ie,
futex ops in the mutex' contended state, via the futex wait queues) will
be less efficient than just letting a scalable mutex implementation take
care of it.  Our current mutex impl doesn't employ spinning at all, but
if critical sections are short, spinning can be much better.
* Doing the requeue stuff requires all waiters to always drive the mutex
into the contended state.  This leads to each waiter having to call
futex_wake after lock release, even if this wouldn't be necessary.

	[BZ #13165]
	* nptl/pthread_cond_broadcast.c (__pthread_cond_broadcast): Rewrite to
	use new algorithm.
	* nptl/pthread_cond_destroy.c (__pthread_cond_destroy): Likewise.
	* nptl/pthread_cond_init.c (__pthread_cond_init): Likewise.
	* nptl/pthread_cond_signal.c (__pthread_cond_signal): Likewise.
	* nptl/pthread_cond_wait.c (__pthread_cond_wait): Likewise.
	(__pthread_cond_timedwait): Move here from pthread_cond_timedwait.c.
	(__condvar_confirm_wakeup, __condvar_cancel_waiting,
	__condvar_cleanup_waiting, __condvar_dec_grefs,
	__pthread_cond_wait_common): New.
	(__condvar_cleanup): Remove.
	* npt/pthread_condattr_getclock.c (pthread_condattr_getclock): Adapt.
	* npt/pthread_condattr_setclock.c (pthread_condattr_setclock):
	Likewise.
	* npt/pthread_condattr_getpshared.c (pthread_condattr_getpshared):
	Likewise.
	* npt/pthread_condattr_init.c (pthread_condattr_init): Likewise.
	* nptl/tst-cond1.c: Add comment.
	* nptl/tst-cond20.c (do_test): Adapt.
	* nptl/tst-cond22.c (do_test): Likewise.
	* sysdeps/aarch64/nptl/bits/pthreadtypes.h (pthread_cond_t): Adapt
	structure.
	* sysdeps/arm/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
	* sysdeps/ia64/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
	* sysdeps/m68k/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
	* sysdeps/microblaze/nptl/bits/pthreadtypes.h (pthread_cond_t):
	Likewise.
	* sysdeps/mips/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
	* sysdeps/nios2/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
	* sysdeps/s390/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
	* sysdeps/sh/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
	* sysdeps/tile/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
	* sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h (pthread_cond_t):
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h (pthread_cond_t):
	Likewise.
	* sysdeps/x86/bits/pthreadtypes.h (pthread_cond_t): Likewise.
	* sysdeps/nptl/internaltypes.h (COND_NWAITERS_SHIFT): Remove.
	(COND_CLOCK_BITS): Adapt.
	* sysdeps/nptl/pthread.h (PTHREAD_COND_INITIALIZER): Adapt.
	* nptl/pthreadP.h (__PTHREAD_COND_CLOCK_MONOTONIC_MASK,
	__PTHREAD_COND_SHARED_MASK): New.
	* nptl/nptl-printers.py (CLOCK_IDS): Remove.
	(ConditionVariablePrinter, ConditionVariableAttributesPrinter): Adapt.
	* nptl/nptl_lock_constants.pysym: Adapt.
	* nptl/test-cond-printers.py: Adapt.
	* sysdeps/unix/sysv/linux/hppa/internaltypes.h (cond_compat_clear,
	cond_compat_check_and_clear): Adapt.
	* sysdeps/unix/sysv/linux/hppa/pthread_cond_timedwait.c: Remove file ...
	* sysdeps/unix/sysv/linux/hppa/pthread_cond_wait.c
	(__pthread_cond_timedwait): ... and move here.
	* nptl/DESIGN-condvar.txt: Remove file.
	* nptl/lowlevelcond.sym: Likewise.
	* nptl/pthread_cond_timedwait.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_broadcast.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_signal.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_timedwait.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_wait.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_broadcast.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_signal.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_timedwait.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_wait.S: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
2016-12-31 14:56:47 +01:00
Joseph Myers 2314a29b62 Add missing hidden_def (__sigsetjmp).
This patch adds the missing hidden_def (__sigsetjmp) on various
architectures that were failing to build (as noted in
<https://sourceware.org/ml/libc-alpha/2016-11/msg01124.html>).

Tested (compilation only) with build-many-glibcs.py.

	* sysdeps/alpha/setjmp.S (__sigsetjmp): Use hidden_def.
	* sysdeps/hppa/setjmp.S (__sigsetjmp): Likewise.
	* sysdeps/mips/mips64/setjmp.S (__sigsetjmp): Likewise.
	* sysdeps/mips/setjmp.S (__sigsetjmp): Likewise.
	* sysdeps/sh/sh3/setjmp.S (__sigsetjmp): Likewise.
	* sysdeps/sh/sh4/setjmp.S (__sigsetjmp): Likewise.
	* sysdeps/sparc/sparc32/setjmp.S (__sigsetjmp): Likewise.
	* sysdeps/tile/setjmp.S (__sigsetjmp): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/setjmp.S (__sigsetjmp):
	Likewise.
2016-12-01 20:49:25 +00:00
Joseph Myers f11e220d2d Refactor FP_FAST_* into bits/fp-fast.h.
Continuing the refactoring of bits/mathdef.h, this patch moves the
FP_FAST_* definitions into a new bits/fp-fast.h header.  Currently
this is only for FP_FAST_FMA*, but in future it would be the
appropriate place for the FP_FAST_* macros from TS 18661-1 as well.

The generic bits/mathdef.h header defines these macros based on
whether the compiler defines __FP_FAST_*.  Most architecture-specific
headers, however, fail to do so, meaning that if the architecture (or
some particular processors) does in fact have fused operations, and
GCC knows to use them inline, the FP_FAST_* macros will still not be
defined.

By refactoring, this patch causes the generic version (based on
__FP_FAST_*) to be used in more cases, and so the macro definitions to
be more accurate.  Architectures that already defined some or all of
these macros other than based on the predefines have their own
versions of fp-fast.h, which are arranged so they define FP_FAST_* if
either the architecture-specific conditions are true or __FP_FAST_*
are defined.

After this refactoring, various bits/mathdef.h headers for
architectures with long double = double are semantically identical to
the generic version.  The patch removes those headers that are
redundant.  (In fact two of the four removed were already redundant
before this patch because they did use __FP_FAST_*.)

Tested for x86_64 and x86, and compilation-only with
build-many-glibcs.py.

	* bits/fp-fast.h: New file.
	* sysdeps/aarch64/bits/fp-fast.h: Likewise.
	* sysdeps/powerpc/bits/fp-fast.h: Likewise.
	* math/Makefile (headers): Add bits/fp-fast.h.
	* math/math.h: Include <bits/fp-fast.h>.
	* bits/mathdef.h (FP_FAST_FMA): Remove.
	(FP_FAST_FMAF): Likewise.
	(FP_FAST_FMAL): Likewise.
	* sysdeps/aarch64/bits/mathdef.h (FP_FAST_FMA): Likewise.
	(FP_FAST_FMAF): Likewise.
	* sysdeps/powerpc/bits/mathdef.h (FP_FAST_FMA): Likewise.
	(FP_FAST_FMAF): Likewise.
	* sysdeps/x86/bits/mathdef.h (FP_FAST_FMA): Likewise.
	(FP_FAST_FMAF): Likewise.
	(FP_FAST_FMAL): Likewise.
	* sysdeps/arm/bits/mathdef.h: Remove file.
	* sysdeps/hppa/fpu/bits/mathdef.h: Likewise.
	* sysdeps/sh/sh4/bits/mathdef.h: Likewise.
	* sysdeps/tile/bits/mathdef.h: Likewise.
2016-11-29 01:45:00 +00:00
Adhemerval Zanella c579f48edb Remove cached PID/TID in clone
This patch remove the PID cache and usage in current GLIBC code.  Current
usage is mainly used a performance optimization to avoid the syscall,
however it adds some issues:

  - The exposed clone syscall will try to set pid/tid to make the new
    thread somewhat compatible with current GLIBC assumptions.  This cause
    a set of issue with new workloads and usecases (such as BZ#17214 and
    [1]) as well for new internal usage of clone to optimize other algorithms
    (such as clone plus CLONE_VM for posix_spawn, BZ#19957).

  - The caching complexity also added some bugs in the past [2] [3] and
    requires more effort of each port to handle such requirements (for
    both clone and vfork implementation).

  - Caching performance gain in mainly on getpid and some specific
    code paths.  The getpid performance leverage is questionable [4],
    either by the idea of getpid being a hotspot as for the getpid
    implementation itself (if it is indeed a justifiable hotspot a
    vDSO symbol could let to a much more simpler solution).

    Other usage is mainly for non usual code paths, such as pthread
    cancellation signal and handling.

For thread creation (on stack allocation) the code simplification in fact
adds some performance gain due the no need of transverse the stack cache
and invalidate each element pid.

Other thread usages will require a direct getpid syscall, such as
cancellation/setxid signal, thread cancellation, thread fail path (at
create_thread), and thread signal (pthread_kill and pthread_sigqueue).
However these are hardly usual hotspots and I think adding a syscall is
justifiable.

It also simplifies both the clone and vfork arch-specific implementation.
And by review each fork implementation there are some discrepancies that
this patch also solves:

  - microblaze clone/vfork does not set/reset the pid/tid field
  - hppa uses the default vfork implementation that fallback to fork.
    Since vfork is deprecated I do not think we should bother with it.

The patch also removes the TID caching in clone. My understanding for
such semantic is try provide some pthread usage after a user program
issue clone directly (as done by thread creation with CLONE_PARENT_SETTID
and pthread tid member).  However, as stated before in multiple discussions
threads, GLIBC provides clone syscalls without further supporting all this
semantics.

I ran a full make check on x86_64, x32, i686, armhf, aarch64, and powerpc64le.
For sparc32, sparc64, and mips I ran the basic fork and vfork tests from
posix/ folder (on a qemu system).  So it would require further testing
on alpha, hppa, ia64, m68k, nios2, s390, sh, and tile (I excluded microblaze
because it is already implementing the patch semantic regarding clone/vfork).

[1] https://codereview.chromium.org/800183004/
[2] https://sourceware.org/ml/libc-alpha/2006-07/msg00123.html
[3] https://sourceware.org/bugzilla/show_bug.cgi?id=15368
[4] http://yarchive.net/comp/linux/getpid_caching.html

	* sysdeps/nptl/fork.c (__libc_fork): Remove pid cache setting.
	* nptl/allocatestack.c (allocate_stack): Likewise.
	(__reclaim_stacks): Likewise.
	(setxid_signal_thread): Obtain pid through syscall.
	* nptl/nptl-init.c (sigcancel_handler): Likewise.
	(sighandle_setxid): Likewise.
	* nptl/pthread_cancel.c (pthread_cancel): Likewise.
	* sysdeps/unix/sysv/linux/pthread_kill.c (__pthread_kill): Likewise.
	* sysdeps/unix/sysv/linux/pthread_sigqueue.c (pthread_sigqueue):
	Likewise.
	* sysdeps/unix/sysv/linux/createthread.c (create_thread): Likewise.
	* sysdeps/unix/sysv/linux/getpid.c: Remove file.
	* nptl/descr.h (struct pthread): Change comment about pid value.
	* nptl/pthread_getattr_np.c (pthread_getattr_np): Remove thread
	pid assert.
	* sysdeps/unix/sysv/linux/pthread-pids.h (__pthread_initialize_pids):
	Do not set pid value.
	* nptl_db/td_ta_thr_iter.c (iterate_thread_list): Remove thread
	pid cache check.
	* nptl_db/td_thr_validate.c (td_thr_validate): Likewise.
	* sysdeps/aarch64/nptl/tcb-offsets.sym: Remove pid offset.
	* sysdeps/alpha/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/arm/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/hppa/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/i386/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/ia64/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/m68k/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/microblaze/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/mips/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/nios2/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/powerpc/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/s390/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/sh/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/sparc/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/tile/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/x86_64/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/clone.S: Remove pid and tid caching.
	* sysdeps/unix/sysv/linux/alpha/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/arm/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/hppa/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/ia64/clone2.S: Likewise.
	* sysdeps/unix/sysv/linux/mips/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/nios2/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/sh/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/tile/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/vfork.S: Remove pid set and reset.
	* sysdeps/unix/sysv/linux/alpha/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/arm/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/ia64/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/m68k/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/m68k/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/mips/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/nios2/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/sh/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/tile/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/tst-clone2.c (f): Remove direct pthread
	struct access.
	(clone_test): Remove function.
	(do_test): Rewrite to take in consideration pid is not cached anymore.
2016-11-24 19:38:51 -02:00
Joseph Myers 93eb85ceb2 Refactor float_t, double_t information into bits/flt-eval-method.h.
At present, definitions of float_t and double_t are split among many
bits/mathdef.h headers.

For all but three architectures, these types are float and double.
Furthermore, if you assume __FLT_EVAL_METHOD__ to be defined, that
provides a more generic way of determining the correct values of these
typedefs.  Defining these typedefs more generally based on
__FLT_EVAL_METHOD__ was previously proposed by Paul Eggert in
<https://sourceware.org/ml/libc-alpha/2012-02/msg00002.html>.

This patch refactors things in the way I proposed in
<https://sourceware.org/ml/libc-alpha/2016-11/msg00745.html>.  A new
header bits/flt-eval-method.h defines a single macro,
__GLIBC_FLT_EVAL_METHOD, which is then used by math.h to define
float_t and double_t.  The default is based on __FLT_EVAL_METHOD__
(although actually a default to 0 would have the same effect for
current ports, because ports where values other than 0 or 16 are
possible all have their own headers).

To avoid changing the existing semantics in any case, including for
compilers not defining __FLT_EVAL_METHOD__, architecture-specific
files are then added for m68k, s390, x86 which replicate the existing
semantics.  At least with __FLT_EVAL_METHOD__ values possible with
GCC, there should be no change to the choices of float_t and double_t
for any supported configuration.

Architecture maintainer notes:

* m68k: sysdeps/m68k/m680x0/bits/flt-eval-method.h always defines
  __GLIBC_FLT_EVAL_METHOD to 2 to replicate the existing logic.  But
  actually GCC defines __FLT_EVAL_METHOD__ to 0 if TARGET_68040.  It
  might make sense to make the header prefer to base things on
  __FLT_EVAL_METHOD__ if defined, like the x86 version, and so make
  the choices of these types more accurate (with a NEWS entry as for
  the other changes to these types on particular architectures).

* s390: sysdeps/s390/bits/flt-eval-method.h always defines
  __GLIBC_FLT_EVAL_METHOD to 1 to replicate the existing logic.  As
  previously discussed, it might make sense in coordination with GCC
  to eliminate the historic mistake, avoid excess precision in the
  -fexcess-precision=standard case and make the typedefs match (with a
  NEWS entry, again).

Tested for x86-64 and x86.  Also did compilation-only testing with
build-many-glibcs.py.

	* bits/flt-eval-method.h: New file.
	* sysdeps/m68k/m680x0/bits/flt-eval-method.h: Likewise.
	* sysdeps/s390/bits/flt-eval-method.h: Likewise.
	* sysdeps/x86/bits/flt-eval-method.h: Likewise.
	* math/Makefile (headers): Add bits/flt-eval-method.h.
	* math/math.h: Include <bits/flt-eval-method.h>.
	[__USE_ISOC99] (float_t): Define based on __GLIBC_FLT_EVAL_METHOD.
	[__USE_ISOC99] (double_t): Likewise.
	* bits/mathdef.h (float_t): Remove.
	(double_t): Likewise.
	* sysdeps/aarch64/bits/mathdef.h (float_t): Likewise.
	(double_t): Likewise.
	* sysdeps/alpha/bits/mathdef.h (float_t): Likewise.
	(double_t): Likewise.
	* sysdeps/arm/bits/mathdef.h (float_t): Likewise.
	(double_t): Likewise.
	* sysdeps/hppa/fpu/bits/mathdef.h (float_t): Likewise.
	(double_t): Likewise.
	* sysdeps/ia64/bits/mathdef.h (float_t): Likewise.
	(double_t): Likewise.
	* sysdeps/m68k/m680x0/bits/mathdef.h (float_t): Likewise.
	(double_t): Likewise.
	* sysdeps/mips/bits/mathdef.h (float_t): Likewise.
	(double_t): Likewise.
	* sysdeps/powerpc/bits/mathdef.h (float_t): Likewise.
	(double_t): Likewise.
	* sysdeps/s390/bits/mathdef.h (float_t): Likewise.
	(double_t): Likewise.
	* sysdeps/sh/sh4/bits/mathdef.h (float_t): Likewise.
	(double_t): Likewise.
	* sysdeps/sparc/bits/mathdef.h (float_t): Likewise.
	(double_t): Likewise.
	* sysdeps/tile/bits/mathdef.h (float_t): Likewise.
	(double_t): Likewise.
	* sysdeps/x86/bits/mathdef.h (float_t): Likewise.
	(double_t): Likewise.
2016-11-24 18:44:50 +00:00
Chris Metcalf c73c7fc07c tile: create new math-tests.h header
The header makes tile use the new mechanisms for suppressing
exception and rounding support (the ROUNDING_TESTS_xxx() and
EXCEPTION_TESTS_xxx macros).

More importantly, it also now sets SNAN_TESTS_PRESERVE_PAYLOAD to 0,
since the tilegx fp hardware does not preserve NaN payloads.
2016-11-18 13:34:47 -05:00
Chris Metcalf a329844ff8 Make sure tilepro uses kernel atomics fo atomic_store
It's not legal for raw stores to be mixed with atomic operations
on tilepro, since the atomics are managed by kernel fast syscalls.
It's possible for a hardware store and a kernel fast atomic to race
with each other in such a way that the hardware store is lost.

Suppose you have an initial zero value, and you race with a store
of 2 and a kernel cmpxchg from 0 to 1.  The legal output is only 2:
either the store hit first and the cmpxchg failed, or the cmpxchg
hit first and succeeded, then was overwritten by the 2.  But if
the kernel cmpxchg starts first and loads the zero, then the store
hits and sets the value to 2, the cmpxchg will still decide it was
successful and write the 1, leaving the value illegally set to 1.

Using atomic_exchange variants to implement atomic_store fixes this
problem for tilepro.
2016-11-10 20:08:24 -05:00
Steve Ellcey 4589d0715c Add definitions to sysdeps/tile/tilepro/bits/wordsize.h.
* sysdeps/tile/tilepro/bits/wordsize.h: Define __WORDSIZE32_SIZE_ULONG
	and __WORDSIZE32_PTRDIFF_LONG.
2016-11-10 07:46:18 -08:00
Florian Weimer c74940f2a7 nptl: Document the reason why __kind in pthread_mutex_t is part of the ABI 2016-11-07 20:24:32 +01:00
Joseph Myers 799131036e Do not hardcode platform names in manual/libm-err-tab.pl (bug 14139).
manual/libm-err-tab.pl hardcodes a list of names for particular
platforms (mapping from sysdeps directory name to friendly name for
the manual).  This goes against the principle of keeping information
about individual platforms in their corresponding sysdeps directory,
and the list is also very out-of-date regarding supported platforms
and their corresponding sysdeps directories.

This patch fixes this by adding a libm-test-ulps-name file alongside
each libm-test-ulps file.  The script then gets the friendly name from
that file, which is required to exist, so it no longer needs to allow
for the mapping being missing.

Tested for x86_64.

	[BZ #14139]
	* manual/libm-err-tab.pl (%pplatforms): Initialize to empty.
	(find_files): Obtain platform name from libm-test-ulps-name and
	store in %pplatforms.
	(canonicalize_platform): Remove.
	(print_platforms): Use $pplatforms directly.
	(by_platforms): Do not allow for platforms missing from
	%pplatforms.
	* sysdeps/aarch64/libm-test-ulps-name: New file.
	* sysdeps/alpha/fpu/libm-test-ulps-name: Likewise.
	* sysdeps/arm/libm-test-ulps-name: Likewise.
	* sysdeps/generic/libm-test-ulps-name: Likewise.
	* sysdeps/hppa/fpu/libm-test-ulps-name: Likewise.
	* sysdeps/i386/fpu/libm-test-ulps-name: Likewise.
	* sysdeps/i386/i686/fpu/multiarch/libm-test-ulps-name: Likewise.
	* sysdeps/ia64/fpu/libm-test-ulps-name: Likewise.
	* sysdeps/m68k/coldfire/fpu/libm-test-ulps-name: Likewise.
	* sysdeps/m68k/m680x0/fpu/libm-test-ulps-name: Likewise.
	* sysdeps/microblaze/libm-test-ulps-name: Likewise.
	* sysdeps/mips/mips32/libm-test-ulps-name: Likewise.
	* sysdeps/mips/mips64/libm-test-ulps-name: Likewise.
	* sysdeps/nios2/libm-test-ulps-name: Likewise.
	* sysdeps/powerpc/fpu/libm-test-ulps-name: Likewise.
	* sysdeps/powerpc/nofpu/libm-test-ulps-name: Likewise.
	* sysdeps/s390/fpu/libm-test-ulps-name: Likewise.
	* sysdeps/sh/libm-test-ulps-name: Likewise.
	* sysdeps/sparc/fpu/libm-test-ulps-name: Likewise.
	* sysdeps/tile/libm-test-ulps-name: Likewise.
	* sysdeps/x86_64/fpu/libm-test-ulps-name: Likewise.
2016-11-04 16:49:06 +00:00
Steve Ellcey d060cd002d Define wordsize.h macros everywhere
* bits/wordsize.h: Add documentation.
	* sysdeps/aarch64/bits/wordsize.h : New file
	* sysdeps/generic/stdint.h (PTRDIFF_MIN, PTRDIFF_MAX): Update
	definitions.
	(SIZE_MAX): Change ifdef to if in __WORDSIZE32_SIZE_ULONG check.
	* sysdeps/gnu/bits/utmp.h (__WORDSIZE_TIME64_COMPAT32): Check
	with #if instead of #ifdef.
	* sysdeps/gnu/bits/utmpx.h (__WORDSIZE_TIME64_COMPAT32): Ditto.
	* sysdeps/mips/bits/wordsize.h (__WORDSIZE32_SIZE_ULONG,
	__WORDSIZE32_PTRDIFF_LONG, __WORDSIZE_TIME64_COMPAT32):
	Add or change defines.
	* sysdeps/powerpc/powerpc32/bits/wordsize.h: Likewise.
	* sysdeps/powerpc/powerpc64/bits/wordsize.h: Likewise.
	* sysdeps/s390/s390-32/bits/wordsize.h: Likewise.
	* sysdeps/s390/s390-64/bits/wordsize.h: Likewise.
	* sysdeps/sparc/sparc32/bits/wordsize.h: Likewise.
	* sysdeps/sparc/sparc64/bits/wordsize.h: Likewise.
	* sysdeps/tile/tilegx/bits/wordsize.h: Likewise.
	* sysdeps/tile/tilepro/bits/wordsize.h: Likewise.
	* sysdeps/unix/sysv/linux/alpha/bits/wordsize.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/wordsize.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/wordsize.h: Likewise.
	* sysdeps/wordsize-32/bits/wordsize.h: Likewise.
	* sysdeps/wordsize-64/bits/wordsize.h: Likewise.
	* sysdeps/x86/bits/wordsize.h: Likewise.
2016-11-04 09:37:44 -07:00
Joseph Myers 9a2835df5c Handle tilegx* machine names.
This patch makes sysdeps/tile/preconfigure handle tilegx* machine
names instead of just plain tilegx.  That matches GCC, and in
particular allows a big-endian toolchain to use the tilegxbe-linux-gnu
name when configuring both GCC and glibc.

Tested with compilation for tilegxbe-linux-gnu, both 32-bit and 64-bit
(building a subsequent GCC against that glibc still falls over because
of both 32-bit and 64-bit libraries going in the lib directory, as
noted at
<https://sourceware.org/ml/libc-alpha/2016-11/msg00129.html>).

	* sysdeps/tile/preconfigure: Accept tilegx* instead of tilegx.
2016-11-04 13:32:06 +00:00
Joseph Myers ec94343f59 Add femode_t functions.
TS 18661-1 defines a type femode_t to represent the set of dynamic
floating-point control modes (such as the rounding mode and trap
enablement modes), and functions fegetmode and fesetmode to manipulate
those modes (without affecting other state such as the raised
exception flags) and a corresponding macro FE_DFL_MODE.

This patch series implements those interfaces for glibc.  This first
patch adds the architecture-independent pieces, the x86 and x86_64
implementations, and the <bits/fenv.h> and ABI baseline updates for
all architectures so glibc keeps building and passing the ABI tests on
all architectures.  Subsequent patches add the fegetmode and fesetmode
implementations for other architectures.

femode_t is generally an integer type - the same type as fenv_t, or as
the single element of fenv_t where fenv_t is a structure containing a
single integer (or the single relevant element, where it has elements
for both status and control registers) - except where architecture
properties or consistency with the fenv_t implementation indicate
otherwise.  FE_DFL_MODE follows FE_DFL_ENV in whether it's a magic
pointer value (-1 cast to const femode_t *), a value that can be
distinguished from valid pointers by its high bits but otherwise
contains a representation of the desired register contents, or a
pointer to a constant variable (the powerpc case; __fe_dfl_mode is
added as an exported constant object, an alias to __fe_dfl_env).

Note that where architectures (that share a register between control
and status bits) gain definitions of new floating-point control or
status bits in future, the implementations of fesetmode for those
architectures may need updating (depending on whether the new bits are
control or status bits and what the implementation does with
previously unknown bits), just like existing implementations of
<fenv.h> functions that take care not to touch reserved bits may need
updating when the set of reserved bits changes.  (As any new bits are
outside the scope of ISO C, that's just a quality-of-implementation
issue for supporting them, not a conformance issue.)

As with fenv_t, femode_t should properly include any software DFP
rounding mode (and for both fenv_t and femode_t I'd consider that
fragment of DFP support appropriate for inclusion in glibc even in the
absence of the rest of libdfp; hardware DFP rounding modes should
already be included if the definitions of which bits are status /
control bits are correct).

Tested for x86_64, x86, mips64 (hard float, and soft float to test the
fallback version), arm (hard float) and powerpc (hard float, soft
float and e500).  Other architecture versions are untested.

	* math/fegetmode.c: New file.
	* math/fesetmode.c: Likewise.
	* sysdeps/i386/fpu/fegetmode.c: Likewise.
	* sysdeps/i386/fpu/fesetmode.c: Likewise.
	* sysdeps/x86_64/fpu/fegetmode.c: Likewise.
	* sysdeps/x86_64/fpu/fesetmode.c: Likewise.
	* math/fenv.h: Update comment on inclusion of <bits/fenv.h>.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (fegetmode): New function
	declaration.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (fesetmode): Likewise.
	* bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (femode_t): New
	typedef.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
	* sysdeps/aarch64/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
	(femode_t): New typedef.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
	* sysdeps/alpha/fpu/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
	(femode_t): New typedef.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
	* sysdeps/arm/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
	(femode_t): New typedef.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
	* sysdeps/hppa/fpu/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
	(femode_t): New typedef.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
	* sysdeps/ia64/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
	(femode_t): New typedef.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
	* sysdeps/m68k/fpu/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
	(femode_t): New typedef.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
	* sysdeps/microblaze/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
	(femode_t): New typedef.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
	* sysdeps/mips/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
	(femode_t): New typedef.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
	* sysdeps/nios2/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
	(femode_t): New typedef.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
	* sysdeps/powerpc/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
	(femode_t): New typedef.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (__fe_dfl_mode): New variable
	declaration.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
	* sysdeps/s390/fpu/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
	(femode_t): New typedef.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
	* sysdeps/sh/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
	(femode_t): New typedef.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
	* sysdeps/sparc/fpu/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
	(femode_t): New typedef.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
	* sysdeps/tile/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
	(femode_t): New typedef.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
	* sysdeps/x86/fpu/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
	(femode_t): New typedef.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
	* manual/arith.texi (FE_DFL_MODE): Document macro.
	(fegetmode): Document function.
	(fesetmode): Likewise.
	* math/Versions (fegetmode): New libm symbol at version
	GLIBC_2.25.
	(fesetmode): Likewise.
	* math/Makefile (libm-support): Add fegetmode and fesetmode.
	(tests): Add test-femode and test-femode-traps.
	* math/test-femode-traps.c: New file.
	* math/test-femode.c: Likewise.
	* sysdeps/powerpc/fpu/fenv_const.c (__fe_dfl_mode): Declare as
	alias for __fe_dfl_env.
	* sysdeps/powerpc/nofpu/fenv_const.c (__fe_dfl_mode): Likewise.
	* sysdeps/powerpc/powerpc32/e500/nofpu/fenv_const.c
	(__fe_dfl_mode): Likewise.
	* sysdeps/powerpc/Versions (__fe_dfl_mode): New libm symbol at
	version GLIBC_2.25.
	* sysdeps/nacl/libm.abilist: Update.
	* 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/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/tilegx/tilegx32/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
2016-09-07 16:40:09 +00:00
Torvald Riegel 76a0b73e81 Remove atomic_compare_and_exchange_bool_rel.
atomic_compare_and_exchange_bool_rel and
catomic_compare_and_exchange_bool_rel are removed and replaced with the
new C11-like atomic_compare_exchange_weak_release.  The concurrent code
in nscd/cache.c has not been reviewed yet, so this patch does not add
detailed comments.

	* nscd/cache.c (cache_add): Use new C11-like atomic operation instead
	of atomic_compare_and_exchange_bool_rel.
	* nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock_full): Likewise.
	* include/atomic.h (atomic_compare_and_exchange_bool_rel,
	catomic_compare_and_exchange_bool_rel): Remove.
	* sysdeps/aarch64/atomic-machine.h
	(atomic_compare_and_exchange_bool_rel): Likewise.
	* sysdeps/alpha/atomic-machine.h
	(atomic_compare_and_exchange_bool_rel): Likewise.
	* sysdeps/arm/atomic-machine.h
	(atomic_compare_and_exchange_bool_rel): Likewise.
	* sysdeps/mips/atomic-machine.h
	(atomic_compare_and_exchange_bool_rel): Likewise.
	* sysdeps/tile/atomic-machine.h
	(atomic_compare_and_exchange_bool_rel): Likewise.
2016-06-24 23:04:40 +03:00
Florian Weimer aca1daef29 elf: Consolidate machine-agnostic DTV definitions in <dl-dtv.h>
Identical definitions of dtv_t and TLS_DTV_UNALLOCATED were
repeated for all architectures using DTVs.
2016-06-20 14:31:40 +02:00
Joseph Myers f7a9f785e5 Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
Chris Metcalf 6a4448afe3 tile: define __NO_LONG_DOUBLE_MATH
This avoids build failures in the tests, and matches what is in
bits/mathdef.h.

Update the libc and libm abilist files to include __finitel,
__isinfl, and __isnanl.
2015-11-24 14:09:31 -05:00
Joseph Myers 2d2c271aea Fix math_private.h multiple include guards.
Various math_private.h headers are guarded by "#ifndef
_MATH_PRIVATE_H", but never define the macro.  Nothing else defines
the macro either (the generic math_private.h that they include defines
a different macro, _MATH_PRIVATE_H_), so those guards are ineffective.

With the recent inclusion of s_sin.c in s_sincos.c, this breaks the
build for MIPS, since the build of s_sincos.c ends up including
<math_private.h> twice and the MIPS version defines inline functions
such as libc_feholdexcept_mips, without a separate fenv_private.h
header with its own guards such as some architectures have.

This patch fixes all the problem headers to use architecture-specific
guard macro names, and to define those macros in the headers they
guard, just as some architectures already do.

Tested for x86 (testsuite, and that installed shared libraries are
unchanged by the patch), and for mips64 (that it fixes the build).

	* sysdeps/arm/math_private.h [!_MATH_PRIVATE_H]: Change guard to
	[!ARM_MATH_PRIVATE_H].
	[!ARM_MATH_PRIVATE_H] (ARM_MATH_PRIVATE_H): Define macro.
	* sysdeps/hppa/math_private.h [!_MATH_PRIVATE_H]: Change guard to
	[!HPPA_MATH_PRIVATE_H].
	[!HPPA_MATH_PRIVATE_H] (HPPA_MATH_PRIVATE_H): Define macro.
	* sysdeps/i386/fpu/math_private.h [!_MATH_PRIVATE_H]: Change guard
	to [!I386_MATH_PRIVATE_H].
	[!I386_MATH_PRIVATE_H] (I386_MATH_PRIVATE_H): Define macro.
	* sysdeps/m68k/m680x0/fpu/math_private.h [!_MATH_PRIVATE_H]:
	Change guard to [!M68K_MATH_PRIVATE_H].
	[!M68K_MATH_PRIVATE_H] (M68K_MATH_PRIVATE_H): Define macro.
	* sysdeps/microblaze/math_private.h [!_MATH_PRIVATE_H]: Change
	guard to [!MICROBLAZE_MATH_PRIVATE_H].
	[!MICROBLAZE_MATH_PRIVATE_H] (MICROBLAZE_MATH_PRIVATE_H): Define
	macro.
	* sysdeps/mips/math_private.h [!_MATH_PRIVATE_H]: Change guard to
	[!MIPS_MATH_PRIVATE_H].
	[!MIPS_MATH_PRIVATE_H] (MIPS_MATH_PRIVATE_H): Define macro.
	* sysdeps/nios2/math_private.h [!_MATH_PRIVATE_H]: Change guard to
	[!NIO2_MATH_PRIVATE_H].
	[!NIO2_MATH_PRIVATE_H] (NIO2_MATH_PRIVATE_H): Define macro.
	* sysdeps/tile/math_private.h [!_MATH_PRIVATE_H]: Change guard to
	[!TILE_MATH_PRIVATE_H].
	[!TILE_MATH_PRIVATE_H] (TILE_MATH_PRIVATE_H): Define macro.
2015-11-20 23:46:23 +00:00
Chris Metcalf 822095e8a4 tile: regenerate libm-test-ulps 2015-10-22 12:00:31 -04:00
Joseph Myers bd2260a206 Convert 231 sysdeps function definitions to prototype style.
This mostly automatically-generated patch converts 231 sysdeps
function definitions in glibc from old-style K&R to prototype-style.

For __aio_sigqueue and __gai_sigqueue I had to add internal_function
to the definitions as noted by Florian in
<https://sourceware.org/ml/libc-alpha/2015-10/msg00595.html> to keep
the functions compiling on x86 after conversion to prototype
definitions.  Otherwise, the patch is automatically generated with all
the same exclusions and caveats as in
<https://sourceware.org/ml/libc-alpha/2015-10/msg00594.html> except
that it's a patch for sysdeps files.

Tested for x86_64 and x86 (testsuite, and that installed stripped
shared libraries are unchanged by the patch).  Also tested for arm,
mips64 and powerpc32 that installed stripped shared libraries are
unchanged by the patch.

	* sysdeps/arm/backtrace.c (__backtrace): Convert to
	prototype-style function definition.
	* sysdeps/i386/backtrace.c (__backtrace): Likewise.
	* sysdeps/i386/ffs.c (__ffs): Likewise.
	* sysdeps/i386/i686/ffs.c (__ffs): Likewise.
	* sysdeps/ia64/nptl/pthread_spin_lock.c (pthread_spin_lock):
	Likewise.
	* sysdeps/ia64/nptl/pthread_spin_trylock.c (pthread_spin_trylock):
	Likewise.
	* sysdeps/ieee754/ldbl-128/e_log2l.c (__ieee754_log2l): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_log2l.c (__ieee754_log2l):
	Likewise.
	* sysdeps/m68k/ffs.c (__ffs): Likewise.
	* sysdeps/m68k/m680x0/fpu/e_acos.c (FUNC): Likewise.
	* sysdeps/m68k/m680x0/fpu/e_fmod.c (FUNC): Likewise.
	* sysdeps/mach/adjtime.c (__adjtime): Likewise.
	* sysdeps/mach/gettimeofday.c (__gettimeofday): Likewise.
	* sysdeps/mach/hurd/_exit.c (_exit): Likewise.
	* sysdeps/mach/hurd/access.c (__access): Likewise.
	* sysdeps/mach/hurd/adjtime.c (__adjtime): Likewise.
	* sysdeps/mach/hurd/chdir.c (__chdir): Likewise.
	* sysdeps/mach/hurd/chmod.c (__chmod): Likewise.
	* sysdeps/mach/hurd/chown.c (__chown): Likewise.
	* sysdeps/mach/hurd/cthreads.c (cthread_keycreate): Likewise.
	(cthread_getspecific): Likewise.
	(cthread_setspecific): Likewise.
	(__libc_getspecific): Likewise.
	* sysdeps/mach/hurd/euidaccess.c (__euidaccess): Likewise.
	* sysdeps/mach/hurd/faccessat.c (faccessat): Likewise.
	* sysdeps/mach/hurd/fchdir.c (__fchdir): Likewise.
	* sysdeps/mach/hurd/fchmod.c (__fchmod): Likewise.
	* sysdeps/mach/hurd/fchmodat.c (fchmodat): Likewise.
	* sysdeps/mach/hurd/fchown.c (__fchown): Likewise.
	* sysdeps/mach/hurd/fchownat.c (fchownat): Likewise.
	* sysdeps/mach/hurd/flock.c (__flock): Likewise.
	* sysdeps/mach/hurd/fsync.c (fsync): Likewise.
	* sysdeps/mach/hurd/ftruncate.c (__ftruncate): Likewise.
	* sysdeps/mach/hurd/getgroups.c (__getgroups): Likewise.
	* sysdeps/mach/hurd/gethostname.c (__gethostname): Likewise.
	* sysdeps/mach/hurd/getitimer.c (__getitimer): Likewise.
	* sysdeps/mach/hurd/getlogin_r.c (__getlogin_r): Likewise.
	* sysdeps/mach/hurd/getpgid.c (__getpgid): Likewise.
	* sysdeps/mach/hurd/getrusage.c (__getrusage): Likewise.
	* sysdeps/mach/hurd/getsockname.c (__getsockname): Likewise.
	* sysdeps/mach/hurd/group_member.c (__group_member): Likewise.
	* sysdeps/mach/hurd/isatty.c (__isatty): Likewise.
	* sysdeps/mach/hurd/lchown.c (__lchown): Likewise.
	* sysdeps/mach/hurd/link.c (__link): Likewise.
	* sysdeps/mach/hurd/linkat.c (linkat): Likewise.
	* sysdeps/mach/hurd/listen.c (__listen): Likewise.
	* sysdeps/mach/hurd/mkdir.c (__mkdir): Likewise.
	* sysdeps/mach/hurd/mkdirat.c (mkdirat): Likewise.
	* sysdeps/mach/hurd/openat.c (__openat): Likewise.
	* sysdeps/mach/hurd/poll.c (__poll): Likewise.
	* sysdeps/mach/hurd/readlink.c (__readlink): Likewise.
	* sysdeps/mach/hurd/readlinkat.c (readlinkat): Likewise.
	* sysdeps/mach/hurd/recv.c (__recv): Likewise.
	* sysdeps/mach/hurd/rename.c (rename): Likewise.
	* sysdeps/mach/hurd/renameat.c (renameat): Likewise.
	* sysdeps/mach/hurd/revoke.c (revoke): Likewise.
	* sysdeps/mach/hurd/rewinddir.c (__rewinddir): Likewise.
	* sysdeps/mach/hurd/rmdir.c (__rmdir): Likewise.
	* sysdeps/mach/hurd/seekdir.c (seekdir): Likewise.
	* sysdeps/mach/hurd/send.c (__send): Likewise.
	* sysdeps/mach/hurd/setdomain.c (setdomainname): Likewise.
	* sysdeps/mach/hurd/setegid.c (setegid): Likewise.
	* sysdeps/mach/hurd/seteuid.c (seteuid): Likewise.
	* sysdeps/mach/hurd/setgid.c (__setgid): Likewise.
	* sysdeps/mach/hurd/setgroups.c (setgroups): Likewise.
	* sysdeps/mach/hurd/sethostid.c (sethostid): Likewise.
	* sysdeps/mach/hurd/sethostname.c (sethostname): Likewise.
	* sysdeps/mach/hurd/setlogin.c (setlogin): Likewise.
	* sysdeps/mach/hurd/setpgid.c (__setpgid): Likewise.
	* sysdeps/mach/hurd/setregid.c (__setregid): Likewise.
	* sysdeps/mach/hurd/setreuid.c (__setreuid): Likewise.
	* sysdeps/mach/hurd/settimeofday.c (__settimeofday): Likewise.
	* sysdeps/mach/hurd/setuid.c (__setuid): Likewise.
	* sysdeps/mach/hurd/shutdown.c (shutdown): Likewise.
	* sysdeps/mach/hurd/sigaction.c (__sigaction): Likewise.
	* sysdeps/mach/hurd/sigaltstack.c (__sigaltstack): Likewise.
	* sysdeps/mach/hurd/sigpending.c (sigpending): Likewise.
	* sysdeps/mach/hurd/sigprocmask.c (__sigprocmask): Likewise.
	* sysdeps/mach/hurd/sigsuspend.c (__sigsuspend): Likewise.
	* sysdeps/mach/hurd/socket.c (__socket): Likewise.
	* sysdeps/mach/hurd/symlink.c (__symlink): Likewise.
	* sysdeps/mach/hurd/symlinkat.c (symlinkat): Likewise.
	* sysdeps/mach/hurd/telldir.c (telldir): Likewise.
	* sysdeps/mach/hurd/truncate.c (__truncate): Likewise.
	* sysdeps/mach/hurd/umask.c (__umask): Likewise.
	* sysdeps/mach/hurd/unlink.c (__unlink): Likewise.
	* sysdeps/mach/hurd/unlinkat.c (unlinkat): Likewise.
	* sysdeps/mips/mips64/__longjmp.c (__longjmp): Likewise.
	* sysdeps/posix/alarm.c (alarm): Likewise.
	* sysdeps/posix/cuserid.c (cuserid): Likewise.
	* sysdeps/posix/dirfd.c (dirfd): Likewise.
	* sysdeps/posix/dup.c (__dup): Likewise.
	* sysdeps/posix/dup2.c (__dup2): Likewise.
	* sysdeps/posix/euidaccess.c (euidaccess): Likewise.
	(main): Likewise.
	* sysdeps/posix/flock.c (__flock): Likewise.
	* sysdeps/posix/fpathconf.c (__fpathconf): Likewise.
	* sysdeps/posix/getcwd.c (__getcwd): Likewise.
	* sysdeps/posix/gethostname.c (__gethostname): Likewise.
	* sysdeps/posix/gettimeofday.c (__gettimeofday): Likewise.
	* sysdeps/posix/isatty.c (__isatty): Likewise.
	* sysdeps/posix/killpg.c (killpg): Likewise.
	* sysdeps/posix/libc_fatal.c (__libc_fatal): Likewise.
	* sysdeps/posix/mkfifoat.c (mkfifoat): Likewise.
	* sysdeps/posix/raise.c (raise): Likewise.
	* sysdeps/posix/remove.c (remove): Likewise.
	* sysdeps/posix/rename.c (rename): Likewise.
	* sysdeps/posix/rewinddir.c (__rewinddir): Likewise.
	* sysdeps/posix/seekdir.c (seekdir): Likewise.
	* sysdeps/posix/sigblock.c (__sigblock): Likewise.
	* sysdeps/posix/sigignore.c (sigignore): Likewise.
	* sysdeps/posix/sigintr.c (siginterrupt): Likewise.
	* sysdeps/posix/signal.c (__bsd_signal): Likewise.
	* sysdeps/posix/sigset.c (sigset): Likewise.
	* sysdeps/posix/sigsuspend.c (__sigsuspend): Likewise.
	* sysdeps/posix/sysconf.c (__sysconf): Likewise.
	* sysdeps/posix/sysv_signal.c (__sysv_signal): Likewise.
	* sysdeps/posix/time.c (time): Likewise.
	* sysdeps/posix/ttyname.c (getttyname): Likewise.
	(ttyname): Likewise.
	* sysdeps/posix/ttyname_r.c (__ttyname_r): Likewise.
	* sysdeps/posix/utime.c (utime): Likewise.
	* sysdeps/powerpc/fpu/s_isnan.c (__isnan): Likewise.
	* sysdeps/powerpc/nptl/pthread_spin_lock.c (pthread_spin_lock):
	Likewise.
	* sysdeps/powerpc/nptl/pthread_spin_trylock.c
	(pthread_spin_trylock): Likewise.
	* sysdeps/pthread/aio_error.c (aio_error): Likewise.
	* sysdeps/pthread/aio_read.c (aio_read): Likewise.
	* sysdeps/pthread/aio_read64.c (aio_read64): Likewise.
	* sysdeps/pthread/aio_write.c (aio_write): Likewise.
	* sysdeps/pthread/aio_write64.c (aio_write64): Likewise.
	* sysdeps/pthread/flockfile.c (__flockfile): Likewise.
	* sysdeps/pthread/ftrylockfile.c (__ftrylockfile): Likewise.
	* sysdeps/pthread/funlockfile.c (__funlockfile): Likewise.
	* sysdeps/pthread/timer_create.c (timer_create): Likewise.
	* sysdeps/pthread/timer_getoverr.c (timer_getoverrun): Likewise.
	* sysdeps/pthread/timer_gettime.c (timer_gettime): Likewise.
	* sysdeps/s390/ffs.c (__ffs): Likewise.
	* sysdeps/s390/nptl/pthread_spin_lock.c (pthread_spin_lock):
	Likewise.
	* sysdeps/s390/nptl/pthread_spin_trylock.c (pthread_spin_trylock):
	Likewise.
	* sysdeps/sh/nptl/pthread_spin_lock.c (pthread_spin_lock):
	Likewise.
	* sysdeps/sparc/nptl/pthread_barrier_destroy.c
	(pthread_barrier_destroy): Likewise.
	* sysdeps/sparc/nptl/pthread_barrier_wait.c
	(__pthread_barrier_wait): Likewise.
	* sysdeps/sparc/sparc32/e_sqrt.c (__ieee754_sqrt): Likewise.
	* sysdeps/sparc/sparc32/pthread_barrier_wait.c
	(__pthread_barrier_wait): Likewise.
	* sysdeps/sparc/sparc32/sem_init.c (__old_sem_init): Likewise.
	* sysdeps/tile/memcmp.c (memcmp_common_alignment): Likewise.
	(memcmp_not_common_alignment): Likewise.
	(MEMCMP): Likewise.
	* sysdeps/tile/wordcopy.c (_wordcopy_fwd_aligned): Likewise.
	(_wordcopy_fwd_dest_aligned): Likewise.
	(_wordcopy_bwd_aligned): Likewise.
	(_wordcopy_bwd_dest_aligned): Likewise.
	* sysdeps/unix/bsd/ftime.c (ftime): Likewise.
	* sysdeps/unix/bsd/gtty.c (gtty): Likewise.
	* sysdeps/unix/bsd/stty.c (stty): Likewise.
	* sysdeps/unix/bsd/tcflow.c (tcflow): Likewise.
	* sysdeps/unix/bsd/tcflush.c (tcflush): Likewise.
	* sysdeps/unix/bsd/tcgetattr.c (__tcgetattr): Likewise.
	* sysdeps/unix/bsd/tcgetpgrp.c (tcgetpgrp): Likewise.
	* sysdeps/unix/bsd/tcsendbrk.c (tcsendbreak): Likewise.
	* sysdeps/unix/bsd/tcsetattr.c (tcsetattr): Likewise.
	* sysdeps/unix/bsd/tcsetpgrp.c (tcsetpgrp): Likewise.
	* sysdeps/unix/bsd/ualarm.c (ualarm): Likewise.
	* sysdeps/unix/bsd/wait3.c (__wait3): Likewise.
	* sysdeps/unix/getlogin_r.c (__getlogin_r): Likewise.
	* sysdeps/unix/sockatmark.c (sockatmark): Likewise.
	* sysdeps/unix/stime.c (stime): Likewise.
	* sysdeps/unix/sysv/linux/_exit.c (_exit): Likewise.
	* sysdeps/unix/sysv/linux/aio_sigqueue.c (__aio_sigqueue):
	Likewise.  Use internal_function.
	* sysdeps/unix/sysv/linux/arm/sigaction.c (__libc_sigaction):
	Convert to prototype-style function definition.
	* sysdeps/unix/sysv/linux/faccessat.c (faccessat): Likewise.
	* sysdeps/unix/sysv/linux/fchmodat.c (fchmodat): Likewise.
	* sysdeps/unix/sysv/linux/fpathconf.c (__fpathconf): Likewise.
	* sysdeps/unix/sysv/linux/gai_sigqueue.c (__gai_sigqueue):
	Likewise.  Use internal_function.
	* sysdeps/unix/sysv/linux/gethostid.c (sethostid): Convert to
	prototype-style function definition
	* sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid):
	Likewise.
	(__getlogin_r): Likewise.
	* sysdeps/unix/sysv/linux/getpt.c (__posix_openpt): Likewise.
	* sysdeps/unix/sysv/linux/hppa/pthread_cond_broadcast.c
	(__pthread_cond_broadcast): Likewise.
	* sysdeps/unix/sysv/linux/hppa/pthread_cond_destroy.c
	(__pthread_cond_destroy): Likewise.
	* sysdeps/unix/sysv/linux/hppa/pthread_cond_init.c
	(__pthread_cond_init): Likewise.
	* sysdeps/unix/sysv/linux/hppa/pthread_cond_signal.c
	(__pthread_cond_signal): Likewise.
	* sysdeps/unix/sysv/linux/hppa/pthread_cond_wait.c
	(__pthread_cond_wait): Likewise.
	* sysdeps/unix/sysv/linux/i386/getmsg.c (getmsg): Likewise.
	* sysdeps/unix/sysv/linux/i386/setegid.c (setegid): Likewise.
	* sysdeps/unix/sysv/linux/ia64/sigaction.c (__libc_sigaction):
	Likewise.
	* sysdeps/unix/sysv/linux/ia64/sigpending.c (sigpending):
	Likewise.
	* sysdeps/unix/sysv/linux/ia64/sigprocmask.c (__sigprocmask):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/sigaction.c (__libc_sigaction):
	Likewise.
	* sysdeps/unix/sysv/linux/msgget.c (msgget): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/ftruncate64.c
	(__ftruncate64): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/truncate64.c
	(truncate64): Likewise.
	* sysdeps/unix/sysv/linux/pt-raise.c (raise): Likewise.
	* sysdeps/unix/sysv/linux/pthread_getcpuclockid.c
	(pthread_getcpuclockid): Likewise.
	* sysdeps/unix/sysv/linux/pthread_getname.c (pthread_getname_np):
	Likewise.
	* sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np):
	Likewise.
	* sysdeps/unix/sysv/linux/pthread_sigmask.c (pthread_sigmask):
	Likewise.
	* sysdeps/unix/sysv/linux/pthread_sigqueue.c (pthread_sigqueue):
	Likewise.
	* sysdeps/unix/sysv/linux/raise.c (raise): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/sigaction.c
	(__libc_sigaction): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/sigpending.c (sigpending):
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/sigprocmask.c
	(__sigprocmask): Likewise.
	* sysdeps/unix/sysv/linux/semget.c (semget): Likewise.
	* sysdeps/unix/sysv/linux/semop.c (semop): Likewise.
	* sysdeps/unix/sysv/linux/setrlimit64.c (setrlimit64): Likewise.
	* sysdeps/unix/sysv/linux/shmat.c (shmat): Likewise.
	* sysdeps/unix/sysv/linux/shmdt.c (shmdt): Likewise.
	* sysdeps/unix/sysv/linux/shmget.c (shmget): Likewise.
	* sysdeps/unix/sysv/linux/sigaction.c (__libc_sigaction):
	Likewise.
	* sysdeps/unix/sysv/linux/sigpending.c (sigpending): Likewise.
	* sysdeps/unix/sysv/linux/sigprocmask.c (__sigprocmask): Likewise.
	* sysdeps/unix/sysv/linux/sigqueue.c (__sigqueue): Likewise.
	* sysdeps/unix/sysv/linux/sigstack.c (sigstack): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/sigpending.c (sigpending):
	Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/sigprocmask.c
	(__sigprocmask): Likewise.
	* sysdeps/unix/sysv/linux/speed.c (cfgetospeed): Likewise.
	(cfgetispeed): Likewise.
	(cfsetospeed): Likewise.
	(cfsetispeed): Likewise.
	* sysdeps/unix/sysv/linux/tcflow.c (tcflow): Likewise.
	* sysdeps/unix/sysv/linux/tcflush.c (tcflush): Likewise.
	* sysdeps/unix/sysv/linux/tcgetattr.c (__tcgetattr): Likewise.
	* sysdeps/unix/sysv/linux/tcsetattr.c (tcsetattr): Likewise.
	* sysdeps/unix/sysv/linux/time.c (time): Likewise.
	* sysdeps/unix/sysv/linux/timer_create.c (timer_create): Likewise.
	* sysdeps/unix/sysv/linux/timer_delete.c (timer_delete): Likewise.
	* sysdeps/unix/sysv/linux/timer_getoverr.c (timer_getoverrun):
	Likewise.
	* sysdeps/unix/sysv/linux/timer_gettime.c (timer_gettime):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/sigpending.c (sigpending):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/sigprocmask.c (__sigprocmask):
	Likewise.
	* sysdeps/x86_64/backtrace.c (__backtrace): Likewise.
2015-10-19 12:04:33 +00:00
Joseph Myers b75bc69cdf Don't use dbl-64/wordsize-64 lround based on llround for ILP32 (bug 19079).
The implementation of lround in dbl-64/wordsize-64 as an alias or
wrapper for llround is always incorrect when long is not 64-bit,
because it misses required exceptions in overflow cases, as shown by
my recently added tests.  This patch removes that alias / wrapper in
the non-LP64 case, together with the REGISTER_CAST_INT32_TO_INT64
macro, restoring the previous version of lround for dbl-64/wordsize-64
(newly conditioned on !_LP64).

Tested for x86_64, and for mips64 with use of dbl-64/wordsize-64
enabled.

	[BZ #19079]
	* sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c: Restore previous
	file, conditioned on [!_LP64].
	* sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c
	[!_LP64] (__lround): Do not define as function or alias.
	[!_LP64] (lround): Likewise.
	[!_LP64] (__lroundl): Likewise.
	[!_LP64] (lroundl): Likewise.
	* sysdeps/tile/sysdep.h (REGISTER_CAST_INT32_TO_INT64): Remove
	macro.
	* sysdeps/x86_64/x32/sysdep.h (REGISTER_CAST_INT32_TO_INT64):
	Likewise.
2015-10-07 00:40:12 +00:00
Joseph Myers de071d199a Move bits/atomic.h to atomic-machine.h (bug 14912).
It was noted in
<https://sourceware.org/ml/libc-alpha/2012-09/msg00305.html> that the
bits/*.h naming scheme should only be used for installed headers.
This patch renames bits/atomic.h to atomic-machine.h to follow that
convention.

This is the only change in this series that needs to change the
filename rather than simply removing a directory level (because both
atomic.h and bits/atomic.h exist at present).

Tested for x86_64 (testsuite, and that installed stripped shared
libraries are unchanged by the patch).

	[BZ #14912]
	* sysdeps/aarch64/bits/atomic.h: Move to ...
	* sysdeps/aarch64/atomic-machine.h: ...here.
	(_AARCH64_BITS_ATOMIC_H): Rename macro to
	_AARCH64_ATOMIC_MACHINE_H.
	* sysdeps/alpha/bits/atomic.h: Move to ...
	* sysdeps/alpha/atomic-machine.h: ...here.
	* sysdeps/arm/bits/atomic.h: Move to ...
	* sysdeps/arm/atomic-machine.h: ...here.  Update comments.
	* bits/atomic.h: Move to ...
	* sysdeps/generic/atomic-machine.h: ...here.
	(_BITS_ATOMIC_H): Rename macro to _ATOMIC_MACHINE_H.
	* sysdeps/i386/bits/atomic.h: Move to ...
	* sysdeps/i386/atomic-machine.h: ...here.
	* sysdeps/ia64/bits/atomic.h: Move to ...
	* sysdeps/ia64/atomic-machine.h: ...here.
	* sysdeps/m68k/coldfire/bits/atomic.h: Move to ...
	* sysdeps/m68k/coldfire/atomic-machine.h: ...here.
	(_BITS_ATOMIC_H): Rename macro to _ATOMIC_MACHINE_H.
	* sysdeps/m68k/m680x0/m68020/bits/atomic.h: Move to ...
	* sysdeps/m68k/m680x0/m68020/atomic-machine.h: ...here.
	* sysdeps/microblaze/bits/atomic.h: Move to ...
	* sysdeps/microblaze/atomic-machine.h: ...here.
	* sysdeps/mips/bits/atomic.h: Move to ...
	* sysdeps/mips/atomic-machine.h: ...here.
	(_MIPS_BITS_ATOMIC_H): Rename macro to _MIPS_ATOMIC_MACHINE_H.
	* sysdeps/powerpc/bits/atomic.h: Move to ...
	* sysdeps/powerpc/atomic-machine.h: ...here.  Update comments.
	* sysdeps/powerpc/powerpc32/bits/atomic.h: Move to ...
	* sysdeps/powerpc/powerpc32/atomic-machine.h: ...here.  Update
	comments.  Include <atomic-machine.h> instead of <bits/atomic.h>.
	* sysdeps/powerpc/powerpc64/bits/atomic.h: Move to ...
	* sysdeps/powerpc/powerpc64/atomic-machine.h: ...here.  Include
	<atomic-machine.h> instead of <bits/atomic.h>.
	* sysdeps/s390/bits/atomic.h: Move to ...
	* sysdeps/s390/atomic-machine.h: ...here.
	* sysdeps/sparc/sparc32/bits/atomic.h: Move to ...
	* sysdeps/sparc/sparc32/atomic-machine.h: ...here.
	(_BITS_ATOMIC_H): Rename macro to _ATOMIC_MACHINE_H.
	* sysdeps/sparc/sparc32/sparcv9/bits/atomic.h: Move to ...
	* sysdeps/sparc/sparc32/sparcv9/atomic-machine.h: ...here.
	* sysdeps/sparc/sparc64/bits/atomic.h: Move to ...
	* sysdeps/sparc/sparc64/atomic-machine.h: ...here.
	* sysdeps/tile/bits/atomic.h: Move to ...
	* sysdeps/tile/atomic-machine.h: ...here.
	* sysdeps/tile/tilegx/bits/atomic.h: Move to ...
	* sysdeps/tile/tilegx/atomic-machine.h: ...here.  Include
	<sysdeps/tile/atomic-machine.h> instead of
	<sysdeps/tile/bits/atomic.h>.
	(_BITS_ATOMIC_H): Rename macro to _ATOMIC_MACHINE_H.
	* sysdeps/tile/tilepro/bits/atomic.h: Move to ...
	* sysdeps/tile/tilepro/atomic-machine.h: ...here.  Include
	<sysdeps/tile/atomic-machine.h> instead of
	<sysdeps/tile/bits/atomic.h>.
	(_BITS_ATOMIC_H): Rename macro to _ATOMIC_MACHINE_H.
	* sysdeps/unix/sysv/linux/arm/bits/atomic.h: Move to ...
	* sysdeps/unix/sysv/linux/arm/atomic-machine.h: ...here.  Include
	<sysdeps/arm/atomic-machine.h> instead of
	<sysdeps/arm/bits/atomic.h>.
	* sysdeps/unix/sysv/linux/hppa/bits/atomic.h: Move to ...
	* sysdeps/unix/sysv/linux/hppa/atomic-machine.h: ...here.
	(_BITS_ATOMIC_H): Rename macro to _ATOMIC_MACHINE_H.
	* sysdeps/unix/sysv/linux/m68k/coldfire/bits/atomic.h: Move to ...
	* sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h: ...here.
	(_BITS_ATOMIC_H): Rename macro to _ATOMIC_MACHINE_H.
	* sysdeps/unix/sysv/linux/nios2/bits/atomic.h: Move to ...
	* sysdeps/unix/sysv/linux/nios2/atomic-machine.h: ...here.
	(_NIOS2_BITS_ATOMIC_H): Rename macro to _NIOS2_ATOMIC_MACHINE_H.
	* sysdeps/unix/sysv/linux/sh/bits/atomic.h: Move to ...
	* sysdeps/unix/sysv/linux/sh/atomic-machine.h: ...here.
	* sysdeps/x86_64/bits/atomic.h: Move to ...
	* sysdeps/x86_64/atomic-machine.h: ...here.
	* include/atomic.h: Include <atomic-machine.h> instead of
	<bits/atomic.h>.
2015-09-11 20:00:19 +00:00
Chris Metcalf 0d261f406d tilepro: fix warnings in sysdeps/tile/tilepro/bits/atomic.h
Using a ({ }) structure avoids the "value computed is not used"
that a simple () structure causes.
2015-08-04 12:07:53 -04:00
Chris Metcalf ef115d3ade tile: Regenerate ULPs.
Regenerated from scratch on tilegx.
2015-07-10 16:16:37 -04:00
Joseph Myers 1769608794 Use libc_hidden_proto / libc_hidden_def with __strnlen.
Various code in glibc uses __strnlen instead of strnlen for namespace
reasons.  However, __strnlen does not use libc_hidden_proto /
libc_hidden_def (as is normally done for any function defined and
called within the same library, whether or not exported from the
library and whatever namespace it is in), so the compiler does not
know that those calls are to a function within libc.

This patch uses libc_hidden_proto / libc_hidden_def with __strnlen.
On x86_64, it makes no difference to the installed stripped shared
libraries.  On 32-bit x86, it causes __strnlen calls to go to the same
place as strnlen calls (the fallback strnlen implementation), rather
than through a PLT entry for the strnlen IFUNC; I'm not sure of the
logic behind when calls from within libc should use IFUNCs versus when
they should go direct to a particular function implementation, but
clearly it doesn't make sense for strnlen and __strnlen to be handled
differently in this regard.

Tested for x86_64 and x86 (testsuite, and comparison of installed
shared libraries as described above).

	* string/strnlen.c [!STRNLEN] (__strnlen): Use libc_hidden_def.
	* include/string.h (__strnlen): Use libc_hidden_proto.
	* sysdeps/aarch64/strnlen.S (__strnlen): Use libc_hidden_def.
	* sysdeps/i386/i686/multiarch/strnlen-c.c [SHARED]
	(libc_hidden_def): Define __GI___strnlen as well as __GI_strnlen.
	* sysdeps/powerpc/powerpc32/power4/multiarch/strnlen-power7.S
	(libc_hidden_def): Undefine and redefine.
	* sysdeps/powerpc/powerpc32/power4/multiarch/strnlen-ppc32.c
	[SHARED] (libc_hidden_def): Define __GI___strnlen as well as
	__GI_strnlen.
	* sysdeps/powerpc/powerpc32/power7/strnlen.S (__strnlen): Use
	libc_hidden_def.
	* sysdeps/tile/tilegx/strnlen.c (__strnlen): Likewise.
2015-06-02 20:24:25 +00:00