[PATCH] Add pthread_cond_timedwait stub to libc.so
Jakub Jelinek
jakub@redhat.com
Mon Sep 1 09:52:00 GMT 2003
Hi!
B0rken software, which doesn't link shared libraries which use
pthread_cond_timedwait against -lpthread is bitten by this.
With the exception of pthread_cond_timedwait, all pthread_cond_*
routines have stubs in libc.so, so they are given @@GLIBC_2.3.2 version
during linking. pthread_cond_timedwait doesn't have the stub, so
unless -lpthread is specified (certainly the right thing to do),
it remains unversioned. Mixing pthread_cond_*@GLIBC_2.3.2 and
pthread_cond_timedwait@GLIBC_2.0 on one pthread_cond_t is deadly.
2003-09-01 Jakub Jelinek <jakub@redhat.com>
nptl/
* sysdeps/pthread/pthread-functions.h (struct pthread_functions): Add
ptr___pthread_cond_timedwait and ptr___pthread_cond_timedwait_2_0.
* init.c (pthread_functions): Initialize them.
* forward.c (pthread_cond_timedwait@GLIBC_2.0,
pthread_cond_timedwait@@GLIBC_2.3.2): New forwards.
* Versions (libc): Export pthread_cond_timedwait@GLIBC_2.0,
pthread_cond_timedwait@@GLIBC_2.3.2.
linuxthreads/
* internals.h (__pthread_cond_timedwait): New prototype.
* sysdeps/pthread/pthread-functions.h (struct pthread_functions): Add
ptr___pthread_cond_timedwait.
* pthread.c (__pthread_functions): Initialize them.
* forward.c (pthread_cond_timedwait@GLIBC_2.0,
pthread_cond_timedwait@@GLIBC_2.3.2): New forwards.
* Versions (libc): Export pthread_cond_timedwait@GLIBC_2.0,
pthread_cond_timedwait@@GLIBC_2.3.2.
--- libc/nptl/sysdeps/pthread/pthread-functions.h.jj 2003-04-12 15:06:09.000000000 -0400
+++ libc/nptl/sysdeps/pthread/pthread-functions.h 2003-09-01 05:17:47.000000000 -0400
@@ -52,12 +52,17 @@ struct pthread_functions
const pthread_condattr_t *);
int (*ptr___pthread_cond_signal) (pthread_cond_t *);
int (*ptr___pthread_cond_wait) (pthread_cond_t *, pthread_mutex_t *);
+ int (*ptr___pthread_cond_timedwait) (pthread_cond_t *, pthread_mutex_t *,
+ const struct timespec *);
int (*ptr___pthread_cond_broadcast_2_0) (pthread_cond_2_0_t *);
int (*ptr___pthread_cond_destroy_2_0) (pthread_cond_2_0_t *);
int (*ptr___pthread_cond_init_2_0) (pthread_cond_2_0_t *,
const pthread_condattr_t *);
int (*ptr___pthread_cond_signal_2_0) (pthread_cond_2_0_t *);
int (*ptr___pthread_cond_wait_2_0) (pthread_cond_2_0_t *, pthread_mutex_t *);
+ int (*ptr___pthread_cond_timedwait_2_0) (pthread_cond_2_0_t *,
+ pthread_mutex_t *,
+ const struct timespec *);
int (*ptr_pthread_equal) (pthread_t, pthread_t);
void (*ptr___pthread_exit) (void *);
int (*ptr_pthread_getschedparam) (pthread_t, int *, struct sched_param *);
--- libc/nptl/init.c.jj 2003-08-27 05:02:38.000000000 -0400
+++ libc/nptl/init.c 2003-09-01 05:15:30.000000000 -0400
@@ -93,12 +93,14 @@ static struct pthread_functions pthread_
.ptr___pthread_cond_init = __pthread_cond_init,
.ptr___pthread_cond_signal = __pthread_cond_signal,
.ptr___pthread_cond_wait = __pthread_cond_wait,
+ .ptr___pthread_cond_timedwait = __pthread_cond_timedwait,
# if SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_3_2)
.ptr___pthread_cond_broadcast_2_0 = __pthread_cond_broadcast_2_0,
.ptr___pthread_cond_destroy_2_0 = __pthread_cond_destroy_2_0,
.ptr___pthread_cond_init_2_0 = __pthread_cond_init_2_0,
.ptr___pthread_cond_signal_2_0 = __pthread_cond_signal_2_0,
.ptr___pthread_cond_wait_2_0 = __pthread_cond_wait_2_0,
+ .ptr___pthread_cond_timedwait_2_0 = __pthread_cond_timedwait_2_0,
# endif
.ptr_pthread_equal = __pthread_equal,
.ptr___pthread_exit = __pthread_exit,
--- libc/nptl/forward.c.jj 2003-04-16 17:51:27.000000000 -0400
+++ libc/nptl/forward.c 2003-09-01 05:13:37.000000000 -0400
@@ -136,6 +136,19 @@ FORWARD (__pthread_cond_wait, (pthread_c
versioned_symbol (libc, __pthread_cond_wait, pthread_cond_wait,
GLIBC_2_3_2);
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
+FORWARD (__pthread_cond_timedwait_2_0,
+ (pthread_cond_2_0_t *cond, pthread_mutex_t *mutex,
+ const struct timespec *abstime), (cond, mutex, abstime), 0)
+compat_symbol (libc, __pthread_cond_timedwait_2_0, pthread_cond_timedwait,
+ GLIBC_2_0);
+#endif
+FORWARD (__pthread_cond_timedwait,
+ (pthread_cond_t *cond, pthread_mutex_t *mutex,
+ const struct timespec *abstime), (cond, mutex, abstime), 0)
+versioned_symbol (libc, __pthread_cond_timedwait, pthread_cond_timedwait,
+ GLIBC_2_3_2);
+
FORWARD (pthread_equal, (pthread_t thread1, pthread_t thread2),
(thread1, thread2), 1)
--- libc/nptl/Versions.jj 2003-07-21 07:44:21.000000000 -0400
+++ libc/nptl/Versions 2003-09-01 05:26:42.000000000 -0400
@@ -9,6 +9,7 @@ libc {
pthread_condattr_destroy; pthread_condattr_init;
pthread_cond_broadcast; pthread_cond_destroy;
pthread_cond_init; pthread_cond_signal; pthread_cond_wait;
+ pthread_cond_timedwait;
pthread_equal; pthread_exit;
pthread_getschedparam; pthread_setschedparam;
pthread_mutex_destroy; pthread_mutex_init;
@@ -23,7 +24,7 @@ libc {
# Changed pthread_cond_t.
pthread_cond_init; pthread_cond_destroy;
pthread_cond_wait; pthread_cond_signal;
- pthread_cond_broadcast;
+ pthread_cond_broadcast; pthread_cond_timedwait;
}
GLIBC_PRIVATE {
# Internal libc interface to libpthread
--- libc/linuxthreads/Versions.jj 2003-06-17 18:28:03.000000000 -0400
+++ libc/linuxthreads/Versions 2003-09-01 05:28:26.000000000 -0400
@@ -7,6 +7,7 @@ libc {
pthread_attr_setschedparam; pthread_attr_setschedpolicy;
pthread_attr_setscope; pthread_cond_broadcast; pthread_cond_destroy;
pthread_cond_init; pthread_cond_signal; pthread_cond_wait;
+ pthread_cond_timedwait;
pthread_condattr_destroy; pthread_condattr_init; pthread_equal;
pthread_exit; pthread_getschedparam; pthread_mutex_destroy;
pthread_mutex_init; pthread_mutex_lock; pthread_mutex_unlock;
@@ -20,7 +21,7 @@ libc {
# Changed pthread_cond_t.
pthread_cond_init; pthread_cond_destroy;
pthread_cond_wait; pthread_cond_signal;
- pthread_cond_broadcast;
+ pthread_cond_broadcast; pthread_cond_timedwait;
}
GLIBC_PRIVATE {
# Internal libc interface to libpthread
--- libc/linuxthreads/sysdeps/pthread/pthread-functions.h.jj 2003-04-20 03:37:06.000000000 -0400
+++ libc/linuxthreads/sysdeps/pthread/pthread-functions.h 2003-09-01 05:35:34.000000000 -0400
@@ -54,6 +54,8 @@ struct pthread_functions
const pthread_condattr_t *);
int (*ptr___pthread_cond_signal) (pthread_cond_t *);
int (*ptr___pthread_cond_wait) (pthread_cond_t *, pthread_mutex_t *);
+ int (*ptr___pthread_cond_timedwait) (pthread_cond_t *, pthread_mutex_t *,
+ const struct timespec *);
int (*ptr_pthread_equal) (pthread_t, pthread_t);
void (*ptr___pthread_exit) (void *);
int (*ptr_pthread_getschedparam) (pthread_t, int *, struct sched_param *);
--- libc/linuxthreads/forward.c.jj 2003-01-02 19:30:04.000000000 -0500
+++ libc/linuxthreads/forward.c 2003-09-01 05:29:57.000000000 -0400
@@ -128,6 +128,15 @@ compat_symbol (libc, __pthread_cond_wait
#endif
versioned_symbol (libc, __pthread_cond_wait, pthread_cond_wait, GLIBC_2_3_2);
+FORWARD (__pthread_cond_timedwait,
+ (pthread_cond_t *cond, pthread_mutex_t *mutex,
+ const struct timespec *abstime), (cond, mutex, abstime), 0)
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
+strong_alias (__pthread_cond_timedwait, __pthread_cond_timedwait_2_0)
+compat_symbol (libc, __pthread_cond_timedwait_2_0, pthread_cond_timedwait, GLIBC_2_0);
+#endif
+versioned_symbol (libc, __pthread_cond_timedwait, pthread_cond_timedwait, GLIBC_2_3_2);
+
FORWARD (pthread_equal, (pthread_t thread1, pthread_t thread2),
(thread1, thread2), 1)
--- libc/linuxthreads/internals.h.jj 2003-06-17 18:22:21.000000000 -0400
+++ libc/linuxthreads/internals.h 2003-09-01 05:30:59.000000000 -0400
@@ -354,6 +354,9 @@ extern int __pthread_cond_init (pthread_
const pthread_condattr_t *cond_attr);
extern int __pthread_cond_destroy (pthread_cond_t *cond);
extern int __pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex);
+extern int __pthread_cond_timedwait (pthread_cond_t *cond,
+ pthread_mutex_t *mutex,
+ const struct timespec *abstime);
extern int __pthread_cond_signal (pthread_cond_t *cond);
extern int __pthread_cond_broadcast (pthread_cond_t *cond);
extern int __pthread_condattr_init (pthread_condattr_t *attr);
--- libc/linuxthreads/pthread.c.jj 2003-08-14 05:05:27.000000000 -0400
+++ libc/linuxthreads/pthread.c 2003-09-01 05:36:55.000000000 -0400
@@ -260,6 +260,7 @@ struct pthread_functions __pthread_funct
.ptr___pthread_cond_init = __pthread_cond_init,
.ptr___pthread_cond_signal = __pthread_cond_signal,
.ptr___pthread_cond_wait = __pthread_cond_wait,
+ .ptr___pthread_cond_timedwait = __pthread_cond_timedwait,
.ptr_pthread_equal = __pthread_equal,
.ptr___pthread_exit = __pthread_exit,
.ptr_pthread_getschedparam = __pthread_getschedparam,
Jakub
More information about the Libc-hacker
mailing list