platform/upstream/glibc.git
7 years agoManual typos: Mathematics
Rical Jasan [Thu, 6 Oct 2016 06:41:07 +0000 (12:11 +0530)]
Manual typos: Mathematics

2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

* manual/math.texi: Fix typos in the manual.

7 years agoManual typos: Syslog
Rical Jasan [Thu, 6 Oct 2016 06:38:46 +0000 (12:08 +0530)]
Manual typos: Syslog

2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

* manual/syslog.texi: Fix typos in the manual.

7 years agoManual typos: Low-Level Terminal Interface
Rical Jasan [Thu, 6 Oct 2016 06:37:28 +0000 (12:07 +0530)]
Manual typos: Low-Level Terminal Interface

2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

* manual/terminal.texi: Fix typos in the manual.

7 years agoManual typos: Sockets
Rical Jasan [Thu, 6 Oct 2016 06:35:11 +0000 (12:05 +0530)]
Manual typos: Sockets

2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

* manual/socket.texi: Fix typos in the manual.

7 years agoManual typos: File System Interface
Rical Jasan [Thu, 6 Oct 2016 06:31:51 +0000 (12:01 +0530)]
Manual typos: File System Interface

2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

* manual/filesys.texi: Fix typos in the manual.

7 years agoManual typos: Low-Level Input/Output
Rical Jasan [Thu, 6 Oct 2016 06:28:02 +0000 (11:58 +0530)]
Manual typos: Low-Level Input/Output

2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

* manual/llio.texi: Fix typos in the manual.

7 years agoManual typos: Input/Output on Streams
Rical Jasan [Thu, 6 Oct 2016 06:25:58 +0000 (11:55 +0530)]
Manual typos: Input/Output on Streams

2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

* manual/stdio.text: Fix typos in the manual.

7 years agoCheck n instead of k1 to decide on sign of sin/cos result
Siddhesh Poyarekar [Wed, 5 Oct 2016 19:04:26 +0000 (00:34 +0530)]
Check n instead of k1 to decide on sign of sin/cos result

For k1 in 1 and 3, n can only have values of 0 and 2, so checking k1 &
2 is equivalent to checking n & 2.  We prefer the latter so that we
don't use k1 for anything other than selecting the quadrant in
do_sincos_1, thus dropping it completely.

The previous logic was:

    "Compute sine for the value and based on the new rotated quadrant
     (k1) negate the value if we're in the fourth quadrant."

With this change, the logic now is:

    "Compute sine for the value and negate it if we were either (1) in
     the fourth quadrant or (2) we actually wanted the cosine and were
     in the third quadrant."

* sysdeps/ieee754/dbl-64/s_sin.c (do_sincos_1): Check N
instead of K1.

7 years agoMake the quadrant shift K a bool in do_sincos_* functions
Siddhesh Poyarekar [Wed, 5 Oct 2016 19:03:54 +0000 (00:33 +0530)]
Make the quadrant shift K a bool in do_sincos_* functions

The do_sincos_* functions are helpers to compute sin/cos, where they
get cosine by computing sine for the next quadrant.  This is decided
with the value of K passed to it, which is the amount by which to
shift the quadrant.  Since we will only need the shift to be 0 or 1,
we make K a bool to make that explicit.

* sysdeps/ieee754/dbl-64/s_sin.c (do_sincos_1): Rename K to
SHIFT_QUADRANT and make it bool.
(do_sincos_2): Likewise.
(sloww): Likewise.
(sloww1): Likewise.
(__sin): Adjust calls to do_sincos_1 and do_sincos_2.
(__cos): Likewise.

7 years agopowerpc: Regenerate ULPs
Tulio Magno Quites Machado Filho [Wed, 5 Oct 2016 11:57:47 +0000 (08:57 -0300)]
powerpc: Regenerate ULPs

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

7 years agoFix LONG_WIDTH, ULONG_WIDTH include ordering issue.
Joseph Myers [Tue, 4 Oct 2016 16:17:59 +0000 (16:17 +0000)]
Fix LONG_WIDTH, ULONG_WIDTH include ordering issue.

As described in
<https://sourceware.org/ml/libc-alpha/2016-10/msg00047.html>, there is
an include ordering issue with the integer width macros in glibc's
<limits.h>, where definitions conditional on LONG_MAX do not work as
intended because when the headers are installed, this part of glibc's
<limits.h> is processed before the part of GCC's <limits.h> that will
define LONG_MAX.  This patch changes the definitions just to use
__WORDSIZE for the expansion of LONG_WIDTH and ULONG_WIDTH rather than
making those definitions conditional on LONG_MAX.

Tested for x86_64 and x86.

* include/limits.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (LONG_WIDTH):
Define to __WORDSIZE, not conditional on [LONG_MAX ==
0x7fffffffL].
[__GLIBC_USE (IEC_60559_BFP_EXT)] (ULONG_WIDTH): Likewise.

7 years agopowerpc: Installed-header hygiene
Tulio Magno Quites Machado Filho [Tue, 4 Oct 2016 13:54:40 +0000 (10:54 -0300)]
powerpc: Installed-header hygiene

Fix powerpc-specific headers:
 - Make it compatible to C89 by replace references to inline by __inline__.
 - Get the definition of sigset_t used by
   sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h.
 - Includes missing header file.

7 years agoS390: Regenerate ULPs
Stefan Liebler [Tue, 4 Oct 2016 13:27:40 +0000 (15:27 +0200)]
S390: Regenerate ULPs

Regenerated ulps file after recent commit "Use __builtin_fma more in dbl-64 code.".

ChangeLog:

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

7 years agoAdd TCP_REPAIR_WINDOW from Linux 4.8.
Joseph Myers [Mon, 3 Oct 2016 21:01:42 +0000 (21:01 +0000)]
Add TCP_REPAIR_WINDOW from Linux 4.8.

Linux 4.8 adds TCP_REPAIR_WINDOW to include/uapi/linux/tcp.h.  This
patch adds it to sysdeps/gnu/netinet/tcp.h accordingly, along with
struct tcp_repair_window as requested in
<https://sourceware.org/ml/libc-alpha/2016-10/msg00019.html>.

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

* sysdeps/gnu/netinet/tcp.h (TCP_REPAIR_WINDOW): New macro.
(struct tcp_repair_window): New type.

7 years agoFix tst-memstream3 build failure
Adhemerval Zanella [Sun, 2 Oct 2016 13:24:32 +0000 (10:24 -0300)]
Fix tst-memstream3 build failure

Add string.h to avoid tst-memstream3 build failure in some environments:

 tst-memstream3.c:32:17: error: implicit declaration of function 'strcmp' [-Werror=implicit-function-declaration]
  # define STRCMP strcmp
                  ^
 tst-memstream3.c:96:7: note: in expansion of macro 'STRCMP'
    if (STRCMP (buf, W("b")) != 0)

Checked on x86_64.

* libio/tst-memstream3.c: Include string.h.

