]> sourceware.org Git - glibc.git/log
glibc.git
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.

7 years agoSet NODELETE flag after checking for NULL pointer
Aurelien Jarno [Sat, 3 Sep 2016 18:25:59 +0000 (20:25 +0200)]
Set NODELETE flag after checking for NULL pointer

The commit b632bdd3 moved the setting of the DF_1_NODELETE flag earlier
in the dl_open_worker function. However when calling dlopen with both
RTLD_NODELETE and RTLD_NOLOAD, the pointer returned by _dl_map_object is
NULL. This condition is checked just after setting the flag, while it
should be done before. Fix that.

Changelog:
[BZ #19810]
* elf/dl-open.c (dl_open_worker): Set DF_1_NODELETE flag later.
* elf/tst-noload.c: New test case.
* elf/Makefile (tests): Add tst-noload.

7 years agoNaCl: Fix compile error for __dup after libc_hidden_proto addition.
Roland McGrath [Fri, 2 Sep 2016 23:58:42 +0000 (16:58 -0700)]
NaCl: Fix compile error for __dup after libc_hidden_proto addition.

* sysdeps/nacl/dup.c: Add libc_hidden_def.

7 years agoFix generic wait3 after union wait_status removal.
Roland McGrath [Fri, 2 Sep 2016 23:57:59 +0000 (16:57 -0700)]
Fix generic wait3 after union wait_status removal.

* sysdeps/posix/wait3.c: Don't treat STAT_LOC as a union, since it's
not any more.

7 years agoNaCl: Fix compile error in clock function.
Roland McGrath [Fri, 2 Sep 2016 23:56:35 +0000 (16:56 -0700)]
NaCl: Fix compile error in clock function.

* sysdeps/nacl/clock.c (clock): nacl_abi_clock_t -> nacl_irt_clock_t

7 years agoInline all support functions for sin and cos
Siddhesh Poyarekar [Fri, 2 Sep 2016 14:36:37 +0000 (20:06 +0530)]
Inline all support functions for sin and cos

The support functions for sin and cos have a lot of identical
functionality, so inlining them gives a pretty decent jump in
functionality: ~19% in the sincos function.  On SPEC2006 this
translates to about 2.1% in the tonto test.

* sysdeps/ieee754/dbl-64/s_sin.c (do_cos): Mark as inline.
(do_cos_slow): Likewise.
(do_sin): Likewise.
(do_sin_slow): Likewise.
(slow): Likewise.
(slow1): Likewise.
(slow2): Likewise.
(sloww): Likewise.
(sloww1): Likewise.
(sloww2): Likewise.
(bsloww): Likewise.
(bsloww1): Likewise.
(bsloww2): Likewise.
(cslow2): Likewise.

7 years agoUse do_sin for sin(x) where 0.25 < |x| < 0.855469
Siddhesh Poyarekar [Thu, 1 Sep 2016 16:41:00 +0000 (22:11 +0530)]
Use do_sin for sin(x) where 0.25 < |x| < 0.855469

The only code looks slightly different from do_sin but on closer
examination, should give exactly the same result.  Drop it in favour
of the do_sin function call.

* sysdeps/ieee754/dbl-64/s_sin.c (__sin): Use do_sin.

7 years agoConsolidate input partitioning into do_cos and do_sin
Siddhesh Poyarekar [Thu, 1 Sep 2016 16:38:51 +0000 (22:08 +0530)]
Consolidate input partitioning into do_cos and do_sin

All calls to do_cos are preceded by code that partitions x into a
larger double that gives an offset into the sincos table and a smaller
double that is used in a polynomial computation.  Consolidate all of
them into do_cos and do_sin to reduce code duplication.

* sysdeps/ieee754/dbl-64/s_sin.c (do_cos): Accept X and DX as input
arguments.  Consolidate input partitioning from callers here.
(do_cos_slow): Likewise.
(do_sin): Likewise.
(do_sin_slow): Likewise.
(do_sincos_1): Remove the no longer necessary input partitioning.
(do_sincos_2): Likewise.
(__sin): Likewise.
(__cos): Likewise.
(slow1): Likewise.
(slow2): Likewise.
(sloww1): Likewise.
(sloww2): Likewise.
(bsloww1): Likewise.
(bsloww2): Likewise.
(cslow2): Likewise.

7 years agovfscanf: Avoid multiple reads of multi-byte character width
Florian Weimer [Fri, 2 Sep 2016 13:59:34 +0000 (15:59 +0200)]
vfscanf: Avoid multiple reads of multi-byte character width

This avoids a race condition if the process-global locale is changed
while vfscanf is running.  MB_LEN_MAX is always larger than MB_CUR_MAX,
so we might realloc earlier than necessary (but even MB_CUR_MAX could
be larger than the minimum required space).

The existing length was a bit questionable because str + MB_LEN_MAX
might point past the end of the buffer.

7 years agovfprintf: Avoid creating a VLA which complicates stack management
Florian Weimer [Fri, 2 Sep 2016 10:56:50 +0000 (12:56 +0200)]
vfprintf: Avoid creating a VLA which complicates stack management

7 years agoRemove unneeded stubs for k_rem_pio2l.
Paul E. Murphy [Thu, 25 Aug 2016 22:25:40 +0000 (17:25 -0500)]
Remove unneeded stubs for k_rem_pio2l.

This is only used for the float and double variants.

Instead, just add it to the type specific list of files,
and remove all stubs, and remove the declaration from
math_private.h.

I verified x86_64, i486, ia64, m68k, and ppc64 build.

7 years agoMake common fmin implementation generic.
Paul E. Murphy [Thu, 25 Aug 2016 22:03:36 +0000 (17:03 -0500)]
Make common fmin implementation generic.

7 years agoMake common fmax implementation generic.
Paul E. Murphy [Thu, 25 Aug 2016 21:48:03 +0000 (16:48 -0500)]
Make common fmax implementation generic.

Also update aarch64 to ensure the correct s_fmin.c is included.
The include order favors including the generated copy.

7 years agoMake common nextdown implementation generic.
Paul E. Murphy [Wed, 24 Aug 2016 21:05:28 +0000 (16:05 -0500)]
Make common nextdown implementation generic.

With the exception of those machines using the ldbl-opt in
an Implies file, this is a trivial transformation.

nextdownl is not subject to the non-trivial versioning rules
of the other generated functions, so to keep things simple,
it is handled as a one-off case in ldbl-opt to preserve the
existing behavior.

7 years agoMake common fdim implementation generic.
Paul E. Murphy [Thu, 25 Aug 2016 16:25:33 +0000 (11:25 -0500)]
Make common fdim implementation generic.

The only difference is the usage of math_narrow_eval when
building s_fdiml.c.  This should be harmless for long double,
but I did observe some code generation changes on m68k, but
lack the resources to test it.

Likewise, to more easily support overriding symbol generation,
the aliasing macros are always conditionally defined on their
absence to reduce boilerplate.

I also ran builds for i486, ppc64, sparcv9, aarch64,
s390x and observed no changes to s_fdim* objects.

7 years agoBase <sys/quota.h> on Linux kernel headers [BZ #20525]
Florian Weimer [Thu, 1 Sep 2016 13:53:13 +0000 (15:53 +0200)]
Base <sys/quota.h> on Linux kernel headers [BZ #20525]

Macros which are also defined in <linux/quota.h> are removed, and
<linux/quota.h> is included instead.

This commit cleans up the definition of fs_to_dq_blocks and struct
dqblock and struct dqinfo, too.

7 years agoldbl-128: Cleanup e_gammal_r.c after _Float128 rename
Paul E. Murphy [Wed, 31 Aug 2016 18:17:35 +0000 (13:17 -0500)]
ldbl-128: Cleanup e_gammal_r.c after _Float128 rename

7 years agoldbl-128: Rename 'long double' to '_Float128'
Paul E. Murphy [Wed, 20 Jul 2016 20:20:51 +0000 (15:20 -0500)]
ldbl-128: Rename 'long double' to '_Float128'

Add a layer of macro indirection for long double files
which need to be built using another typename.  Likewise,
add the L(num) macro used in a later patch to override
real constants.

These macros are only defined through the ldbl-128
math_ldbl.h header, thereby implicitly restricting
these macros to machines which back long double
with an IEEE binary128 format.

Likewise, appropriate changes are made for the few
files which indirectly include such ldbl-128 files.

These changes produce identical binaries for s390x,
aarch64, and ppc64.

7 years agoS390: Do not set FE_INEXACT with feraiseexcept (FE_OWERFLOW|FE_UNDERFLOW).
Stefan Liebler [Wed, 31 Aug 2016 12:54:55 +0000 (14:54 +0200)]
S390: Do not set FE_INEXACT with feraiseexcept (FE_OWERFLOW|FE_UNDERFLOW).

On s390 feraiseexcept (FE_OVERFLOW|FE_UNDERFLOW) sets FE_INEXACT, too.
This patch uses z196 zarch load rounded instruction which can suppress
FE_INEXACT exception if gcc has z196 support in used configuration.
Otherwise FE_INEXACT flag is set as before. The gcc support is tested
in a new configure-check.

A comment in fsetexcptflg.c is corrected as new exceptions are not
executed with the next floating-point instruction if fpc is set with
_FPU_SETCW macro. It seems the comment was copied e.g. from
sysdeps/x86_64/fpu/fsetexcptflg.c file.

ChangeLog:

* config.h.in (HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT):
New undefine.
* sysdeps/s390/configure.ac: Add test for z196 zarch support.
* sysdeps/s390/configure: Regenerated.
* sysdeps/s390/fpu/fraiseexcpt.c (__feraiseexcept): Use ledbra
instruction for raising over-/underflow if z196 zarch is supported
by default.
* sysdeps/s390/fpu/fsetexcptflg.c (fesetexceptflag):
Correct comment.

7 years agohurd: Fix adjtime call with OLDDELTA == NULL
Svante Signell [Tue, 30 Aug 2016 21:06:31 +0000 (23:06 +0200)]
hurd: Fix adjtime call with OLDDELTA == NULL

* sysdeps/mach/hurd/adjtime.c (__adjtime): When OLDDELTA is NULL, make
it point to a dumb buffer for RPC to fill it.

7 years agoUse fabs(x) instead of branching on signedness of input to sin and cos
Siddhesh Poyarekar [Tue, 30 Aug 2016 07:31:59 +0000 (13:01 +0530)]
Use fabs(x) instead of branching on signedness of input to sin and cos

The sin and cos code is inconsistent about its use of fabs to get the
absolute value of X where in some places it conditionalizes the code
while in others it uses fabs.  fabs seems to be a better candidate in
most cases because it avoids a branch.  Similarly there is an attempt
to make it easier for the compiler to emit conditional assignment
instructions (like fcsel on aarch64) where it can, by isolating
conditional assignment constructs from the rest of the expression.

A further benefit of this change is to identify common constructs
across functions and consolidate them in future patches.

* sysdeps/ieee754/dbl-64/s_sin.c (do_cos_slow): Use ternary
instead of if/else.
(do_sin_slow): Likewise.
(do_sincos_1): Use fabs instead of if/else.
(do_sincos_2): Likewise.
(__sin): Likewise.
(__cos): Likewise.
(slow2): Likewise.
(sloww): Likewise.
(sloww1): Likewise.  Drop argument M.
(sloww2): Use fabs instead of if/else.
(bsloww): Likewise.
(bsloww1): Likewise.
(bsloww2): Likewise.

7 years agoAdd fall through comments
Siddhesh Poyarekar [Tue, 30 Aug 2016 07:30:29 +0000 (13:00 +0530)]
Add fall through comments

Add fall through comments I had missed writing in previously.

7 years agoConsolidate reduce_and_compute code
Siddhesh Poyarekar [Tue, 30 Aug 2016 07:21:39 +0000 (12:51 +0530)]
Consolidate reduce_and_compute code

This patch reshuffles the reduce_and_compute code so that the
structure matches other code structures of the same type elsewhere in
s_sin.c and s_sincos.c.  This is the beginning of an attempt to
consolidate and reduce code duplication in functions in s_sin.c to
make it easier to read and possibly also easier for the compiler to
optimize.

* sysdeps/ieee754/dbl-64/s_sin.c (reduce_and_compute):
Consolidate switch cases 0 and 2.

7 years agoConvert remaining complex function to generated files
Paul E. Murphy [Tue, 28 Jun 2016 19:28:04 +0000 (14:28 -0500)]
Convert remaining complex function to generated files

Convert cpow, clog, clog10, cexp, csqrt, and cproj functions
into generated templates.  Note, ldbl-opt still retains
s_clog10l.c as the aliasing rules are non-trivial.

7 years agoPrepare to convert remaining _Complex functions
Paul E. Murphy [Fri, 1 Jul 2016 16:03:51 +0000 (11:03 -0500)]
Prepare to convert remaining _Complex functions

This patch has no function changes, except to
ensure the git history correctly tracks the
changes to convert the double version of these
functions into a templated version.

7 years agosparcv9: Restore fdiml@GLIBC_2.1
Paul E. Murphy [Fri, 26 Aug 2016 18:58:19 +0000 (13:58 -0500)]
sparcv9: Restore fdiml@GLIBC_2.1

Use s_fdim.c from sysdeps/ieee754/ldbl-opt/ instead of
math/ to ensure a compat symbol for fdiml is created.

7 years agoAdd fetestexceptflag.
Joseph Myers [Mon, 29 Aug 2016 11:47:21 +0000 (11:47 +0000)]
Add fetestexceptflag.

TS 18661-1 defines an fetestexceptflag function to test the exception
state saved in an fexcept_t object by fegetexceptflag.

This patch implements this function for glibc.  Almost all
architectures save exception state in such a way that it can be
directly ANDed with exception flag bits, so rather than having lots of
fetestexceptflag implementations that all do the same thing, the math/
implementation is made to use this generic logic (which is also OK in
the fallback case where FE_ALL_EXCEPT is zero).  The only architecture
that seems to need anything different is s390.

(fegetexceptflag and fesetexceptflag use abbreviated filenames
fgetexcptflg.c and fsetexcptflg.c.  Because we are no longer concerned
by 14-character filename limits, fetestexceptflag uses the obvious
filename fetestexceptflag.c.)

The NEWS entry is intended to be expanded along the lines given in
<https://sourceware.org/ml/libc-alpha/2016-08/msg00356.html> when
fegetmode and fesetmode are added.

Tested for x86_64, x86, mips64 and powerpc.

* math/fetestexceptflag.c: New file.
* sysdeps/s390/fpu/fetestexceptflag.c: Likewise.  Comment by
Stefan Liebler.
* math/fenv.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(fetestexceptflag): New function declaration.
* manual/arith.texi (fetestexceptflag): Document function.
* math/Versions (fetestexceptflag): New libm symbol at version
GLIBC_2.25.
* math/Makefile (libm-support): Add fetestexceptflag.
(tests): Add test-fetestexceptflag.
* math/test-fetestexceptflag.c: New file.
* 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 agomalloc: Simplify static malloc interposition [BZ #20432]
Florian Weimer [Fri, 26 Aug 2016 20:40:27 +0000 (22:40 +0200)]
malloc: Simplify static malloc interposition [BZ #20432]

Existing interposed mallocs do not define the glibc-internal
fork callbacks (and they should not), so statically interposed
mallocs lead to link failures because the strong reference from
fork pulls in glibc's malloc, resulting in multiple definitions
of malloc-related symbols.

7 years agoFix test-skeleton C99 designed initialization
Adhemerval Zanella [Fri, 26 Aug 2016 20:33:47 +0000 (17:33 -0300)]
Fix test-skeleton C99 designed initialization

ISO C forbids empty initializer braces (6.7.9 initializer-list must
contain at least one initializer). However GCC allows it, generating
a warning depending of the version.

With GCC 4.8 on ARM I noticed tst-initializers1.c fails to build with:

In file included from tst-initializers1.c:60:0:
../test-skeleton.c: In function 'delayed_exit_thread':
../test-skeleton.c:687:10: error: missing initializer for field 'tv_sec' of 'struct timespec' [-Werror=missing-field-initializers]
   struct timespec remaining = {}

While with GCC 5.1 the same warning is just spilled with -pedantic.
To be safe this patch just zero initialize the struct as expected.

Tested on armhf.

* test-skeleton.c (delayed_exit_thread): Add initializer on struct
timespec C99 designated initialization.

This page took 0.107404 seconds and 5 git commands to generate.