Skip to content

Commit

Permalink
Merge commit 'origin/master' into fedora/master
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Schwab committed Jul 30, 2009
2 parents ca2a37b + 78c4ef4 commit b870de5
Show file tree
Hide file tree
Showing 28 changed files with 471 additions and 67 deletions.
46 changes: 46 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
2009-07-29 Ulrich Drepper <drepper@redhat.com>

* math/s_fma.c: Don't define alias if __fma is a macro.
* math/s_fmaf.c: Likewise.
* sysdeps/x86_64/multiarch/s_fma.c: New file.
* sysdeps/x86_64/multiarch/s_fmaf.c: New file.
Partially based on a patch by H.J. Lu <hongjiu.lu@intel.com>.

* sysdeps/x86_64/multiarch/init-arch.h (__get_cpu_features): Declare.
(HAS_POPCOUNT, HAS_SSE4_2): Add variants which work outside libc.
New macro HAS_FMA.
* sysdeps/x86_64/multiarch/init-arch.c (__get_cpu_features): New
function.
* include/libc-symbols.h (libm_ifunc): Define.
* sysdeps/x86_64/multiarch/Versions: New file.

* sysdeps/x86_64/dl-trampoline.S (_dl_runtime_profile): Improve CFI.

2009-07-28 H.J. Lu <hongjiu.lu@intel.com>

* sysdeps/x86_64/dl-trampoline.S: Properly restore AVX registers.

2009-07-29 Ulrich Drepper <drepper@redhat.com>

* elf/dl-runtime.c (_dl_fixup): Indicate before _dl_lookup_symbol_x
call that registers used in calling conventions need to be preserved.
* elf/dl-lookup.c (do_lookup_x): Use RTLD_*_FOREIGN_CALL macros
to preserve register content if necessary.
* sysdeps/x86_64/dl-trampoline.S (_dl_x86_64_save_sse): New function.
(_dl_x86_64_restore_sse): New function.
* sysdeps/x86_64/tst-xmmymm.sh: There is now one more function that
is allowed to modify xmm/ymm registers.

* stdio-common/scanf15.c: Undefine _LIBC. We want to test from an
application's perspective.
* stdio-common/scanf17.c: Likewise.

2009-07-28 Ulrich Drepper <drepper@redhat.com>

* csu/libc-tls.c (__libc_setup_tls) [TLS_TCB_AT_TP]: Don't add TCB
size to memsz.
(init_static_tls) [TLS_TCB_AT_TP]: Add it to GL(dl_tls_static_size)
here.
* elf/dl-reloc.c (_dl_try_allocate_static_tls): Compute freebytes in
two steps to catch bugs.

2009-07-27 Ulrich Drepper <drepper@redhat.com>

* sysdeps/x86_64/tst-xmmymm.sh: Refine testing. The script now
Expand Down
9 changes: 5 additions & 4 deletions csu/libc-tls.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Initialization code for TLS in statically linked application.
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 2002-2006, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -99,6 +99,9 @@ init_static_tls (size_t memsz, size_t align)
surplus that permits dynamic loading of modules with IE-model TLS. */
GL(dl_tls_static_size) = roundup (memsz + GL(dl_tls_static_size),
TLS_TCB_ALIGN);
#if TLS_TCB_AT_TP
GL(dl_tls_static_size) += TLS_TCB_SIZE;
#endif
GL(dl_tls_static_used) = memsz;
/* The alignment requirement for the static TLS block. */
GL(dl_tls_static_align) = align;
Expand Down Expand Up @@ -211,9 +214,7 @@ __libc_setup_tls (size_t tcbsize, size_t tcbalign)

memsz = roundup (memsz, align ?: 1);

#if TLS_TCB_AT_TP
memsz += tcbsize;
#elif TLS_DTV_AT_TP
#if TLS_DTV_AT_TP
memsz += tcb_offset;
#endif

