From 78306c6f140c57f45336f77ef72d027887632581 Mon Sep 17 00:00:00 2001 From: "mostang.com!davidm" Date: Thu, 12 Dec 2002 09:17:41 +0000 Subject: [PATCH] Move pthread-locking stuff to "internal.h". (_U_dyn_info_list_lock): Rename from "registration_lock" and change from r/w-lock to a simple mutex (spin) lock. (_U_dyn_register): Insert into doubly-linked list. (Logical change 1.30) --- src/dyn-register.c | 51 ++++++++-------------------------------------- 1 file changed, 9 insertions(+), 42 deletions(-) diff --git a/src/dyn-register.c b/src/dyn-register.c index 835a79b6..796b9ac9 100644 --- a/src/dyn-register.c +++ b/src/dyn-register.c @@ -1,52 +1,19 @@ -#include +#include "internal.h" -#ifndef HAVE_CMP8XCHG16 +pthread_mutex_t _U_dyn_info_list_lock = PTHREAD_MUTEX_INITIALIZER; -#include - -/* Make it easy to write thread-safe code which may or may not be - linked against libpthread. The macros below can be used - unconditionally and if -lpthread is around, they'll call the - corresponding routines otherwise, they do nothing. */ - -#pragma weak pthread_rwlock_rdlock -#pragma weak pthread_rwlock_wrlock -#pragma weak pthread_rwlock_unlock - -#define rw_rdlock(l) (pthread_rwlock_rdlock ? pthread_rwlock_rdlock (l) : 0) -#define rw_wrlock(l) (pthread_rwlock_wrlock ? pthread_rwlock_wrlock (l) : 0) -#define rw_unlock(l) (pthread_rwlock_unlock ? pthread_rwlock_unlock (l) : 0) - -static pthread_rwlock_t registration_lock = PTHREAD_RWLOCK_INITIALIZER; - -#endif - -extern unw_dyn_info_list_t _U_dyn_info_list; - -int +void _U_dyn_register (unw_dyn_info_t *di) { -#ifdef HAVE_CMP8XCHG16 - unw_dyn_info_t *old_list_head, *new_list_head; - unsigned long old_gen, new_gen; - - do - { - old_gen = _U_dyn_info_list.generation; - old_list_head = _U_dyn_info_list.first; - - new_gen = old_gen + 1; - new_list_head = di; - di->next = old_list_head; - } - while (cmp8xchg16 (&_U_dyn_info_list, new_gen, new_list_head) != old_gen); -#else - rw_wrlock (®istration_lock); + mutex_lock (&_U_dyn_info_list_lock); { ++_U_dyn_info_list.generation; + di->next = _U_dyn_info_list.first; + di->prev = NULL; + if (di->next) + di->next->prev = di; _U_dyn_info_list.first = di; } - rw_unlock (®istration_lock); -#endif + mutex_unlock (&_U_dyn_info_list_lock); }