]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
7 years agoaarch64: Use explicit offsets in _dl_tlsdesc_dynamic
Florian Weimer [Fri, 2 Dec 2016 15:52:57 +0000 (16:52 +0100)] 
aarch64: Use explicit offsets in _dl_tlsdesc_dynamic

Commit 389d1f1b232b3d6b9d73ee2c50e543ace6675621 (“Partial ILP32
support for aarch64”) broke dynamic TLS support because a load
offset changed:

 0000000000000030 <_dl_tlsdesc_dynamic>:
   30:  a9bc7bfd        stp     x29, x30, [sp,#-64]!
   34:  910003fd        mov     x29, sp
   38:  a9020be1        stp     x1, x2, [sp,#32]
   3c:  a90313e3        stp     x3, x4, [sp,#48]
   40:  d53bd044        mrs     x4, tpidr_el0
   44:  c8dffc1f        ldar    xzr, [x0]
   48:  f9400401        ldr     x1, [x0,#8]
   4c:  f9400080        ldr     x0, [x4]
   50:  f9400823        ldr     x3, [x1,#16]
   54:  f9400002        ldr     x2, [x0]
   58:  eb02007f        cmp     x3, x2
   5c:  540001a8        b.hi    90 <_dl_tlsdesc_dynamic+0x60>
   60:  f9400022        ldr     x2, [x1]
   64:  8b021000        add     x0, x0, x2, lsl #4
   68:  f9400000        ldr     x0, [x0]
   6c:  b100041f        cmn     x0, #0x1
   70:  54000100        b.eq    90 <_dl_tlsdesc_dynamic+0x60>
-  74:  f9400421        ldr     x1, [x1,#8]
+  74:  f9400821        ldr     x1, [x1,#16]
   78:  8b010000        add     x0, x0, x1


This commit introduces explicit struct offsets, generated
from the C headers, fixing the regression.

7 years agoS390: Regenerate ULPs.
Stefan Liebler [Fri, 2 Dec 2016 11:52:36 +0000 (12:52 +0100)] 
S390: Regenerate ULPs.

Updated ulps file.

ChangeLog:

* sysdeps/s390/fpu/libm-test-ulps: Regenerated.

7 years agoFix new testcase elf/tst-latepthread on s390x.
Stefan Liebler [Fri, 2 Dec 2016 08:09:55 +0000 (09:09 +0100)] 
Fix new testcase elf/tst-latepthread on s390x.

The first dlopen ("tst-latepthreadmod.so", RTLD_LOCAL | RTLD_LAZY) call
in elf/tst-latepthread.c fails on s390x with "error: dlopen failed:
.../build-s390x/elf/tst-latepthreadmod.so:
undefined symbol: this_function_is_not_defined".

In elf/tst-latepthreadmod.c, this_function_is_not_defined is a sibling
call which leads to a R_390_GLOB_DAT relocation in .rela.dyn instead of
a R_390_JMP_SLOT in .rela.plt.

As RTLD_LAZY skips the JMP_SLOT relocations, but not GLOB_DAT ones,
the dlopen call fails. If elf/tst-latepthreadmod.c is build with
-fno-optimize-sibling-calls, a JMP_SLOT relocation is generated for
this_function_is_not_defined and the test passes.

ChangeLog:

* elf/Makefile (CFLAGS-tst-latepthreadmod.c):
Add -fno-optimize-sibling-calls.

7 years agoAdd llogb, llogbf, llogbl.
Joseph Myers [Fri, 2 Dec 2016 01:42:49 +0000 (01:42 +0000)] 
Add llogb, llogbf, llogbl.

TS 18661-1 defines llogb functions that are like ilogb except that
they return long int instead of int.  Corresponding FP_LLOGB* macros
are defined, whose values are required to have the obvious
correspondence to those of the FP_ILOGB* macros.

This patch implements these functions and macros for glibc.  llogb
uses the type-generic infrastructure, with an implementation similar
to the wrapper for ilogb but with additional conversion from FP_ILOGB*
to FP_LLOGB*; this approach avoids needing to modify or duplicate any
of the architecture-specific ilogb implementations.  Tests are also
based on those for ilogb.

Ideally the llogb functions would alias the ilogb ones when long is
32-bit, but such aliasing requires the associated header declarations
of the different-type alias to be hidden, typically by defining macros
before including the header (see e.g. how
sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c defines lround to
__hidden_lround before including <math.h>).  The infrastructure for
type-generic function implementations does not support defining such
macros at present (since C code can't define a macro whose name is
determined by other macros).  So this patch leaves them as separate
functions (similar to e.g. scalbln and scalbn being separate in such a
case as well), but with the remapping of FP_ILOGB* to FP_LLOGB*
conditioned out in the case where it would be the identity map.

Tested for x86_64, x86, mips64 and powerpc.

* math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (llogb):
New declaration.
* math/tgmath.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (llogb): New
macro.
* math/math.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (__FP_LONG_MAX):
New macro.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (FP_LLOGB0): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (FP_LLOGBNAN): Likewise.
* math/Versions (llogb): New libm symbol at version GLIBC_2.25.
(llogbf): Likewise.
(llogbl): Likewise.
* math/Makefile (gen-libm-calls): Add w_llogbF.
(tests): Add test-fp-llogb-constants.
* math/w_llogb_template.c: New file.  Based on
math/w_ilogb_template.c.
* math/libm-test.inc (llogb_test_data): New array.
(llogb_test): New function.
(main): Call llogb_test.
* math/test-fp-llogb-constants.c: New file.  Based on
math/test-fp-ilogb-constants.c.
* math/test-tgmath-ret.c (llogb): New CHECK_RET_CONST call.
(do_test): Call check_return_llogb.
* math/test-tgmath.c (NCALLS): Increase to 126.
(F(compile_test)): Call llogb.
(F(llogb)): New function.
* manual/math.texi (Exponents and Logarithms): Document llogb,
llogbf, llogbl, FP_LLOGB0 and FP_LLOGBNAN.
* manual/libm-err-tab.pl (@all_functions): Add llogb.
* sysdeps/ieee754/ldbl-opt/nldbl-llogb.c: New file.
* sysdeps/ieee754/ldbl-opt/w_llogbl.c: Likewise.
* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add llogb.
(CFLAGS-nldbl-llogb.c): New variable.
* 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.

7 years agoMake ldbl-128 getpayload, setpayload functions use _Float128.
Joseph Myers [Thu, 1 Dec 2016 23:23:51 +0000 (23:23 +0000)] 
Make ldbl-128 getpayload, setpayload functions use _Float128.

When I added the getpayload and setpayload functions I failed to make
the ldbl-128 functions use the _Float128 type name like most other
ldbl-128 functions do in preparation for being used to implement *f128
functions.  This patch fixes them to use that name.

Tested for mips64.

* sysdeps/ieee754/ldbl-128/s_getpayloadl.c (getpayloadl): Use
_Float128 instead of long double.
* sysdeps/ieee754/ldbl-128/s_setpayloadl_main.c (FUNC): Likewise.

7 years agoAdd missing hidden_def (__sigsetjmp).
Joseph Myers [Thu, 1 Dec 2016 20:49:25 +0000 (20:49 +0000)] 
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.

7 years agopowerpc: Remove stpcpy internal clash with IFUNC
Adhemerval Zanella [Thu, 1 Dec 2016 17:53:16 +0000 (15:53 -0200)] 
powerpc: Remove stpcpy internal clash with IFUNC

Commit c7debbdfacb redirected the internal strrch to default powerpc64
implementation by redefining the weak_alias at
sysdeps/powerpc/powerpc64/multiarch/strchr-ppc64.c:

  #undef weak_alias
  #define weak_alias(name, aliasname) \
    extern __typeof (__strrchr_ppc) aliasname \
      __attribute__ ((weak, alias ("__strrchr_ppc")));

This creates a __GI_strchr alias that clashes with the IFUNC symbol in
stprchr.os.  There is not need to define the default version for internal
version, since ifunc should work internally for powerpc64.  This patch
removes the weak_alias indirection.

Checked on powerpc64le.

* sysdeps/powerpc/powerpc64/multiarch/strrchr-ppc64.c (weak_alias):
Remove redirection to __strrchr_ppc.

7 years agopowerpc: strcmp optimization for power9
Rajalakshmi Srinivasaraghavan [Thu, 1 Dec 2016 06:05:43 +0000 (11:35 +0530)] 
powerpc: strcmp optimization for power9

Vectorized loops are used for strings > 32B when compared
to power8 optimization.

Tested on power9 ppc64le simulator.

7 years agoRefactor FP_ILOGB* out of bits/mathdef.h.
Joseph Myers [Thu, 1 Dec 2016 02:56:55 +0000 (02:56 +0000)] 
Refactor FP_ILOGB* out of bits/mathdef.h.

Continuing the refactoring of bits/mathdef.h, this patch stops it
defining FP_ILOGB0 and FP_ILOGBNAN, moving the required information to
a new header bits/fp-logb.h.

There are only two possible values of each of those macros permitted
by ISO C.  TS 18661-1 adds corresponding macros for llogb, and their
values are required to correspond to those of the ilogb macros in the
obvious way.  Thus two boolean values - for which the same choices are
correct for most architectures - suffice to determine the value of all
these macros, and by defining macros for those boolean values in
bits/fp-logb.h we can then define the public FP_* macros in math.h and
avoid the present duplication of the associated feature test macro
logic.

This patch duly moves to bits/fp-logb.h defining __FP_LOGB0_IS_MIN and
__FP_LOGBNAN_IS_MIN.  Default definitions of those to 0 are correct
for both architectures, while ia64, m68k and x86 get their own
versions of bits/fp-logb.h to reflect their use of values different
from the defaults.

The patch renders many copies of bits/mathdef.h trivial (needed only
to avoid the default __NO_LONG_DOUBLE_MATH).  I'll revise
<https://sourceware.org/ml/libc-alpha/2016-11/msg00865.html>
accordingly so that it removes all bits/mathdef.h headers except the
default one and the alpha one, and arranges for the header to be
included only by complex.h as the only remaining use at that point
will be for the alpha ABI issues there.

Tested for x86_64 and x86.  Also did compile-only testing with
build-many-glibcs.py (using glibc sources from before the commit that
introduced many build failures with undefined __GI___sigsetjmp).

* bits/fp-logb.h: New file.
* sysdeps/ia64/bits/fp-logb.h: Likewise.
* sysdeps/m68k/m680x0/bits/fp-logb.h: Likewise.
* sysdeps/x86/bits/fp-logb.h: Likewise.
* math/Makefile (headers): Add bits/fp-logb.h.
* math/math.h: Include <bits/fp-logb.h>.
[__USE_ISOC99] (FP_ILOGB0): Define based on __FP_LOGB0_IS_MIN.
[__USE_ISOC99] (FP_ILOGBNAN): Define based on __FP_LOGBNAN_IS_MIN.
* bits/mathdef.h (FP_ILOGB0): Remove.
(FP_ILOGBNAN): Likewise.
* sysdeps/aarch64/bits/mathdef.h (FP_ILOGB0): Likewise.
(FP_ILOGBNAN): Likewise.
* sysdeps/alpha/bits/mathdef.h (FP_ILOGB0): Likewise.
(FP_ILOGBNAN): Likewise.
* sysdeps/ia64/bits/mathdef.h (FP_ILOGB0): Likewise.
(FP_ILOGBNAN): Likewise.
* sysdeps/m68k/m680x0/bits/mathdef.h (FP_ILOGB0): Likewise.
(FP_ILOGBNAN): Likewise.
* sysdeps/mips/bits/mathdef.h (FP_ILOGB0): Likewise.
(FP_ILOGBNAN): Likewise.
* sysdeps/powerpc/bits/mathdef.h (FP_ILOGB0): Likewise.
(FP_ILOGBNAN): Likewise.
* sysdeps/s390/bits/mathdef.h (FP_ILOGB0): Likewise.
(FP_ILOGBNAN): Likewise.
* sysdeps/sparc/bits/mathdef.h (FP_ILOGB0): Likewise.
(FP_ILOGBNAN): Likewise.
* sysdeps/x86/bits/mathdef.h (FP_ILOGB0): Likewise.
(FP_ILOGBNAN): Likewise.

7 years agoMake build-many-glibcs.py support running as a bot.
Joseph Myers [Thu, 1 Dec 2016 00:09:25 +0000 (00:09 +0000)] 
Make build-many-glibcs.py support running as a bot.

This patch makes build-many-glibcs.py support a "bot" action, for
repeatedly running a checkout and build cycle.

Two new configuration variables are used in bot-config.json.  "delay"
indicates the time to sleep after each bot-cycle round (regardless of
whether that round actually ran any builds); "run" is a boolean, which
is false if the bot should just exit (the point of this is that you
can edit bot-config.json to set this to false to cause a running bot
to exit cleanly between builds) and true if the bot should run.  The
bot does not exit if the bot-cycle process exits with error status
(that can occur when sourceware's load limiting means anonymous
version control access fails, for example), just sleeps until it's
time to try again.

The script is changed to flush stdout before running a subprocess in
bot-cycle, so that when output is redirected (as expected for a bot)
the status messages from bot-cycle appear in their proper position in
its redirected output relative to the output from the subprocesses
run, and to copy the logs directory before running builds in bot-cycle
so that the logs from at least one complete build are always available
for looking at how something failed, even while the next build is
running.

* scripts/build-many-glibcs.py: Add bot to usage message.  Import
time module.
(Context.__init__): Initialize self.logsdir_old.
(Context.run_builds): Handle bot action.
(Context.bot_cycle): Copy logs directory before running builds.
(Context.bot_run_self): Take argument for whether to check
subprocess result.  Flush stdout before running subprocess.
(Context.bot): New function.
(get_parser): Allow bot action.

7 years agoAdd build-many-glibcs.py bot-cycle action.
Joseph Myers [Wed, 30 Nov 2016 18:56:37 +0000 (18:56 +0000)] 
Add build-many-glibcs.py bot-cycle action.

This patch continues the process of setting up build-many-glibcs.py to
run as a bot monitoring for and reporting on build issues by adding a
bot-cycle action to the script.  When this action is used, it will run
the checkout action (re-execing itself if it was changed by that
action), then rebuild whichever of host-libraries, compilers, glibcs
should be rebuilt based on changed versions, time elapsed and state of
previous builds.  Email is sent with the results of the build (for
each build action done).

The rebuild logic is: if previous build time or versions aren't
recorded, rebuild that component.  If the script has changed, rebuild
everything.  If any relevant component version has changed, rebuild,
except for not rebuilding compilers if the time indicated in the bot
configuration has not passed since the last build of the compilers.
If one piece is rebuilt then rebuild subsequent pieces as well.

Using bot-cycle requires a configuration file bot-config.json in the
toplevel directory used by build-many-glibcs.py.  It might contain
e.g.

{
  "compilers-rebuild-delay": 604800,
  "email-from": "Example Name <user@example.org>",
  "email-server": "localhost",
  "email-subject": "GCC 6 %(action)s %(build-time)s build results",
  "email-to": "libc-testresults@sourceware.org"
}

My next intended step is adding a further action "bot" which loops
running bot-cycle then sleeping for an amount of time given in
bot-config.json.  Then I'll set up a bot using that action (building
with GCC 6 branch; a bot using GCC mainline may wait until the SH
out-of-memory issues
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78460> are fixed; I
expect the bot to mail to me until it seems ready to switch to mailing
to gcc-testresults).

* scripts/build-many-glibcs.py: Add bot-cycle to usage message.
Import email.mime.text, email.utils and smtplib modules.
(Context.__init__): Initialize self.bot_config_json.
(Context.run_builds): Handle bot-cycle action.
(Context.load_bot_config_json): New function.
(Context.part_build_old): Likewise.
(Context.bot_cycle): Likewise.
(Context.bot_build_mail): Likewise.
(Context.bot_run_self): Likewise.
(get_parser): Allow bot-cycle action.

7 years agopowerpc: Remove stpcpy internal clash with IFUNC
Adhemerval Zanella [Wed, 30 Nov 2016 13:31:41 +0000 (11:31 -0200)] 
powerpc: Remove stpcpy internal clash with IFUNC

Commit 142e0a99530 redirected the internal stpcpy to default powerpc64
implementation by redefining the weak_alias at
sysdeps/powerpc/powerpc64/multiarch/stpcpy-ppc64.c:

  #undef weak_alias
  #define weak_alias(name, aliasname) \
    extern __typeof (__stpcpy_ppc) aliasname \
      __attribute__ ((weak, alias ("__stpcpy_ppc")));

This creates a __GI_stpcpy alias that clashes with the IFUNC symbol in
stpcpy.os.  There is not need to define the default version for internal
version, since ifunc should work internally for powerpc64.  This patch
removes the weak_alias indirection.

Checked on powerpc64le.

* sysdeps/powerpc/powerpc64/multiarch/stpcpy-ppc64.c (weak_alias):
Remove redirection to __stpcpy_ppc.

7 years agold.so: Remove __libc_memalign
Florian Weimer [Wed, 30 Nov 2016 15:23:58 +0000 (16:23 +0100)] 
ld.so: Remove __libc_memalign

It is no longer needed since commit 6c444ad6e953dbdf9c7be065308a0a777
(elf: Do not use memalign for TCB/TLS blocks allocation [BZ #17730]).
Applications do not link against ld.so and will use the definition in
libc.so, so there is no ABI impact.

7 years agoImplement _dl_catch_error, _dl_signal_error in libc.so [BZ #16628]
Florian Weimer [Wed, 30 Nov 2016 14:59:57 +0000 (15:59 +0100)] 
Implement _dl_catch_error, _dl_signal_error in libc.so [BZ #16628]

This change moves the main implementation of _dl_catch_error,
_dl_signal_error to libc.so, where TLS variables can be used
directly.  This removes a writable function pointer from the
rtld_global variable.

For use during initial relocation, minimal implementations of these
functions are provided in ld.so.  These are eventually interposed
by the libc.so implementations.  This is implemented by compiling
elf/dl-error-skeleton.c twice, via elf/dl-error.c and
elf/dl-error-minimal.c.

As a side effect of this change, the static version of dl-error.c
no longer includes support for the
_dl_signal_cerror/_dl_receive_error mechanism because it is only
used in ld.so.

7 years agolibio: Limit buffer size to 8192 bytes [BZ #4099]
Florian Weimer [Wed, 30 Nov 2016 13:59:27 +0000 (14:59 +0100)] 
libio: Limit buffer size to 8192 bytes [BZ #4099]

This avoids overly large buffers with network file systems which report
very large block sizes.

7 years agoRemove out of date PROJECTS file.
Carlos O'Donell [Wed, 30 Nov 2016 13:07:24 +0000 (08:07 -0500)] 
Remove out of date PROJECTS file.

Developers should use:
https://sourceware.org/glibc/wiki/Development_Todo/Master

7 years agogconv: Adjust GBK to support the Euro sign
Florian Weimer [Tue, 29 Nov 2016 17:35:12 +0000 (18:35 +0100)] 
gconv: Adjust GBK to support the Euro sign

Commit aa4d00ca39e604ac4e9fead401ccd4483e11a281 only updated the
data used by locales.

7 years agoUse XSTAT_IS_XSTAT64 in generic xstat functions
Steve Ellcey [Tue, 29 Nov 2016 16:06:47 +0000 (08:06 -0800)] 
Use XSTAT_IS_XSTAT64 in generic xstat functions

* sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c: Do not define
fxstat if XSTAT_IS_XSTAT64 is set to non-zero.
* sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c: Ditto for
fxstatat.
* sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat.c: Ditto for
lxstat.
* sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c: Ditto for xstat.

* sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat64.c: New file.
* sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat64.c: New file.
* sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat64.c: Make __lxstat
an alias of __lxstat64 if XSTAT_IS_XSTAT64 is set to non-zero.
* sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c: Ditto for
__xstat.

7 years agopowerpc: Add hidden definition for __sigsetjmp
Florian Weimer [Tue, 29 Nov 2016 09:16:35 +0000 (10:16 +0100)] 
powerpc: Add hidden definition for __sigsetjmp

There already is a hidden prototype for __sigsetjmp, but the
architecture-specific definition was missing.

7 years agopowerpc: Remove unintended __longjmp symbol from ABI
Florian Weimer [Tue, 29 Nov 2016 09:08:06 +0000 (10:08 +0100)] 
powerpc: Remove unintended __longjmp symbol from ABI

The __longjmp symbol was left in accidentally.  It is not exported
through a Versions file, but through a .symver assembler directive.

The corresponding exported symbol was removed from the non-fpu
powerpc64 targets in commit 9b9ef823581ecee546653d6ac3fd335f7b79faca.

7 years agoRefactor FP_FAST_* into bits/fp-fast.h.
Joseph Myers [Tue, 29 Nov 2016 01:45:00 +0000 (01:45 +0000)] 
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.

7 years agoMake ilogb wrappers type-generic.
Joseph Myers [Mon, 28 Nov 2016 23:27:23 +0000 (23:27 +0000)] 
Make ilogb wrappers type-generic.

This patch converts the ilogb wrappers (which set errno directly
rather than doing anything with __kernel_standard) to use the
type-generic template machinery.  This is intended as preparation for
adding llogb.

Tested for x86_64 and x86, and tested compile for other architectures
with build-many-glibcs.py.

* math/w_ilogb_template.c: New file.  Based on math/w_ilogb.c.
* math/w_ilogb.c: Remove.
* math/w_ilogbf.c: Likewise.
* math/w_ilogbl.c: Likewise.
* sysdeps/ieee754/ldbl-opt/w_ilogb.c: Likewise.
* sysdeps/ieee754/ldbl-opt/w_ilogbl.c: Likewise.
* math/Makefile (gen-libm-calls): Add w_ilogbF.
(libm-calls): Remove w_ilogbF.
* sysdeps/ieee754/ldbl-opt/math-type-macros-double.h
(LDOUBLE_ilogbl_libm_version): New macro.

7 years agoWork around IA64 tst-setcontext2.c compile failure.
Joseph Myers [Mon, 28 Nov 2016 23:13:46 +0000 (23:13 +0000)] 
Work around IA64 tst-setcontext2.c compile failure.

Building tests for IA64 runs into a build failure compiling
stdlib/tst-setcontext2.c:

tst-setcontext2.c: In function 'do_test':
tst-setcontext2.c:210:20: error: passing argument 1 of 'sigismember' from incompatible pointer type [-Werror=incompatible-pointer-types]
   if (sigismember (&oldctx.uc_sigmask, SIGUSR2) != 1)
                    ^

Indeed, the IA64 uc_sigmask as unsigned long rather than the larger
userspace sigset_t.  Fixing this might be hard; this patch works
around the build failure by making IA64 wrap the test with a version
that #defines sigismember to add a cast (I'd welcome a better approach
for fixing this).

Tested (compilation only) for ia64.

* sysdeps/unix/sysv/linux/ia64/tst-setcontext2.c: New file.

7 years agoFix sysdeps/ia64/fpu/libm-symbols.h for inclusion in testcases.
Joseph Myers [Mon, 28 Nov 2016 23:12:49 +0000 (23:12 +0000)] 
Fix sysdeps/ia64/fpu/libm-symbols.h for inclusion in testcases.

IA64 builds in math/ use "-include libm-symbols.h".  This breaks the
signgam tests, which rely on undefining _LIBC and feature test macros
and defining _ISOMAC before including system headers to get them to
provide only ISO C declarations (libm-symbols.h ending up indirectly
including headers which result in this breaking); similarly, it breaks
C++ tests as some headers included from libm-symbols.h are not ready
for inclusion in C++ code.  This patch disables the contents of
libm-symbols.h if __STRICT_ANSI__ or __cplusplus are defined to avoid
this problem (this header can only test symbols defined before the
source file is processed, so can't test _ISOMAC because that's defined
within the source file, after this header is included).

Tested (compilation only) for ia64.

* sysdeps/ia64/fpu/libm-symbols.h: Make contents conditional on
[!__STRICT_ANSI__ && !__cplusplus].

7 years agoX86_64: Don't use PLT nor GOT in static archives [BZ #20750]
H.J. Lu [Mon, 28 Nov 2016 17:44:49 +0000 (09:44 -0800)] 
X86_64: Don't use PLT nor GOT in static archives [BZ #20750]

There is no need to use PLT nor GOT in static archives to branch to a
function, regardless whether static archives is compiled with PIC or
not.  When static archives are used to create dynamic executable,
PLT/GOT may be used.  The resulting executable still works correctly.

[BZ #20750]
* sysdeps/x86_64/sysdep.h (JUMPTARGET): Check SHARED instead
of PIC.

7 years agoPartial ILP32 support for aarch64.
Steve Ellcey [Mon, 28 Nov 2016 17:01:23 +0000 (09:01 -0800)] 
Partial ILP32 support for aarch64.

* sysdeps/aarch64/crti.S: Add include of sysdep.h.
(call_weak_fn): Use PTR_REG to get correct reg name in ILP32.
* sysdeps/aarch64/dl-irel.h: Add include of sysdep.h.
(elf_irela): Use AARCH64_R macro to get correct relocation in ILP32.
* sysdeps/aarch64/dl-machine.h: Add include of sysdep.h.
(elf_machine_load_address, RTLD_START, RTLD_START_1, RTLD_START,
elf_machine_type_class, ELF_MACHINE_JMP_SLOT, elf_machine_rela,
elf_machine_lazy_rel): Add ifdef's for ILP32 support.
* sysdeps/aarch64/dl-tlsdesc.S (_dl_tlsdesc_return,
_dl_tlsdesc_return_lazy, _dl_tlsdesc_dynamic,
_dl_tlsdesc_resolve_hold): Extend pointers in ILP32, use PTR_REG
to get correct reg name for ILP32.
* sysdeps/aarch64/dl-trampoline.S (ip01): New Macro.
(RELA_SIZE): New Macro.
(_dl_runtime_resolve, _dl_runtime_profile): Use new macros and PTR_REG
to support ILP32.
* sysdeps/aarch64/jmpbuf-unwind.h (_JMPBUF_CFA_UNWINDS_ADJ): Add
cast for ILP32 mode.
* sysdeps/aarch64/memcmp.S (memcmp): Extend arg pointers for ILP32 mode.
* sysdeps/aarch64/memcpy.S (memmove, memcpy): Ditto.
* sysdeps/aarch64/memset.S (__memset): Ditto.
* sysdeps/aarch64/strchr.S (strchr): Ditto.
* sysdeps/aarch64/strchrnul.S (__strchrnul): Ditto.
* sysdeps/aarch64/strcmp.S (strcmp): Ditto.
* sysdeps/aarch64/strcpy.S (strcpy): Ditto.
* sysdeps/aarch64/strlen.S (__strlen): Ditto.
* sysdeps/aarch64/strncmp.S (strncmp): Ditto.
* sysdeps/aarch64/strnlen.S (strnlen): Ditto.
* sysdeps/aarch64/strrchr.S (strrchr): Ditto.
* sysdeps/unix/sysv/linux/aarch64/clone.S: Ditto.
* sysdeps/unix/sysv/linux/aarch64/setcontext.S (__setcontext): Ditto.
* sysdeps/unix/sysv/linux/aarch64/swapcontext.S (__swapcontext): Ditto.
* sysdeps/aarch64/__longjmp.S (__longjmp): Extend pointers in ILP32,
change PTR_MANGLE call to use register numbers instead of names.
* sysdeps/unix/sysv/linux/aarch64/getcontext.S (__getcontext): Ditto.
* sysdeps/aarch64/setjmp.S (__sigsetjmp): Extend arg pointers for
ILP32 mode, change PTR_MANGLE calls to use register numbers.
* sysdeps/aarch64/start.S (_start): Ditto.
* sysdeps/aarch64/nptl/bits/pthreadtypes.h
(__PTHREAD_RWLOCK_INT_FLAGS_SHARED): New define.
(__SIZEOF_PTHREAD_ATTR_T, __SIZEOF_PTHREAD_MUTEX_T,
__SIZEOF_PTHREAD_MUTEXATTR_T, __SIZEOF_PTHREAD_COND_T,
__SIZEOF_PTHREAD_COND_COMPAT_T, __SIZEOF_PTHREAD_CONDATTR_T,
__SIZEOF_PTHREAD_RWLOCK_T, __SIZEOF_PTHREAD_RWLOCKATTR_T,
__SIZEOF_PTHREAD_BARRIER_T, __SIZEOF_PTHREAD_BARRIERATTR_T):
Make defined values dependent on __ILP32__.
* sysdeps/aarch64/nptl/bits/semaphore.h (__SIZEOF_SEM_T): Change define.
(sem_t): Change __align type.
* sysdeps/aarch64/sysdep.h (AARCH64_R, PTR_REG, PTR_LOG_SIZE, DELOUSE,
PTR_SIZE): New Macros.
(LDST_PCREL, LDST_GLOBAL) Update to use PTR_REG.
* sysdeps/unix/sysv/linux/aarch64/bits/fcntl.h (O_LARGEFILE):
Set when in ILP32 mode.
(F_GETLK64, F_SETLK64, F_SETLKW64): Only set in LP64 mode.
* sysdeps/unix/sysv/linux/aarch64/dl-cache.h (DL_CACHE_DEFAULT_ID):
Set elf flags for ILP32.
(add_system_dir): Set ILP32 library directories.
* sysdeps/unix/sysv/linux/aarch64/init-first.c
(_libc_vdso_platform_setup): Set minimum kernel version for ILP32.
* sysdeps/unix/sysv/linux/aarch64/ldconfig.h
(SYSDEP_KNOWN_INTERPRETER_NAMES): Add ILP32 names.
* sysdeps/unix/sysv/linux/aarch64/sigcontextinfo.h (GET_PC, SET_PC):
New Macros.
* sysdeps/unix/sysv/linux/aarch64/sysdep.h: Handle ILP32 pointers.

7 years agoFix for [f]statfs64/[f]statfs aliasing patch
Steve Ellcey [Mon, 28 Nov 2016 16:51:01 +0000 (08:51 -0800)] 
Fix for [f]statfs64/[f]statfs aliasing patch

* sysdeps/unix/sysv/linux/fstatfs64.c: Reorder include files,
only alias fstatfs and __fstatfs if STATFS_IS_STATFS64 is non-zero.
* sysdeps/unix/sysv/linux/statfs64.c: Ditto for statfs and __statfs.

7 years agoDo not include asm/cachectl.h in nios2 sys/cachectl.h.
Joseph Myers [Mon, 28 Nov 2016 13:55:31 +0000 (13:55 +0000)] 
Do not include asm/cachectl.h in nios2 sys/cachectl.h.

The nios2 sys/cachectl.h includes a kernel header asm/cachectl.h,
which does not exist, so causing the check-installed-headers tests to
fail.  This patch removes the include of a nonexistent header.

Tested (compilation only) for nios2.

* sysdeps/unix/sysv/linux/nios2/sys/cachectl.h: Do not include
<asm/cachectl.h>.

7 years agoMinor problems exposed by compiling C++ tests under _ISOMAC.
Zack Weinberg [Sun, 27 Nov 2016 17:36:16 +0000 (12:36 -0500)] 
Minor problems exposed by compiling C++ tests under _ISOMAC.

* libio/libio.h: Use __USE_GNU, not _GNU_SOURCE, in a conditional.
* test-skeleton.c: Include stdint.h to ensure uintptr_t is available.

7 years agohurd: fix using hurd/signal.h in C++ programs
Samuel Thibault [Sun, 27 Nov 2016 16:22:22 +0000 (17:22 +0100)] 
hurd: fix using hurd/signal.h in C++ programs

* hurd/hurd/signal.h (HURD_MSGPORT_RPC): Cast expressions results to
error_t to fix usage in C++ programs.

7 years agolocaledata: GBK: add mapping for 0x80->Euro sign [BZ #20864]
Mike Frysinger [Fri, 25 Nov 2016 16:12:10 +0000 (11:12 -0500)] 
localedata: GBK: add mapping for 0x80->Euro sign [BZ #20864]

Microsoft long ago added a mapping for 0x80 to the Euro sign to their
CP936.  While GBK 1.0 doesn't include this mapping, it is compatible,
and Microsoft and glibc alias the two codepages.  We could split them
apart so GBK wouldn't include the mapping, but that seems like a lot
of work for little gain.

7 years agoMake build-many-glibcs.py store more information about builds.
Joseph Myers [Sat, 26 Nov 2016 00:10:24 +0000 (00:10 +0000)] 
Make build-many-glibcs.py store more information about builds.

This patch makes build-many-glibcs.py store information about builds
in JSON format.  This is part of preparing it for use in a bot
checking for regressions.

The information stored is: time of last build (of host-libraries,
compilers or glibcs); versions of components used in the last build
(for compilers, host library versions are properly copied from those
used for the previous host-libraries build, and for glibcs, component
versions other than that of glibc are similarly copied from the last
compilers build); PASS/FAIL/UNRESOLVED results of the individual build
steps; a list of changed results; a list of tests (that are still run
at all) that have ever been recorded to PASS.

The first pieces of information are intended to be used by a bot to
decide whether a rebuild is appropriate (based on some combination of
elapsed time and changes to versions; a bot might want to rebuild
glibcs if there had been any change but only rebuild compilers after
enough time had elapsed, for example).  All the information is
intended to be used in generating mails with results information.

This state is specifically for full builds (no individual configs for
building compilers or glibcs specified).  If individual configs are
specified, build-time and build-versions information is cleared (since
it will no longer accurately reflect the install directory contents),
while the other information is left unchanged.  This reflects the
motivation of providing information for a bot checking for
regressions; the contents of build-state.json in a tree used for
manual builds that may be only for some configurations are not
particularly important.

* scripts/build-many-glibcs.py: Import datetime module.
(Context.__init__): Load JSON build state.  Initialize list of
status logs.
(Context.run_builds): Update saved build state.
(Context.add_makefile_cmdlist): Update list of status logs.
(Context.load_build_state_json): New function.
(Context.store_build_state_json): Likewise.
(Context.clear_last_build_state): Likewise.
(Context.update_build_state): Likewise.
(CommandList.status_logs): Likewise.

7 years agoMake build-many-glibcs.py re-exec itself if changed by checkout.
Joseph Myers [Fri, 25 Nov 2016 00:58:22 +0000 (00:58 +0000)] 
Make build-many-glibcs.py re-exec itself if changed by checkout.

Updating build-many-glibcs.py may result in changes to the default
versions of components, or to the set of components (if e.g. Hurd
support is added and that requires a new component).

It's desirable for the checkout process to leave a source tree that is
ready to use.  If the checkout updated the script itself, that means
it needs to be rerun to cause any new versions or components
referenced by the new script version to be properly checked out.  This
patch makes the script check if it was modified by the checkout
process, and re-exec itself (with the same arguments) if so.

* scripts/build-many-glibcs.py (Context.__init__): Save text of
script being executed.
(Context.get_script_text): New function.
(Context.exec_self): Likewise.
(Context.checkout): Re-exec script if changed by checkout process.

7 years agoAdd setpayloadsig, setpayloadsigf, setpayloadsigl.
Joseph Myers [Thu, 24 Nov 2016 23:56:48 +0000 (23:56 +0000)] 
Add setpayloadsig, setpayloadsigf, setpayloadsigl.

TS 18661-1 defines functions for manipulating the payloads of NaNs.
This patch implements the setpayloadsig functions for glibc; these are
like the setpayload functions, but produce a signaling NaN instead of
a quiet NaN.

The substance of the implementation was included with the setpayload
implementation, so the new files here just need to wrap the main files
with different defines to build the new functions.

Because the functions store a signaling NaN via a pointer and the
libm-test macros choose a suitable initial value for the variable in
such a case by comparing with the expected value, the relevant macro
needs to clear exceptions after FE_INVALID may have been raised by
that comparison.

Tested for x86_64, x86, mips64 and powerpc.

* math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(setpayloadsig): New declaration.
* math/Versions (setpayloadsig): New libm symbol at version
GLIBC_2.25.
(setpayloadsigf): Likewise.
(setpayloadsigl): Likewise.
* math/Makefile (libm-calls): Add s_setpayloadsigF.
* math/libm-test.inc (RUN_TEST_Ff_b1): Call feclearexcept
(FE_ALL_EXCEPT) after initializing EXTRA_VAR.
(setpayloadsig_test_data): New array.
(setpayloadsig_test): New function.
(main): Call setpayloadsig_test.
* manual/arith.texi (FP Bit Twiddling): Document setpayloadsig,
setpayloadsigf and setpayloadsigl.
* manual/libm-err-tab.pl: Update comment on interfaces without
ulps tabulated.
* sysdeps/ieee754/dbl-64/s_setpayloadsig.c: New file.
* sysdeps/ieee754/flt-32/s_setpayloadsigf.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_setpayloadsigl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_setpayloadsigl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_setpayloadsigl.c: Likewise.
* sysdeps/ieee754/ldbl-opt/nldbl-setpayloadsig.c: Likewise.
* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add
setpayloadsig.
(CFLAGS-nldbl-setpayloadsig.c): New variable.
* 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.

7 years agoMake build-many-glibcs.py track component versions requested and used.
Joseph Myers [Thu, 24 Nov 2016 22:25:58 +0000 (22:25 +0000)] 
Make build-many-glibcs.py track component versions requested and used.

This patch makes build-many-glibcs.py record the component versions
checked out, and whether those versions were explicitly requested or
defaults, in a file versions.json in the source directory.

The preferred version of a component is the first of: one explicitly
specified on the command line; one explicitly specified on the command
line in a previous run of build-many-glibcs.py; a default version for
that component.  Thus, once you've run build-many-glibcs.py checkout
once with the updated script (making sure to specify the right
versions of any components previously checked out with a non-default
version), in future you can just run it without version specifiers and
it will know when a default-version component has changed its default
version and so should be checked out again.

Because you might have local changes and not want a default-version
component checkout replaced, you need to pass the --replace-sources
option to allow the script to delete and replace a component source
directory automatically; otherwise, it will give an error if a version
has changed.  The script does not try to change branches of git or SVN
checkouts without checking out from scratch; if the version number
requested has changed and --replace-sources is used, the relevant
source directory will be removed completely and a new one checked out
from scratch.

Apart from allowing automatic updates of components with default
versions, this also facilitates bots reporting on the versions used in
a given build.  versions.json contains not just information on the
version number and whether that was requested explicitly, but also git
or SVN revision information intended to be used in email reports from
bots.

* scripts/build-many-glibcs.py: Import json module.
(Context.__init__): Take replace_sources argument.  Load
versions.json.
(Context.load_versions_json): New function.
(Context.store_json): Likewise.
(Context.store_versions_json): Likewise.
(Context.set_component_version): Likewise.
(Context.checkout): Update versions.json.  Check for and handle
changes of version.  Prefer previously explicitly specified
version to default version.
(Context.checkout_vcs): Return a revision identifier.
(Context.git_checkout): Likewise.
(Context.gcc_checkout): Likewise.
(get_parser): Add --replace-sources option.
(main): Pass replace_sources argument to Context call.

7 years agoRemove cached PID/TID in clone
Adhemerval Zanella [Mon, 10 Oct 2016 18:08:39 +0000 (15:08 -0300)] 
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.

7 years agoRefactor float_t, double_t information into bits/flt-eval-method.h.
Joseph Myers [Thu, 24 Nov 2016 18:44:50 +0000 (18:44 +0000)] 
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.

7 years agox86_64: fix static build of __memcpy_chk for compilers defaulting to PIC/PIE
Aurelien Jarno [Thu, 24 Nov 2016 11:10:13 +0000 (12:10 +0100)] 
x86_64: fix static build of __memcpy_chk for compilers defaulting to PIC/PIE

When glibc is compiled with gcc 6.2 that has been configured with
to default to PIC/PIE, the static version of __memcpy_chk is not built,
as the test is done on PIC instead of SHARED. Fix the test to check for
SHARED, like it is done for similar functions like memmove_chk.

Changelog:
* sysdeps/x86_64/memcpy_chk.S (__memcpy_chk): Check for SHARED
instead of PIC.

7 years agoMore NEWS entries / fixes for float_t / double_t changes.
Joseph Myers [Wed, 23 Nov 2016 21:30:04 +0000 (21:30 +0000)] 
More NEWS entries / fixes for float_t / double_t changes.

Document changes for x86_64 -mfpmath=sse and -mfpmath=sse+387.  Don't
put these NEWS entries in the middle of TS 18661-1 entries.

7 years agoFix SH4 FP_ILOGB0 (bug 20859).
Joseph Myers [Wed, 23 Nov 2016 21:23:12 +0000 (21:23 +0000)] 
Fix SH4 FP_ILOGB0 (bug 20859).

ISO C requires that the value of FP_ILOGB0 must be INT_MIN or
-INT_MAX.  In sysdeps/sh/sh4/bits/mathdef.h, it's 0x80000001; that is,
a positive unsigned value that would be -INT_MAX if converted to int,
which is not valid (there's no actual constraint on the type, but
whatever the type the integer value must be one of the two permitted,
and types other than int don't really make sense).  This patch makes
the ABI-compatible change to (-0x7fffffff).

(The testcase handles positive and negative sign separately to avoid
any issues with implicit conversions that could result in e.g. INT_MIN
converted to uintmax_t wrongly passing.)

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

[BZ #20859]
* sysdeps/sh/sh4/bits/mathdef.h (FP_ILOGB0): Define to
(-0x7fffffff) instead of 0x80000001.
* math/test-fp-ilogb-constants.c: New file.
* math/Makefile (tests): Add test-fp-ilogb-constants.

7 years agoMIPS: Use R_MICROMIPS_JALR rather than R_MIPS_JALR in microMIPS code
Maciej W. Rozycki [Wed, 23 Nov 2016 12:39:39 +0000 (12:39 +0000)] 
MIPS: Use R_MICROMIPS_JALR rather than R_MIPS_JALR in microMIPS code

In a microMIPS compilation of `.init' code use the R_MICROMIPS_JALR
relocation intended for PIC call relaxation in microMIPS code rather
than the corresponding R_MIPS_JALR relocation meant for regular MIPS
code only.

* sysdeps/mips/mips32/crti.S (JALR_RELOC): New macro.
(_init): Use it in place of hardcoded R_MIPS_JALR.
* sysdeps/mips/mips64/n32/crti.S (JALR_RELOC): New macro.
(_init): Use it in place of hardcoded R_MIPS_JALR.
* sysdeps/mips/mips64/n64/crti.S (JALR_RELOC): New macro.
(_init): Use it in place of hardcoded R_MIPS_JALR.

7 years agoFix x86_64 -mfpmath=387 float_t, double_t (bug 20787).
Joseph Myers [Wed, 23 Nov 2016 17:56:31 +0000 (17:56 +0000)] 
Fix x86_64 -mfpmath=387 float_t, double_t (bug 20787).

Bug 20787 reports that, while float_t and double_t for 32-bit x86
properly respect -mfpmath=sse, for x86_64 they fail to reflect
-mfpmath=387, which is valid if unusual and results in FLT_EVAL_METHOD
being 2.  This patch fixes the definitions to respect
__FLT_EVAL_METHOD__ in that case, arranging for the test that the
types correspond with FLT_EVAL_METHOD to be run with both -mfpmath=387
and -mfpmath=sse.

Note: this patch will also have the effect of making float_t and
double_t be long double for x86_64 with -mfpmath=sse+387, when
FLT_EVAL_METHOD is -1.  It seems reasonable for x86_64 to be
consistent with 32-bit x86 in this case (and that definition is
conservatively safe, in that it makes the types correspond to the
widest evaluation format that might be used).

Tested for x86-64 and x86.

[BZ #20787]
* sysdeps/x86/bits/mathdef.h (float_t): Do not define to float if
[__x86_64__] when __FLT_EVAL_METHOD__ is nonzero.
(double_t): Do not define to double if [__x86_64__] when
__FLT_EVAL_METHOD__ is nonzero.
* sysdeps/x86/fpu/test-flt-eval-method-387.c: New file.
* sysdeps/x86/fpu/test-flt-eval-method-sse.c: Likewise.
* sysdeps/x86/fpu/Makefile [$(subdir) = math] (tests): Add
test-flt-eval-method-387 and test-flt-eval-method-sse.
[$(subdir) = math] (CFLAGS-test-flt-eval-method-387.c): New
variable.
[$(subdir) = math] (CFLAGS-test-flt-eval-method-sse.c): Likewise.

7 years agobuild-many-glibcs: Revert -fno-isolate-erroneous-paths options for tilepro
Chris Metcalf [Wed, 23 Nov 2016 17:25:23 +0000 (12:25 -0500)] 
build-many-glibcs: Revert -fno-isolate-erroneous-paths options for tilepro

TILEPro now has a __builtin_trap instruction in gcc tip and gcc 6.

7 years agoelf: Assume TLS is initialized in _dl_map_object_from_fd
Florian Weimer [Wed, 23 Nov 2016 12:12:03 +0000 (13:12 +0100)] 
elf: Assume TLS is initialized in _dl_map_object_from_fd

libc.so uses TLS data, so when dlopen is called later, the
TLS data structures have already been initialized.

7 years agoFix default float_t definition (bug 20855).
Joseph Myers [Wed, 23 Nov 2016 00:28:30 +0000 (00:28 +0000)] 
Fix default float_t definition (bug 20855).

The default (top-level) version of bits/mathdef.h defines float_t to
double.  It is used on ColdFire, MicroBlaze, Nios II and SH3, all of
which define FLT_EVAL_METHOD to 0, so float_t should be float (and C11
requires a certain correspondence between these typedefs and
FLT_EVAL_METHOD values).

I proposed fixing this default in
<https://sourceware.org/ml/libc-alpha/2015-01/msg00499.html>, with no
objections from architecture maintainers, and this patch makes that
fix.  As noted in the NEWS entry added, this might affect the ABIs of
non-glibc libraries (ImageMagick has been mentioned in gcc-patches
discussion of the S/390 case - which is unaffected by this patch), but
as noted in my previous message, affected libraries would have
problems with -mfpmath=sse anyway on 32-bit x86.

A (compilation) testcase is added to verify the required
correspondence of typedefs to FLT_EVAL_METHOD values.  This test is
built with -fexcess-precision=standard to avoid any issues with GCC 7
on S/390 providing a more accurate FLT_EVAL_METHOD definition in the
default (no excess precision) mode.  (This will also be usable to test
a fix for the recently reported bug about these typedefs on x86_64
-mfpmath=387, as architecture-specific tests can be added that

It is entirely possible that the fixed default makes some
architecture-specific versions of bits/mathdef.h semantically
equivalent to the default version and so no longer required.  I don't
intend to investigate that separately from the refactoring I proposed
in <https://sourceware.org/ml/libc-alpha/2016-11/msg00745.html>, which
will create as few header variants as possible for each group of
definitions.

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

[BZ #20855]
* bits/mathdef.h (float_t): Define to float.
* math/test-flt-eval-method.c: New file.
* math/Makefile (tests): Add test-flt-eval-method.
(CFLAGS-test-flt-eval-method.c): New variable.

7 years agoAllow [f]statfs64 to alias [f]statfs
Steve Ellcey [Tue, 22 Nov 2016 17:59:12 +0000 (09:59 -0800)] 
Allow [f]statfs64 to alias [f]statfs

* sysdeps/unix/sysv/linux/fstatfs64.c: Hide prototypes for fstatfs
and __fstatfs.  Make them aliases of __fstatfs64 if
STATFS_IS_STATFS64 is set to non-zero.
* sysdeps/unix/sysv/linux/statfs64.c: Ditto for __statfs, statfs,
and __statfs64.
* sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c: Do not
define __fstatfs and fstatfs if STATFS_IS_STATFS64 is non-zero.
* sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c: Ditto
for __statfs and statfs.
* sysdeps/unix/sysv/linux/alpha/kernel_stat.h: Set STATFS_IS_STATFS64
to 0.
* sysdeps/unix/sysv/linux/generic/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/hppa/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/ia64/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/microblaze/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/mips/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/x86_64/kernel_stat.h: Ditto.

7 years agoFix multiple definitions of mk[o]stemp[s]64
Andreas Schwab [Tue, 22 Nov 2016 10:56:08 +0000 (11:56 +0100)] 
Fix multiple definitions of mk[o]stemp[s]64

7 years agoFix writes past the allocated array bounds in execvpe (BZ#20847)
Adhemerval Zanella [Mon, 21 Nov 2016 13:06:15 +0000 (11:06 -0200)] 
Fix writes past the allocated array bounds in execvpe (BZ#20847)

This patch fixes an invalid write out or stack allocated buffer in
2 places at execvpe implementation:

  1. On 'maybe_script_execute' function where it allocates the new
     argument list and it does not account that a minimum of argc
     plus 3 elements (default shell path, script name, arguments,
     and ending null pointer) should be considered.  The straightforward
     fix is just to take account of the correct list size on argument
     copy.

  2. On '__execvpe' where the executable file name lenght may not
     account for ending '\0' and thus subsequent path creation may
     write past array bounds because it requires to add the terminating
     null.  The fix is to change how to calculate the executable name
     size to add the final '\0' and adjust the rest of the code
     accordingly.

As described in GCC bug report 78433 [1], these issues were masked off by
GCC because it allocated several bytes more than necessary so that many
off-by-one bugs went unnoticed.

Checked on x86_64 with a latest GCC (7.0.0 20161121) with -O3 on CFLAGS.

[BZ #20847]
* posix/execvpe.c (maybe_script_execute): Remove write past allocated
array bounds.
(__execvpe): Likewise.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78433

7 years agoMake build-many-glibcs.py use -fno-isolate-erroneous-paths options for tilepro.
Joseph Myers [Tue, 22 Nov 2016 01:58:26 +0000 (01:58 +0000)] 
Make build-many-glibcs.py use -fno-isolate-erroneous-paths options for tilepro.

My most recent build-many-glibcs.py build with GCC mainline showed
build failures for tilepro with the symptoms (multiple definitions of
symbols building ld.so, see the build log referenced in the GCC bug
referenced in the comment for an example) that correspond to the
isolate-erroneous-paths optimization not being suitable for building
glibc unless the GCC port provides a trap pattern (so __builtin_trap
expands to an inline instruction rather than a call to abort).  Since
tilepro indeed lacks such as pattern in GCC, this patch duly arranges
for this optimization to be disabled when building for tilepro, as it
is for sh.

Tested (compilation only) for tilepro.

* scripts/build-many-glibcs.py (Context.add_all_configs): Also use
-fno-isolate-erroneous-paths options for tilepro.

7 years agoAlways define XSTAT_IS_XSTAT64
Steve Ellcey [Mon, 21 Nov 2016 16:23:12 +0000 (08:23 -0800)] 
Always define XSTAT_IS_XSTAT64

* sysdeps/unix/sysv/linux/generic/kernel_stat.h: Set XSTAT_IS_XSTAT64
to 0 when in 32 bit mode.
* sysdeps/unix/sysv/linux/hppa/kernel_stat.h: Set XSTAT_IS_XSTAT64 to 0.
* sysdeps/unix/sysv/linux/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/microblaze/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/mips/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/fxstat.c: Replace #ifdef with #if on
XSTAT_IS_XSTAT64 test.
* sysdeps/unix/sysv/linux/fxstatat.c: Ditto.
* sysdeps/unix/sysv/linux/generic/lxstat.c: Ditto.
* sysdeps/unix/sysv/linux/generic/xstat.c: Ditto.
* sysdeps/unix/sysv/linux/i386/fxstat.c: Ditto.
* sysdeps/unix/sysv/linux/i386/fxstatat.c: Ditto.
* sysdeps/unix/sysv/linux/i386/lxstat.c: Ditto.
* sysdeps/unix/sysv/linux/i386/xstat.c: Ditto.
* sysdeps/unix/sysv/linux/lxstat.c: Ditto.
* sysdeps/unix/sysv/linux/mips/xstatconv.c: Ditto.
* sysdeps/unix/sysv/linux/xstat.c: Ditto.
* sysdeps/unix/sysv/linux/xstatconv.c: Ditto.

7 years agoAdd setpayload, setpayloadf, setpayloadl.
Joseph Myers [Sat, 19 Nov 2016 00:16:28 +0000 (00:16 +0000)] 
Add setpayload, setpayloadf, setpayloadl.

TS 18661-1 defines functions for manipulating the payloads of NaNs.
This patch implements the setpayload functions for glibc; these set a
number (pointed to by a function argument) to a quiet NaN with the
given payload, or to +0 if the given payload is not valid.  The
implementations are structured to allow the substance of the
implementation to be shared with the setpayloadsig functions when
those are added.

The semantics in the TS are not entirely clear in the case where the
payload passed to the function is zero (see discussion on the WG14
reflector last month).  This patch implements what seems the most
sensible interpretation, that -0 is never valid to give as the
payload, but +0 is valid in the case where the kind of NaN being
generated has its high mantissa bit set so payload 0 is actually
possible in such a NaN.

Tested for x86_64, x86, mips64 and powerpc.

* math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(setpayload): New declaration.
* math/Versions (setpayload): New libm symbol at version
GLIBC_2.25.
(setpayloadf): Likewise.
(setpayloadl): Likewise.
* math/Makefile (libm-calls): Add s_setpayloadF.
* math/libm-test.inc (struct test_Ffp_b1_data): Rename to struct
test_Ff_b1_data.
(RUN_TEST_Ff_b1): New macro.
(RUN_TEST_LOOP_Ff_b1): Likewise.
(canonicalize_test_data): Update type.
(setpayload_test_data): New array.
(setpayload_test): New function.
(main): Call setpayload_test.
* manual/arith.texi (FP Bit Twiddling): Document setpayload,
setpayloadf and setpayloadl.
* manual/libm-err-tab.pl: Update comment on interfaces without
ulps tabulated.
* sysdeps/ieee754/dbl-64/s_setpayload.c: New file.
* sysdeps/ieee754/dbl-64/s_setpayload_main.c: Likewise.
* sysdeps/ieee754/dbl-64/wordsize-64/s_setpayload_main.c:
Likewise.
* sysdeps/ieee754/flt-32/s_setpayloadf.c: Likewise.
* sysdeps/ieee754/flt-32/s_setpayloadf_main.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_setpayloadl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_setpayloadl_main.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_setpayloadl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_setpayloadl_main.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_setpayloadl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_setpayloadl_main.c: Likewise.
* sysdeps/ieee754/ldbl-opt/nldbl-setpayload.c: Likewise.
* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add
setpayload.
(CFLAGS-nldbl-setpayload.c): New variable.
* 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.

7 years agoFix hurd __access_noerrno implementation.
Adhemerval Zanella [Fri, 18 Nov 2016 18:41:00 +0000 (16:41 -0200)] 
Fix hurd __access_noerrno implementation.

This patch fixes some hurd bits from commit afcf3cd8eb that added the
__access_noerrno internal symbol.  It basically removes the nonrequired
__hurd_fail_noerrno (since the 'err' argument is ignored) and fixes
a typo for EACCES.

However, as stated on maillist [1] this __access_noerrno may still be
unsafe to run during initialization of tunables on the Hurd.  The
access_common calls __hurd_file_name_lookup, which calls
__hurd_file_name_lookup_retry, which can set errno.

[1] https://sourceware.org/ml/libc-alpha/2016-11/msg00646.html

7 years agotile: create new math-tests.h header
Chris Metcalf [Wed, 16 Nov 2016 15:09:50 +0000 (10:09 -0500)] 
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.

7 years agoMake tile's set_dataplane API compatibility-only
Chris Metcalf [Mon, 14 Nov 2016 16:41:38 +0000 (11:41 -0500)] 
Make tile's set_dataplane API compatibility-only

The set_dataplane() API in <sys/dataplane.h> originally supported the
Tilera version of Linux as shipped to our customers.  Once we started
upstreaming the dataplane support in the kernel, the API changed
to use fcntl() as part of the current task-isolation patch series.

It doesn't seem like continuing to support the old API is useful
for newly-compiled code, and even supporting the old glibc binary
API on an upstream kernel that supports the new task isolation mode
isn't straightforward, since the semantics have changed in ways that
make it hard to map the old semantics precisely to the new ones,
so just return ENOSYS.

7 years agoQuote shell commands in logs from build-many-glibcs.py.
Joseph Myers [Fri, 18 Nov 2016 18:22:09 +0000 (18:22 +0000)] 
Quote shell commands in logs from build-many-glibcs.py.

As requested in
<https://sourceware.org/ml/libc-alpha/2016-11/msg00664.html>, this
patch makes the commands recorded in build-many-glibcs.py quote words
so they can be cut-and-pasted back into a shell.  (Note that these
logs are generated by the wrapper script generated to run commands
with logs, hence the needs for quoting logic to be implemented in that
shell script.)

* scripts/build-many-glibcs.py (Context.write_files): Make wrapper
script quote words in command output to log suitably for input to
the shell.

7 years agoMIPS: Add `.insn' to ensure a text label is defined as code not data
Maciej W. Rozycki [Thu, 17 Nov 2016 19:15:51 +0000 (19:15 +0000)] 
MIPS: Add `.insn' to ensure a text label is defined as code not data

Avoid a build error with microMIPS compilation and recent versions of
GAS which complain if a branch targets a label which is marked as data
rather than microMIPS code:

../sysdeps/mips/mips32/crti.S: Assembler messages:
../sysdeps/mips/mips32/crti.S:72: Error: branch to a symbol in another ISA mode
make[2]: *** [.../csu/crti.o] Error 1

as commit 9d862524f6ae ("MIPS: Verify the ISA mode and alignment of
branch and jump targets") closed a hole in branch processing, making
relocation calculation respect the ISA mode of the symbol referred.
This allowed diagnosing the situation where an attempt is made to pass
control from code assembled for one ISA mode to code assembled for a
different ISA mode and either relaxing the branch to a cross-mode jump
or if that is not possible, then reporting this as an error rather than
letting such code build and then fail unpredictably at the run time.

This however requires the correct annotation of branch targets as code,
because the ISA mode is not relevant for data symbols and is therefore
not recorded for them.  The `.insn' pseudo-op is used for this purpose
and has been supported by GAS since:

Wed Feb 12 14:36:29 1997  Ian Lance Taylor  <ian@cygnus.com>

* config/tc-mips.c (mips_pseudo_table): Add "insn".
(s_insn): New static function.
* doc/c-mips.texi: Document .insn.

so there has been no reason to avoid it where required.  More recently
this pseudo-op has been documented, by the microMIPS architecture
specification[1][2], as required for the correct interpretation of any
code label which is not followed by an actual instruction in an assembly
source.

Use it in our crti.S files then, to mark that the trailing label there
with no instructions following is indeed not a code bug and the branch
is legitimate.

References:

[1] "MIPS Architecture for Programmers, Volume II-B: The microMIPS32
    Instruction Set", MIPS Technologies, Inc., Document Number: MD00582,
    Revision 5.04, January 15, 2014, Section 7.1 "Assembly-Level
    Compatibility", p. 533

[2] "MIPS Architecture for Programmers, Volume II-B: The microMIPS64
    Instruction Set", MIPS Technologies, Inc., Document Number: MD00594,
    Revision 5.04, January 15, 2014, Section 8.1 "Assembly-Level
    Compatibility", p. 623

2016-11-18  Matthew Fortune  <Matthew.Fortune@imgtec.com>
            Maciej W. Rozycki  <macro@imgtec.com>

* sysdeps/mips/mips32/crti.S (_init): Add `.insn' pseudo-op at
`.Lno_weak_fn' label.
* sysdeps/mips/mips64/n32/crti.S (_init): Likewise.
* sysdeps/mips/mips64/n64/crti.S (_init): Likewise.

7 years agoConsolidate Linux setrlimit and getrlimit implementation
Adhemerval Zanella [Tue, 18 Oct 2016 11:41:56 +0000 (09:41 -0200)] 
Consolidate Linux setrlimit and getrlimit implementation

This patch consolidates all Linux setrlimit and getrlimit on the default
sysdeps/unix/sysv/linux/{set,get}rlimit{64}.c.  It contains two exceptions:

  1. mips32 and mips64n32 which requires a versioned symbol for GLIBC 2.19
     and higher due a broken RLIM64_INFINITY constant.
  2. sparc32 does not define a compat symbol for getrlimit64 for old 2GB
     limit. I am not sure if it is required, but a RLIM_INFINITY fix [1]
     change its definition without adding a compat symbol.  This patch does
     not aim to address this possible issue, it follow current symbol
     export.

The default implementation uses prlimit64 for 64 bit rlim_t ({set,get}rlimit64)
and if it fails with ENOSYS it fall back to {get,set}rlimit syscall.  This
code path is only used on kernel older than 2.6.36 (basically now only x86)
and I avoid to user __ASSUME_PRLIMTI64 to simplify the implementation.  Once
x86 moves to be on par with other architectures regarding minimum kernel
supported we can get rid of using old syscalls and default path.

A new type size define is added, __RLIM_T_MATCHES_RLIM64_T, where is set as
default for 64 bits ports.  This allows the default implementation to avoid
{get,set}rlimit building and alias {get,set}rlimit64 to {get,set}rlimit.

Checked on x86_64, i386, armhf, aarch64, and powerpc64le.  I also did a
sanity build plus check-abi on all other supported architectures.

[1] Commit 9c96ff23858b0759e12ad69e3c4599931c90bee8

Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Yury Norov  <ynorov@caviumnetworks.com>

* bits/typesizes.h (__RLIM_T_MATCHES_RLIM64_T): define.
* sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
(__RLIM_T_MATCHES_RLIM64_T): Likewise.
* sysdeps/unix/sysv/linux/generic/bits/typesizes.h
(__RLIM_T_MATCHES_RLIM64_T): Likewise.
* sysdeps/unix/sysv/linux/s390/bits/typesizes.h [__s390x__]
(__RLIM_T_MATCHES_RLIM64_T): Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
[__arch64__ || __sparcv9] (__RLIM_T_MATCHES_RLIM64_T): Likewise.
* sysdeps/unix/sysv/linux/x86/bits/typesizes.h [__86_64__]
(__RLIM_T_MATCHES_RLIM64_T): Likewise.
* sysdeps/unix/sysv/linux/arm/Makefile [$(subdir) = resource]
(sysdep_routines): Remove oldgetrlimit64.
* sysdeps/unix/sysv/linux/i386/Makefile [$(subdir) = resource]
(sysdep_routines): Likewise.
* sysdeps/unix/sysv/linux/m68k/Makefile [$(subdir) = resource]
(sysdep_routines): Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile
[$(subdir) = resource] (sysdep_routines): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/Makefile
[$(subdir) = resource] (sysdep_routines): Likewise.
* sysdeps/unix/sysv/linux/arm/getrlimit64.c: Remove file.
* sysdeps/unix/sysv/linux/arm/oldgetrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/hppa/getrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/i386/getrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/m68k/getrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/m68k/oldgetrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/powerpc/getrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/powerpc/oldgetrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/getrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/oldgetrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/sh/getrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/wordsize-64/getrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/wordsize-64/setrlimit64.c: Likewise.
* sysdeps/sysv/linux/generic/wordsize-32/syscalls.list: Remove
setrlimit and getrlimit.
* sysdeps/unix/sysv/linux/hppa/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/i386/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/getrlimit.c: New file.
* sysdeps/unix/sysv/linux/sparc/getrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/setrlimit.c: Likewise.
* sysdeps/unix/sysv/linux/getrlimit64.c (__getrlimit64): Handle
__RLIM_T_MATCHES_RLIM64_T and add alias if defined.
(__old_getrlimit64): Add compatibility symbol.
* sysdeps/unix/sysv/linux/setrlimit64.c (__setrlimit): Likewise.

7 years agoActually use newly built host libraries in build-many-glibcs.py.
Joseph Myers [Thu, 17 Nov 2016 17:45:41 +0000 (17:45 +0000)] 
Actually use newly built host libraries in build-many-glibcs.py.

This patch adds the missing GCC configure options required to make use
of the newly built host libraries in build-many-glibcs.py.

* scripts/build-many-glibcs.py (Config.build_gcc): Configure with
newly built gmp, mpfr and mpc.

7 years agoMake Alpha <sys/user.h> self-contained.
Joseph Myers [Thu, 17 Nov 2016 14:15:03 +0000 (14:15 +0000)] 
Make Alpha <sys/user.h> self-contained.

The check-installed-headers tests show up that the Alpha <sys/user.h>
is not self-contained, using size_t without including any header that
defines it.  This patch fixes it by including <stddef.h>, as done for
other architectures' versions of this header.

Tested for Alpha (compilation only).

* sysdeps/unix/sysv/linux/alpha/sys/user.h: Include <stddef.h>.

7 years agoEnable linknamespace testing for libdl and libcrypt.
Joseph Myers [Wed, 16 Nov 2016 22:47:57 +0000 (22:47 +0000)] 
Enable linknamespace testing for libdl and libcrypt.

When I set up linknamespace testing, the lists of libraries that might
contain functions from various standards were based on the -l options
POSIX says may be required to find certain functions with the c99
utility.

glibc has some POSIX functions in the libdl and libcrypt libraries,
not mentioned in the definition of the c99 utility (so an
implementation of that utility using glibc would need to use -ldl
-lcrypt automatically).  This patch adds those libraries to the ones
considered in linknamespace testing for relevant standards.  (The
crypt functions are XSI only, present in XPG3 and above; the libdl
ones were added in UNIX98, then moved from XSI to BASE in the 2008
edition of POSIX.)

* conform/Makefile (linknamespace-libs): Rename to
linknamespace-libs-thr.
(linknamespace-libs-posix): New variable.
(linknamespace-libs-xsi): Likewise.
(linknamespace-libs-XPG3): Include libcrypt.a.
(linknamespace-libs-XPG4): Use $(linknamespace-libs-XPG3).
(linknamespace-libs-POSIX): Use $(linknamespace-libs-thr).
(linknamespace-libs-UNIX98): Use $(linknamespace-libs-xsi).
(linknamespace-libs-XOPEN2K): Likewise.
(linknamespace-libs-XOPEN2K8): Likewise.
(linknamespace-libs-POSIX2008): Use $(linknamespace-libs-posix).

7 years agoFix crypt snprintf namespace (bug 20829).
Joseph Myers [Wed, 16 Nov 2016 22:46:48 +0000 (22:46 +0000)] 
Fix crypt snprintf namespace (bug 20829).

Extending linknamespace tests to cover libcrypt showed that crypt
brings in references to snprintf, but is in XPG3 and XPG4 which don't
have snprintf.  This patch fixes it to use __snprintf instead,
exporting __snprintf from libc.so at version GLIBC_PRIVATE and adding
libc_hidden_proto / libc_hidden_def accordingly.

Tested for x86_64 and x86, in conjunction with the testsuite changes
to enable linknamespace testing for libdl and libcrypt.  Also tested
(compilation only) for powerpc to make sure there were no problem
interactions with the optional-long-double handling for snprintf.

[BZ #20829]
* stdio-common/Versions (__snprintf): Add to version
GLIBC_PRIVATE.
* include/stdio.h (__snprintf): Use libc_hidden_proto.
* stdio-common/snprintf.c (__snprintf): Use libc_hidden_def.
* crypt/sha256-crypt.c (__sha256_crypt_r): Use __snprintf instead
of snprintf.
* crypt/sha512-crypt.c (__sha512_crypt_r): Likewise.

7 years agoCorrect comments in string.h re strcoll_l, strxfrm_l.
Zack Weinberg [Wed, 16 Nov 2016 19:18:32 +0000 (14:18 -0500)] 
Correct comments in string.h re strcoll_l, strxfrm_l.

* string/string.h: Remove obsolete comment stating that
strcoll_l and strxfrm_l have not yet been standardized.

7 years agoNew internal function __access_noerrno
Adhemerval Zanella [Thu, 10 Nov 2016 11:28:00 +0000 (09:28 -0200)] 
New internal function __access_noerrno

Implement an internal version of __access called __access_noerrno that
avoids setting errno.  This is useful to check accessibility of files
very early on in process startup i.e. before TLS setup.  This allows
tunables to replace MALLOC_CHECK_ safely (i.e. check existence of
/etc/suid-debug to enable/disable MALLOC_CHECK) and at the same time
initialize very early so that it can override IFUNCs.

Checked on x86_64.

* hurd/hurd.h (__hurd_fail_noerrno): New function.
* include/unistd.h [IS_IN (rtld) || !defined SHARED]: Declare
__access_noerrno.
* io/access.c (__access_noerrno): New function.
* sysdeps/mach/hurd/access.c (hurd_fail_seterrno): New function.
(hurd_fail_seterrno): Likewise.
(access_common): Likewise.
(__access_noerrno): Likewise.
* sysdeps/nacl/access.c (__access_noerrno): Likewise.
* sysdeps/unix/sysv/linux/access.c (__access_noerrno): Likewise.
* sysdeps/nacl/nacl-interfaces.h (NACL_CALL_NOERRNO): New
macro.

7 years agoFix SH4 register-dump.h for soft-float.
Joseph Myers [Wed, 16 Nov 2016 03:45:49 +0000 (03:45 +0000)] 
Fix SH4 register-dump.h for soft-float.

This patch fixes SH4 register-dump.h to declare a variable inside the
the build for soft-float.

Tested (compilation only) for SH4 soft-float.

* sysdeps/unix/sysv/linux/sh/sh4/register-dump.h (register_dump):
Only declare fpregs if [__SH_FPU_ANY__].

7 years agoMake SH ucontext always match current kernels.
Joseph Myers [Tue, 15 Nov 2016 21:44:36 +0000 (21:44 +0000)] 
Make SH ucontext always match current kernels.

As discussed in the thread starting at
<https://sourceware.org/ml/libc-alpha/2015-06/msg00657.html>, there
are various problems with the sigcontext / mcontext / ucontext
structures on SH.  The soft-float SH4 case in fact does not build at
present, with errors processing
sysdeps/unix/sysv/linux/sh/sh4/ucontext_i.sym with gen-as-const.awk
("error: 'mcontext_t {aka struct <anonymous>}' has no member named
'fpregs'").

Linux 4.8 (commit bbe6c77857c38f4acbdc4fc70399515226d1859a) moved to
always using the same sigcontext structure on SH, with room for
floating-point registers whether or not present on the processor.
This patch makes the glibc header match.

Tested (compilation only) for sh4-linux-gnu hard float, and in
conjunction with other fixes for soft float.

* sysdeps/unix/sysv/linux/sh/sys/ucontext.h [__SH4__ || __SH4A__]:
Make code unconditional.
[!(__SH4__ || __SH4A__)]: Remove conditional code.

7 years agomanual: Remove non-existent mount options S_IMMUTABLE and S_APPEND [BZ #11235]
Rical Jasan [Sun, 13 Nov 2016 08:29:27 +0000 (00:29 -0800)] 
manual: Remove non-existent mount options S_IMMUTABLE and S_APPEND [BZ #11235]

These were removed in 2010, while addressing [BZ #11235].
This commit removes their documentation from the manual.

7 years agoChangeLog: fix date
Mike Frysinger [Tue, 15 Nov 2016 19:30:03 +0000 (14:30 -0500)] 
ChangeLog: fix date

7 years agoconfigure: accept __stack_chk_fail_local for ssp support too [BZ #20662]
Denis Kaganovich [Thu, 20 Oct 2016 20:01:39 +0000 (22:01 +0200)] 
configure: accept __stack_chk_fail_local for ssp support too [BZ #20662]

When glibc is compiled with gcc 6.2 that has been configured with
--enable-default-pie and --enable-default-ssp, the configure script
fails to detect that the compiler has ssp turned on by default when
being built for i686-linux-gnu.

This is because gcc is emitting __stack_chk_fail_local but the
script is only looking for __stack_chk_fail.  Support both.

Example output:
checking whether x86_64-pc-linux-gnu-gcc -m32 -Wl,-O1 -Wl,--as-needed
implicitly enables -fstack-protector... no

7 years agos390x: Add hidden definition for __sigsetjmp
Florian Weimer [Tue, 15 Nov 2016 14:51:01 +0000 (15:51 +0100)] 
s390x: Add hidden definition for __sigsetjmp

7 years agoFix build-many-glibcs.py style issues.
Joseph Myers [Mon, 14 Nov 2016 23:48:50 +0000 (23:48 +0000)] 
Fix build-many-glibcs.py style issues.

* scripts/build-many-glibcs.py (os.path): Do not import.
(Context): Inherit explicitly from object.  Remove blank line
between class and docstring.
(Config): Likewise.
(Glibc): Likewise.
(Command): Likewise.
(CommandList): Likewise.
(Context.write_files): Store chmod mode in a variable.

7 years agoMake tilegx32 install libraries in lib32 directories.
Joseph Myers [Mon, 14 Nov 2016 23:34:54 +0000 (23:34 +0000)] 
Make tilegx32 install libraries in lib32 directories.

This patch makes tilegx32 install libraries in lib32 directories,
matching what GCC expects and avoiding conflict with 64-bit libraries
installed in lib directories.

Tested (compilation only) for tilegx (32-bit and 64-bit, BE and LE,
GCC 5).

* sysdeps/unix/sysv/linux/tile/tilegx/configure.ac: Use
LIBC_SLIBDIR_RTLDDIR for tilegx32.
* sysdeps/unix/sysv/linux/tile/tilegx/configure: Regenerated.

7 years agoForgot to add the ChangeLog to the previous commit, doh.
Zack Weinberg [Mon, 14 Nov 2016 19:29:22 +0000 (14:29 -0500)] 
Forgot to add the ChangeLog to the previous commit, doh.

7 years agoFix build-and-build-again bug in sunrpc tests.
Zack Weinberg [Mon, 14 Nov 2016 19:25:11 +0000 (14:25 -0500)] 
Fix build-and-build-again bug in sunrpc tests.

rpcgen will error out if the file it's asked to create already exists.
Several other rules in sunrpc/Makefile take care to delete rpcgen-
generated files before creating them, but rpcgen-tests doesn't, which
can lead to spurious test failures in an incremental rebuild.

* sunrpc/Makefile (rpcgen-tests): Delete the .out file before
creating or re-creating it.

7 years agoFix typo in string/bits/string2.h.
Zack Weinberg [Mon, 14 Nov 2016 17:35:10 +0000 (12:35 -0500)] 
Fix typo in string/bits/string2.h.

The comment above the bzero() macro in this file appears to have been
copied verbatim from the comment above the memset() prototype in
string.h proper.  bzero() has no 'c' argument and can only set memory
contents to 0.  (The comment above the prototype of bzero() in
string.h proper does not make the same mistake.)

* string/bits/string2.h: Fix typo in comment.

7 years ago[BZ #19239] Issue deprecation warnings on macro expansion.
Zack Weinberg [Mon, 14 Nov 2016 13:34:59 +0000 (08:34 -0500)] 
[BZ #19239] Issue deprecation warnings on macro expansion.

By using __glibc_macro_warning instead of __attribute_deprecated__,
we get the deprecation warnings whenever the macros are expanded,
not just when they compile to a function call.  This is important
for unintentional uses like the test case in #19239 (C++ var(value)
initialization syntax, with a variable named "major").  It's also
simpler, because __REDIRECT is no longer required.

* misc/sys/sysmacros.h (__SYSMACROS_DM, __SYSMACROS_DM1): New macros.
(__SYSMACROS_DEPRECATION_MSG, __SYSMACROS_FST_DECL_TEMPL)
(__SYSMACROS_FST_IMPL_TEMPL): Delete.
(major, minor, makedev): Use __SYSMACROS_DM in definition, instead
of redirected function names.

* misc/sys/cdefs.h (__glibc_macro_warning): Activate for clang >= 3.5
as well.  Document that MESSAGE must be a single string literal.

7 years agoAdd script to build many glibc configurations.
Joseph Myers [Fri, 11 Nov 2016 21:07:08 +0000 (21:07 +0000)] 
Add script to build many glibc configurations.

This patch adds a Python (3.5 or later) script to build many different
configurations of glibc, including building the required cross
compilers first.  It's not intended to change any patch testing
requirements, although some people may wish to use it for high-risk
patches such as adding warning options (and it can also be used to
test building, including compiling tests, for an individual
configuration, if e.g. you wish to do such a compilation test of a
patch for an architecture it touches).

The configurations include all the GNU/Linux ABI variants in
<https://sourceware.org/glibc/wiki/ABIList> (although some do not yet
build cleanly) and it would be desirable to cover enough other
variants e.g. for CPUs using different sysdeps directories to test
building each piece of code in glibc at least once.  It would also be
desirable to extend it to cover Hurd and NaCl, which might best be
done by people familiar with those configurations.

You call the script as

build-many-glibcs.py /some/where thing-to-do <other-arguments>

where /some/where is a working directory for the script.  It will
create and use subdirectories build, install, logs therein.  You can
use it with thing-to-do being "checkout" to create a subdirectory src
therein, with subdirectories binutils, gcc, glibc, gmp, linux, mpc,
mpfr with the sources of those components, or create those directories
manually (all except glibc can be symlinks to sources elsewhere).  In
the checkout case, by default it checks out GCC 6 branch, binutils
2.27 branch, glibc mainline and releases of other components.  You can
specify <component>-<version> to choose a version to check out, where
<version> is "vcs-mainline" or "vcs-<branch>" to check out from
version control (only supported for gcc, binutils, glibc) and
otherwise a release version number to download and use a tarball;
components not specified on the command line have default versions
checked out.  If you rerun "checkout" (with the same version
specifications) it will update checkouts from version control, but
will not detect cases where the location something is expected to be
checked out from has changed.

Other than "checkout", thing-to-do is one of host-libraries,
compilers, glibcs.  So you run, in that order:

build-many-glibcs.py /some/where host-libraries
build-many-glibcs.py /some/where compilers
build-many-glibcs.py /some/where glibcs

host-libraries is run once and then those libraries are used for all
the compilers.  compilers can be run once and then used many times for
testing different glibc versions (so a bot only needs to update glibc
and rerun the glibcs task, if using stable GCC / binutils; if testing
the latest versions of the whole toolchain together including mainline
GCC, it would probably want to update everything and rerun both
compilers and glibcs).  You can also name particular variants after
"compilers" or "glibcs" to build just those variants (the possible
variants are hardcoded in the script).

I may add support for allowing the set of configurations to depend on
the GCC version (to get cleaner default results), and optionally
looping over architecture-independent glibc variants of CFLAGS and
configure options as well, for every glibc configuration listed
(e.g. -Os).

GCC versions before 4.9 are not expected to work (the code uses
--with-glibc-version to get the bootstrap GCC appropriately
configured).  There are various problems for particular configurations
as well.

Command-line options to the script: -jN to run N jobs in parallel
(default the number of CPU cores reported by the system); --keep=all
or --keep=failed to control keeping around build directories (default
--keep=none).

* scripts/build-many-glibcs.py: New file.

7 years agoIgnore -Wmaybe-uninitialized in stdlib/bug-getcontext.c.
Joseph Myers [Fri, 11 Nov 2016 21:05:51 +0000 (21:05 +0000)] 
Ignore -Wmaybe-uninitialized in stdlib/bug-getcontext.c.

Doing all-ABIs compile testing produces a compiler warning in
stdlib/bug-getcontext.c on nios2 and tilepro (with GCC 5 branch):

bug-getcontext.c: In function 'do_test':
bug-getcontext.c:53:6: error: 'except_mask' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   if (mask != except_mask)
      ^

This warning appears nonsensical; except_mask is initialized where
it's declared.  I think what must be happening here is that the
compiler is confused by the returns-twice nature of getcontext: if
there were a call to setcontext, local variables could indeed have
lost their values on the second return from getcontext.  This patch
duly uses the DIAG_* macros to disable the warning here.

Tested for nios2 and tilepro (compilation only; after this patch all
the tests compile, though there are other failures) and x86_64 (full
testsuite run).

* stdlib/bug-getcontext.c: Include <libc-internal.h>.
(do_test): Disable -Wmaybe-uninitialized around uses of
except_mask.

7 years agoMake SH <sys/user.h> self-contained.
Joseph Myers [Fri, 11 Nov 2016 21:04:28 +0000 (21:04 +0000)] 
Make SH <sys/user.h> self-contained.

The check-installed-headers tests show up that the SH <sys/user.h> is
not self-contained, using size_t without including any header that
defines it.  This patch fixes it by including <stddef.h>, as done for
other architectures' versions of this header.

Tested for SH3 and SH4 (compilation only).

* sysdeps/unix/sysv/linux/sh/sys/user.h: Include <stddef.h>.

7 years agoMake sure tilepro uses kernel atomics fo atomic_store
Chris Metcalf [Fri, 11 Nov 2016 01:08:24 +0000 (20:08 -0500)] 
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.

7 years agoRefactor some libm type-generic macros.
Joseph Myers [Thu, 10 Nov 2016 21:41:56 +0000 (21:41 +0000)] 
Refactor some libm type-generic macros.

This patch refactors some type-generic libm macros, in both math.h and
math_private.h, to be based on a common __MATH_TG macro rather than
all replicating similar logic to choose a function to call based on
the type of the argument.

This should serve to illustrate what I think float128 support for such
macros should look like: common macros such as __MATH_TG may need
different definitions depending on whether float128 is supported in
glibc, so that the individual macros themselves do not need
conditionals on float128 support.

Tested for x86_64, x86, mips64 and powerpc.

* math/math.h (__MATH_TG): New macro.
[__USE_ISOC99] (fpclassify): Define using __MATH_TG.
[__USE_ISOC99] (signbit): Likewise.
[__USE_ISOC99] (isfinite): Likewise.
[__USE_ISOC99] (isnan): Likewise.
[__USE_ISOC99] (isinf): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (issignaling): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (__MATH_EVAL_FMT2): New macro.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (iseqsig): Define using
__MATH_TG and __MATH_EVAL_FMT2.
* sysdeps/generic/math_private.h (fabs_tg): Define using
__MATH_TG.
* sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h
[!__NO_LONG_DOUBLE_MATH] (__iscanonicalf): New macro.
[!__NO_LONG_DOUBLE_MATH] (__iscanonical): Likewise.
[!__NO_LONG_DOUBLE_MATH] (iscanonical): Define using __MATH_TG.
* sysdeps/ieee754/ldbl-96/bits/iscanonical.h (__iscanonicalf): New
macro.
(__iscanonical): Likewise.
(iscanonical): Define using __MATH_TG.

7 years agoFix sh4 build with __ASSUME_ST_INO_64_BIT redefinition
Adhemerval Zanella [Wed, 9 Nov 2016 12:33:34 +0000 (10:33 -0200)] 
Fix sh4 build with __ASSUME_ST_INO_64_BIT redefinition

Since 327792c sh4 builds fails with:

../sysdeps/unix/sysv/linux/kernel-features.h:49:0: error: "__ASSUME_ST_INO_64_BIT" redefined [-Werror]
 #define __ASSUME_ST_INO_64_BIT  1
 ^
In file included from ../sysdeps/unix/sysv/linux/sysdep.h:19:0,
                 from ../sysdeps/unix/sysv/linux/sh/sysdep.h:24,
                 from ../sysdeps/unix/sysv/linux/sh/sh4/sysdep.h:4,
                 from <stdin>:1:
../sysdeps/unix/sysv/linux/sh/kernel-features.h:47:0: note: this is the location of the previous definition
 #define __ASSUME_ST_INO_64_BIT 0

It is because sh4 kernel-features.sh is included multiple times
without guards and this patch fixes by adding them.

Tested on a sh4-linux-gnu build.

* sysdeps/unix/sysv/linux/sh/kernel-features.h: Add include
guards.

7 years agoConsolidate Linux access implementation
Adhemerval Zanella [Thu, 10 Nov 2016 11:24:34 +0000 (09:24 -0200)] 
Consolidate Linux access implementation

This patch consolidates the Linux access implementation on
sysdeps/unix/sysv/linux/access.c.  Similar to auto-generation through
syscalls.list, __NR_access is check and __NR_faccessat is used only
for newer architectures (where __NR_access is not defined).

Checked on x86_64.

* sysdeps/unix/sysv/linux/access.c: New file.
* sysdeps/unix/sysv/linux/generic/access.c: Remove file.

7 years agoAdd definitions to sysdeps/tile/tilepro/bits/wordsize.h.
Steve Ellcey [Thu, 10 Nov 2016 15:46:18 +0000 (07:46 -0800)] 
Add definitions to sysdeps/tile/tilepro/bits/wordsize.h.

* sysdeps/tile/tilepro/bits/wordsize.h: Define __WORDSIZE32_SIZE_ULONG
and __WORDSIZE32_PTRDIFF_LONG.

7 years agoRegenerate ULPs for aarch64
Siddhesh Poyarekar [Thu, 10 Nov 2016 11:22:35 +0000 (16:52 +0530)] 
Regenerate ULPs for aarch64

* sysdeps/aarch64/libm-test-ulps: Regenerated.

7 years agoConsolidate Linux truncate implementations
Adhemerval Zanella [Fri, 26 Aug 2016 15:19:18 +0000 (12:19 -0300)] 
Consolidate Linux truncate implementations

This patch consolidates all Linux truncate implementation on
sysdeps/unix/sysv/linux/truncate{64}.c.  It is based on
{INTERNAL,INLINE}_SYSCALL patch [1] to simplify the syscall
construction.

General idea is to build ftruncate iff __OFF_T_MATCHES_OFF64_T is not
defined, otherwise ftruncate64 will be build and ftruncate will be an
alias.  The fallocate will use old compat syscall and pass 32-bit off_t
argument, while fallocate64 will handle the correct off64_t passing using
__ALIGNMENT_ARG and SYSCALL_LL64 macros.

Tested on x86_64, i386, aarch64, and armhf.

* sysdeps/unix/sysv/linux/arm/truncate64.c: Remove file.
* sysdeps/unix/sysv/linux/generic/wordsize-32/truncate.c: Likewise.
* sysdeps/sysv/linux/generic/wordsize-32/truncate64.c: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/truncate64.c: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/truncate64.c: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/truncate64.c: Likewise.
* sysdeps/unix/sysv/linux/wordsize-64/truncate64.c: Likewise.
* sysdeps/unix/sysv/linux/truncate.c: New file.
* sysdeps/unix/sysv/linux/truncate64.c (truncate64): Use
INLINE_SYSCALL_CALL, __ALIGNMENT_ARG and SYSCALL_LL64 macros.
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (truncate):
Remove.
* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list (truncate):
Likewise.

[1] https://sourceware.org/ml/libc-alpha/2016-08/msg00646.html

7 years agoConsolidate Linux ftruncate implementations
Adhemerval Zanella [Fri, 26 Aug 2016 13:42:58 +0000 (10:42 -0300)] 
Consolidate Linux ftruncate implementations

THis patch consolidates all Linux ftruncate implementation on
sysdeps/unix/sysv/linux/ftruncate{64}.c.  It is based on
{INTERNAL,INLINE}_SYSCALL patch [1] to simplify the syscall construction.

General idea is to build ftruncate iff __OFF_T_MATCHES_OFF64_T is not
defined, otherwise ftruncate64 will be build and ftruncate will be an
alias.  The fallocate will use old compat syscall and pass 32-bit off_t
argument, while fallocate64 will handle the correct off64_t passing using
__ALIGNMENT_ARG and SYSCALL_LL64 macros.

Tested on x86_64, i386, aarch64, and armhf.

* posix/tst-truncate-common.c: New file.
* posix/tst-truncate.c: Use tst-truncate-common.c.
* posix/tst-truncate64.c: Likewise and add LFS tests.
* sysdeps/unix/sysv/linux/arm/ftruncate64.c: Remove file.
* sysdeps/unix/sysv/linux/generic/wordsize-32/ftruncate.c: Likewise.
* sysdeps/unix/sysv/linux/generic/wordsize-32/ftruncate64.c: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/ftruncate64.c: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/ftruncate64.c: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/ftruncate64.c: Likewise.
* sysdeps/unix/sysv/linux/wordsize-64/ftruncate64.c: Likewise.
* sysdeps/unix/sysv/linux/ftruncate.c: New file.
* sysdeps/unix/sysv/linux/ftruncate64.c (__ftruncate64): Use
INLINE_SYSCALL_CALL, __ALIGNMENT_ARG and SYSCALL_LL64 macros.
[__OFF_T_MATCHES_OFF64_T] (ftruncate): Add alias.
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (ftruncate):
Remove.
* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list (ftruncate):
Likewise.

[1] https://sourceware.org/ml/libc-alpha/2016-08/msg00646.html

7 years agoFix rpcgen buffer overrun (bug 20790).
Joseph Myers [Tue, 8 Nov 2016 23:44:51 +0000 (23:44 +0000)] 
Fix rpcgen buffer overrun (bug 20790).

Building with GCC 7 produces an error building rpcgen:

rpc_parse.c: In function 'get_prog_declaration':
rpc_parse.c:543:25: error: may write a terminating nul past the end of the destination [-Werror=format-length=]
     sprintf (name, "%s%d", ARGNAME, num); /* default name of argument */
                     ~~~~^
rpc_parse.c:543:5: note: format output between 5 and 14 bytes into a destination of size 10
     sprintf (name, "%s%d", ARGNAME, num); /* default name of argument */
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

That buffer overrun is for the case where the .x file declares a
program with a million arguments.  The strcpy two lines above can
generate a buffer overrun much more simply for a long argument name.

The limit on length of line read by rpcgen (MAXLINESIZE == 1024)
provides a bound on the buffer size needed, so this patch just changes
the buffer size to MAXLINESIZE to avoid both possible buffer
overruns.  A testcase is added that rpcgen does not crash with a
500-character argument name, where it previously crashed.

It would not at all surprise me if there are many other ways of
crashing rpcgen with either valid or invalid input; fuzz testing would
likely find various such bugs, though I don't think they are that
important to fix (rpcgen is not that likely to be used with untrusted
.x files as input).  (As well as fuzz-findable bugs there are probably
also issues when various int variables get overflowed on very large
input.)  The test infrastructure for rpcgen-not-crashing tests would
need extending if tests are to be added for cases where rpcgen should
produce an error, as opposed to cases where it should succeed.

Tested for x86_64 and x86.

[BZ #20790]
* sunrpc/rpc_parse.c (get_prog_declaration): Increase buffer size
to MAXLINESIZE.
* sunrpc/bug20790.x: New file.
* sunrpc/Makefile [$(run-built-tests) = yes] (rpcgen-tests): New
variable.
[$(run-built-tests) = yes] (tests-special): Add $(rpcgen-tests).
[$(run-built-tests) = yes] ($(rpcgen-tests)): New rule.

7 years agoAdd localplt.data for sh.
Joseph Myers [Tue, 8 Nov 2016 23:43:17 +0000 (23:43 +0000)] 
Add localplt.data for sh.

This patch adds a localplt.data file for sh so that test passes.  The
architecture-specific entries are for _Unwind_Find_FDE, _exit and
__errno_location.

Tested for sh3 and sh4.

* sysdeps/unix/sysv/linux/sh/localplt.data: New file.

7 years agoAdd localplt.data for hppa.
Joseph Myers [Tue, 8 Nov 2016 23:42:36 +0000 (23:42 +0000)] 
Add localplt.data for hppa.

This patch adds a localplt.data file for hppa so that test passes.
Architecture maintainers should feel free to clean up the sysdeps code
so that some or all of the system-specific entries

libc.so: _exit
libc.so: __sigsetjmp
libc.so: _IO_funlockfile
libc.so: sigprocmask
libc.so: __errno_location
libpthread.so: __errno_location

are no longer needed.

Tested for hppa.  Note: check-execstack and check-textrel still fail;
you may wish to look at those to get to a clean baseline there (they
are less obvious for people not familiar with the architecture).

* sysdeps/unix/sysv/linux/hppa/localplt.data: New file.

7 years agoUpdate alpha localplt.data.
Joseph Myers [Tue, 8 Nov 2016 23:41:51 +0000 (23:41 +0000)] 
Update alpha localplt.data.

This patch updates alpha localplt.data so the localplt test passes in
my compile-only all-ABIs glibc testing.  The failures I see without
this patch are:

Missing required PLT reference: ld.so: __tls_get_addr
Missing required PLT reference: ld.so: free

Now, __tls_get_addr can be made optional.  For free, rather than
making it optional as in libc.so it seems better to mark all the
malloc-related symbols in both libc.so and ld.so as allowing an
R_ALPHA_GLOB_DAT relocation as an alternative to using a PLT entry, so
this patch does so.

Tested for alpha.

* sysdeps/unix/sysv/linux/alpha/localplt.data: Make __tls_get_addr
optional in ld.so.  Allow R_ALPHA_GLOB_DAT relocation for malloc,
calloc, realloc, free, memalign and __libc_memalign rather than
making them optional.

7 years agoUpdate nios2 localplt.data.
Joseph Myers [Tue, 8 Nov 2016 23:41:05 +0000 (23:41 +0000)] 
Update nios2 localplt.data.

This patch updates nios2 localplt.data so the localplt test passes in
my compile-only all-ABIs glibc testing.  A new PLT entry for
__extendsfdf2 is added.

Tested for nios2.

* sysdeps/unix/sysv/linux/nios2/localplt.data: Add __extendsfdf2
for libc.so.

7 years agoConsolidate lseek/lseek64/llseek implementations
Adhemerval Zanella [Thu, 25 Aug 2016 20:42:44 +0000 (17:42 -0300)] 
Consolidate lseek/lseek64/llseek implementations

This patch consolidates all Linux lseek/lseek64/llseek implementation
in on on sysdeps/unix/sysv/linux/lseek{64}.c.  It also removes the llseek
file and instead consolidate the LFS lseek implementation on lseek64.c
as for other LFS symbols implementations.

The general idea is:

  - lseek: ABIs that not define __OFF_T_MATCHES_OFF64_T will preferable
  use __NR__llseek if kernel supports it, otherwise they will use __NR_lseek.
  ABIs that defines __OFF_T_MATCHES_OFF64_T won't produce any symbol.

  - lseek64: ABIs with __OFF_T_MATCHES_OFF64_T will preferable use __NR_lseek
  (since it will use 64-bit arguments without low/high splitting) and
  __NR__llseek if __NR_lseek is not defined (for some ILP32 ports).

  - llseek: files will be removed and symbols will be aliased ot lseek64.

ABI without __OFF_T_MATCHES_OFF64_T and without __NR_llseek (basically MIPS64n32
so far) are covered by building lseek with off_t as expected and lseek64
using __NR_lseek (as expected for off64_t being passed using 64-bit registers).

For this consolidation I mantained the x32 assembly specific implementation
because to correctly fix this it would required both the x32 fix for
{INLINE,INTERNAL}_SYSCALL [1] and a wrapper to correctly subscribe it to
return 64 bits instead of default 32 bits (as for times).  It could a future
cleanup.

It is based on my previous {INTERNAL,INLINE}_SYSCALL_CALL macro [2],
although it is mainly for simplification.

Tested on x86_64, i686, aarch64, armhf, and powerpc64le.

* nptl/Makefile (libpthread-routines): Remove ptw-llseek and add
ptw-lseek64.
* sysdeps/unix/sysv/linux/Makefile (sysdeps_routines): Remove llseek.
* sysdeps/unix/sysv/linux/alpha/Makefile  (sysdeps_routines):
Likewise.
* sysdeps/unix/sysv/linux/generic/wordsize-32/llseek.c: Remove file.
* sysdeps/unix/sysv/linux/generic/wordsize-32/lseek.c: Remove file.
* sysdeps/unix/sysv/linux/mips/mips64/llseek.c: Likewise.
* sysdeps/unix/sysv/linux/llseek.c: Remove file.
* sysdeps/unix/sysv/linux/lseek.c: New file.
* sysdeps/unix/sysv/linux/lseek64.c: Add default Linux implementation.
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list: Remove lseek and
__libc_lseek64 from auto-generation.
* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/lseek64.S: New file.

[1] https://sourceware.org/ml/libc-alpha/2016-08/msg00443.html
[2] https://sourceware.org/ml/libc-alpha/2016-08/msg00646.html

7 years agoWrite messages to stdout and use write_message instead of write
Gabriel F. T. Gomes [Tue, 1 Nov 2016 00:09:12 +0000 (22:09 -0200)] 
Write messages to stdout and use write_message instead of write

Replaces calls to write on file descriptor 2 with calls to write_message,
which writes to STDOUT_FILENO (1) and properly deals with the return of
write.

7 years agoUse write_message instead of write
Gabriel F. T. Gomes [Mon, 31 Oct 2016 01:51:27 +0000 (23:51 -0200)] 
Use write_message instead of write

In the test cases, there are writes to stdout which do not check the result
value.  This patch replaces such occurrences with calls to write_message,
which properly deals with the unused result.

Tested for powerpc64le.

7 years agoMake check-installed-headers.sh ignore sys/sysctl.h for x32.
Joseph Myers [Mon, 7 Nov 2016 23:32:17 +0000 (23:32 +0000)] 
Make check-installed-headers.sh ignore sys/sysctl.h for x32.

check-installed-headers tests were failing for x32 because of the x86
bits/sysctl.h containing a #error for x32.  This patch makes the tests
ignore sys/sysctl.h for x32, similar to the other special-casing of
particular headers.

Tested for x86_64 (full testing for -m64, compile-only for x32).

* scripts/check-installed-headers.sh: Ignore sys/sysctl.h for x32.

7 years agoDefine __ASSUME_ST_INO_64_BIT on all platforms.
Steve Ellcey [Mon, 7 Nov 2016 21:26:27 +0000 (13:26 -0800)] 
Define __ASSUME_ST_INO_64_BIT on all platforms.

* sysdeps/unix/sysv/linux/alpha/kernel-features.h: #define
  __ASSUME_ST_INO_64_BIT as 0
* sysdeps/unix/sysv/linux/sh/kernel-features.h: Likewise.
* sysdeps/unix/sysv/linux/fxstat64.c: Replace #ifdef with #if
  over the code where __ASSUME_ST_INO_64_BIT is used.
* sysdeps/unix/sysv/linux/lxstat64.c: Likewise.
* sysdeps/unix/sysv/linux/xstat64.c: Likewise.
* sysdeps/unix/sysv/linux/xstatconv.c: Likewise.

7 years agonptl: Document the reason why __kind in pthread_mutex_t is part of the ABI
Florian Weimer [Mon, 7 Nov 2016 13:38:12 +0000 (14:38 +0100)] 
nptl: Document the reason why __kind in pthread_mutex_t is part of the ABI

7 years agoDocument do_test in test-skeleton.c
Steve Ellcey [Mon, 7 Nov 2016 16:28:52 +0000 (08:28 -0800)] 
Document do_test in test-skeleton.c

* test-skeleton.c: Document do_test usage.

7 years agogconv.h: fix build with GCC 7
Aurelien Jarno [Sun, 6 Nov 2016 20:33:10 +0000 (21:33 +0100)] 
gconv.h: fix build with GCC 7

gconv.h is using a flex array to define the __gconv_info member in an
invalid way, causing GCC 7 to issue an error:

| In file included from ../include/gconv.h:1:0,
|                  from ../sysdeps/unix/sysv/linux/_G_config.h:32,
|                  from ../libio/libio.h:31,
|                  from ../include/libio.h:4,
|                  from ../libio/stdio.h:74,
|                  from ../include/stdio.h:5,
|                  from test-math-isinff.cc:22:
| ../iconv/gconv.h:142:50: error: flexible array member '__gconv_info::__data' not at end of 'struct _IO_codecvt'
| In file included from ../include/libio.h:4:0,
|                  from ../libio/stdio.h:74,
|                  from ../include/stdio.h:5,
|                  from test-math-isinff.cc:22:
| ../libio/libio.h:211:14: note: next member '_G_iconv_t _IO_codecvt::__cd_out' declared here
| ../libio/libio.h:187:8: note: in the definition of 'struct _IO_codecvt'
| In file included from ../include/gconv.h:1:0,
|                  from ../sysdeps/unix/sysv/linux/_G_config.h:32,
|                  from ../libio/libio.h:31,
|                  from ../include/libio.h:4,
|                  from ../libio/stdio.h:74,
|                  from ../include/stdio.h:5,
|                  from test-math-isinff.cc:22:
| ../iconv/gconv.h:142:50: error: flexible array member '__gconv_info::__data' not at end of 'struct _IO_wide_data'
| In file included from ../include/libio.h:4:0,
|                  from ../libio/stdio.h:74,
|                  from ../include/stdio.h:5,
|                  from test-math-isinff.cc:22:
| ../libio/libio.h:211:14: note: next member '_G_iconv_t _IO_codecvt::__cd_out' declared here
| ../libio/libio.h:215:8: note: in the definition of 'struct _IO_wide_data'

This is basically a revert to the code from 15 years ago. More details
are available in the GCC bug:
  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78039

Changelog:
* iconv/gconv.h (__gconv_info): Define __data element using a
zero-length array.

7 years agoSpeed up math/test-tgmath2.c
Steve Ellcey [Fri, 4 Nov 2016 22:59:22 +0000 (15:59 -0700)] 
Speed up math/test-tgmath2.c

* math/test-tgmath2.c: Split up test function.