summaryrefslogtreecommitdiff
path: root/libpthread/nptl/forward.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2010-04-22 11:06:41 +0000
committerAustin Foxley <austinf@cetoncorp.com>2010-04-22 08:54:10 -0700
commit279c728ee62e53eb055227695bc6fafb31a3a5f1 (patch)
treed7ceb8ed28bec1266dfcfac8af1501948b8f9bda /libpthread/nptl/forward.c
parentb93b98daf0dd45ac52f99fc4d906e5926cdd5239 (diff)
nptl: fix libc internal, dynamically enabled locking
Final iteration to fix libc internal locking if libpthread is pulled in by dlopen call (directly or indirectly). We cannot really use the weak symbol trick for shared build, since the symbols won't get refreshed if libpthread is pulled in dynamically. In glibc, they have #ifdef SHARED magic to either use pthread_functions table, or weaks. But as we shared object files with both builds, this does not sounds good either. The reintroduces the libc weaks.c, but uses them now only with static build. For dynamic build, we still use the symbols with same name, but provide weaks in forward.c so they end up dereferencing the pthread_functions table indirectly if we are not linked to libpthread. Mutex initialization is hard coded as inline, as it needs to happen even if libpthread is not initially loaded. Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
Diffstat (limited to 'libpthread/nptl/forward.c')
-rw-r--r--libpthread/nptl/forward.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/libpthread/nptl/forward.c b/libpthread/nptl/forward.c
index 8f528d0a8..7878334ac 100644
--- a/libpthread/nptl/forward.c
+++ b/libpthread/nptl/forward.c
@@ -35,10 +35,11 @@ int __libc_pthread_functions_init attribute_hidden;
rettype \
name decl \
{ \
- if (!__libc_pthread_functions_init) \
+ if (!__libc_pthread_functions_init) { \
defaction; \
- \
- return PTHFCT_CALL (ptr_##name, params); \
+ } else { \
+ return PTHFCT_CALL (ptr_##name, params); \
+ } \
}
#define FORWARD(name, decl, params, defretval) \
@@ -130,9 +131,10 @@ FORWARD (pthread_mutex_init,
(mutex, mutexattr), 0)
FORWARD (pthread_mutex_lock, (pthread_mutex_t *mutex), (mutex), 0)
+weak_alias (pthread_mutex_lock, __pthread_mutex_lock)
FORWARD (pthread_mutex_unlock, (pthread_mutex_t *mutex), (mutex), 0)
-
+weak_alias (pthread_mutex_unlock, __pthread_mutex_unlock)
FORWARD2 (pthread_self, pthread_t, (void), (), return 0)
@@ -143,6 +145,16 @@ FORWARD (pthread_setcancelstate, (int state, int *oldstate), (state, oldstate),
FORWARD (pthread_setcanceltype, (int type, int *oldtype), (type, oldtype), 0)
#define return /* value is void */
+FORWARD2(_pthread_cleanup_push_defer,
+ void, (struct _pthread_cleanup_buffer *buffer, void (*routine)(void *), void *arg),
+ (buffer, routine, arg),
+ { buffer->__routine = routine; buffer->__arg = arg; });
+
+FORWARD2(_pthread_cleanup_pop_restore,
+ void, (struct _pthread_cleanup_buffer *buffer, int execute),
+ (buffer, execute),
+ if (execute) { buffer->__routine(buffer->__arg); });
+
FORWARD2(__pthread_unwind,
void attribute_hidden __attribute ((noreturn)) __cleanup_fct_attribute,
(__pthread_unwind_buf_t *buf), (buf), {