7 years agolibio: Multiple fixes for open_{w}memstram (BZ#18241 and BZ#20181)
Adhemerval Zanella [Mon, 25 Jul 2016 17:54:29 +0000 (14:54 -0300)]
libio: Multiple fixes for open_{w}memstram (BZ#18241 and BZ#20181)

This patches fixes multiples issues on open_{w}memstream reported on both
BZ#18241 and BZ#20181:

  - failed fseek does not set errno.
  - negative offset in fseek fails even when resulting position is
    a valid one.
  - a flush after write if the current write position is not at the
    end of the stream currupt data.

The main fix is on seek operation for memstream (_IO_{w}str_seekoff), where
both _IO_read_ptr and _IO_read_end pointer are updated if a write operation
has occured (similar to default file operations).  Also, to calculate the
offset on both read and write pointers, a temporary value is instead of
updating the argument supplied value.  Negative offset are valid if resulting
internal pointer is within the range of _IO_{read,write}_base and
_IO_{read,write}_end.

Also POSIX states that a null or wide null shall be appended to the current
buffer iff a write moves the position to a value larger than the current
lenght.  Current implementation appends a null or wide null regardless
of this condition.  This patch fixes it by removing the 'else' condition
on _IO_{w}mem_sync.

Checked on x86_64.

[BZ #18241]
[BZ #20181]
* libio/Makefile (test): Add tst-memstream3 and tst-wmemstream3.
* libio/memstream.c (_IO_mem_sync): Only append a null byte if
write position is at the end the buffer.
* libio/wmemstream.c (_IO_wmem_sync): Likewise.
* libio/strops.c (_IO_str_switch_to_get_mode): New function.
(_IO_str_seekoff): Set correct offset from negative displacement and
set EINVAL for invalid ones.
* libio/wstrops.c (enlarge_userbuf): Use correct function to calculate
buffer length.
(_IO_wstr_switch_to_get_mode): New function.
(_IO_wstr_seekoff): Set correct offset from negative displacement and
set EINVAL for invalid ones.
* libio/tst-memstream3.c: New file.
* libio/tst-wmemstream3.c: Likewise.
* manual/examples/memstrm.c: Remove warning when priting size_t.

7 years agoUse __builtin_fma more in dbl-64 code.
Joseph Myers [Fri, 30 Sep 2016 15:49:51 +0000 (15:49 +0000)]
Use __builtin_fma more in dbl-64 code.

sysdeps/ieee754/dbl-64/dla.h can use a macro DLA_FMS for more
efficient double-width operations when fused multiply-subtract is
supported.  However, this macro is only defined for x86_64,
conditional on architecture-specific __FMA4__.  This patch makes the
code use __builtin_fma conditional on __FP_FAST_FMA, as used elsewhere
in glibc.

Tested for x86_64, x86 and powerpc.  On powerpc (where this is causing
fused operations to be used where they weren't previously) I see an
increase from 1ulp to 2ulp in the imaginary part of clog10:

testing double (without inline functions)
Failure: Test: Imaginary part of: clog10 (0x1.7a858p+0 - 0x6.d940dp-4 i)
Result:
 is:         -1.2237865208199886e-01  -0x1.f5435146bb61ap-4
 should be:  -1.2237865208199888e-01  -0x1.f5435146bb61cp-4
 difference:  2.7755575615628914e-17   0x1.0000000000000p-55
 ulp       :  2.0000
 max.ulp   :  1.0000
Maximal error of real part of: clog10
 is      : 3 ulp
 accepted: 3 ulp
Maximal error of imaginary part of: clog10
 is      : 2 ulp
 accepted: 1 ulp

This is actually resulting from atan2 becoming *more* accurate (atan2
(-0x6.d940dp-4, 0x1.7a858p+0) should ideally be -0x1.208cd6e841554p-2
but was -0x1.208cd6e841555p-2 from a powerpc libm built before this
change, and is -0x1.208cd6e841554p-2 from a powerpc libm built after
this change).  Since these functions are not expected to be correctly
rounding by glibc's accuracy goals, neither result is a problem, but
this does imply that some of this code, although designed to be
correctly rounding, is not in fact correctly rounding (possibly
because of GCC creating fused operations where the code does not
expect it, something we've only disabled for specific functions where
it was found to cause large errors).  (Of course as previously
discussed I think we should remove the slow cases where an error
analysis shows this wouldn't increase the errors much above 0.5ulp;
it's only functions such as cratan2 that are expected to be correctly
rounding, not atan2.)

* sysdeps/ieee754/dbl-64/dla.h [__FP_FAST_FMA] (DLA_FMS): Define
macro to use __builtin_fma.
* sysdeps/x86_64/fpu/dla.h: Remove file.

7 years agoFix ldbl-128ibm iscanonical for -mlong-double-64.
Joseph Myers [Fri, 30 Sep 2016 15:08:08 +0000 (15:08 +0000)]
Fix ldbl-128ibm iscanonical for -mlong-double-64.

This patch fixes the ldbl-128ibm version of the iscanonical macro not
to use __iscanonicall when long double = double (-mlong-double-64).

Tested for powerpc.

* sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h
[__NO_LONG_DOUBLE_MATH] (__iscanonicall): Do not declare.
[__NO_LONG_DOUBLE_MATH] (iscanonical): Define to evaluate to 1.

7 years agoBug 20292 - Simplify and test _dl_addr_inside_object
Carlos O'Donell [Fri, 30 Sep 2016 01:54:31 +0000 (21:54 -0400)]
Bug 20292 - Simplify and test _dl_addr_inside_object

The function _dl_addr_inside_object is simplified by removing
the conditional 'reladdr - l->l_phdr[n].p_vaddr >= 0' which is
always true. The function is refactored into it's own object file
and a unit test added to verify the correct behaviour of the
function.

7 years agoAdd iscanonical.
Joseph Myers [Fri, 30 Sep 2016 00:24:19 +0000 (00:24 +0000)]
Add iscanonical.

TS 18661-1 adds an iscanonical classification macro to <math.h>.

The motivation for this is decimal floating-point, where some values
have both canonical and noncanonical encodings.  For IEEE binary
interchange formats, all encodings are canonical.  For x86/m68k
ldbl-96, and for ldbl-128ibm, there are encodings that do not
represent any valid value of the type; although formally iscanonical
does not need to handle trap representations (and so could just always
return 1), it seems useful, and in line with the description in the TS
of "representations that are extraneous to the floating-point model"
as being non-canonical (as well as "redundant representations of some
or all of its values"), for it to detect those representations and
return 0 for them.

This patch adds iscanonical to glibc.  It goes in a header
<bits/iscanonical.h>, included under appropriate conditions in
<math.h>.  The default header version just evaluates the argument
(converted to its semantic type, though current GCC will probably
discard that conversion and any exceptions resulting from it) and
returns 1.  ldbl-96 and ldbl-128ibm then have versions of the header
that call a function __iscanonicall for long double (the sizeof-based
tests will of course need updating for float128 support, like other
such type-generic macro implementations).  The ldbl-96 version of
__iscanonicall has appropriate conditionals to reflect the differences
in the m68k version of that format (where the high mantissa bit may be
either 0 or 1 when the exponent is 0 or 0x7fff).  Corresponding tests
for those formats are added as well.  Other architectures do not have
any new functions added because just returning 1 is correct for all
their floating-point formats.

Tested for x86_64, x86, mips64 (to test the default macro version) and
powerpc.

* math/math.h [__GLIBC_USE (IEC_60559_BFP_EXT)]: Include
<bits/iscanonical.h>.
* bits/iscanonical.h: New file.
* math/s_iscanonicall.c: Likewise.
* math/Versions (__iscanonicall): New libm symbol at version
GLIBC_2.25.
* math/libm-test.inc (iscanonical_test_data): New array.
(iscanonical_test): New function.
(main): Call iscanonical_test.
* math/Makefile (headers): Add bits/iscanonical.h.
(type-ldouble-routines): Add s_iscanonicall.
* manual/arith.texi (Floating Point Classes): Document
iscanonical.
* manual/libm-err-tab.pl: Update comment on interfaces without
ulps tabulated.
* sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h: New file.
* sysdeps/ieee754/ldbl-128ibm/s_iscanonicall.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/test-iscanonical-ldbl-128ibm.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm/Makefile (tests): Add
test-iscanonical-ldbl-128ibm.
* sysdeps/ieee754/ldbl-96/bits/iscanonical.h: New file.
* sysdeps/ieee754/ldbl-96/s_iscanonicall.c: Likewise.
* sysdeps/ieee754/ldbl-96/test-iscanonical-ldbl-96.c: Likewise.
* sysdeps/ieee754/ldbl-96/Makefile: Likewise.
* sysdeps/unix/sysv/linux/i386/libm.abilist: Update.
* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/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/x86_64/64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.

7 years agoRemove C++ style comments from string3.h
Adhemerval Zanella [Thu, 29 Sep 2016 19:02:16 +0000 (12:02 -0700)]
Remove C++ style comments from string3.h

The new check-installed-headers rule check now complains with C++
comment from string3.h with:

../string/bits/string3.h:129:1: error: C++ style comments are not allowed in ISO C90
 // XXX We have no corresponding builtin yet.

Let use old C style comment to make compiler happy in old modes.

Tested on x86_64.

* string/bits/string3.h: Remove C++ style comments.

7 years agoUse copysign instead of ternary for some sin/cos input ranges
Siddhesh Poyarekar [Thu, 29 Sep 2016 23:49:05 +0000 (05:19 +0530)]
Use copysign instead of ternary for some sin/cos input ranges

These are remaining cases where we can deduce and conclude that the
sign of the result should be the same as the sign of the input being
checked.  For example, for sin(x), the sign of the result is the same
as the result itself for x < pi.  Likewise, for sine values where x
after range reduction falls into this range and its sign is preserved.

* sysdeps/ieee754/dbl-64/s_sin.c (do_sincos_1): Use copysign
instead of ternary condition.
(do_sincos_2): Likewise.
(__sin): Likewise.
(__cos): Likewise.
(slow): Likewise.
(sloww): Likewise.
(sloww1): Likewise.
(bsloww): Likewise.
(bsloww1): Likewise.

7 years agoUse copysign instead of ternary conditions for positive constants
Siddhesh Poyarekar [Thu, 29 Sep 2016 23:47:55 +0000 (05:17 +0530)]
Use copysign instead of ternary conditions for positive constants

This is the first very simple substitution of ternary conditions for
correction adjustments with __copysign for positive constants.

* sysdeps/ieee754/dbl-64/s_sin.c (do_cos_slow): use copysign
instead of ternary condition.
(do_sin_slow): Likewise.
(do_sincos_1): Likewise.
(do_sincos_2): Likewise.
(__cos): Likewise.
(sloww): Likewise.
(sloww1): Likewise.
(sloww2): Likewise.
(bsloww): Likewise.
(bsloww1): Likewise.
(bsloww2): Likewise.

7 years agoconsolidate sign checks for slow2
Siddhesh Poyarekar [Thu, 29 Sep 2016 23:45:55 +0000 (05:15 +0530)]
consolidate sign checks for slow2

Simplify the code a bit by consolidating sign checks in slow1 and
slow2 into __sin at the higher level.

* sysdeps/ieee754/dbl-64/s_sin.c (slow1): Consolidate sign
check from here...
(slow2): ... and here...
(__sin): ... to here.

7 years agoFix iszero for excess precision.
Joseph Myers [Wed, 28 Sep 2016 21:11:58 +0000 (21:11 +0000)]
Fix iszero for excess precision.

Floating-point classification macros are supposed to remove any excess
range or precision from their arguments.  This patch fixes the
non-sNaN version of iszero to do so, by casting the argument to its
own type.  (This will of course work only for standard-conforming
excess precision, not for what GCC does on 32-bit x86 by default where
the back end hides excess precision from the front end; the same
applies to most of the classification macros in that case, as showed
up when we made them use GCC built-in functions.)

(iseqsig will have the reverse issue, needing to ensure that when an
underlying function is used it's for a type wide enough not to remove
any excess precision, since comparison macros must not remove excess
precision.)

Tested for x86_64 and x86.

* math/math.h
[__GLIBC_USE (IEC_60559_BFP_EXT) && !__SUPPORT_SNAN__] (iszero):
Cast argument to its own type.
* math/test-iszero-excess-precision.c: New file.
* math/Makefile (tests): Add test-iszero-excess-precision.
(CFLAGS-test-iszero-excess-precision.c): New variable.

7 years agoposix: Fix open file action for posix_spawn on Linux
Adhemerval Zanella [Fri, 16 Sep 2016 20:44:50 +0000 (17:44 -0300)]
posix: Fix open file action for posix_spawn on Linux

On posix_spawn open file action (issued by posix_spawn_file_actions_addopen)
POSIX states that if fildes was already an open file descriptor, it shall be
closed before the new file is openedi [1].  This avoid pontential issues when
posix_spawn plus addopen action is called with the process already at maximum
number of file descriptor opened and also for multiple actions on single-open
special paths (like /dev/watchdog).

This fixes its behavior on Linux posix_spawn implementation and also adds
a tests to check for its behavior.

Checked on x86_64.

* posix/Makefile (tests): Add tst-spawn3.
* posix/tst-spawn3.c: New file.
* sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Close file descriptor
if it is already opened for open action.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn_file_actions_addclose.html

7 years agolinux: spawni.c: simplify error reporting to parent
Rasmus Villemoes [Wed, 28 Sep 2016 00:52:17 +0000 (17:52 -0700)]
linux: spawni.c: simplify error reporting to parent

Using CLONE_VFORK already ensures that the parent does not run until the
child has either exec'ed succesfully or called _exit. Hence we don't
need to read from a CLOEXEC pipe to ensure proper synchronization - we
just make explicit use of the fact the the child and parent run in the
same VM, so the child can write an error code to a field of the
posix_spawn_args struct instead of sending it through a pipe.

To ensure that this mechanism really works, the parent initializes the
field to -1 and the child writes 0 before execing.

This eliminates some annoying bookkeeping that is necessary to avoid
the file actions from clobbering the write end of the pipe, and
getting rid of the pipe creation in the first place means fewer system
calls (four in the parent, usually one in the child) and fewer
chanches for the spawn to fail (e.g. if we're close to EMFILE).

Checked on x86_64 and i686.

* sysdeps/unix/sysv/linux/spawni.c (posix_spawn_args): Remove pipe
field, add err field.
(__spawni_child): Report error through err member instead of pipe.
(__spawnix): Likewise.

7 years agoMinor corrections to scripts/check-installed-headers.sh.
Zack Weinberg [Wed, 28 Sep 2016 11:28:00 +0000 (07:28 -0400)]
Minor corrections to scripts/check-installed-headers.sh.

* scripts/check-installed-headers.sh: Generalize treatment of
sys/elf.h to all target architectures.

7 years agoMinor correction to the "installed header hygiene" patches.
Zack Weinberg [Wed, 28 Sep 2016 11:19:59 +0000 (07:19 -0400)]
Minor correction to the "installed header hygiene" patches.

   * sysdeps/unix/sysv/linux/s390/sys/ucontext.h: Restore accidentally-
deleted typedef ucontext_t.

7 years agoAdd INTERNAL_SYSCALL_CALL
Adhemerval Zanella [Thu, 30 Jun 2016 19:34:18 +0000 (16:34 -0300)]
Add INTERNAL_SYSCALL_CALL

This patch adds two new macros for internal and inline syscall to use
within GLIBC: INTERNAL_SYSCALL_CALL and INLINE_SYSCALL_CALL.  They are
similar to the old INTERNAL_SYSCALL and INLINE_SYSCALL with the difference
the new macros accept a variable argument call and do not require to pass
the expected argument size.

The advantage is it is possible to use variable argument macros like
SYSCALL_LL{64} without the need to also handle the argument size.  So
for an ABI where SYSCALL_LL might split the argument in high and low
parts, instead of:

  INTERNAL_SYSCALL_DECL (err);
 #if ...
  INTERNAL_SYSCALL (syscall, err, 2, SYSCALL_LL (len));
 #else
  INTERNAL_SYSCALL (syscall, err, 1, SYSCALL_LL (len));
 #endif

It will be just:

  INTERNAL_SYSCALL_CALL (syscall, err, SYSCALL_LL (len));

The INLINE_SYSCALL_CALL follows the same semanthic regarding the argument
and is similar to INLINE_SYSCALL regarding setting errno.

Checked with a build for x86_64, i386, aach64, armhf, powerpc64le, powerpc32,
and mips32.  No code generation changed.

* sysdeps/unix/sysdep.h (__INTERNAL_SYSCALL0): New macro.
(__INTERNAL_SYSCALL1): Likewise.
(__INTERNAL_SYSCALL2): Likewise.
(__INTERNAL_SYSCALL3): Likewise.
(__INTERNAL_SYSCALL4): Likewise.
(__INTERNAL_SYSCALL5): Likewise.
(__INTERNAL_SYSCALL6): Likewise.
(__INTERNAL_SYSCALL7): Likewise.
(__INTERNAL_SYSCALL_NARGS_X): Likewise.
(__INTERNAL_SYSCALL_NARGS): Likewise.
(__INTERNAL_SYSCALL_DISP): Likewise.
(INTERNAL_SYSCALL_CALL): Likewise.
(__SYSCALL0): Rename to __INLINE_SYSCALL0.
(__SYSCALL1): Rename to __INLINE_SYSCALL1.
(__SYSCALL2): Rename to __INLINE_SYSCALL2.
(__SYSCALL3): Rename to __INLINE_SYSCALL3.
(__SYSCALL4): Rename to __INLINE_SYSCALL4.
(__SYSCALL5): Rename to __INLINE_SYSCALL5.
(__SYSCALL6): Rename to __INLINE_SYSCALL6.
(__SYSCALL7): Rename to __INLINE_SYSCALL7.
(__SYSCALL_NARGS_X): Rename to __INLINE_SYSCALL_NARGS_X.
(__SYSCALL_NARGS): Rename to __INLINE_SYSCALL_NARGS.
(__SYSCALL_DISP): Rename to __INLINE_SYSCALL_DISP.
(__SYSCALL_CALL): Rename to INLINE_SYSCALL_CALL.
(SYSCALL_CANCEL): Replace __SYSCALL_CALL with INLINE_SYSCALL_CALL.

7 years agoAdd iszero.
Joseph Myers [Fri, 23 Sep 2016 21:54:21 +0000 (21:54 +0000)]
Add iszero.

TS 18661-1 adds an iszero classification macro to <math.h>.  This
patch implements it for glibc.  There are no new underlying functions
in libm because the implementation uses fpclassify when sNaN support
is required and a direct comparison otherwise; any optimizations for
this macro should be done through adding __builtin_iszero in GCC and
using it in the header for suitable GCC versions, not through adding
other optimized inline or out-of-line versions to glibc.

Tested for x86_64 and x86.

* math/math.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (iszero): New
macro.
* math/libm-test.inc (iszero_test_data): New array.
(iszero_test): New function.
(main): Call iszero_test.
* manual/arith.texi (Floating Point Classes): Document iszero.
* manual/libm-err-tab.pl: Update comment on interfaces without
ulps tabulated.

7 years agoInstalled header hygiene (BZ#20366): Test of installed headers.
Zack Weinberg [Wed, 24 Aug 2016 01:19:17 +0000 (21:19 -0400)]
Installed header hygiene (BZ#20366): Test of installed headers.

This adds a test to ensure that the problems fixed in the last several
patches do not recur.  Each directory checks the headers that it
installs for two properties: first, each header must be compilable in
isolation, as both C and C++, under a representative combination of
language and library conformance levels; second, there is a blacklist
of identifiers that may not appear in any installed header, currently
consisting of the legacy BSD typedefs.  (There is an exemption for the
headers that define those typedefs, and for the RPC headers.  It may be
necessary to make this more sophisticated if we add more stuff to the
blacklist in the future.)

In order for this test to work correctly, every wrapper header
that actually defines something must guard those definitions with
 #ifndef _ISOMAC.  This is the existing mechanism used by the conform/
tests to tell wrapper headers not to define anything that the public
header wouldn't, and not to use anything from libc-symbols.h.  conform/
only cares for headers that we need to check for standards conformance,
whereas this test applies to *every* header.  (Headers in include/ that
are either installed directly, or are internal-use-only and do *not*
correspond to any installed header, are not affected.)

* scripts/check-installed-headers.sh: New script.
* Rules: In each directory that defines header files to be installed,
run check-installed-headers.sh on them as a special test.
* Makefile: Likewise for the headers installed at top level.

* include/aliases.h, include/alloca.h, include/argz.h
* include/arpa/nameser.h, include/arpa/nameser_compat.h
* include/elf.h, include/envz.h, include/err.h
* include/execinfo.h, include/fpu_control.h, include/getopt.h
* include/gshadow.h, include/ifaddrs.h, include/libintl.h
* include/link.h, include/malloc.h, include/mcheck.h
* include/mntent.h, include/netinet/ether.h
* include/nss.h, include/obstack.h, include/printf.h
* include/pty.h, include/resolv.h, include/rpc/auth.h
* include/rpc/auth_des.h, include/rpc/auth_unix.h
* include/rpc/clnt.h, include/rpc/des_crypt.h
* include/rpc/key_prot.h, include/rpc/netdb.h
* include/rpc/pmap_clnt.h, include/rpc/pmap_prot.h
* include/rpc/pmap_rmt.h, include/rpc/rpc.h
* include/rpc/rpc_msg.h, include/rpc/svc.h
* include/rpc/svc_auth.h, include/rpc/xdr.h
* include/rpcsvc/nis_callback.h, include/rpcsvc/nislib.h
* include/rpcsvc/yp.h, include/rpcsvc/ypclnt.h
* include/rpcsvc/ypupd.h, include/shadow.h
* include/stdio_ext.h, include/sys/epoll.h
* include/sys/file.h, include/sys/gmon.h, include/sys/ioctl.h
* include/sys/prctl.h, include/sys/profil.h
* include/sys/statfs.h, include/sys/sysctl.h
* include/sys/sysinfo.h, include/ttyent.h, include/utmp.h
* sysdeps/arm/nacl/include/bits/setjmp.h
* sysdeps/mips/include/sys/asm.h
* sysdeps/unix/sysv/linux/include/sys/sysinfo.h
* sysdeps/unix/sysv/linux/include/sys/timex.h
* sysdeps/x86/fpu/include/bits/fenv.h:
Add #ifndef _ISOMAC guard around internal declarations.
Add multiple-inclusion guard if not already present.

7 years agoInstalled-header hygiene (BZ#20366): stack_t.
Zack Weinberg [Wed, 13 Jul 2016 20:11:57 +0000 (16:11 -0400)]
Installed-header hygiene (BZ#20366): stack_t.

sys/ucontext.h unconditionally uses stack_t, and it does not make
sense to change that.  But signal.h only declares stack_t under
__USE_XOPEN_EXTENDED || __USE_XOPEN2K8.  The actual definition is
already in a bits header, bits/sigstack.h, but that header insists on
only being included by signal.h, so we have to change that as well as
all of the sys/ucontext.h variants.  (Some but not all variants of
bits/sigcontext.h, which sys/ucontext.h may also need, had already
received this adjustment; for consistency, I made them all the same,
even if that's not strictly necessary in some configurations.)
bits/sigcontext.h and bits/sigstack.h also all need to receive
multiple inclusion guards.

* sysdeps/generic/sys/ucontext.h
* sysdeps/arm/sys/ucontext.h
* sysdeps/i386/sys/ucontext.h
* sysdeps/m68k/sys/ucontext.h
* sysdeps/mips/sys/ucontext.h
* sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h
* sysdeps/unix/sysv/linux/alpha/sys/ucontext.h
* sysdeps/unix/sysv/linux/arm/sys/ucontext.h
* sysdeps/unix/sysv/linux/hppa/sys/ucontext.h
* sysdeps/unix/sysv/linux/ia64/sys/ucontext.h
* sysdeps/unix/sysv/linux/m68k/sys/ucontext.h
* sysdeps/unix/sysv/linux/mips/sys/ucontext.h
* sysdeps/unix/sysv/linux/nios2/sys/ucontext.h
* sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h
* sysdeps/unix/sysv/linux/s390/sys/ucontext.h
* sysdeps/unix/sysv/linux/sh/sys/ucontext.h
* sysdeps/unix/sysv/linux/sparc/sys/ucontext.h
* sysdeps/unix/sysv/linux/tile/sys/ucontext.h
* sysdeps/unix/sysv/linux/x86/sys/ucontext.h:
Include both bits/sigcontext.h and bits/sigstack.h.
Fix grammar error in comment, if present.

* bits/sigstack.h
* sysdeps/unix/sysv/linux/aarch64/bits/sigstack.h
* sysdeps/unix/sysv/linux/alpha/bits/sigstack.h
* sysdeps/unix/sysv/linux/bits/sigstack.h
* sysdeps/unix/sysv/linux/ia64/bits/sigstack.h
* sysdeps/unix/sysv/linux/mips/bits/sigstack.h
* sysdeps/unix/sysv/linux/powerpc/bits/sigstack.h
* sysdeps/unix/sysv/linux/sparc/bits/sigstack.h
* bits/sigcontext.h
* sysdeps/mach/hurd/i386/bits/sigcontext.h
* sysdeps/unix/sysv/linux/bits/sigcontext.h
* sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h
* sysdeps/unix/sysv/linux/sparc/bits/sigcontext.h:
Add multiple inclusion guard.  Permit inclusion by sys/ucontext.h
as well as signal.h, if this was not already allowed.  Request
definition of size_t if necessary.  Minimize semantically-null
differences across files.

7 years agoInstalled-header hygiene (BZ#20366): time.h types.
Zack Weinberg [Wed, 24 Aug 2016 15:54:34 +0000 (11:54 -0400)]
Installed-header hygiene (BZ#20366): time.h types.

Many headers are expected to expose a subset of the type definitions
in time.h.  time.h has a whole bunch of messy logic for conditionally
defining some its types and structs, but, as best I can tell, this
has never worked 100%.  In particular, __need_timespec is ineffective
if _TIME_H has already been defined, which means that if you compile

  #include <time.h>
  #include <sched.h>

with e.g. -fsyntax-only -std=c89 -Wall -Wsystem-headers, you will get

In file included from test.c:2:0:
/usr/include/sched.h:74:57: warning: "struct timespec" declared inside
  parameter list will not be visible outside of this definition or declaration
 extern int sched_rr_get_interval (__pid_t __pid, struct timespec *__t) __THROW;
                                                         ^~~~~~~~

And if you want to _use_ sched_rr_get_interval in a TU compiled that
way, you're hosed.

This patch replaces all of that with small bits/types/TYPE.h headers
as introduced earlier.  time.h and bits/time.h are now *much* simpler,
and a lot of other headers are slightly simpler.

* time/time.h, bits/time.h, sysdeps/unix/sysv/linux/bits/time.h:
Remove all logic conditional on __need macros.  Move all the
conditionally defined types to their own headers...
* time/bits/types/clock_t.h: Define clock_t here.
* time/bits/types/clockid_t.h: Define clockid_t here.
* time/bits/types/struct_itimerspec.h: Define struct itimerspec here.
* time/bits/types/struct_timespec.h: Define struct timespec here.
* time/bits/types/struct_timeval.h: Define struct timeval here.
* time/bits/types/struct_tm.h: Define struct tm here.
* time/bits/types/time_t.h: Define time_t here.
* time/bits/types/timer_t.h: Define timer_t here.
* time/Makefile: Install the new headers.

* bits/resource.h, io/fcntl.h, io/sys/poll.h, io/sys/stat.h
* io/utime.h, misc/sys/select.h, posix/sched.h, posix/sys/times.h
* posix/sys/types.h, resolv/netdb.h, rt/aio.h, rt/mqueue.h
* signal/signal.h, pthread/semaphore.h, sysdeps/nptl/pthread.h
* sysdeps/unix/sysv/linux/alpha/bits/resource.h
* sysdeps/unix/sysv/linux/alpha/sys/acct.h
* sysdeps/unix/sysv/linux/bits/resource.h
* sysdeps/unix/sysv/linux/bits/timex.h
* sysdeps/unix/sysv/linux/mips/bits/resource.h
* sysdeps/unix/sysv/linux/net/ppp_defs.h
* sysdeps/unix/sysv/linux/sparc/bits/resource.h
* sysdeps/unix/sysv/linux/sys/acct.h
* sysdeps/unix/sysv/linux/sys/timerfd.h
* sysvipc/sys/msg.h, sysvipc/sys/sem.h, sysvipc/sys/shm.h
* time/sys/time.h, time/sys/timeb.h
Use the new bits/types headers.

* include/time.h: Remove __need logic.
* include/bits/time.h
* include/bits/types/clock_t.h, include/bits/types/clockid_t.h
* include/bits/types/time_t.h, include/bits/types/timer_t.h
* include/bits/types/struct_itimerspec.h
* include/bits/types/struct_timespec.h
* include/bits/types/struct_timeval.h
* include/bits/types/struct_tm.h:
New wrapper headers.

7 years agoInstalled-header hygiene (BZ#20366): conditionally defined structures.
Zack Weinberg [Wed, 13 Jul 2016 19:20:29 +0000 (15:20 -0400)]
Installed-header hygiene (BZ#20366): conditionally defined structures.

Several network-related structures are defined conditionally under
__USE_MISC, but unconditionally used by other headers.  The path of
least resistance is usually to condition the uses on __USE_MISC as
well.

* sysdeps/mach/hurd/net/if_ppp.h
* sysdeps/unix/sysv/linux/net/if_ppp.h:
        Only define struct ifpppstatsreq and struct ifpppcstatsreq
        if __USE_MISC is defined, to ensure struct ifreq is declared.

* inet/netinet/ether.h: Condition all function prototypes
        on __USE_MISC, to ensure struct ether_addr is declared.

sys/socket.h defines struct osockaddr only under __USE_MISC, whereas
protocols/talkd.h requires it unconditionally.  Here it doesn't make
sense to condition the entire body of protocols/talkd.h on __USE_MISC.
Rather than complicate sys/socket.h with a __need macro or duplicate
the definition, I am introducing a new concept: tiny headers named
bits/types/TYPE.h that define TYPE and nothing else.  This can, I hope,
ultimately replace *all* the __need macros.  The guard macro for such
headers will be __TYPE_defined, just in case application or third-party
library code is looking at them.

* socket/bits/types/struct_osockaddr.h: New header.
* include/bits/types/struct_osockaddr.h: New wrapper.
* socket/Makefile: Install the new header.
* socket/sys/socket.h,  inet/protocols/talkd.h:
Refer to bits/types/struct_osockaddr.h for the definition of
struct osockaddr.

7 years agoInstalled-header hygiene (BZ#20366): obsolete BSD u_* types.
Zack Weinberg [Sun, 21 Aug 2016 19:38:41 +0000 (15:38 -0400)]
Installed-header hygiene (BZ#20366): obsolete BSD u_* types.

The types u_char, u_short, u_int, u_long, ushort, uint, ulong, u_int8_t,
u_int16_t, u_int32_t, u_int64_t, quad_t, and u_quad_t are BSDisms that
have never been standardized.  While glibc should continue to *provide*
these types for compatibility's sake, its public headers should not
use them.

The meat of this change was mechanically generated by the following
shell command:

    perl -pi~ -e '
        s/\b(__)?u_char\b/unsigned char/g;
        s/\b(__)?u_?short\b/unsigned short/g;
        s/\b(__)?u_?int\b/unsigned int/g;
        s/\b(__)?u_?long\b/unsigned long/g;
        s/\b(__)?u_int8_t\b/uint8_t/g;
        s/\b(__)?u_int16_t\b/uint16_t/g;
        s/\b(__)?u_int32_t\b/uint32_t/g;
        s/\b(__)?u_int64_t\b/uint64_t/g;
        s/\b(__)?u_quad_t\b/uint64_t/g;
        s/\b(__)?quad_t\b/uint64_t/g;
    ' $(grep -lE -e '\<((__)?(quad_t|u(short|int|long|_(char|short|int([0-9]+_t)?|long|quad_t))))\>' \
        $(grep -LE '\<(_(SYS|BITS)_TYPES_H|rpc/(rpc|rpc_msg|types|xdr)\.h)\>' \
          $(find . \( -false $(sed 's/^/-o -name /' all-installed-headers) \
                   \) -printf '%P\n' | sort -u)))

where 'all-installed-headers' was a list of the basenames of all installed
header files, manually extracted from the Makefiles.  Non-installed
wrapper headers in include/ are also adjusted, for consistency.
I then manually fixed up indentation and line-wrapping.

sys/types.h and bits/types.h are excluded because they must continue
to define the u_* types (under __USE_MISC) for compatibility with
applications.  They do not use these types themselves.

All headers that (transitively) include rpc/types.h are also excluded,
for three reasons.  First, the u_* types are defined by rpc/types.h,
unconditionally (not just under __USE_MISC) so they are logically part
of the SunRPC API.  Second, many of those headers appear to be
machine-generated.  Third, it's my understanding that we are getting
rid of as much of SunRPC as possible in the near future.

(The one file under sunrpc/ that's touched, sunrpc/rpc/rpc_des.h, does
*not* include rpc/types.h.  This may itself be a bug.)

After changing from u_intNN_t to uintNN_t, a number of headers now
need to include stdint.h to pick up those types.  It might be more
hygenic, namespace-wise, to use __uintNN_t instead, but none of these
headers are bound by ISO or POSIX to do so, and it's unlikely that
anyone using them will be bothered.  (The two files that were using
__-prefixed versions of the u_types, sysdeps/mach/hurd/net/route.h and
sysdeps/unix/sysv/linux/net/route.h, both already also contained uses of
the unprefixed versions.)

Some of these files directly included features.h and/or sys/cdefs.h,
which I removed, as the style generally seems to be to let sys/types.h
do that for us.  (This does not change the set of definitions exposed
by any header; sys/types.h unconditionally includes both features.h
and sys/cdefs.h.)

One file included asm/types.h unnecessarily.

* bits/in.h, gmon/sys/gmon.h, inet/netinet/igmp.h
* inet/protocols/routed.h, inet/protocols/talkd.h
* inet/protocols/timed.h, io/fts.h, nptl_db/thread_db.h
* resolv/arpa/nameser.h, resolv/resolv.h, sunrpc/rpc/rpc_des.h
* sysdeps/generic/netinet/if_ether.h
* sysdeps/generic/netinet/in_systm.h
* sysdeps/generic/netinet/ip.h, sysdeps/generic/netinet/tcp.h
* sysdeps/gnu/netinet/ip_icmp.h, sysdeps/gnu/netinet/tcp.h
* sysdeps/gnu/netinet/udp.h, sysdeps/mach/hurd/net/ethernet.h
* sysdeps/mach/hurd/net/if_arp.h
* sysdeps/mach/hurd/net/if_ppp.h
* sysdeps/mach/hurd/net/route.h, sysdeps/mach/sys/reboot.h
* sysdeps/unix/sysv/linux/bits/in.h
* sysdeps/unix/sysv/linux/net/ethernet.h
* sysdeps/unix/sysv/linux/net/if_arp.h
* sysdeps/unix/sysv/linux/net/if_ppp.h
* sysdeps/unix/sysv/linux/net/if_shaper.h
* sysdeps/unix/sysv/linux/net/route.h
* sysdeps/unix/sysv/linux/netinet/if_ether.h
* sysdeps/unix/sysv/linux/netinet/if_fddi.h
* sysdeps/unix/sysv/linux/netinet/if_tr.h
* sysdeps/unix/sysv/linux/netipx/ipx.h
* sysdeps/unix/sysv/linux/sys/acct.h
* include/arpa/nameser.h, include/resolv.h:
Change all uses of u_char to unsigned char,
u_short and ushort to unsigned short, u_int and uint to unsigned int,
u_long and ulong to unsigned long, u_int8_t to uint8_t,
        u_int16_t to uint16_t, u_int32_t to uint32_t, quad_t to int64_t,
and u_int64_t and u_quad_t to uint64_t.

* mach/sys/reboot.h: Remove two casts of integer literals
to the types they already have.

* bits/in.h: Correct error in description of IP_MULTICAST_LOOP.
* sysdeps/unix/sysv/linux/bits/in.h: Likewise.
* sysdeps/unix/sysv/linux/netinet/if_ether.h: Change a comment
from referring to 'unsigned char' to 'uint8_t' for consistency with
the macro definition below.

* gmon/sys/gmon.h, inet/netinet/igmp.h, inet/protocols/talkd.h
* io/fts.h, resolv/arpa/nameser.h, resolv/resolv.h
* sunrpc/rpc/rpc_des.h, sysdeps/generic/netinet/ip.h
* sysdeps/gnu/netinet/tcp.h, sysdeps/gnu/netinet/udp.h
* sysdeps/mach/hurd/net/if_ppp.h, sysdeps/unix/sysv/linux/net/if_ppp.h
* sysdeps/unix/sysv/linux/sys/acct.h
* include/arpa/nameser.h, include/resolv.h:
Fix indentation disrupted by mechanical edits.

* inet/protocols/talkd.h, resolv/arpa/nameser.h
* sysdeps/generic/netinet/in_systm.h
* sysdeps/gnu/netinet/ip_icmp.h, sysdeps/gnu/netinet/tcp.h
* sysdeps/gnu/netinet/udp.h
* sysdeps/unix/sysv/linux/net/ethernet.h
* sysdeps/unix/sysv/linux/net/if_arp.h
* sysdeps/unix/sysv/linux/net/if_ppp.h
* sysdeps/unix/sysv/linux/net/if_shaper.h
* sysdeps/unix/sysv/linux/netinet/if_fddi.h
* sysdeps/unix/sysv/linux/netinet/if_tr.h
* sysdeps/unix/sysv/linux/netipx/ipx.h
* sysdeps/unix/sysv/linux/sys/acct.h
Include stdint.h for uintNN_t definitions.
Don't include sys/cdefs.h, features.h, or asm/types.h directly.

7 years agoInstalled-header hygiene (BZ#20366): Simple self-contained fixes.
Zack Weinberg [Mon, 22 Aug 2016 12:06:30 +0000 (08:06 -0400)]
Installed-header hygiene (BZ#20366): Simple self-contained fixes.

Some headers did not include all of their prerequisite headers.

* rpcsvc/nislib.h: Include rpcsvc/nis.h.
* sysdeps/unix/sysv/linux/netrose/rose.h:
Include sys/socket.h and netax25/ax25.h.

<endian.h> only defines BYTE_ORDER, BIG_ENDIAN, LITTLE_ENDIAN,
etc. under __USE_MISC; glibc's headers should use __BYTE_ORDER,
__BIG_ENDIAN, __LITTLE_ENDIAN, etc. instead.

* inet/netinet/icmp6.h, inet/netinet/ip6.h
* resolv/arpa/nameser_compat.h:
Use __BYTE_ORDER etc. instead of BYTE_ORDER etc.

sys/types.h only conditionally defines caddr_t and clockid_t.

* sysdeps/unix/sysv/linux/sys/quota.h:
Use __caddr_t instead of caddr_t.
* sysdeps/unix/sysv/linux/sys/timerfd.h:
Use __clockid_t instead of clockid_t.

Remove a #warning that was the sole actual problem with using sys/ipc.h
without _GNU_SOURCE/_XOPEN_SOURCE.

* sysvipc/sys/ipc.h: Remove unnecessary #warning.

_LIBC, __USE_XOPEN2K8, and __STDC_VERSION__ are not always defined.

It seems to me that _LIBC should not appear in installed headers, but
avoiding that for argp specifically would require more surgery than
feels appropriate for this patch set.  It's possible that
"#ifdef _LIBC" would be sufficient, but I wanted to be conservative.

All three versions of bits/socket.h want to know whether __flexarr
will produce a real flexible array member -- specifically, one that
doesn't alter sizeof(the structure containing it).  They were testing
for this with a complicated #if condition that did not agree with
sys/cdefs.h and that tripped -Wundef warnings under -std=c90.
I added a new macro to sys/cdefs.h, __glibc_c99_flexarr_available,
which reveals exactly what these headers want to know.  I also took
the opportunity to flatten the rather messy conditional nest defining
__flexarr.

* argp/argp.h: Check whether _LIBC is defined before expanding it.
* posix/glob.h: Check whether __USE_XOPEN2K8 is defined instead
of expanding it.

* misc/sys/cdefs.h: Tidy up conditional nest defining __flexarr.
Define __glibc_c99_flexarr_available to 1 when the compiler
supports C99-compatible flexible array members, 0 otherwise.
* sysdeps/unix/sysv/linux/bits/socket.h
* sysdeps/mach/hurd/bits/socket.h
* bits/socket.h: Use __glibc_c99_flexarr_available in
definitions of struct cmsghdr and CMSG_DATA.

7 years agomanual: Clarify NSS error reporting
Florian Weimer [Fri, 23 Sep 2016 12:18:08 +0000 (14:18 +0200)]
manual: Clarify NSS error reporting

The manual already required that NSS implementation functions set
error codes if they return a value that is not NSS_STATUS_SUCCESS,
but this was not very explicit.  The errnop parameter was omitted
in a few places, and the function return value was incorrect.

7 years agotst-open-tmpfile: Add checks for open64, openat64, linkat
Florian Weimer [Fri, 23 Sep 2016 11:38:09 +0000 (13:38 +0200)]
tst-open-tmpfile: Add checks for open64, openat64, linkat

The /proc/self/fd approach is expected to work for all users
(with and without CAP_DAC_READ_SEARCH).

7 years agotest-skeleton.c: Remove unintended #include <stdarg.h>.
Florian Weimer [Fri, 23 Sep 2016 07:41:35 +0000 (09:41 +0200)]
test-skeleton.c: Remove unintended #include <stdarg.h>.

7 years ago[PR19826] fix non-LE TLS in static programs
Alexandre Oliva [Thu, 22 Sep 2016 01:01:16 +0000 (22:01 -0300)]
[PR19826] fix non-LE TLS in static programs

An earlier fix for TLS dropped early initialization of DTV entries for
modules using static TLS, leaving it for __tls_get_addr to set them
up.  That worked on platforms that require the GD access model to be
relaxed to LE in the main executable, but it caused a regression on
platforms that allow GD in the main executable, particularly in
statically-linked programs: they use a custom __tls_get_addr that does
not update the DTV, which fails when the DTV early initialization is
not performed.

In static programs, __libc_setup_tls performs the DTV initialization
for the main thread, but the DTV of other threads is set up in
_dl_allocate_tls_init, so that's the fix that matters.

Restoring the initialization in the remaining functions modified by
this patch was just for uniformity.  It's not clear that it is ever
needed: even on platforms that allow GD in the main executable, the
dynamically-linked version of __tls_get_addr would set up the DTV
entries, even for static TLS modules, while updating the DTV counter.

for  ChangeLog

[BZ #19826]
* elf/dl-tls.c (_dl_allocate_tls_init): Restore DTV early
initialization of static TLS entries.
* elf/dl-reloc.c (_dl_nothread_init_static_tls): Likewise.
* nptl/allocatestack.c (init_one_static_tls): Likewise.

7 years agohurd: Fix stack pointer corruption in syscall
Samuel Thibault [Thu, 22 Sep 2016 00:43:39 +0000 (02:43 +0200)]
hurd: Fix stack pointer corruption in syscall

Thanks Justus Winter for the report.

* sysdeps/mach/i386/syscall.S (syscall): Push back syscall number.

7 years agohurdmalloc: Run fork handler as late as possible [BZ #19431]
Samuel Thibault [Wed, 21 Sep 2016 23:45:48 +0000 (01:45 +0200)]
hurdmalloc: Run fork handler as late as possible [BZ #19431]

This is the hurd-specific follow-up for
29d794863cd6e03115d3670707cc873a9965ba92 : hurdmalloc also needs the
same fix

* hurd/hurdmalloc.c (malloc_fork_prepare): Rename to
_hurd_malloc_fork_prepare.
(malloc_fork_parent): Rename to _hurd_malloc_fork_parent.
(malloc_fork_child): Rename to _hurd_malloc_fork_child.
(_hurd_fork_prepare_hook): Drop malloc_fork_prepare.
(_hurd_fork_parent_hook): Drop malloc_fork_parent.
(_hurd_fork_child_hook): Drop malloc_fork_child.
* hurd/hurdmalloc.h (_hurd_malloc_fork_prepare,
_hurd_malloc_fork_parent, _hurd_malloc_fork_child): Add declarations.
* sysdeps/mach/hurd/fork.c (__fork): Call __malloc_fork_lock_parent
after locking locks (notably hurd_dtable_lock). Call
_hurd_malloc_fork_prepare after that. Call _hurd_malloc_fork_parent
before __malloc_fork_unlock_parent and _hurd_malloc_fork_child before
__malloc_fork_unlock_child.

7 years ago[soft-fp] Add support for various half-precision conversion routines.
James Greenhalgh [Wed, 21 Sep 2016 21:02:54 +0000 (21:02 +0000)]
[soft-fp] Add support for various half-precision conversion routines.

This patch adds conversion routines required for _Float16 support in
AArch64.

These are one-step conversions to and from TImode and TFmode. We need
these on AArch64 regardless of presence of the ARMv8.2-A 16-bit
floating-point extensions.

In the patch, soft-fp/half.h is derived from soft-fp/single.h .  The
conversion routines are derivatives of their respective SFmode
variants.

* soft-fp/extendhftf2.c: New.
* soft-fp/fixhfti.c: Likewise.
* soft-fp/fixunshfti.c: Likewise.
* soft-fp/floattihf.c: Likewise.
* soft-fp/floatuntihf.c: Likewise.
* soft-fp/half.h: Likewise.
* soft-fp/trunctfhf2.c: Likewise.

7 years agoAdd issubnormal.
Joseph Myers [Wed, 21 Sep 2016 20:52:02 +0000 (20:52 +0000)]
Add issubnormal.

TS 18661-1 adds an issubnormal classification macro to <math.h>.  This
patch implements it for glibc.  There are no new underlying functions
in libm because the implementation uses fpclassify; any optimizations
for this macro should be done through adding __builtin_subnormal in
GCC and using it in the header for suitable GCC versions, not through
adding other optimized inline or out-of-line versions to glibc.

The intended structure of the NEWS entry for <math.h> features from TS
18661-1 is like:

* New <math.h> features are added from TS 18661-1:2014:

  - Nearest integer functions: roundeven, roundevenf, roundevenl.

  - Comparison macros: iseqsig.

  - Classification macros: iscanonical, issubnormal, iszero.

(that is, following the grouping of interfaces in TS 18661-1:2014,
with any group where any interfaces are new in glibc 2.25 being listed
like that).

Tested for x86_64 and x86.

* math/math.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (issubnormal): New
macro.
* math/libm-test.inc (issubnormal_test_data): New array.
(issubnormal_test): New function.
* manual/arith.texi (Floating Point Classes): Document
issubnormal.
* manual/libm-err-tab.pl: Update comment on interfaces without
ulps tabulated.

7 years agoAdd <stdint.h> integer width macros.
Joseph Myers [Wed, 21 Sep 2016 17:06:36 +0000 (17:06 +0000)]
Add <stdint.h> integer width macros.

TS 18661-1 defines macros for the width of integer types, intended for
use with the fromfp functions to convert from floating-point types to
integer types of any width, in any rounding mode and with control over
whether "inexact" is raised.  Such macros are, of course, more
generally useful than just with those functions.

Those macros are added to <limits.h> and <stdint.h>.  Having
previously added the <limits.h> macros, this patch adds the <stdint.h>
ones.  I've also added these macros to GCC's headers for GCC 7, but
for glibc systems, the definitions in GCC's <stdint.h> will only be
used with -ffreestanding.

Tested for x86_64 and x86.

* sysdeps/generic/stdint.h: Define
__GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION and include
<bits/libc-header-start.h> instead of including <features.h>.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (INT8_WIDTH): New macro.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (UINT8_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (INT16_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (UINT16_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (INT32_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (UINT32_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (INT64_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (UINT64_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (INT_LEAST8_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (UINT_LEAST8_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (INT_LEAST16_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (UINT_LEAST16_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (INT_LEAST32_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (UINT_LEAST32_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (INT_LEAST64_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (UINT_LEAST64_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (INT_FAST8_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (UINT_FAST8_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (INT_FAST16_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (UINT_FAST16_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (INT_FAST32_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (UINT_FAST32_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (INT_FAST64_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (UINT_FAST64_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (INTPTR_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (UINTPTR_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (INTMAX_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (UINTMAX_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (PTRDIFF_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (SIG_ATOMIC_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (SIZE_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (WCHAR_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (WINT_WIDTH): Likewise.
* manual/arith.texi (Integers): Document these macros for types
specified by width properties.
* manual/lang.texi (Width of Type): Document these macros for
other standard typedefs.
* stdlib/tst-width-stdint.c: New file.
* stdlib/Makefile (tests): Add tst-width-stdint.

7 years agoresolv: Remove unsupported hook functions from the API [BZ #20016]
Florian Weimer [Wed, 21 Sep 2016 14:30:27 +0000 (16:30 +0200)]
resolv: Remove unsupported hook functions from the API [BZ #20016]

7 years agomalloc: Manual part of conversion to __libc_lock
Florian Weimer [Wed, 21 Sep 2016 14:28:08 +0000 (16:28 +0200)]
malloc: Manual part of conversion to __libc_lock

This removes the old mutex_t-related definitions from malloc-machine.h,
too.

7 years ago<arpa/nameser.h>: Remove RR type classification macros [BZ #20592]
Florian Weimer [Wed, 21 Sep 2016 14:27:14 +0000 (16:27 +0200)]
<arpa/nameser.h>: Remove RR type classification macros [BZ #20592]

The macros are no longer up-to-date, and the classification is not
useful.  In this particular case, removal without prior deprecation
seems the right approach.

7 years ago<arpa/nameser.h>, <arpa/nameser_compat.h>: Remove versions
Florian Weimer [Wed, 21 Sep 2016 14:09:20 +0000 (16:09 +0200)]
<arpa/nameser.h>, <arpa/nameser_compat.h>: Remove versions

Our header files no longer match the BIND versions.

7 years agoresolv: Remove the BIND_4_COMPAT macro
Florian Weimer [Wed, 21 Sep 2016 14:09:03 +0000 (16:09 +0200)]
resolv: Remove the BIND_4_COMPAT macro

7 years agoRemove obsolete DNSSEC support [BZ #20591]
Florian Weimer [Wed, 21 Sep 2016 14:08:31 +0000 (16:08 +0200)]
Remove obsolete DNSSEC support [BZ #20591]

The removed function declaration have never been implemented in libresolv.

7 years agomanual: Clarify the documentation of strverscmp [BZ #20524]
Florian Weimer [Wed, 21 Sep 2016 13:41:17 +0000 (15:41 +0200)]
manual: Clarify the documentation of strverscmp [BZ #20524]

7 years agoAdd test case for O_TMPFILE handling in open, openat
Florian Weimer [Wed, 21 Sep 2016 13:24:01 +0000 (15:24 +0200)]
Add test case for O_TMPFILE handling in open, openat

Also put xasprintf into test-skeleton.c (written in such a way that
including <stdarg.h> is not needed).

7 years agoAvoid running $(CXX) during build to obtain header file paths
Florian Weimer [Wed, 21 Sep 2016 08:45:32 +0000 (10:45 +0200)]
Avoid running $(CXX) during build to obtain header file paths

This reduces the build time somewhat and is particularly noticeable
during rebuilds with few code changes.

7 years agoGenerate .op pattern rules for profiling builds only
Florian Weimer [Wed, 21 Sep 2016 08:45:19 +0000 (10:45 +0200)]
Generate .op pattern rules for profiling builds only

.op pattern rules are not used in non-profiling builds.

This does not cause any changes to both profiling and non-profiling
builds.

7 years agosln: Preprocessor cleanups
Florian Weimer [Wed, 21 Sep 2016 08:42:52 +0000 (10:42 +0200)]
sln: Preprocessor cleanups

7 years agoFix old-style function definition
Samuel Thibault [Tue, 20 Sep 2016 20:25:37 +0000 (22:25 +0200)]
Fix old-style function definition

* mach/errstring.c (mach_error_type, mach_error_string): Fix old-style
function definition.

7 years agomach: Fix old-style function definition.
Samuel Thibault [Tue, 20 Sep 2016 20:24:13 +0000 (22:24 +0200)]
mach: Fix old-style function definition.

* mach/mach_error.c (mach_error): Fix old-style function definition.

7 years agoposix: Correctly block/unblock all signals on Linux posix_spawn
Adhemerval Zanella [Wed, 14 Sep 2016 17:41:21 +0000 (14:41 -0300)]
posix: Correctly block/unblock all signals on Linux posix_spawn

This patch correctly block and unblocks all signals when executing
Linux posix_spawn by using the __libc_signal_{un}block_all functions
instead of default sigprocmask.  The latter might remove both
SIGCANCEL and SIGSETXID from the blocked signal list.

Checked on x86_64, i686, powerpc64le, and aarch64.

* sysdeps/unix/sysv/linux/spawni.c (__spawnix): Correctly block and unblock
all signals when executing the clone vfork child.
(SIGALL_SET): Remove macro.

7 years agoposix: Correctly enable/disable cancellation on Linux posix_spawn
Adhemerval Zanella [Wed, 14 Sep 2016 17:07:20 +0000 (14:07 -0300)]
posix: Correctly enable/disable cancellation on Linux posix_spawn

This patch correctly enable and disable asynchronous cancellation on
Linux posix_spawn.  Current code invert the logic by enabling and
disabling instead.  It also adds a new test to check if posix_spawn
is not a cancellation entrypoint.

Checked on x86_64, i686, powerpc64le, and aarch64.

* nptl/Makefile (tests): Add tst-exec5.
* nptl/tst-exec5.c: New file.
* sysdeps/unix/sysv/linux/spawni.c (__spawni): Correctly enable and disable
asynchronous cancellation.

7 years agoFix exc2signal.c template
Samuel Thibault [Tue, 20 Sep 2016 19:58:36 +0000 (21:58 +0200)]
Fix exc2signal.c template

As a follow-up to 0e3426bbcf2ff61d06d580fc9362fde79953a281

* hurd/exc2signal.c: #include <hurd/signal.h>
(_hurd_exception2signal): Replace 'exception', 'code', 'subcode',
'sigcode', 'error' parameters with 'detail' parameter.  Fix code
accordingly.

7 years agoBuild s_nan* objects from a generic template
Paul E. Murphy [Mon, 12 Sep 2016 22:32:07 +0000 (17:32 -0500)]
Build s_nan* objects from a generic template

This requires adding a macro to synthesize the call
to __strto*_nan.  Since this is likely to be the only
usage ever for strto* functions in generated libm
calls, a dedicated macro is defined for it.

7 years agoRemove __nan{f,,l} macros
Paul E. Murphy [Mon, 12 Sep 2016 22:11:45 +0000 (17:11 -0500)]
Remove __nan{f,,l} macros

Use the GCC builtin instead.  With the exception of the
files built from a template, they are unused.  This
is preparation for making the s_nanF objects generated.

7 years agoMake ldexpF generic.
Paul E. Murphy [Thu, 8 Sep 2016 13:48:08 +0000 (08:48 -0500)]
Make ldexpF generic.

This one is a little more tricky since it is built both for
libm and libc, and exports multiple aliases.

To simplify aliasing, a new macro is introduced which handles
aliasing to two symbols.  By default, it just applies
declare_mgen_alias to both target symbols.

Likewise, the makefile is tweaked a little to generate
templates for shared files too, and a new rule is added
to build m_*.c objects from the objpfx directory.

Verified there are no symbol or code changes using a script
to diff the *_ldexp* object files on s390x, aarch64, arm,
x86_64, and ppc64.

7 years agoRemove remnants of .og patterns
Florian Weimer [Tue, 20 Sep 2016 10:18:13 +0000 (12:18 +0200)]
Remove remnants of .og patterns

This was used by --enable-omitfp, and the bulk of it was removed in this
commit:

commit bdeba1354b7364d9b7857a048286a71ddbcdff86
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Sat Jan 7 11:29:31 2012 -0500

    Remove --enable-omitfp support

7 years agosysd-rules: Cut down the number of rtld-% pattern rules
Florian Weimer [Tue, 20 Sep 2016 08:41:04 +0000 (10:41 +0200)]
sysd-rules: Cut down the number of rtld-% pattern rules

rtld only needs shared objects, so the other patterns are pointless and
significantly increase the work make has to perform while identifying
which pattern rule to apply.

7 years agopowerpc: Fix POWER9 implies
Tulio Magno Quites Machado Filho [Fri, 16 Sep 2016 20:31:58 +0000 (17:31 -0300)]
powerpc: Fix POWER9 implies

Fix multiarch build for POWER9 by correcting the order of the
directories listed at sysnames configure variable.

7 years agoAdd <limits.h> integer width macros.
Joseph Myers [Mon, 19 Sep 2016 12:25:36 +0000 (12:25 +0000)]
Add <limits.h> integer width macros.

TS 18661-1 defines macros for the width of integer types, intended for
use with the fromfp functions to convert from floating-point types to
integer types of any width, in any rounding mode and with control over
whether "inexact" is raised.  Such macros are, of course, more
generally useful than just with those functions.

Those macros are added to <limits.h> and <stdint.h>.  This patch adds
the <limits.h> macros to glibc's header, with the <stdint.h> ones
intended to be added in a separate patch (which would add to the NEWS
entry created by this patch).  I've also added these macros to GCC's
headers for GCC 7, but definitions in glibc's <limits.h> are still
useful for older GCC, for non-GNU compilers and for when it's
_GNU_SOURCE rather than __STDC_WANT_IEC_60559_BFP_EXT__ that implies
the macros should be defined since the GCC header only considers
__STDC_WANT_IEC_60559_BFP_EXT__ (and for glibc systems, the
definitions in GCC's <stdint.h> will only be used with
-ffreestanding).

Tested for x86_64 and x86.

* include/limits.h: Define
__GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION and include
<bits/libc-header-start.h> instead of including <features.h>.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (CHAR_WIDTH): New macro.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (SCHAR_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (UCHAR_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (SHRT_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (USHRT_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (INT_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (UINT_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (LONG_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (ULONG_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (LLONG_WIDTH): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (ULLONG_WIDTH): Likewise.
* manual/lang.texi (Width of Type): Document these macros.
* stdlib/tst-width.c: New file.
* stdlib/Makefile (tests): Add tst-width.

7 years agohurd: fix fcntl visibility
Samuel Thibault [Sun, 18 Sep 2016 21:48:55 +0000 (23:48 +0200)]
hurd: fix fcntl visibility

* sysdeps/posix/dup.c (__dup): Call __fcntl instead of fcntl.

7 years agohurd: fix pathconf visibility
Samuel Thibault [Sun, 18 Sep 2016 21:45:12 +0000 (23:45 +0200)]
hurd: fix pathconf visibility

* intl/dcigettext.c (PATH_MAX): Call __pathconf instead of pathconf.

7 years agonptl: Consolidate sem_init implementations
Adhemerval Zanella [Thu, 15 Sep 2016 14:21:52 +0000 (11:21 -0300)]
nptl: Consolidate sem_init implementations

Current sparc32 sem_init and default one only differ on sem.newsem.pad
initialization.  This patch removes sparc32 and sparc32v9 sem_init arch
specific implementation and set sparc32 to use nptl default one.
The default implementation sets the required sem.newsem.pad to 0 (which
is ununsed in other architectures).

I checked on i686 and a sparc32v9 build.

        * nptl/sem_init.c (sem_init): Init pad value to 0.
        * sysdeps/sparc/sparc32/sem_init.c: Remove file.
        * sysdeps/sparc/sparc32/sparcv9/sem_init.c: Likewise.

7 years agort: Set shm_open as a non cancellation point (BZ #18243)
Adhemerval Zanella [Mon, 22 Aug 2016 13:31:42 +0000 (10:31 -0300)]
rt: Set shm_open as a non cancellation point (BZ #18243)

This patch changes shm_open to not act as a cancellation point.
Cancellation is disable at start and reenable in function exit.
It fixes BZ #18243.

Tested on x86_64 and i686.

[BZ #18243]
* rt/Makefile (test): Add tst-shm-cancel.
* rt/tst-shm-cancel.c: New file.
* sysdeps/posix/shm_open.c: Disable asynchronous cancellation.

7 years agonptl: Fix sem_wait and sem_timedwait cancellation (BZ#18243)
Adhemerval Zanella [Mon, 22 Aug 2016 12:39:46 +0000 (09:39 -0300)]
nptl: Fix sem_wait and sem_timedwait cancellation (BZ#18243)

This patch fixes both sem_wait and sem_timedwait cancellation point for
uncontended case.  In this scenario only atomics are involved and thus
the futex cancellable call is not issue and a pending cancellation signal
is not handled.

The fix is straighforward by calling pthread_testcancel is both function
start.  Although it would be simpler to call CANCELLATION_P directly, I
decided to add an internal pthread_testcancel alias and use it to export
less internal implementation on such function.  A possible change on
how pthread_testcancel is internally implemented would lead to either
continue to force use CANCELLATION_P or to adjust its every use.

GLIBC testcase also does have tests for uncontended cases, test-cancel12
and test-cancel14.c,  however both are flawed by adding another
cancellation point just after thread pthread_cleanup_pop:

 47 static void *
 48 tf (void *arg)
 49 {
 50   pthread_cleanup_push (cleanup, NULL);
 51
 52   int e = pthread_barrier_wait (&bar);
 53   if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
 54     {
 55       puts ("tf: 1st barrier_wait failed");
 56       exit (1);
 57     }
 58
 59   /* This call should block and be cancelable.  */
 60   sem_wait (&sem);
 61
 62   pthread_cleanup_pop (0);
 63
 64   puts ("sem_wait returned");
 65
 66   return NULL;
 67 }

So sem_{timed}wait does not act on cancellation, pthread_cleanup_pop executes
'cleanup' and then 'puts' acts on cancellation.  Since pthread_cleanup_pop
removed the clean-up handler, it will ran only once and thus it won't accuse
an error to indicate sem_wait has not acted on the cancellation signal.

This patch also fixes this behavior by removing the cancellation point 'puts'.
It also adds some cleanup on all sem_{timed}wait cancel tests.

It partially fixes BZ #18243.  Checked on x86_64.

[BZ #18243]
* nptl/pthreadP.h (__pthread_testcancel): Add prototype and hidden_proto.
* nptl/pthread_testcancel.c (pthread_cancel): Add internal aliais
definition.
* nptl/sem_timedwait.c (sem_timedwait): Add cancellation check for
uncontended case.
* nptl/sem_wait.c (__new_sem_wait): Likewise.
* nptl/tst-cancel12.c (cleanup): Remove wrong cancellation point.
(tf): Fix check for uncontended case.
(do_test): Likewise.
* nptl/tst-cancel13.c (cleanup): Remove wrong cancellation point.
(tf): Fix check for uncontended case.
(do_test): Likewise.
* nptl/tst-cancel14.c (cleanup): Remove wrong cancellation point.
(tf): Fix check for uncontended case.
(do_test): Likewise.
* nptl/tst-cancel15.c (cleanup): Remove wrong cancellation point.
(tf): Fix check for uncontended case.
(do_test): Likewise.

7 years agonptl: Remove sparc sem_wait
Adhemerval Zanella [Sun, 21 Aug 2016 20:14:35 +0000 (17:14 -0300)]
nptl: Remove sparc sem_wait

This patch removes the sparc32 sem_wait.c implementation since it is
identical to default nptl one.  The sparcv9 is no longer required with
the removal.

Checked with a sparcv9 build.

* sysdeps/sparc/sparc32/sem_wait.c: Remove file.
* sysdeps/sparc/sparc32/sparcv9/sem_wait.c: Likewise.

7 years agonptl: Set sem_open as a non cancellation point (BZ #15765)
Adhemerval Zanella [Sat, 20 Aug 2016 14:23:08 +0000 (11:23 -0300)]
nptl: Set sem_open as a non cancellation point (BZ #15765)

This patch changes sem_open to not act as a cancellation point.
Cancellation is disable at start and reenable in function exit.
It fixes BZ #15765.

Tested on x86_64 and i686.

[BZ #15765]
* nptl/Makefile (tests): Add tst-sem16.
* nptl/tst-sem16.c: New file.
* nptl/sem_open.c (sem_open): Disable asynchronous cancellation.

7 years agonptl: Consolidate sem_open implementations
Adhemerval Zanella [Fri, 19 Aug 2016 18:30:01 +0000 (15:30 -0300)]
nptl: Consolidate sem_open implementations

Current sparc32 sem_open and default one only differ on:

  1. Default one contains a 'futex_supports_pshared' check.
  2. sem.newsem.pad is initialized to zero.

This patch removes sparc32 and sparc32v9 sem_open arch specific
implementation and instead set sparc32 to use nptl default one.
Using 1. is fine since it should always evaluate 0 for Linux
(an optimized away by the compiler). Adding 2. to default
implementation should be ok since 'pad' field is used mainly
on sparc32 code.

I checked on i686 and checked a sparc32v9 build.

* nptl/sem_open.c (sem_open): Init pad value to 0.
* sysdeps/sparc/sparc32/sem_open.c: Remove file.
* sysdeps/sparc/sparc32/sparcv9/sem_open.c: Likewise.

7 years agoinet: Add __inet6_scopeid_pton function [BZ #20611]
Florian Weimer [Thu, 15 Sep 2016 13:46:30 +0000 (15:46 +0200)]
inet: Add __inet6_scopeid_pton function [BZ #20611]

__inet6_scopeid_pton implements strict validation of numeric scope IDs.
Use it in getaddrinfo and __res_vinit.

7 years agoRemove the ptw-% patterns
Florian Weimer [Wed, 14 Sep 2016 14:02:06 +0000 (16:02 +0200)]
Remove the ptw-% patterns

Nothing depends on the PTW macro anymore, so the mechanism to define
PTW for recompliations of libc routines is no longer needed.  The
source files are still recompiled for the nptl directory, just without
the “ptw-” prefix.

(Reducing the number of pattern rules in sysd-rules is critical for
improving make performance.)

7 years agoldbl-128: Use L(x) macro for long double constants
Paul E. Murphy [Fri, 2 Sep 2016 16:01:07 +0000 (11:01 -0500)]
ldbl-128: Use L(x) macro for long double constants

This runs the attached sed script against these files using
a regex which aggressively matches long double literals
when not obviously part of a comment.

Likewise, 5 digit or less integral constants are replaced
with integer constants, excepting the two cases of 0 used
in large tables, which are also the only integral values
of the form x.0*E0L encountered within these converted
files.

Likewise, -L(x) is transformed into L(-x).

Naturally, the script has a few minor hiccups which are
more clearly remedied via the attached fixup patch.  Such
hiccups include, context-sensitive promotion to a real
type, and munging constants inside harder to detect
comment blocks.

7 years agoresolv: Remove _LIBC_REENTRANT
Florian Weimer [Tue, 13 Sep 2016 13:08:37 +0000 (15:08 +0200)]
resolv: Remove _LIBC_REENTRANT

7 years agoAdd tests-static to tests in malloc/Makefile
Siddhesh Poyarekar [Sat, 10 Sep 2016 10:40:51 +0000 (16:10 +0530)]
Add tests-static to tests in malloc/Makefile

This is a trivial change to add the static tests only to tests-static
and then adding all of tests-static to the tests target to make it
look consistent with some other Makefiles.  This avoids having to
duplicate the test names across the two make targets.

* malloc/Makefile (tests): Remove individual static test names
and just add all of tests-static.

7 years agoRemove __libc_csu_irel declaration
Siddhesh Poyarekar [Sat, 10 Sep 2016 10:20:53 +0000 (15:50 +0530)]
Remove __libc_csu_irel declaration

21ad055803de5dd03606588753c46fbf8a5863b2 removed the function, but
missed the declaration in libc-start.  Removed and verified that the
generated assembly is unchanged.

* csu/libc-start.c (__libc_csu_irel): Remove declaration.

7 years agoAdd e500 version of fetestexceptflag.
Joseph Myers [Wed, 7 Sep 2016 17:47:11 +0000 (17:47 +0000)]
Add e500 version of fetestexceptflag.

When I added fetestexceptflag, I missed that e500 was another case
that needed its own version because saved exceptions were not directly
stored in a form that could be ANDed with exception bits (they were
stored with exceptions in SPE form, but the FE_* macros always use the
classic hard-float form).  This patch adds an e500 version with the
required call to __fexcepts_from_spe to convert from one form to the
other.

Tested for e500.

* sysdeps/powerpc/powerpc32/e500/nofpu/fetestexceptflag.c: New
file.

7 years agoAdd femode_t functions: sparc.
Joseph Myers [Wed, 7 Sep 2016 16:48:41 +0000 (16:48 +0000)]
Add femode_t functions: sparc.

This patch adds SPARC versions of fegetmode and fesetmode.  Untested.

* sysdeps/sparc/fpu/fegetmode.c: New file.
* sysdeps/sparc/fpu/fesetmode.c: Likewise.

7 years agoAdd femode_t functions: sh.
Joseph Myers [Wed, 7 Sep 2016 16:48:08 +0000 (16:48 +0000)]
Add femode_t functions: sh.

This patch adds SH versions of fegetmode and fesetmode.  Untested.

* sysdeps/sh/sh4/fpu/fegetmode.c: New file.
* sysdeps/sh/sh4/fpu/fesetmode.c: Likewise.

7 years agoAdd femode_t functions: s390.
Joseph Myers [Wed, 7 Sep 2016 16:47:30 +0000 (16:47 +0000)]
Add femode_t functions: s390.

This patch adds S/390 versions of fegetmode and fesetmode.  Untested.

* sysdeps/s390/fpu/fegetmode.c: New file.
* sysdeps/s390/fpu/fesetmode.c: Likewise.

7 years agoAdd femode_t functions: powerpc.
Joseph Myers [Wed, 7 Sep 2016 16:46:47 +0000 (16:46 +0000)]
Add femode_t functions: powerpc.

This patch adds PowerPC versions of fegetmode and fesetmode.

* sysdeps/powerpc/fpu/fegetmode.c: New file.
* sysdeps/powerpc/fpu/fesetmode.c: Likewise.
* sysdeps/powerpc/nofpu/fegetmode.c: Likewise.
* sysdeps/powerpc/nofpu/fesetmode.c: Likewise.
* sysdeps/powerpc/powerpc32/e500/nofpu/fegetmode.c: Likewise.
* sysdeps/powerpc/powerpc32/e500/nofpu/fesetmode.c: Likewise.

7 years agoAdd femode_t functions: mips.
Joseph Myers [Wed, 7 Sep 2016 16:46:02 +0000 (16:46 +0000)]
Add femode_t functions: mips.

This patch adds MIPS versions of fegetmode and fesetmode.

* sysdeps/mips/fpu/fegetmode.c: New file.
* sysdeps/mips/fpu/fesetmode.c: Likewise.

7 years agoAdd femode_t functions: m68k.
Joseph Myers [Wed, 7 Sep 2016 16:45:21 +0000 (16:45 +0000)]
Add femode_t functions: m68k.

This patch adds M68K versions of fegetmode and fesetmode.  Untested.

* sysdeps/m68k/fpu/fegetmode.c: New file.
* sysdeps/m69k/fpu/fesetmode.c: Likewise.

7 years agoAdd femode_t functions: ia64.
Joseph Myers [Wed, 7 Sep 2016 16:44:22 +0000 (16:44 +0000)]
Add femode_t functions: ia64.

This patch adds IA64 versions of fegetmode and fesetmode.  Untested.

* sysdeps/ia64/fpu/fegetmode.c: New file.
* sysdeps/ia64/fpu/fesetmode.c: Likewise.

7 years agoAdd femode_t functions: hppa.
Joseph Myers [Wed, 7 Sep 2016 16:43:43 +0000 (16:43 +0000)]
Add femode_t functions: hppa.

This patch adds HPPA versions of fegetmode and fesetmode.  Untested.

* sysdeps/hppa/fpu/fegetmode.c: New file.
* sysdeps/hppa/fpu/fesetmode.c: Likewise.

7 years agoAdd femode_t functions: arm.
Joseph Myers [Wed, 7 Sep 2016 16:43:03 +0000 (16:43 +0000)]
Add femode_t functions: arm.

This patch adds ARM versions of fegetmode and fesetmode.

* sysdeps/arm/fegetmode.c: New file.
* sysdeps/arm/fesetmode.c: Likewise.

7 years agoAdd femode_t functions: alpha.
Joseph Myers [Wed, 7 Sep 2016 16:42:19 +0000 (16:42 +0000)]
Add femode_t functions: alpha.

This patch adds Alpha versions of fegetmode and fesetmode.  Untested.

* sysdeps/alpha/fpu/fegetmode.c: New file.
* sysdeps/alpha/fpu/fesetmode.c: Likewise.

7 years agoAdd femode_t functions: aarch64.
Joseph Myers [Wed, 7 Sep 2016 16:41:20 +0000 (16:41 +0000)]
Add femode_t functions: aarch64.

This patch adds AArch64 versions of fegetmode and fesetmode.
Untested.

* sysdeps/aarch64/fpu/fegetmode.c: New file.
* sysdeps/aarch64/fpu/fesetmode.c: Likewise.

7 years agoAdd femode_t functions.
Joseph Myers [Wed, 7 Sep 2016 16:40:09 +0000 (16:40 +0000)]
Add femode_t functions.

TS 18661-1 defines a type femode_t to represent the set of dynamic
floating-point control modes (such as the rounding mode and trap
enablement modes), and functions fegetmode and fesetmode to manipulate
those modes (without affecting other state such as the raised
exception flags) and a corresponding macro FE_DFL_MODE.

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

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

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

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

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

* math/fegetmode.c: New file.
* math/fesetmode.c: Likewise.
* sysdeps/i386/fpu/fegetmode.c: Likewise.
* sysdeps/i386/fpu/fesetmode.c: Likewise.
* sysdeps/x86_64/fpu/fegetmode.c: Likewise.
* sysdeps/x86_64/fpu/fesetmode.c: Likewise.
* math/fenv.h: Update comment on inclusion of <bits/fenv.h>.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (fegetmode): New function
declaration.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (fesetmode): Likewise.
* bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (femode_t): New
typedef.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
* sysdeps/aarch64/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(femode_t): New typedef.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
* sysdeps/alpha/fpu/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(femode_t): New typedef.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
* sysdeps/arm/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(femode_t): New typedef.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
* sysdeps/hppa/fpu/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(femode_t): New typedef.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
* sysdeps/ia64/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(femode_t): New typedef.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
* sysdeps/m68k/fpu/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(femode_t): New typedef.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
* sysdeps/microblaze/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(femode_t): New typedef.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
* sysdeps/mips/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(femode_t): New typedef.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
* sysdeps/nios2/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(femode_t): New typedef.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
* sysdeps/powerpc/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(femode_t): New typedef.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (__fe_dfl_mode): New variable
declaration.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
* sysdeps/s390/fpu/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(femode_t): New typedef.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
* sysdeps/sh/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(femode_t): New typedef.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
* sysdeps/sparc/fpu/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(femode_t): New typedef.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
* sysdeps/tile/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(femode_t): New typedef.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
* sysdeps/x86/fpu/bits/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(femode_t): New typedef.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (FE_DFL_MODE): New macro.
* manual/arith.texi (FE_DFL_MODE): Document macro.
(fegetmode): Document function.
(fesetmode): Likewise.
* math/Versions (fegetmode): New libm symbol at version
GLIBC_2.25.
(fesetmode): Likewise.
* math/Makefile (libm-support): Add fegetmode and fesetmode.
(tests): Add test-femode and test-femode-traps.
* math/test-femode-traps.c: New file.
* math/test-femode.c: Likewise.
* sysdeps/powerpc/fpu/fenv_const.c (__fe_dfl_mode): Declare as
alias for __fe_dfl_env.
* sysdeps/powerpc/nofpu/fenv_const.c (__fe_dfl_mode): Likewise.
* sysdeps/powerpc/powerpc32/e500/nofpu/fenv_const.c
(__fe_dfl_mode): Likewise.
* sysdeps/powerpc/Versions (__fe_dfl_mode): New libm symbol at
version GLIBC_2.25.
* sysdeps/nacl/libm.abilist: Update.
* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.

7 years agoX86-64: Add _dl_runtime_resolve_avx[512]_{opt|slow} [BZ #20508]
H.J. Lu [Tue, 6 Sep 2016 15:50:55 +0000 (08:50 -0700)]
X86-64: Add _dl_runtime_resolve_avx[512]_{opt|slow} [BZ #20508]

There is transition penalty when SSE instructions are mixed with 256-bit
AVX or 512-bit AVX512 load instructions.  Since _dl_runtime_resolve_avx
and _dl_runtime_profile_avx512 save/restore 256-bit YMM/512-bit ZMM
registers, there is transition penalty when SSE instructions are used
with lazy binding on AVX and AVX512 processors.

To avoid SSE transition penalty, if only the lower 128 bits of the first
8 vector registers are non-zero, we can preserve %xmm0 - %xmm7 registers
with the zero upper bits.

For AVX and AVX512 processors which support XGETBV with ECX == 1, we can
use XGETBV with ECX == 1 to check if the upper 128 bits of YMM registers
or the upper 256 bits of ZMM registers are zero.  We can restore only the
non-zero portion of vector registers with AVX/AVX512 load instructions
which will zero-extend upper bits of vector registers.

This patch adds _dl_runtime_resolve_sse_vex which saves and restores
XMM registers with 128-bit AVX store/load instructions.  It is used to
preserve YMM/ZMM registers when only the lower 128 bits are non-zero.
_dl_runtime_resolve_avx_opt and _dl_runtime_resolve_avx512_opt are added
and used on AVX/AVX512 processors supporting XGETBV with ECX == 1 so
that we store and load only the non-zero portion of vector registers.
This avoids SSE transition penalty caused by _dl_runtime_resolve_avx and
_dl_runtime_profile_avx512 when only the lower 128 bits of vector
registers are used.

_dl_runtime_resolve_avx_slow is added and used for AVX processors which
don't support XGETBV with ECX == 1.  Since there is no SSE transition
penalty on AVX512 processors which don't support XGETBV with ECX == 1,
_dl_runtime_resolve_avx512_slow isn't provided.

[BZ #20495]
[BZ #20508]
* sysdeps/x86/cpu-features.c (init_cpu_features): For Intel
processors, set Use_dl_runtime_resolve_slow and set
Use_dl_runtime_resolve_opt if XGETBV suports ECX == 1.
* sysdeps/x86/cpu-features.h (bit_arch_Use_dl_runtime_resolve_opt):
New.
(bit_arch_Use_dl_runtime_resolve_slow): Likewise.
(index_arch_Use_dl_runtime_resolve_opt): Likewise.
(index_arch_Use_dl_runtime_resolve_slow): Likewise.
* sysdeps/x86_64/dl-machine.h (elf_machine_runtime_setup): Use
_dl_runtime_resolve_avx512_opt and _dl_runtime_resolve_avx_opt
if Use_dl_runtime_resolve_opt is set.  Use
_dl_runtime_resolve_slow if Use_dl_runtime_resolve_slow is set.
* sysdeps/x86_64/dl-trampoline.S: Include <cpu-features.h>.
(_dl_runtime_resolve_opt): New.  Defined for AVX and AVX512.
(_dl_runtime_resolve): Add one for _dl_runtime_resolve_sse_vex.
* sysdeps/x86_64/dl-trampoline.h (_dl_runtime_resolve_avx_slow):
New.
(_dl_runtime_resolve_opt): Likewise.
(_dl_runtime_profile): Define only if _dl_runtime_profile is
defined.

7 years agoS390: Support PLT and GOT references in check-localplt.
Stefan Liebler [Tue, 6 Sep 2016 12:44:15 +0000 (14:44 +0200)]
S390: Support PLT and GOT references in check-localplt.

on s390x the test elf/check-localplt is failing after recent commits:
"elf: Do not use memalign for TCB/TLS blocks allocation [BZ #17730]"
"elf: Avoid using memalign for TLS allocations [BZ #17730]"
"elf: dl-minimal malloc needs to respect fundamental alignment"
due to "Missing required PLT reference: ld.so: __libc_memalign".

After the commits __libc_memalign is only called in elf/dl-minimal.c in
malloc() function in ld.so and gcc -O2/-O3 leads to R_390_GLOB_DAT
instead of R_390_JMP_SLOT. __libc_memalign is called via
function-pointer loaded from GOT instead of calling via a plt-stub. In
this case there is the R_390_GLOB_DAT relocation in section .rela.dyn
instead of R_390_JMP_SLOT in .rela.plt.
This patch marks ld.so: __libc_memalign with R_390_GLOB_DAT in
localplt.data to allow both relocations.
If build with -fno-optimize-sibling-calls or on s390(31bit) a
R_390_JMP_SLOT is generated.

ChangeLog:

* sysdeps/unix/sysv/linux/s390/localplt.data: Mark
ld.so: __libc_memalign with "+ RELA R_390_GLOB_DAT".

7 years agomalloc: Automated part of conversion to __libc_lock
Florian Weimer [Tue, 6 Sep 2016 10:49:54 +0000 (12:49 +0200)]
malloc: Automated part of conversion to __libc_lock

7 years agoconform tests: call perl with '-I.'
Aurelien Jarno [Mon, 5 Sep 2016 20:53:22 +0000 (22:53 +0200)]
conform tests: call perl with '-I.'

Historically perl includes the current directory in the module search
path. Over the time this has been considered as a security issue and
the recent vulnerabilities [1] made people to reconsider this behaviour.
It is almost sure that this will be removed in the future [2], possibly
for the 5.26 release, although this is not yet firmly decided.

Debian has decided to backport the patches [3], so the perl binary in
unstable do not have '.' in @INC anymore.

This behaviour is used in the conform perl scripts to include the
GlibcConform module. This patch fixes that by calling perl with '-I.'.
This is not a security issue in this case as make ensures that the
current directory is $(srcdir)/conform/ when the scripts are called.
Passing the full path would do exactly the same.

[1] CVE-2016-1238 CVE-2016-6185
[2] https://rt.perl.org/Public/Bug/Display.html?id=127810
[3] https://lists.debian.org/debian-devel-announce/2016/08/msg00013.html

Changelog:
* conform/Makefile (conformtest-header-tests): Pass -I. to $(PERL).
(linknamespace-symlists-tests): Likewise.
(linknamespace-header-tests): Likewise.