2000-07-18 Kaz Kylheku <kaz@ashi.footprints.net>

	* spinlock.c (__pthread_alt_lock, __pthread_alt_timedlock): Fixed
	bug whereby thr field of waitnode structure would not be correctly
	set unless a null self pointer is passed to the functions.
	Eliminated redundant calls to thread_self().
This commit is contained in:
Ulrich Drepper 2000-07-18 17:18:38 +00:00
parent e862aada83
commit e6574c9ca2
9 changed files with 29 additions and 25 deletions

View file

@ -46,7 +46,7 @@ __dlopen_check (const char *file, int mode)
struct dlopen_args args;
args.file = file;
args.mode = mode;
args.caller = __builtin_return_address (0);
args.caller = RETURN_ADDRESS (0);
return _dlerror_run (dlopen_doit, &args) ? NULL : args.new;
}

View file

@ -50,7 +50,7 @@ __dlopen_nocheck (const char *file, int mode)
{
struct dlopen_args args;
args.file = file;
args.caller = __builtin_return_address (0);
args.caller = RETURN_ADDRESS (0);
if ((mode & RTLD_BINDING_MASK) == 0)
/* By default assume RTLD_LAZY. */

View file

@ -1,5 +1,5 @@
/* Look up a symbol in a shared object loaded by `dlopen'.
Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
Copyright (C) 1995, 96, 97, 98, 99, 2000 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
@ -44,7 +44,7 @@ void *
dlsym (void *handle, const char *name)
{
struct dlsym_args args;
args.who = __builtin_return_address (0);
args.who = RETURN_ADDRESS (0);
args.handle = handle;
args.name = name;

View file

@ -1,5 +1,5 @@
/* Look up a versioned symbol in a shared object loaded by `dlopen'.
Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
Copyright (C) 1995, 96, 97, 98, 99, 2000 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
@ -48,7 +48,7 @@ __dlvsym (void *handle, const char *name, const char *version_str)
args.handle = handle;
args.name = name;
args.who = __builtin_return_address (0);
args.who = RETURN_ADDRESS (0);
args.version = version_str;
return (_dlerror_run (dlvsym_doit, &args) ? NULL : args.sym);

View file

@ -30,8 +30,7 @@ extern struct link_map *_dl_profile_map;
void
_dl_mcount_wrapper (void *selfpc)
{
_dl_mcount ((ElfW(Addr)) __builtin_return_address (0),
(ElfW(Addr)) selfpc);
_dl_mcount ((ElfW(Addr)) RETURN_ADDRESS (0), (ElfW(Addr)) selfpc);
}
@ -39,6 +38,5 @@ void
_dl_mcount_wrapper_check (void *selfpc)
{
if (_dl_profile_map != NULL)
_dl_mcount ((ElfW(Addr)) __builtin_return_address (0),
(ElfW(Addr)) selfpc);
_dl_mcount ((ElfW(Addr)) RETURN_ADDRESS (0), (ElfW(Addr)) selfpc);
}

View file

@ -1,3 +1,10 @@
2000-07-18 Kaz Kylheku <kaz@ashi.footprints.net>
* spinlock.c (__pthread_alt_lock, __pthread_alt_timedlock): Fixed
bug whereby thr field of waitnode structure would not be correctly
set unless a null self pointer is passed to the functions.
Eliminated redundant calls to thread_self().
2000-07-18 Jakub Jelinek <jakub@redhat.com>
* pthread.c (__pthread_initialize_manager): Lock

View file

@ -345,7 +345,7 @@ static void wait_node_dequeue(struct wait_node **pp_head,
if (pp_node == pp_head) {
long oldvalue = (long) p_node;
long newvalue = (long) p_node->next;
if (__compare_and_swap((long *) pp_node, oldvalue, newvalue))
return;
@ -388,7 +388,7 @@ void __pthread_alt_lock(struct _pthread_fastlock * lock,
wait_node.abandoned = 0;
wait_node.next = (struct wait_node *) lock->__status;
wait_node.thr = self = thread_self();
wait_node.thr = self;
suspend_needed = 1;
}
@ -408,7 +408,8 @@ void __pthread_alt_lock(struct _pthread_fastlock * lock,
newstatus = 1;
} else {
if (self == NULL)
wait_node.thr = self = thread_self();
self = thread_self();
wait_node.thr = self;
newstatus = (long) &wait_node;
}
wait_node.abandoned = 0;
@ -461,7 +462,7 @@ int __pthread_alt_timedlock(struct _pthread_fastlock * lock,
p_wait_node->abandoned = 0;
p_wait_node->next = (struct wait_node *) lock->__status;
p_wait_node->thr = self = thread_self();
p_wait_node->thr = self;
}
WRITE_MEMORY_BARRIER();
@ -478,7 +479,7 @@ int __pthread_alt_timedlock(struct _pthread_fastlock * lock,
newstatus = 1;
} else {
if (self == NULL)
p_wait_node->thr = self = thread_self();
p_wait_node->thr = self;
newstatus = (long) p_wait_node;
}
p_wait_node->abandoned = 0;

View file

@ -2678,7 +2678,7 @@ Void_t* mALLOc(bytes) size_t bytes;
Void_t* result;
#if defined __GNUC__ && __GNUC__ >= 2
result = (*__malloc_hook)(bytes, __builtin_return_address (0));
result = (*__malloc_hook)(bytes, RETURN_ADDRESS (0));
#else
result = (*__malloc_hook)(bytes, NULL);
#endif
@ -2996,7 +2996,7 @@ void fREe(mem) Void_t* mem;
#if defined _LIBC || defined MALLOC_HOOKS
if (__free_hook != NULL) {
#if defined __GNUC__ && __GNUC__ >= 2
(*__free_hook)(mem, __builtin_return_address (0));
(*__free_hook)(mem, RETURN_ADDRESS (0));
#else
(*__free_hook)(mem, NULL);
#endif
@ -3201,7 +3201,7 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
Void_t* result;
#if defined __GNUC__ && __GNUC__ >= 2
result = (*__realloc_hook)(oldmem, bytes, __builtin_return_address (0));
result = (*__realloc_hook)(oldmem, bytes, RETURN_ADDRESS (0));
#else
result = (*__realloc_hook)(oldmem, bytes, NULL);
#endif
@ -3478,8 +3478,7 @@ Void_t* mEMALIGn(alignment, bytes) size_t alignment; size_t bytes;
Void_t* result;
#if defined __GNUC__ && __GNUC__ >= 2
result = (*__memalign_hook)(alignment, bytes,
__builtin_return_address (0));
result = (*__memalign_hook)(alignment, bytes, RETURN_ADDRESS (0));
#else
result = (*__memalign_hook)(alignment, bytes, NULL);
#endif
@ -3671,7 +3670,7 @@ Void_t* cALLOc(n, elem_size) size_t n; size_t elem_size;
if (__malloc_hook != NULL) {
sz = n * elem_size;
#if defined __GNUC__ && __GNUC__ >= 2
mem = (*__malloc_hook)(sz, __builtin_return_address (0));
mem = (*__malloc_hook)(sz, RETURN_ADDRESS (0));
#else
mem = (*__malloc_hook)(sz, NULL);
#endif

View file

@ -1,5 +1,5 @@
/* Machine-dependent definitions for profiling support. Generic GCC 2 version.
Copyright (C) 1996, 1997 Free Software Foundation, Inc.
Copyright (C) 1996, 1997, 2000 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
@ -22,7 +22,7 @@
void *__builtin_return_address (unsigned int N)
returns the return address of the frame N frames up. */
/* Be warned that GCC cannot usefully compile __builtin_return_address(N)
/* Be warned that GCC cannot usefully compile __builtin_return_address(N)
for N != 0 on all machines. In this case, you may have to write
your own version of _mcount(). */
@ -50,6 +50,5 @@ static inline void mcount_internal (u_long frompc, u_long selfpc)
#define MCOUNT \
void _mcount (void) \
{ \
mcount_internal ((u_long) __builtin_return_address (1), \
(u_long) __builtin_return_address (0)); \
mcount_internal ((u_long) RETURN_ADDRESS (1), (u_long) RETURN_ADDRESS (0)); \
}