platform/upstream/glibc.git
10 years agoChangeLog cleanup
Andreas Schwab [Wed, 30 Apr 2014 14:23:50 +0000 (16:23 +0200)]
ChangeLog cleanup

10 years agoMore fixes for unsafe compiler optimization
Adhemerval Zanella [Tue, 29 Apr 2014 19:15:45 +0000 (14:15 -0500)]
More fixes for unsafe compiler optimization

GCC 4.9 -ftree-loop-distribute-patterns now may transform loops in
memcpy.  Add the alias to internal GLIBC symbol to avoid PLT creation.

10 years agoFix lll_unlock twice in pthread_cond_broadcast
Yang Yingliang [Wed, 30 Apr 2014 10:16:18 +0000 (15:46 +0530)]
Fix lll_unlock twice in pthread_cond_broadcast

lll_unlock() will be called again if it goes to "wake_all" in
pthread_cond_broadcast(). This may make another thread which is
waiting for lock in pthread_cond_timedwait() unlock.  So there are
more than one threads get the lock, it will break the shared data.

It's introduced by commit 8313cb997d2d("FUTEX_*_REQUEUE_PI support for
non-x86 code")

10 years agoInitialize all of datahead structure in nscd (BZ #16791)
Siddhesh Poyarekar [Wed, 30 Apr 2014 06:30:39 +0000 (12:00 +0530)]
Initialize all of datahead structure in nscd (BZ #16791)

The datahead structure has an unused padding field that remains
uninitialized.  Valgrind prints out a warning for it on querying a
netgroups entry.  This is harmless, but is a potential data leak since
it would result in writing out an uninitialized byte to the cache
file.  Besides, this happens only when there is a cache miss, so we're
not adding computation to any fast path.

10 years agoConsolidate code to initialize nscd dataset header
Siddhesh Poyarekar [Wed, 30 Apr 2014 06:27:09 +0000 (11:57 +0530)]
Consolidate code to initialize nscd dataset header

This patch consolidates the code to initialize the header of a dataset
into a single set of functions (one for positive and another for
negative datasets) primarily to reduce repetition of code.  The
secondary reason is to simplify Patch 2/2 which fixes the problem of
an uninitialized byte in the header by initializing an unused field in
the structure and hence preventing a possible data leak into the cache
file.

10 years agoDo not fail if one of the two responses to AF_UNSPEC fails (BZ #14308)
Siddhesh Poyarekar [Wed, 30 Apr 2014 06:18:43 +0000 (11:48 +0530)]
Do not fail if one of the two responses to AF_UNSPEC fails (BZ #14308)

[Fixes BZ #14308, #12994, #13651]

AF_UNSPEC results in sending two queries in parallel, one for the A
record and the other for the AAAA record.  If one of these is a
referral, then the query fails, which is wrong.  It should return at
least the one successful response.

The fix has two parts.  The first part makes the referral fall back to
the SERVFAIL path, which results in using the successful response.
There is a bug in that path however, due to which the second part is
necessary.  The bug here is that if the first response is a failure
and the second succeeds, __libc_res_nsearch does not detect that and
assumes a failure.  The case where the first response is a success and
the second fails, works correctly.

This condition is produced by buggy routers, so here's a crude
interposable library that can simulate such a condition.  The library
overrides the recvfrom syscall and modifies the header of the packet
received to reproduce this scenario.  It has two key variables:
mod_packet and first_error.

The mod_packet variable when set to 0, results in odd packets being
modified to be a referral.  When set to 1, even packets are modified
to be a referral.

The first_error causes the first response to be a failure so that a
domain-appended search is performed to test the second part of the
__libc_nsearch fix.

The driver for this fix is a simple getaddrinfo program that does an
AF_UNSPEC query.  I have omitted this since it should be easy to
implement.

I have tested this on x86_64.

The interceptor library source:

/* Override recvfrom and modify the header of the first DNS response to make it
   a referral and reproduce bz #845218.  We have to resort to this ugly hack
   because we cannot make bind return the buggy response of a referral for the
   AAAA record and an authoritative response for the A record.  */
 #define _GNU_SOURCE
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <stdio.h>
 #include <stdbool.h>
 #include <endian.h>
 #include <dlfcn.h>
 #include <stdlib.h>

/* Lifted from resolv/arpa/nameser_compat.h.  */
typedef struct {
    unsigned        id :16;         /*%< query identification number */
 #if BYTE_ORDER == BIG_ENDIAN
    /* fields in third byte */
    unsigned        qr: 1;          /*%< response flag */
    unsigned        opcode: 4;      /*%< purpose of message */
    unsigned        aa: 1;          /*%< authoritive answer */
    unsigned        tc: 1;          /*%< truncated message */
    unsigned        rd: 1;          /*%< recursion desired */
    /* fields
     * in
     * fourth
     * byte
     * */
    unsigned        ra: 1;          /*%< recursion available */
    unsigned        unused :1;      /*%< unused bits (MBZ as of 4.9.3a3) */
    unsigned        ad: 1;          /*%< authentic data from named */
    unsigned        cd: 1;          /*%< checking disabled by resolver */
    unsigned        rcode :4;       /*%< response code */
 #endif
 #if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
    /* fields
     * in
     * third
     * byte
     * */
    unsigned        rd :1;          /*%< recursion desired */
    unsigned        tc :1;          /*%< truncated message */
    unsigned        aa :1;          /*%< authoritive answer */
    unsigned        opcode :4;      /*%< purpose of message */
    unsigned        qr :1;          /*%< response flag */
    /* fields
     * in
     * fourth
     * byte
     * */
    unsigned        rcode :4;       /*%< response code */
    unsigned        cd: 1;          /*%< checking disabled by resolver */
    unsigned        ad: 1;          /*%< authentic data from named */
    unsigned        unused :1;      /*%< unused bits (MBZ as of 4.9.3a3) */
    unsigned        ra :1;          /*%< recursion available */
 #endif
    /* remaining
     * bytes
     * */
    unsigned        qdcount :16;    /*%< number of question entries */
    unsigned        ancount :16;    /*%< number of answer entries */
    unsigned        nscount :16;    /*%< number of authority entries */
    unsigned        arcount :16;    /*%< number of resource entries */
} HEADER;

static int done = 0;

/* Packets to modify.  0 for the odd packets and 1 for even packets.  */
static const int mod_packet = 0;

/* Set to true if the first request should result in an error, resulting in a
   search query.  */
static bool first_error = true;

static ssize_t (*real_recvfrom) (int sockfd, void *buf, size_t len, int flags,
  struct sockaddr *src_addr, socklen_t *addrlen);

void
__attribute__ ((constructor))
init (void)
{
  real_recvfrom = dlsym (RTLD_NEXT, "recvfrom");

  if (real_recvfrom == NULL)
    {
      printf ("Failed to get reference to recvfrom: %s\n", dlerror ());
      printf ("Cannot simulate test\n");
      abort ();
    }
}

/* Modify the second packet that we receive to set the header in a manner as to
   reproduce BZ #845218.  */
static void
mod_buf (HEADER *h, int port)
{
  if (done % 2 == mod_packet || (first_error && done == 1))
    {
      printf ("(Modifying header)");

      if (first_error && done == 1)
h->rcode = 3;
      else
h->rcode = 0; /* NOERROR == 0.  */
      h->ancount = 0;
      h->aa = 0;
      h->ra = 0;
      h->arcount = 0;
    }
  done++;
}

ssize_t
recvfrom (int sockfd, void *buf, size_t len, int flags,
  struct sockaddr *src_addr, socklen_t *addrlen)
{
  ssize_t ret = real_recvfrom (sockfd, buf, len, flags, src_addr, addrlen);
  int port = htons (((struct sockaddr_in *) src_addr)->sin_port);
  struct in_addr addr = ((struct sockaddr_in *) src_addr)->sin_addr;
  const char *host = inet_ntoa (addr);
  printf ("\n*** From %s:%d: ", host, port);

  mod_buf (buf, port);

  printf ("returned %zd\n", ret);
  return ret;
}

10 years agoFinal update to ports ChangeLog.
Carlos O'Donell [Tue, 29 Apr 2014 17:33:08 +0000 (13:33 -0400)]
Final update to ports ChangeLog.

Indicate the removal of the README and carry out the
final update to the ports/ChangeLog.

10 years agoRemove ports README and update machine ChangeLogs.
Carlos O'Donell [Tue, 29 Apr 2014 17:31:05 +0000 (13:31 -0400)]
Remove ports README and update machine ChangeLogs.

This patch removes the ports/README now that ports is no longer
being used. It also adds a header to all ChangeLogs for all machines
that were moved to the main libc tree. The header indicates that the
ChangeLog is no longer used.

10 years ago2014-04-29 Steve Ellcey <sellcey@mips.com>
Steve Ellcey [Tue, 29 Apr 2014 17:19:30 +0000 (10:19 -0700)]
2014-04-29  Steve Ellcey  <sellcey@mips.com>

* iconf/skeleton.c (ONE_DIRECTION): Set default value if not set.

10 years agoMention BZ16823 in NEWS
Stefan Liebler [Tue, 29 Apr 2014 13:45:11 +0000 (15:45 +0200)]
Mention BZ16823 in NEWS

10 years ago[BZ #16823] Fix log1pl returning wrong infinity sign
Stefan Liebler [Tue, 29 Apr 2014 13:43:36 +0000 (15:43 +0200)]
[BZ #16823] Fix log1pl returning wrong infinity sign

10 years agoFix
Adhemerval Zanella [Tue, 29 Apr 2014 12:45:05 +0000 (07:45 -0500)]
Fix

10 years agoPowerPC: Suppress unnecessary FPSCR write
Adhemerval Zanella [Mon, 28 Apr 2014 19:38:24 +0000 (14:38 -0500)]
PowerPC: Suppress unnecessary FPSCR write

This patch optimizes the FPSCR update on exception and rounding change
functions by just updating its value if new value if different from
current one.  It also optimizes fedisableexcept and feenableexcept by
removing an unecessary FPSCR read.

10 years agoRelocate hppa from ports to libc.
Carlos O'Donell [Tue, 29 Apr 2014 07:08:48 +0000 (03:08 -0400)]
Relocate hppa from ports to libc.

10 years agohppa: Update lowlevellock.h.
Carlos O'Donell [Tue, 29 Apr 2014 06:48:16 +0000 (02:48 -0400)]
hppa: Update lowlevellock.h.

Cleanup and remove old lll_private_futex_wake macro and add
generic support for PI-aware futexes.

10 years agohppa: Use lll_futex_wake.
Carlos O'Donell [Tue, 29 Apr 2014 06:38:50 +0000 (02:38 -0400)]
hppa: Use lll_futex_wake.

The lll_private_futex_wake function no longer exists. Instead use
lll_futex_make with LLL_PRIVATE as the last argument.

10 years agohppa: Use r25 as second input to __longjmp.
Carlos O'Donell [Tue, 29 Apr 2014 06:35:06 +0000 (02:35 -0400)]
hppa: Use r25 as second input to __longjmp.

The generated assembly is simplified if we use r25,
the expected second argument to the function given the
calling convention.

10 years agoFix types of stream hook functions in manual.
Ondřej Bílka [Mon, 28 Apr 2014 16:50:22 +0000 (18:50 +0200)]
Fix types of stream hook functions in manual.

10 years agoFix recvmmsg comment.
Ondřej Bílka [Mon, 28 Apr 2014 16:08:32 +0000 (18:08 +0200)]
Fix recvmmsg comment.

10 years ago[ARM] Add support for fenv_private on ARM.
Wilco Dijkstra [Mon, 28 Apr 2014 09:53:04 +0000 (10:53 +0100)]
[ARM] Add support for fenv_private on ARM.

10 years agoReplace __int128 with __int128_t in bits/link.h
H.J. Lu [Fri, 25 Apr 2014 16:33:41 +0000 (09:33 -0700)]
Replace __int128 with __int128_t in bits/link.h

__int128 was added in GCC 4.6 and __int128_t was added before x86-64
was supported.  This patch replaces __int128 with __int128_t so that
the installed bits/link.h can be used with older GCC.

* sysdeps/x86/bits/link.h (La_x86_64_regs): Replace __int128
with __int128_t.
(La_x86_64_retval): Likewise.

10 years ago[AArch64] Suppress unnecessary FPSR and FPCR writes.
Ian Bolton [Thu, 24 Apr 2014 06:15:33 +0000 (07:15 +0100)]
[AArch64] Suppress unnecessary FPSR and FPCR writes.

10 years agoUse test-skeleton.c in tst-sem3 and tst-sem4
Siddhesh Poyarekar [Wed, 23 Apr 2014 06:51:00 +0000 (12:21 +0530)]
Use test-skeleton.c in tst-sem3 and tst-sem4

10 years agoFix sigaction conform test failures on sparc.
David S. Miller [Wed, 23 Apr 2014 00:47:12 +0000 (17:47 -0700)]
Fix sigaction conform test failures on sparc.

* sysdeps/unix/sysv/linux/sparc/bits/sigaction.h
(struct sigaction): New struct member __glibc_reserved0, change
type of sa_flags to int.

10 years ago[AArch64] Use GCC builtins to count leading/tailing zeros.
Yufeng Zhang [Tue, 22 Apr 2014 16:26:59 +0000 (17:26 +0100)]
[AArch64] Use GCC builtins to count leading/tailing zeros.

10 years agoInclude atomic.h in sem_wait.c and sem_trywait.c
Siddhesh Poyarekar [Tue, 22 Apr 2014 11:27:49 +0000 (16:57 +0530)]
Include atomic.h in sem_wait.c and sem_trywait.c

10 years agoaarch64: Add setjmp and longjmp SystemTap probes
Venkataramanan Kumar [Tue, 8 Apr 2014 13:11:44 +0000 (14:11 +0100)]
aarch64: Add setjmp and longjmp SystemTap probes

Add setjmp, longjmp and longjmp_target SystemTap probes.

ChangeLog:

2014-04-22  Will Newton  <will.newton@linaro.org>
    Venkataramanan Kumar  <venkataramanan.kumar@linaro.org>

* sysdeps/aarch64/__longjmp.S: Include stap-probe.h.
(__longjmp): Add longjmp and longjmp_target SystemTap
probes.
* sysdeps/aarch64/setjmp.S: Include stap-probe.h.
(__sigsetjmp): Add setjmp SystemTap probe.

10 years agomanual: Sort overview listing by manual order.
Carlos O'Donell [Thu, 17 Apr 2014 23:41:09 +0000 (19:41 -0400)]
manual: Sort overview listing by manual order.

In the glibc manual we have a "Roadmap to the manual" section at
the end of the "Introduction" chapter.

The introductory text says "Here is an overview of the contents
of the remaining chapters of this manual.", but then proceeds to
list chapters out of order and some chapter are never referenced.

This commit reorders the overview to correctly match the manual
order.

See:
https://sourceware.org/ml/libc-alpha/2014-02/msg00823.html

10 years agoPowerPC: Sync pthread_once with default implementation
Adhemerval Zanella [Sun, 13 Apr 2014 23:13:42 +0000 (18:13 -0500)]
PowerPC: Sync pthread_once with default implementation

This patch removes the arch specific powerpc implementation and instead
uses the linux default one.  Although the current powerpc implementation
already constains the required memory barriers for correct
initialization, the default implementation shows a better performance on
newer chips.

10 years agoPowerPC: Add fenv macros for long double
Adhemerval Zanella [Thu, 17 Apr 2014 18:39:01 +0000 (15:39 -0300)]
PowerPC: Add fenv macros for long double

This patch add the missing libc_<function>l_ctx macros for long
double.  Similar for float, they point to default double versions.

10 years agoAdd fenv test support for AArch64.
Ian Bolton [Thu, 17 Apr 2014 15:31:01 +0000 (15:31 +0000)]
Add fenv test support for AArch64.

10 years agoDetect if AVX2 is usable
Sihai Yao [Thu, 17 Apr 2014 15:00:21 +0000 (08:00 -0700)]
Detect if AVX2 is usable

This patch checks and sets bit_AVX2_Usable in __cpu_features.feature.

* sysdeps/x86_64/multiarch/ifunc-defines.sym (COMMON_CPUID_INDEX_7):
New.
* sysdeps/x86_64/multiarch/init-arch.c (__init_cpu_features):
Check and set bit_AVX2_Usable.
* sysdeps/x86_64/multiarch/init-arch.h (bit_AVX2_Usable): New
macro.
(bit_AVX2): Likewise.
(index_AVX2_Usable): Likewise.
(CPUID_AVX2): Likewise.
(HAS_AVX2): Likewise.

10 years agomanual/setjmp.texi: Clarify setcontext and signal handlers text
Will Newton [Thu, 13 Mar 2014 09:45:29 +0000 (09:45 +0000)]
manual/setjmp.texi: Clarify setcontext and signal handlers text

Calling setcontext from a signal handler can be done safely so
it is sufficient to note that it is not recommended.

Also mention in setcontext documentation that the behaviour of
setcontext when restoring a context created by a call to a signal
handler is unspecified.

2014-04-17  Will Newton  <will.newton@linaro.org>

* manual/setjmp.texi (System V contexts): Add note that
calling setcontext on a context created by a call to a
signal handler is undefined.  Update text to note that
setcontext from a signal handler is possible but not
recommended.

10 years agostdlib/tst-setcontext.c: Check for clobbering of signal stack
Will Newton [Tue, 25 Feb 2014 14:29:32 +0000 (14:29 +0000)]
stdlib/tst-setcontext.c: Check for clobbering of signal stack

On aarch64 calling swapcontext clobbers the state of the signal
stack (BZ #16629). Check that the address and size of the signal
stack before and after the call to swapcontext remains the same.

ChangeLog:

2014-04-17  Will Newton  <will.newton@linaro.org>

[BZ #16629]
* stdlib/tst-setcontext.c: Include signal.h.
(main): Check that the signal stack before and
after swapcontext is the same.

10 years agoaarch64: Re-implement setcontext without rt_sigreturn syscall
Will Newton [Wed, 12 Mar 2014 16:14:51 +0000 (16:14 +0000)]
aarch64: Re-implement setcontext without rt_sigreturn syscall

The current implementation of setcontext uses rt_sigreturn to restore
the contents of registers. This contrasts with the way most other
architectures implement setcontext:

  powerpc64, mips, tile:

  Call rt_sigreturn if context was created by a call to a signal handler,
  otherwise restore in user code.

  powerpc32:

  Call swapcontext system call and don't call sigreturn or rt_sigreturn.

  x86_64, sparc, hppa, sh, ia64, m68k, s390, arm:

  Only support restoring "synchronous" contexts, that is contexts
  created by getcontext, and restoring in user code and don't call
  sigreturn or rt_sigreturn.

  alpha:

  Call sigreturn (but not rt_sigreturn) in all cases to do the restore.

The text of the setcontext manpage suggests that the requirement to be
able to restore a signal handler created context has been dropped from
SUSv2:

  If  the context was obtained by a call to a signal handler, then old
  standard text says that "program execution continues with the program
  instruction following the instruction interrupted by the signal".
  However, this sentence was removed in SUSv2, and the present verdict
  is "the result is unspecified".

Implementing setcontext by calling rt_sigreturn unconditionally causes
problems when used with sigaltstack as in BZ #16629. On this basis it
seems that aarch64 is broken and that new ports should only support
restoring contexts created with getcontext and do not need to call
rt_sigreturn at all.

This patch re-implements the aarch64 setcontext function to restore
the context in user code in a similar manner to x86_64 and other ports.

ChangeLog:

2014-04-17  Will Newton  <will.newton@linaro.org>

[BZ #16629]
* sysdeps/unix/sysv/linux/aarch64/setcontext.S (__setcontext):
Re-implement to restore registers in user code and avoid
rt_sigreturn system call.

10 years agoAdd fenv test support for targets which don't have FP traps.
Wilco [Thu, 17 Apr 2014 08:39:27 +0000 (09:39 +0100)]
Add fenv test support for targets which don't have FP traps.

10 years ago[AArch64] Define HAVE_RM_CTX and related hooks.
Ian Bolton [Wed, 16 Apr 2014 22:41:04 +0000 (23:41 +0100)]
[AArch64] Define HAVE_RM_CTX and related hooks.

10 years ago[AArch64] Provide initial implementation of math_private.h.
Ian Bolton [Wed, 16 Apr 2014 14:41:52 +0000 (14:41 +0000)]
[AArch64] Provide initial implementation of math_private.h.

10 years agoalpha: Remove alpha-linux pthread_once.c
Richard Henderson [Thu, 17 Apr 2014 04:36:33 +0000 (21:36 -0700)]
alpha: Remove alpha-linux pthread_once.c

10 years agoalpha: Enable unwind tables for backtrace.c
Richard Henderson [Thu, 17 Apr 2014 04:32:27 +0000 (21:32 -0700)]
alpha: Enable unwind tables for backtrace.c

10 years agoalpha: Fix __pointer_chk_guard definition for the testsuite
Richard Henderson [Thu, 17 Apr 2014 04:28:50 +0000 (21:28 -0700)]
alpha: Fix __pointer_chk_guard definition for the testsuite

10 years agoalpha: Regenerate sysdeps/alpha/libm-test-ulps
Richard Henderson [Thu, 17 Apr 2014 04:25:35 +0000 (21:25 -0700)]
alpha: Regenerate sysdeps/alpha/libm-test-ulps

10 years ago[AArch64] Regenerate libm-test-ulps.
Marcus Shawcroft [Wed, 16 Apr 2014 21:37:32 +0000 (21:37 +0000)]
[AArch64] Regenerate libm-test-ulps.

10 years agoSave/restore bound registers for _dl_runtime_profile
Igor Zamyatin [Wed, 16 Apr 2014 21:43:16 +0000 (14:43 -0700)]
Save/restore bound registers for _dl_runtime_profile

This patch saves and restores bound registers in x86-64 PLT for
ld.so profile and LD_AUDIT:

* sysdeps/x86_64/bits/link.h (La_x86_64_regs): Add lr_bnd.
(La_x86_64_retval): Add lrv_bnd0 and lrv_bnd1.
* sysdeps/x86_64/dl-trampoline.S (_dl_runtime_profile): Save
Intel MPX bound registers before _dl_profile_fixup.
* sysdeps/x86_64/dl-trampoline.h: Restore Intel MPX bound
registers after _dl_profile_fixup.  Save and restore bound
registers bnd0/bnd1 when calling _dl_call_pltexit.
* sysdeps/x86_64/link-defines.sym (BND_SIZE): New.
(LR_BND_OFFSET): Likewise.
(LRV_BND0_OFFSET): Likewise.
(LRV_BND1_OFFSET): Likewise.

10 years agohurd: Add i386 fields to TLS structure
Samuel Thibault [Wed, 16 Apr 2014 21:45:36 +0000 (23:45 +0200)]
hurd: Add i386 fields to TLS structure

* sysdeps/mach/hurd/i386/tls.h (tcbhead_t): Add multiple_threads,
sysinfo, stack_guard, pointer_guard, gscope_flag, private_futex,
__private_tm, __private_ss fields.

10 years agohurd: Move dtv, dtv_t, tcbhead_t declaration to per-arch file.
Samuel Thibault [Wed, 16 Apr 2014 21:43:28 +0000 (23:43 +0200)]
hurd: Move dtv, dtv_t, tcbhead_t declaration to per-arch file.

10 years agohurd: Do not allow unmapping address 0
Samuel Thibault [Wed, 16 Apr 2014 21:16:15 +0000 (23:16 +0200)]
hurd: Do not allow unmapping address 0

* sysdeps/mach/munmap.c (__munmap): Return EINVAL if `addr' is 0.

10 years agoS/390: Regenerate ULPs
Stefan Liebler [Wed, 16 Apr 2014 11:00:29 +0000 (13:00 +0200)]
S/390: Regenerate ULPs

10 years ago[BZ #14770] S/390: Require Binutils >= 2.24 for target S/390.
Stefan Liebler [Wed, 16 Apr 2014 10:58:02 +0000 (12:58 +0200)]
[BZ #14770] S/390: Require Binutils >= 2.24 for target S/390.

10 years ago[BZ #16824] Fix failing y1 due to too large ulps in downward/upward rounding mode.
Stefan Liebler [Wed, 16 Apr 2014 10:52:52 +0000 (12:52 +0200)]
[BZ #16824] Fix failing y1 due to too large ulps in downward/upward rounding mode.

10 years agoUpdate fixed bug list
Alan Modra [Wed, 16 Apr 2014 10:17:02 +0000 (19:47 +0930)]
Update fixed bug list

10 years agoCorrect IBM long double frexpl.
Alan Modra [Wed, 16 Apr 2014 10:03:32 +0000 (19:33 +0930)]
Correct IBM long double frexpl.

Besides fixing the bugzilla, this also fixes corner-cases where the high
and low double differ greatly in magnitude, and handles a denormal
input without resorting to a fp rescale.

[BZ #16740]
[BZ #16619]
* sysdeps/ieee754/ldbl-128ibm/s_frexpl.c (__frexpl): Rewrite.
* math/libm-test.inc (frexp_test_data): Add tests.

10 years agobenchtests: Link against objects in build directory
Siddhesh Poyarekar [Tue, 15 Apr 2014 09:03:06 +0000 (14:33 +0530)]
benchtests: Link against objects in build directory

Using -lm and -lpthread results in the shared objects in the system
being used to link against.  This happened to work for libm because
there haven't been any changes to the libm ABI recently that could
break the existing benchmarks.  This doesn't always work for the
pthread benchmarks.  The correct way to build against libraries in the
build directory is to have the binaries explicitly depend on them so
that $(+link) can pick them up.

10 years agoSupport _r_debug for static binaries.
Carlos O'Donell [Fri, 11 Apr 2014 16:43:58 +0000 (12:43 -0400)]
Support _r_debug for static binaries.

We initialize _r_debug for static binaries to allows debug
agents to treat static binaries a little more like dyanmic
ones. This simplifies the work a debug agent has to do to
access TLS in a static binary via libthread_db.

Tested on x86_64.

See:
https://sourceware.org/ml/libc-alpha/2014-04/msg00183.html

[BZ #16831]
* csu/libc-start.c (LIBC_START_MAIN) [!SHARED]: Call
_dl_debug_initialize.

10 years agonscd: Make SELinux checks dynamic.
Carlos O'Donell [Thu, 10 Apr 2014 22:31:53 +0000 (18:31 -0400)]
nscd: Make SELinux checks dynamic.

The SELinux team has indicated to me that glibc's SELinux checks
in nscd are not being carried out as they would expect the API
to be used today. They would like to move away from static header
defines for class and permissions and instead use dynamic checks
at runtime that provide an answer which is dependent on the runtime
status of SELinux i.e. more dynamic.

The following patch is a minimal change that moves us forward in
this direction.

It does the following:

* Stop checking for SELinux headers that define NSCD__SHMEMHOST.
  Check only for the presence or absence of the library.

* Don't encode the specific SELinux permission constants into a
  table at build time, and instead use the symbolic name for the
  permission as expected.

* Lookup the "What do we do if we don't know this permission?"
  policy and use that if we find SELinux's policy is older than
  the glibc policy e.g. we make a request for a permission that
  SELinux doesn't know about.

* Lastly, translate the class and permission and then make
  the permission check. This is done every time we lookup
  a permission, and this is the expected way to use the API.
  SELinux will optimize this for us, and we expect the network
  latencies to hide these extra library calls.

Tested on x86, x86-64, and via Fedora Rawhide since November 2013.

See:
https://sourceware.org/ml/libc-alpha/2014-04/msg00179.html

10 years agoRegenerate sparc ULPs.
David S. Miller [Mon, 14 Apr 2014 01:27:19 +0000 (18:27 -0700)]
Regenerate sparc ULPs.

* sysdeps/sparc/fpu/libm-test-ulps: Update.

10 years agoFix qsort argument order in collation example
Allan McRae [Sat, 12 Apr 2014 04:26:29 +0000 (14:26 +1000)]
Fix qsort argument order in collation example

10 years agoFix typo on ChangeLog.
Paul Pluzhnikov [Fri, 11 Apr 2014 19:16:38 +0000 (12:16 -0700)]
Fix typo on ChangeLog.

10 years agomath: make test-fenv-preserve.c a no-op if FE_ALL_EXCEPT == 0.
Chris Metcalf [Fri, 11 Apr 2014 19:13:42 +0000 (15:13 -0400)]
math: make test-fenv-preserve.c a no-op if FE_ALL_EXCEPT == 0.

This fixes a testsuite failure for tile (and possibly microblaze).

10 years ago2014-04-11 Paul Pluzhnikov <ppluzhnikov@google.com>
Paul Pluzhnikov [Fri, 11 Apr 2014 18:25:53 +0000 (11:25 -0700)]
2014-04-11  Paul Pluzhnikov  <ppluzhnikov@google.com>

* elf/Makefile (tests): make tst-dlopen-aout conditional on
enable-hardcoded-path-in-tests

10 years agobenchtests: Improve readability of JSON output
Will Newton [Tue, 8 Apr 2014 09:18:16 +0000 (10:18 +0100)]
benchtests: Improve readability of JSON output

Add a small library to print JSON values and use it to improve the
readability of the benchmark output and the readability of the
benchmark code.

ChangeLog:

2014-04-11  Will Newton  <will.newton@linaro.org>

* benchtests/Makefile (extra-objs): Add json-lib.o.
(bench-func): Tidy up JSON output.
* benchtests/bench-skeleton.c: Include json-lib.h.
(main): Use JSON library functions to do output of
benchmark results.
* benchtests/bench-timing-type.c (main): Output the
timing type simply, leaving formatting to the user.
* benchtests/json-lib.c: New file.
* benchtests/json-lib.h: Likewise.

10 years agoFixed and unified pthread_once.
Torvald Riegel [Wed, 8 May 2013 14:35:10 +0000 (16:35 +0200)]
Fixed and unified pthread_once.

[BZ #15215] This unifies various pthread_once architecture-specific
implementations which were using the same algorithm with slightly different
implementations.  It also adds missing memory barriers that are required for
correctness.

10 years agoS/390: Unify 31 and 64 bit configure.ac
Stefan Liebler [Fri, 11 Apr 2014 11:11:50 +0000 (13:11 +0200)]
S/390: Unify 31 and 64 bit configure.ac

10 years agoNEWS: Add comment about changed ABI on s390 and s390x.
Andreas Krebbel [Tue, 8 Apr 2014 14:30:07 +0000 (16:30 +0200)]
NEWS: Add comment about changed ABI on s390 and s390x.

10 years agoFix typo in comment in res_query.c
Joseph Anthony Pasquale Holsten [Fri, 11 Apr 2014 09:46:13 +0000 (15:16 +0530)]
Fix typo in comment in res_query.c

10 years agomalloc: Fix MALLOC_DEBUG -Wundef warning
Will Newton [Mon, 31 Mar 2014 14:00:32 +0000 (15:00 +0100)]
malloc: Fix MALLOC_DEBUG -Wundef warning

MALLOC_DEBUG is set optionally on the command line. Default the value
to zero if it is not set on the command line, and test its value
with #if rather than #ifdef. Verified the code is identical before
and after this change apart from line numbers.

ChangeLog:

2014-04-11  Will Newton  <will.newton@linaro.org>

* malloc/malloc.c [!MALLOC_DEBUG]: #define MALLOC_DEBUG
to zero if it is not defined elsewhere.  (mtrim): Test
the value of MALLOC_DEBUG with #if rather than #ifdef.

10 years agobenchtests: Add pthread_once common-case test.
Torvald Riegel [Tue, 8 Oct 2013 11:17:01 +0000 (14:17 +0300)]
benchtests: Add pthread_once common-case test.

We have a single thread that runs a no-op initialization once and then
repeatedly runs checks of the initialization (i.e., an acquire load and
conditional jump) in a tight loop.  This gives us, on average, the
best-case latency of pthread_once (the initialization is the
exactly-once slow path, and we're not looking at initialization-related
synchronization overheads in this case).

10 years agoSave/restore bound registers in _dl_runtime_resolve
Igor Zamyatin [Tue, 1 Apr 2014 17:16:04 +0000 (10:16 -0700)]
Save/restore bound registers in _dl_runtime_resolve

This patch saves and restores bound registers in symbol lookup for x86-64:

1. Branches without BND prefix clear bound registers.
2. x86-64 pass bounds in bound registers as specified in MPX psABI
extension on hjl/mpx/master branch at

https://github.com/hjl-tools/x86-64-psABI
https://groups.google.com/forum/#!topic/x86-64-abi/KFsB0XTgWYc

Binutils has been updated to create an alternate PLT to add BND prefix
when branching to ld.so.

* config.h.in (HAVE_MPX_SUPPORT): New #undef.
* sysdeps/x86_64/configure.ac: Set HAVE_MPX_SUPPORT.
* sysdeps/x86_64/configure: Regenerated.
* sysdeps/x86_64/dl-trampoline.S (REGISTER_SAVE_AREA): New
macro.
(REGISTER_SAVE_RAX): Likewise.
(REGISTER_SAVE_RCX): Likewise.
(REGISTER_SAVE_RDX): Likewise.
(REGISTER_SAVE_RSI): Likewise.
(REGISTER_SAVE_RDI): Likewise.
(REGISTER_SAVE_R8): Likewise.
(REGISTER_SAVE_R9): Likewise.
(REGISTER_SAVE_BND0): Likewise.
(REGISTER_SAVE_BND1): Likewise.
(REGISTER_SAVE_BND2): Likewise.
(_dl_runtime_resolve): Use them.  Save and restore Intel MPX
bound registers when calling _dl_fixup.

10 years agoDefine _STRING_ARCH_unaligned unconditionally
Adhemerval Zanella [Wed, 26 Mar 2014 20:37:35 +0000 (15:37 -0500)]
Define _STRING_ARCH_unaligned unconditionally

This patch defines _STRING_ARCH_unaligned to 0 on default bits/string.h
header to avoid undefined compiler warnings on platforms that do not
define it.  It also make adjustments in code where tests checked if macro
existed or not.

10 years agoUse statvfs64() for pathconf(_PC_NAME_MAX).
Peter TB Brett [Mon, 7 Apr 2014 20:56:12 +0000 (21:56 +0100)]
Use statvfs64() for pathconf(_PC_NAME_MAX).

pathconf(_PC_NAME_MAX) was implemented on top of statfs().  The 32bit
version therefore fails EOVERFLOW if the filesystem blockcount is
sufficiently large.

Most pathconf() queries use statvfs64(), which avoids this issue.  This
patch modifies pathconf(_PC_NAME_MAX) to do likewise.

10 years agoMove __PTHREAD_SPINS definition to architecture specific header
Adhemerval Zanella [Wed, 26 Mar 2014 18:48:00 +0000 (13:48 -0500)]
Move __PTHREAD_SPINS definition to architecture specific header

This patch moves the __PTHREAD_SPINS definition to arch specific header
since pthread_mutex_t layout is also arch specific.  This leads to no
need to defining __PTHREAD_MUTEX_HAVE_ELISION and thus removing of the
undefined compiler warning.

10 years agoPowerPC: Fix --disable-multi-arch builds
Adhemerval Zanella [Tue, 8 Apr 2014 22:25:14 +0000 (17:25 -0500)]
PowerPC: Fix --disable-multi-arch builds

This patch fixes some powerpc32 and powerpc64 builds with
--disable-multi-arch option along with different --with-cpu=powerN.
It cleanups the Implies directories by removing the multiarch
folder for non multiarch config and also fixing two assembly
implementations: powerpc64/power7/strncat.S that is calling the
wrong strlen; and power8/fpu/s_isnan.S that misses the hidden_def and
weak_alias directives.

10 years agomanual/ipc.texi: Fix AC-safety notes.
Carlos O'Donell [Tue, 8 Apr 2014 21:12:15 +0000 (17:12 -0400)]
manual/ipc.texi: Fix AC-safety notes.

The function sem_close is AC-unsafe because lll_lock*
leaks a lock (aculock) and not because of twalk.

10 years agostring: Cosmetic cleanup of string functions
Will Newton [Mon, 31 Mar 2014 12:47:56 +0000 (13:47 +0100)]
string: Cosmetic cleanup of string functions

Clean up string functions that do not have a version in gnulib on
the assumption that glibc is the canonical upstream copy of this
code. basename has a copy in gnulib but it is largely written to
handle Windows paths so merging it is not really viable. The changes
mostly consist of switching to ANSI function prototypes and removing
unused includes.

As many of these functions do not get built in a typical build due
to architecture optimized versions being used instead I built these
by hand to verify there were no build warnings and the code was
identical.

2014-04-07  Will Newton  <will.newton@linaro.org>

* string/basename.c [HAVE_CONFIG_H]: Remove #ifdef and
and contents.  [!_LIBC] Remove #ifndef and contents.
(basename): Use ANSI prototype.  [_LIBC] Remove #idef.
* string/memccpy.c (__memccpy): Use ANSI prototype.
* string/memfrob.c (memfrob): Likewise.
* string/strcoll.c (STRCOLL): Likewise.
* string/strlen.c (strlen): Likewise.
* string/strtok.c (STRTOK): Likewise.
* string/strcat.c: Remove unused #include of memcopy.h.
(strcat): Use ANSI prototype.
* string/strchr.c: Remove unused #include of memcopy.h.
(strchr): Use ANSI prototype.
* string/strcmp.c: Remove unused #include of memcopy.h.
(strcmp): Use ANSI prototype.
* string/strcpy.c: Remove unused #include of memcopy.h.
(strcpy): Use ANSI prototype.

10 years agoPowerPC: define _CALL_ELF if compiler does not
Adhemerval Zanella [Sun, 6 Apr 2014 21:26:32 +0000 (16:26 -0500)]
PowerPC: define _CALL_ELF if compiler does not

This patch makes the configure adds -D_CALL_ELF=1 when compiler does
not define _CALL_ELF (versions before powerpc64le support).  It cleans
up compiler warnings on old compiler where _CALL_ELF is not defined
on powerpc64(be) builds.

It does by add a new config.make variable for configure-deduced
CPPFLAGS and accumulate into that (confix-extra-cppflags).  It also
generalizes libc_extra_cflags so it accumulates in sysdeps configure
fragmenets.

10 years agoPowerPC: Fix nearbyint/nearbyintf result for FE_DOWNWARD
Adhemerval Zanella [Sun, 6 Apr 2014 19:50:11 +0000 (14:50 -0500)]
PowerPC: Fix nearbyint/nearbyintf result for FE_DOWNWARD

This patch fixes the powerpc32 optimized nearbyint/nearbyintf bogus
results for FE_DOWNWARD rounding mode.  This is due wrong instructions
sequence used in the rounding calculation (two subtractions instead of
adition and a subtraction).

Fixes BZ#16815.

10 years agotile: Fix cut-and-paste bug in commit fcccd5128.
Chris Metcalf [Fri, 4 Apr 2014 19:03:47 +0000 (15:03 -0400)]
tile: Fix cut-and-paste bug in commit fcccd5128.

10 years agomanual: clarify buffer behavior in getline [BZ #5666]
David Svoboda [Wed, 2 Apr 2014 09:13:02 +0000 (05:13 -0400)]
manual: clarify buffer behavior in getline [BZ #5666]

If the user has requested automatic buffer creation, getline may create
it and not free things when an error occurs.  That means the user is
always responsible for calling free() regardless of the return value.

The current documentation does not explicitly cover this which leaves it
slightly ambiguous to the reader.  So clarify things.

URL: https://sourceware.org/bugzilla/show_bug.cgi?id=5666

10 years agoFactor mmap/munmap of PT_LOAD segments out of _dl_map_object_from_fd et al.
Roland McGrath [Thu, 3 Apr 2014 17:47:14 +0000 (10:47 -0700)]
Factor mmap/munmap of PT_LOAD segments out of _dl_map_object_from_fd et al.

10 years agoelf/dl-lookup.c: Remove obsolete comment about nested function
Will Newton [Wed, 2 Apr 2014 14:23:16 +0000 (15:23 +0100)]
elf/dl-lookup.c: Remove obsolete comment about nested function

The nested function referred to has gone away so remove the
comment. Also move the variable declaration down to where other
variables of a similar lifetime are declared for clarity.

2014-04-03  Will Newton  <will.newton@linaro.org>

* elf/dl-lookup.c (do_lookup_x): Remove comment
referring to nested function and move variable
declarations down to before first use.

10 years agoFix catan, catanh, __ieee754_logf in round-downward mode (bug 16799, bug 16800).
Joseph Myers [Wed, 2 Apr 2014 17:41:02 +0000 (17:41 +0000)]
Fix catan, catanh, __ieee754_logf in round-downward mode (bug 16799, bug 16800).

This patch fixes incorrect results from catan and catanh of certain
special inputs in round-downward mode (bug 16799), and incorrect
results of __ieee754_logf (+/-0) in round-downward mode (bug 16800)
that show up through catan/catanh when tested in all rounding modes,
but not directly in the testing for logf because the bug gets hidden
by the wrappers.

Both bugs involve a zero that should be +0 being -0 instead: one
computed as (1-x)*(1+x) in the catan/catanh case, and one as (x-x) in
the logf case.  The fixes ensure positive zero is used.  Testing of
catan and catanh in all rounding modes is duly enabled.

I expect there are various other bugs in special cases in __ieee754_*
functions that are normally hidden by the wrappers but would show up
for testing with -lieee (or in future with -fno-math-errno if we
replace -lieee and _LIB_VERSION with compile-time redirection to new
*_noerrno symbol names).

Tested x86_64 and x86 and ulps updated accordingly.

[BZ #16799]
[BZ #16800]
* math/s_catan.c (__catan): Avoid passing -0 denominator to atan2
with 0 numerator.
* math/s_catanf.c (__catanf): Likewise.
* math/s_catanh.c (__catanh): Likewise.
* math/s_catanhf.c (__catanhf): Likewise.
* math/s_catanhl.c (__catanhl): Likewise.
* math/s_catanl.c (__catanl): Likewise.
* sysdeps/ieee754/flt-32/e_logf.c (__ieee754_logf): Always divide
by positive zero when computing -Inf result.
* math/libm-test.inc (catan_test): Use ALL_RM_TEST.
(catanh_test): Likewise.
* sysdeps/i386/fpu/libm-test-ulps: Update.
* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.

10 years agoFix clog / clog10 sign of zero result in round-downward mode (bug 16789).
Joseph Myers [Wed, 2 Apr 2014 13:10:19 +0000 (13:10 +0000)]
Fix clog / clog10 sign of zero result in round-downward mode (bug 16789).

This patch fixes bug 16789, incorrect sign of (real part) zero result
from clog and clog10 in round-downward mode, arising from that real
part being computed as 0 - 0.  To ensure that an underflow exception
occurred, the code used an underflowing value (the next term in the
series for log1p) in arithmetic computing the real part of the result,
yielding the problematic 0 - 0 computation in some cases even when the
mathematical result would be small but positive.  The patch changes
this code to use the math_force_eval approach to ensuring that an
underflowing computation actually occurs.  Tests of clog and clog10
are enabled in all rounding modes.

Tested x86_64 and x86 and ulps updated accordingly.

[BZ #16789]
* math/s_clog.c (__clog): Use math_force_eval to ensure underflow
instead of using underflowing value in computing result.
* math/s_clog10.c (__clog10): Likewise.
* math/s_clog10f.c (__clog10f): Likewise.
* math/s_clog10l.c (__clog10l): Likewise.
* math/s_clogf.c (__clogf): Likewise.
* math/s_clogl.c (__clogl): Likewise.
* math/libm-test.inc (clog_test): Use ALL_RM_TEST.
(clog10_test): Likewise.
* sysdeps/i386/fpu/libm-test-ulps: Update.
* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.

10 years agoCorrect IBM long double nextafterl.
Alan Modra [Wed, 2 Apr 2014 03:16:19 +0000 (13:46 +1030)]
Correct IBM long double nextafterl.

Fix for values near a power of two, and some tidies.

[BZ #16739]
* sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c (__nextafterl): Correct
output when value is near a power of two.  Use int64_t for lx and
remove casts.  Use decimal rather than hex exponent constants.
Don't use long double multiplication when double will suffice.
* math/libm-test.inc (nextafter_test_data): Add tests.
* NEWS: Add 16739 and 16786 to bug list.

10 years agoCorrect prefetch hint in power7 memrchr.
Alan Modra [Wed, 2 Apr 2014 03:12:27 +0000 (13:42 +1030)]
Correct prefetch hint in power7 memrchr.

Typo fix.

* sysdeps/powerpc/powerpc64/power7/memrchr.S: Correct stream hint.

10 years agoFix reference to toc symbol.
Alan Modra [Wed, 2 Apr 2014 03:10:21 +0000 (13:40 +1030)]
Fix reference to toc symbol.

https://sourceware.org/ml/binutils/2014-03/msg00033.html removes the
"magic" treatment of symbols defined in a .toc section.

* sysdeps/powerpc/powerpc64/start.S: Add @toc to toc symbol reference.

10 years agoUpdate NEWS for fixed bug 13347
Florian Weimer [Tue, 1 Apr 2014 12:20:01 +0000 (14:20 +0200)]
Update NEWS for fixed bug 13347

10 years agobenchtests: Build ffs and ffsl benchtests with -fno-builtin
Will Newton [Mon, 31 Mar 2014 14:58:19 +0000 (15:58 +0100)]
benchtests: Build ffs and ffsl benchtests with -fno-builtin

Without this flag it is possible that the compiler will optimize
away the calls to ffs/ffsll.

ChangeLog:

2014-04-01  Will Newton  <will.newton@linaro.org>

* benchtests/Makefile (CFLAGS-bench-ffs.c): Add
-fno-builtin.  (CFLAGS-bench-ffsll.c): Likewise.

10 years agoCheck for syscall error in the SETXID implementation in NPTL (bug 13347).
Florian Weimer [Mon, 24 Mar 2014 14:24:02 +0000 (15:24 +0100)]
Check for syscall error in the SETXID implementation in NPTL (bug 13347).

At this point, we can only abort the process because we have already
switched credentials on other threads.  Returning an error would still
leave the process in an inconsistent state.

The new xtest needs root privileges to run.

10 years agoFix s_copysign stack temp for PowerPC64 ELFv2
Alan Modra [Tue, 1 Apr 2014 03:37:42 +0000 (14:07 +1030)]
Fix s_copysign stack temp for PowerPC64 ELFv2

[BZ #16786]
* sysdeps/powerpc/powerpc64/fpu/s_copysign.S: Don't trash stack.

10 years agoSet errno for scalb errors (bug 6803, bug 6804).
Joseph Myers [Mon, 31 Mar 2014 14:57:53 +0000 (14:57 +0000)]
Set errno for scalb errors (bug 6803, bug 6804).

This patch fixes the default mode of scalb to set errno (bugs 6803 and
6804).

Previously, the _LIB_VERSION == _SVID_ mode would set errno but only
in some relevant cases, and with various peculiarities (such as errno
setting when an exact infinity or zero result arises with an argument
to scalb being an infinity).  This patch leaves this mode
bug-compatible, while making the default mode set errno in accordance
with normal practice (so an exact infinity from an infinite argument
is not an error, and nor is an exact zero result).  gen-libm-test.pl
is taught new notation such as ERRNO_PLUS_OFLOW to facilitate writing
the tests of errno setting for underflow / overflow in libm-test.inc.

Note that bug 6803 also covers scalbn and scalbln, but this patch only
addresses the scalb parts of that bug (along with the whole of bug
6804).

Tested x86_64 and x86.

[BZ #6803]
[BZ #6804]
* math/w_scalb.c (__scalb): For non-SVID mode, check result and
set errno as appropriate.
* math/w_scalbf.c (__scalbf): Likewise.
* math/w_scalbl.c (__scalbl): Likewise.
* math/gen-libm-test.pl (parse_args): Handle ERRNO_PLUS_OFLOW,
ERRNO_MINUS_OFLOW, ERRNO_PLUS_UFLOW and ERRNO_MINUS_UFLOW.
* math/libm-test.inc (scalb_test_data): Add errno expectations.
Add more NaN tests.

10 years agoSet errno for atan2 underflow (bug 16349).
Joseph Myers [Mon, 31 Mar 2014 14:56:37 +0000 (14:56 +0000)]
Set errno for atan2 underflow (bug 16349).

This patch fixes bug 16349, missing errno setting for atan2 underflow,
by adding appropriate checks to the existing wrappers.  (As in other
cases, the __kernel_standard support for calling matherr is considered
to be for existing code expecting existing rules for what's considered
an error, even if those don't correspond to a general logical scheme
for what counts as what kind of error, so __set_errno calls are added
directly without any changes to __kernel_standard.)

Tested x86_64 and x86.

[BZ #16349]
* math/w_atan2.c: Include <errno.h>.
(__atan2): Set errno for result underflowing to zero.
* math/w_atan2f.c: Include <errno.h>.
(__atan2f): Set errno for result underflowing to zero.
* math/w_atan2l.c: Include <errno.h>.
(__atan2l): Set errno for result underflowing to zero.
* math/auto-libm-test-in: Don't allow missing errno for some atan2
tests.
* math/auto-libm-test-out: Regenerated.

10 years agoPowerPC: Fix little endian enconding for mfvsrd
Adhemerval Zanella [Mon, 31 Mar 2014 13:00:38 +0000 (08:00 -0500)]
PowerPC: Fix little endian enconding for mfvsrd

This patch fixes the MFVSRD_R3_V1 macro that encodes 'mfvsrd  r3,vs1'
(to support old binutils) for little endian.

10 years agoCorrect robust mutex / PI futex kernel assumptions (bug 9894).
Joseph Myers [Mon, 31 Mar 2014 12:55:18 +0000 (12:55 +0000)]
Correct robust mutex / PI futex kernel assumptions (bug 9894).

This patch continues fixing __ASSUME_* issues in preparation for
moving to a 2.6.32 minimum kernel version by addressing assumptions on
robust mutex and PI futex support availability.  Those assumptions are
bug 9894, but to be clear this patch does not address all the issues
from that bug about wrong version assumptions, only those still
applicable for --enable-kernel=2.6.32 or later (with the expectation
that the move to that minimum kernel will obsolete the other parts of
the bug).  The patch is independent of
<https://sourceware.org/ml/libc-alpha/2014-03/msg00585.html>, my other
pending-review patch preparing for the kernel version change; the two
together complete all the changes I believe are needed in preparation
regarding any macro in sysdeps/unix/sysv/linux/kernel-features.h that
would be affected by such a change.  (I have not checked the
correctness of macros whose conditions are unaffected by such a
change, or macros only defined in other kernel-features.h files.)

As discussed in that bug, robust mutexes and PI futexes need
futex_atomic_cmpxchg_inatomic to be implemented, in addition to
certain syscalls needed for robust mutexes (and
architecture-independent kernel pieces for all the features in
question).  That is, as I understand it, they need
futex_atomic_cmpxchg_inatomic to *work* (not return an ENOSYS error).

The issues identified in my analysis relate to ARM, M68K, MicroBlaze,
MIPS and SPARC.

On ARM, whether futex_atomic_cmpxchg_inatomic works depends on the
kernel configuration.  As of 3.13, the condition for *not* working is
CONFIG_CPU_USE_DOMAINS && CONFIG_SMP.  As of 2.6.32 it was simply
CONFIG_SMP that meant the feature was not implemented.  I don't know
if there are any circumstances in which we can say "we can assume a
userspace glibc binary built with these options will never run on a
kernel with the problematic configuration", but at least for now I'm
just undefining the relevant __ASSUME_* macros for ARM.

On M68K, two of the three macros are undefined for kernels before
3.10, but as far as I can see __ASSUME_FUTEX_LOCK_PI is in the same
group needing futex_atomic_cmpxchg_inatomic support and so should be
undefined as well.

On MicroBlaze the required support was added in 2.6.33.

On MIPS, the support depends on cpu_has_llsc in the kernel - that is,
actual hardware LL/SC support (GCC and glibc for MIPS GNU/Linux rely
on the instructions being supported in some way, but it may be kernel
emulation; futex_atomic_cmpxchg_inatomic doesn't work with that
emulation).  The same condition as in GCC for indicating LL/SC support
may not be available is used for undefining the macros in glibc,
__mips == 1 || defined _MIPS_ARCH_R5900.  (Maybe we could in fact
desupport MIPS processors without the hardware support in glibc.)

On SPARC, 32-bit kernels don't support futex_atomic_cmpxchg_inatomic;
__arch64__ || __sparc_v9__ is used as the condition for binaries that
won't run on 32-bit kernels.

This patch is not tested beyond the sanity check of an x86_64 build.

[BZ #9894]
* sysdeps/unix/sysv/linux/kernel-features.h
[__sparc__ && !__arch64__ && !__sparc_v9__]
(__ASSUME_SET_ROBUST_LIST): Do not define.
[__sparc__ && !__arch64__ && !__sparc_v9__]
(__ASSUME_FUTEX_LOCK_PI): Likewise.
[__sparc__ && !__arch64__ && !__sparc_v9__] (__ASSUME_REQUEUE_PI):
Likewise.
* sysdeps/unix/sysv/linux/arm/kernel-features.h
(__ASSUME_FUTEX_LOCK_PI): Undefine.
(__ASSUME_REQUEUE_PI): Likewise.
(__ASSUME_SET_ROBUST_LIST): Likewise.
* sysdeps/unix/sysv/linux/m68k/kernel-features.h
[__LINUX_KERNEL_VERSION < 0x030a00] (__ASSUME_FUTEX_LOCK_PI):
Undefine.
* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
[__LINUX_KERNEL_VERSION < 0x020621] (__ASSUME_FUTEX_LOCK_PI):
Likewise.
[__LINUX_KERNEL_VERSION < 0x020621] (__ASSUME_REQUEUE_PI):
Likewise.
[__LINUX_KERNEL_VERSION < 0x020621] (__ASSUME_SET_ROBUST_LIST):
Likewise.
* sysdeps/unix/sysv/linux/mips/kernel-features.h
[__mips == 1 || _MIPS_ARCH_R5900] (__ASSUME_FUTEX_LOCK_PI):
Undefine.
[__mips == 1 || _MIPS_ARCH_R5900] (__ASSUME_REQUEUE_PI): Likewise.
[__mips == 1 || _MIPS_ARCH_R5900] (__ASSUME_SET_ROBUST_LIST):
Likewise.

10 years agoFix futimesat for older MicroBlaze kernels (bug 16648).
Joseph Myers [Mon, 31 Mar 2014 12:51:45 +0000 (12:51 +0000)]
Fix futimesat for older MicroBlaze kernels (bug 16648).

Continuing the fixes for __ASSUME_* issues in preparation for moving
to a 2.6.32 minimum kernel version, this *untested* patch fixes bug
16648, the definition of __ASSUME_ATFCTS meaning that the futimesat
syscall is assumed for all MicroBlaze kernels despite not being
present until 2.6.33.

__ASSUME_ATFCTS controls conditionals relating to a lot of different
syscalls in Linux-specific code (fstatat64 faccessat fchmodat fchownat
futimesat newfstatat linkat mkdirat openat readlinkat renameat
symlinkat unlinkat mknodat), where whether newfstatat fstatat64
futimesat are used depends on the architecture, as well as controlling
whether openat64_not_cancel_3 is expected to work in
sysdeps/posix/getcwd.c.  The assumptions are all OK as of 2.6.32
except for this MicroBlaze case, and it's generally desirable to get
rid of as many of the __ASSUME_ATFCTS conditionals as possible, to
simplify the code (the fallbacks include potential unbounded dynamic
stack allocations).  Thus, rather than the simplest approach of
undefining __ASSUME_ATFCTS for older kernels on MicroBlaze, this patch
takes the approach of using the linux-generic implementation of
futimesat for MicroBlaze kernels before 2.6.33 (all such kernels have
the utimensat syscall).

[BZ #16648]
* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
[__LINUX_KERNEL_VERSION >= 0x020621] (__ASSUME_FUTIMESAT): Define.
* sysdeps/unix/sysv/linux/microblaze/futimesat.c: New file.

10 years agobenchtests: Add benchtests for ffs and ffsll
Will Newton [Fri, 28 Mar 2014 17:30:44 +0000 (17:30 +0000)]
benchtests: Add benchtests for ffs and ffsll

Add benchtests for ffs and ffsll. There is no benchtest for ffsl as
it is identical to one of the other functions.

2014-03-31  Will Newton  <will.newton@linaro.org>

* benchtests/Makefile (bench): Add ffs and ffsll to list
of tests.
* benchtests/ffs-inputs: New file.
* benchtests/ffsll-inputs: Likewise.

10 years agoFix ChangeLog formatting.
Carlos O'Donell [Sun, 30 Mar 2014 23:03:19 +0000 (19:03 -0400)]
Fix ChangeLog formatting.

10 years agoFix scalb spurious "invalid" exceptions (bug 16770).
Joseph Myers [Sat, 29 Mar 2014 17:22:14 +0000 (17:22 +0000)]
Fix scalb spurious "invalid" exceptions (bug 16770).

This patch fixes bug 16770, spurious "invalid" exceptions from scalb
when testing whether the second argument is an integer, by inserting
appropriate range checks to determine whether a cast to int is safe.
(Note that invalid_fn is a function that handles both nonintegers and
large integers, distinguishing them reliably using functions such as
__rint; note also that there are no issues with scalb needing to avoid
spurious "inexact" exceptions - it's an old-POSIX XSI function, not a
standard C function bound to an IEEE 754 operation - although the
return value is still fully determined.)

Tested x86_64 and x86.

[BZ #16770]
* math/e_scalb.c (__ieee754_scalb): Check second argument is not
too large before casting to int.
* math/e_scalbf.c (__ieee754_scalbf): Likewise.
* math/e_scalbl.c (__ieee754_scalbl): Likewise.
* math/libm-test.inc (scalb_test_data): Add more tests.

10 years agoDetailed benchmark outputs for functions
Siddhesh Poyarekar [Sat, 29 Mar 2014 04:10:19 +0000 (09:40 +0530)]
Detailed benchmark outputs for functions

This patch adds an option to get detailed benchmark output for
functions.  Invoking the benchmark with 'make DETAILED=1 bench' causes
each benchmark program to store a mean execution time for each input
it works on.  This is useful to give a more comprehensive picture of
performance of functions compared to just the single mean figure.

10 years agoMake bench.out in json format
Siddhesh Poyarekar [Sat, 29 Mar 2014 04:07:44 +0000 (09:37 +0530)]
Make bench.out in json format

This patch changes the output format of the main benchmark output file
(bench.out) to an extensible format.  I chose JSON over XML because in
addition to being extensible, it is also not too verbose.
Additionally it has good support in python.

The significant change I have made in terms of functionality is to put
timing information as an attribute in JSON instead of a string and to
do that, there is a separate program that prints out a JSON snippet
mentioning the type of timing (hp_timing or clock_gettime).  The mean
timing has now changed from iterations per unit to actual timing per
iteration.

10 years ago[benchtests] Use inputs file for modf
Siddhesh Poyarekar [Sat, 29 Mar 2014 04:05:50 +0000 (09:35 +0530)]
[benchtests] Use inputs file for modf

The modf benchmark can now use the framework since the introduction of
output arguments.