Expand Down
13 changes: 13 additions & 0 deletions elf/dl-lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,10 @@ do_lookup_x (const char *undef_name, uint_fast32_t new_hash,
if (size * 3 <= tab->n_elements * 4)
{
/* Expand the table. */
#ifdef RTLD_CHECK_FOREIGN_CALL
/* This must not happen during runtime relocations. */
assert (!RTLD_CHECK_FOREIGN_CALL);
#endif
size_t newsize = _dl_higher_prime_number (size + 1);
struct unique_sym *newentries
= calloc (sizeof (struct unique_sym), newsize);
Expand All @@ -405,6 +409,11 @@ do_lookup_x (const char *undef_name, uint_fast32_t new_hash,
}
else
{
#ifdef RTLD_CHECK_FOREIGN_CALL
/* This must not happen during runtime relocations. */
assert (!RTLD_CHECK_FOREIGN_CALL);
#endif

#define INITIAL_NUNIQUE_SYM_TABLE 31
size = INITIAL_NUNIQUE_SYM_TABLE;
entries = calloc (sizeof (struct unique_sym), size);
Expand Down Expand Up @@ -600,6 +609,10 @@ add_dependency (struct link_map *undef_map, struct link_map *map, int flags)
unsigned int max
= undef_map->l_reldepsmax ? undef_map->l_reldepsmax * 2 : 10;

#ifdef RTLD_PREPARE_FOREIGN_CALL
RTLD_PREPARE_FOREIGN_CALL;
#endif

newp = malloc (sizeof (*newp) + max * sizeof (struct link_map *));
if (newp == NULL)
{
Expand Down
5 changes: 4 additions & 1 deletion elf/dl-reloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ _dl_try_allocate_static_tls (struct link_map *map)
size_t n;
size_t blsize;

freebytes = GL(dl_tls_static_size) - GL(dl_tls_static_used) - TLS_TCB_SIZE;
freebytes = GL(dl_tls_static_size) - GL(dl_tls_static_used);
if (freebytes < TLS_TCB_SIZE)
goto fail;
freebytes -= TLS_TCB_SIZE;

blsize = map->l_tls_blocksize + map->l_tls_firstbyte_offset;
if (freebytes < blsize)
Expand Down
8 changes: 8 additions & 0 deletions elf/dl-runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,21 @@ _dl_fixup (
flags |= DL_LOOKUP_GSCOPE_LOCK;
}

#ifdef RTLD_ENABLE_FOREIGN_CALL
RTLD_ENABLE_FOREIGN_CALL;
#endif

result = _dl_lookup_symbol_x (strtab + sym->st_name, l, &sym, l->l_scope,
version, ELF_RTYPE_CLASS_PLT, flags, NULL);

/* We are done with the global scope. */
if (!RTLD_SINGLE_THREAD_P)
THREAD_GSCOPE_RESET_FLAG ();

#ifdef RTLD_FINALIZE_FOREIGN_CALL
RTLD_FINALIZE_FOREIGN_CALL;
#endif

/* Currently result contains the base load address (or link map)
of the object that defines sym. Now add in the symbol
offset. */
Expand Down
13 changes: 12 additions & 1 deletion include/libc-symbols.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Support macros for making weak and strong aliases for symbols,
and for using symbol sets and linker warnings with GNU ld.
Copyright (C) 1995-1998, 2000-2006, 2008 Free Software Foundation, Inc.
Copyright (C) 1995-1998,2000-2006,2008,2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -845,6 +845,17 @@ for linking")
} \
__asm__ (".type " #name ", %gnu_indirect_function");

/* The body of the function is supposed to use __get_cpu_features
which will, if necessary, initialize the data first. */
#define libm_ifunc(name, expr) \
extern void *name##_ifunc (void) __asm__ (#name); \
void *name##_ifunc (void) \
{ \
__typeof (name) *res = expr; \
return res; \
} \
__asm__ (".type " #name ", %gnu_indirect_function");

#ifdef HAVE_ASM_SET_DIRECTIVE
# define libc_ifunc_hidden_def1(local, name) \
__asm__ (declare_symbol_alias_1_stringify (ASM_GLOBAL_DIRECTIVE) \
Expand Down
4 changes: 3 additions & 1 deletion math/s_fma.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Compute x * y + z as ternary operation.
Copyright (C) 1997, 2001 Free Software Foundation, Inc.
Copyright (C) 1997, 2001, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
Expand All @@ -25,7 +25,9 @@ __fma (double x, double y, double z)
{
return (x * y) + z;
}
#ifndef __fma
weak_alias (__fma, fma)
#endif

#ifdef NO_LONG_DOUBLE
strong_alias (__fma, __fmal)
Expand Down
4 changes: 3 additions & 1 deletion math/s_fmaf.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Compute x * y + z as ternary operation.
Copyright (C) 1997 Free Software Foundation, Inc.
Copyright (C) 1997, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
Expand All @@ -25,4 +25,6 @@ __fmaf (float x, float y, float z)
{
return (x * y) + z;
}
#ifndef __fmaf
weak_alias (__fmaf, fmaf)
#endif
29 changes: 29 additions & 0 deletions nptl/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
2009-07-29 Ulrich Drepper <drepper@redhat.com>

* sysdeps/x86_64/tls.h (TLS_TCB_ALIGN): Define explicitly to 32.

* sysdeps/x86_64/tls.h (tcbhead_t): Add room for SSE registers the
dynamic linker might have to save.
Define RTLD_CHECK_FOREIGN_CALL, RTLD_ENABLE_FOREIGN_CALL,
RTLD_PREPARE_FOREIGN_CALL, and RTLD_FINALIZE_FOREIGN_CALL. Pretty
printing.

* sysdeps/x86_64/tcb-offsets.sym: Add RTLD_SAVESPACE_SSE.

2009-07-28 Ulrich Drepper <drepper@redhat.com>

* pthread_mutex_lock.c [NO_INCR] (__pthread_mutex_cond_lock_adjust):
New function.
* pthreadP.h: Declare __pthread_mutex_cond_lock_adjust.
* sysdeps/unix/sysv/linux/pthread-pi-defines.sym: Add ROBUST_BIT.
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S: Don't use
requeue_pi for robust mutexes.
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S: Likewise.
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
Don't only skip __pthread_mutex_cond_lock. Call instead
__pthread_mutex_cond_lock_adjust.
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.

* pthread_mutex_unlock.c (__pthread_mutex_unlock_full): Minor
optimization of PI mutex handling.

2009-07-27 Ulrich Drepper <drepper@redhat.com>

[BZ #10418]
Expand Down
2 changes: 2 additions & 0 deletions nptl/pthreadP.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,8 @@ extern int __pthread_mutex_lock_internal (pthread_mutex_t *__mutex)
attribute_hidden;
extern int __pthread_mutex_cond_lock (pthread_mutex_t *__mutex)
attribute_hidden internal_function;
extern void __pthread_mutex_cond_lock_adjust (pthread_mutex_t *__mutex)
attribute_hidden internal_function;
extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex);
extern int __pthread_mutex_unlock_internal (pthread_mutex_t *__mutex)
attribute_hidden;
Expand Down
21 changes: 20 additions & 1 deletion nptl/pthread_mutex_lock.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2002-2007, 2008 Free Software Foundation, Inc.
/* Copyright (C) 2002-2007, 2008, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
Expand Down Expand Up @@ -473,3 +473,22 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex)
strong_alias (__pthread_mutex_lock, pthread_mutex_lock)
strong_alias (__pthread_mutex_lock, __pthread_mutex_lock_internal)
#endif


#ifdef NO_INCR
void
__pthread_mutex_cond_lock_adjust (mutex)
pthread_mutex_t *mutex;
{
assert ((mutex->__data.__kind & PTHREAD_MUTEX_PRIO_INHERIT_NP) != 0);
assert ((mutex->__data.__kind & PTHREAD_MUTEX_ROBUST_NORMAL_NP) == 0);
assert ((mutex->__data.__kind & PTHREAD_MUTEX_PSHARED_BIT) == 0);

/* Record the ownership. */
pid_t id = THREAD_GETMEM (THREAD_SELF, tid);
mutex->__data.__owner = id;

if (mutex->__data.__kind == PTHREAD_MUTEX_PI_RECURSIVE_NP)
++mutex->__data.__count;
}
#endif
7 changes: 4 additions & 3 deletions nptl/pthread_mutex_unlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ __pthread_mutex_unlock_full (pthread_mutex_t *mutex, int decr)
if (--mutex->__data.__count != 0)
/* We still hold the mutex. */
return 0;
goto continue_pi;
goto continue_pi_non_robust;

case PTHREAD_MUTEX_PI_ROBUST_RECURSIVE_NP:
/* Recursive mutex. */
Expand All @@ -173,7 +173,7 @@ __pthread_mutex_unlock_full (pthread_mutex_t *mutex, int decr)
/* We still hold the mutex. */
return 0;

goto continue_pi;
goto continue_pi_robust;

case PTHREAD_MUTEX_PI_ERRORCHECK_NP:
case PTHREAD_MUTEX_PI_NORMAL_NP:
Expand All @@ -195,9 +195,9 @@ __pthread_mutex_unlock_full (pthread_mutex_t *mutex, int decr)
pi_notrecoverable:
newowner = PTHREAD_MUTEX_NOTRECOVERABLE;

continue_pi:
if ((mutex->__data.__kind & PTHREAD_MUTEX_ROBUST_NORMAL_NP) != 0)
{
continue_pi_robust:
/* Remove mutex from the list.
Note: robust PI futexes are signaled by setting bit 0. */
THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
Expand All @@ -206,6 +206,7 @@ __pthread_mutex_unlock_full (pthread_mutex_t *mutex, int decr)
DEQUEUE_MUTEX (mutex);
}

continue_pi_non_robust:
mutex->__data.__owner = newowner;
if (decr)
/* One less user. */
Expand Down
1 change: 1 addition & 0 deletions nptl/sysdeps/unix/sysv/linux/pthread-pi-defines.sym
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
-- These PI macros are used by assembly code.

MUTEX_KIND offsetof (pthread_mutex_t, __data.__kind)
ROBUST_BIT PTHREAD_MUTEX_ROBUST_NORMAL_NP
PI_BIT PTHREAD_MUTEX_PRIO_INHERIT_NP
PS_BIT PTHREAD_MUTEX_PSHARED_BIT
6 changes: 4 additions & 2 deletions nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ __pthread_cond_broadcast:
jne 9f

/* Requeue to a PI mutex if the PI bit is set. */
testl $PI_BIT, MUTEX_KIND(%r8)
jne 81f
movl MUTEX_KIND(%r8), %eax
andl $(ROBUST_BIT|PI_BIT), %eax
cmpl $PI_BIT, %eax
je 81f

/* Wake up all threads. */
#ifdef __ASSUME_PRIVATE_FUTEX
Expand Down
6 changes: 4 additions & 2 deletions nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ __pthread_cond_signal:

/* Get the address of the mutex used. */
movq dep_mutex(%r8), %rcx
testl $PI_BIT, MUTEX_KIND(%rcx)
jne 9f
movl MUTEX_KIND(%rcx), %eax
andl $(ROBUST_BIT|PI_BIT), %eax
cmpl $PI_BIT, %eax
je 9f

#ifdef __ASSUME_PRIVATE_FUTEX
movl $(FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG), %esi
Expand Down
24 changes: 16 additions & 8 deletions nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,12 @@ __pthread_cond_timedwait:
je 60f

movq dep_mutex(%rdi), %r8
/* Requeue to a PI mutex if the PI bit is set. */
testl $PI_BIT, MUTEX_KIND(%r8)
je 61f
/* Requeue to a non-robust PI mutex if the PI bit is set and
the robust bit is not set. */
movl MUTEX_KIND(%r8), %eax
andl $(ROBUST_BIT|PI_BIT), %eax
cmpl $PI_BIT, %eax
jne 61f

movl $(FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG), %esi
xorl %eax, %eax
Expand Down Expand Up @@ -289,11 +292,10 @@ __pthread_cond_timedwait:

/* If requeue_pi is used the kernel performs the locking of the
mutex. */
41: xorl %eax, %eax
41: movq 16(%rsp), %rdi
testl %r15d, %r15d
jnz 63f
jnz 64f

movq 16(%rsp), %rdi
callq __pthread_mutex_cond_lock

63: testq %rax, %rax
Expand All @@ -316,12 +318,18 @@ __pthread_cond_timedwait:

retq

/* Initial locking failed. */
31: cfi_adjust_cfa_offset(4 * 8 + FRAME_SIZE)
cfi_adjust_cfa_offset(4 * 8 + FRAME_SIZE)
cfi_rel_offset(%r12, FRAME_SIZE + 24)
cfi_rel_offset(%r13, FRAME_SIZE + 16)
cfi_rel_offset(%r14, FRAME_SIZE + 8)
cfi_rel_offset(%r15, FRAME_SIZE)

64: callq __pthread_mutex_cond_lock_adjust
movq %r14, %rax
jmp 48b

/* Initial locking failed. */
31:
#if cond_lock != 0
addq $cond_lock, %rdi
#endif
Expand Down
Loading

0 comments on commit b870de5

Please sign in to comment.