* pthreadP.h (pthread_cond_2_0_t): New type.
(struct pthread_functions): Use new type for 2.0 condvar callbacks.
Use new type for the 2.0 condvar function prototypes.
* forward.c: Use pthread_cond_2_0_t for 2.0 condvar functions.
* old_pthread_cond_init.c: Use pthread_cond_2_0_t for condvar
parameter.
* old_pthread_cond_destroy.c: Likewise.
* old_pthread_cond_broadcast.c: Likewise. Lock appropriately.
* old_pthread_cond_signal.c: Likewise.
* old_pthread_cond_timedwait.c: Likewise.
* old_pthread_cond_wait.c: Likewise.
2003-01-03 Ulrich Drepper <drepper@redhat.com>
+ * pthreadP.h (pthread_cond_2_0_t): New type.
+ (struct pthread_functions): Use new type for 2.0 condvar callbacks.
+ Use new type for the 2.0 condvar function prototypes.
+ * forward.c: Use pthread_cond_2_0_t for 2.0 condvar functions.
+ * old_pthread_cond_init.c: Use pthread_cond_2_0_t for condvar
+ parameter.
+ * old_pthread_cond_destroy.c: Likewise.
+ * old_pthread_cond_broadcast.c: Likewise. Lock appropriately.
+ * old_pthread_cond_signal.c: Likewise.
+ * old_pthread_cond_timedwait.c: Likewise.
+ * old_pthread_cond_wait.c: Likewise.
+
* sysdeps/unix/sysv/linux/i386/i486/lowlevelcond.S
(__pthread_cond_wait): Don't save cancellation mode and seq value
in same location.
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
FORWARD (pthread_condattr_init, (pthread_condattr_t *attr), (attr), 0)
#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
-FORWARD (__pthread_cond_broadcast_2_0, (pthread_cond_t *cond), (cond), 0)
+FORWARD (__pthread_cond_broadcast_2_0, (pthread_cond_2_0_t *cond), (cond), 0)
compat_symbol (libc, __pthread_cond_broadcast_2_0, pthread_cond_broadcast,
GLIBC_2_0);
#endif
GLIBC_2_3_2);
#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
-FORWARD (__pthread_cond_destroy_2_0, (pthread_cond_t *cond), (cond), 0)
+FORWARD (__pthread_cond_destroy_2_0, (pthread_cond_2_0_t *cond), (cond), 0)
compat_symbol (libc, __pthread_cond_destroy_2_0, pthread_cond_destroy,
GLIBC_2_0);
#endif
#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
FORWARD (__pthread_cond_init_2_0,
- (pthread_cond_t *cond, const pthread_condattr_t *cond_attr),
+ (pthread_cond_2_0_t *cond, const pthread_condattr_t *cond_attr),
(cond, cond_attr), 0)
compat_symbol (libc, __pthread_cond_init_2_0, pthread_cond_init, GLIBC_2_0);
#endif
versioned_symbol (libc, __pthread_cond_init, pthread_cond_init, GLIBC_2_3_2);
#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
-FORWARD (__pthread_cond_signal_2_0, (pthread_cond_t *cond), (cond), 0)
+FORWARD (__pthread_cond_signal_2_0, (pthread_cond_2_0_t *cond), (cond), 0)
compat_symbol (libc, __pthread_cond_signal_2_0, pthread_cond_signal,
GLIBC_2_0);
#endif
#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
FORWARD (__pthread_cond_wait_2_0,
- (pthread_cond_t *cond, pthread_mutex_t *mutex), (cond, mutex), 0)
+ (pthread_cond_2_0_t *cond, pthread_mutex_t *mutex), (cond, mutex), 0)
compat_symbol (libc, __pthread_cond_wait_2_0, pthread_cond_wait,
GLIBC_2_0);
#endif
#include <errno.h>
#include <stdlib.h>
#include "pthreadP.h"
+#include <lowlevellock.h>
#include <shlib-compat.h>
#if SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_3_2)
int
__pthread_cond_broadcast_2_0 (cond)
- pthread_cond_t *cond;
+ pthread_cond_2_0_t *cond;
{
- pthread_cond_t **realp = (pthread_cond_t **) cond;
-
- if (*realp == NULL)
+ if (cond->cond == NULL)
{
- *realp = (pthread_cond_t *) malloc (sizeof (pthread_cond_t));
- if (*realp == NULL)
+ lll_mutex_lock (cond->lock);
+
+ /* Check whether the condvar is still not allocated. */
+ if (cond->cond == NULL)
+ cond->cond = (pthread_cond_t *) malloc (sizeof (pthread_cond_t));
+
+ lll_mutex_unlock (cond->lock);
+
+ if (cond->cond == NULL)
return ENOMEM;
- **realp = (struct pthread_cond_t) PTHREAD_COND_INITIALIZER;
+ *cond->cond = (struct pthread_cond_t) PTHREAD_COND_INITIALIZER;
}
- return __pthread_cond_broadcast (*realp);
+ return __pthread_cond_broadcast (cond->cond);
}
compat_symbol (libpthread, __pthread_cond_broadcast_2_0,
pthread_cond_broadcast, GLIBC_2_0);
#if SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_3_2)
int
__pthread_cond_destroy_2_0 (cond)
- pthread_cond_t *cond;
+ pthread_cond_2_0_t *cond;
{
/* Free the memory which was eventually allocated. */
- free (*(void **) cond);
+ free (cond->cond);
return 0;
}
#if SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_3_2)
int
__pthread_cond_init_2_0 (cond, cond_attr)
- pthread_cond_t *cond;
+ pthread_cond_2_0_t *cond;
const pthread_condattr_t *cond_attr;
{
/* Note that we don't need the COND-ATTR. It contains only the
/* The type of the first argument is actually that of the old, too
small pthread_cond_t. We use only the first word of it, as a
pointer. */
- *((void **) cond) = NULL;
+ cond->cond = NULL;
return 0;
}
#if SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_3_2)
int
__pthread_cond_signal_2_0 (cond)
- pthread_cond_t *cond;
+ pthread_cond_2_0_t *cond;
{
- pthread_cond_t **realp = (pthread_cond_t **) cond;
-
- if (*realp == NULL)
+ if (cond->cond == NULL)
{
- *realp = (pthread_cond_t *) malloc (sizeof (pthread_cond_t));
- if (*realp == NULL)
+ lll_mutex_lock (cond->lock);
+
+ /* Check whether the condvar is still not allocated. */
+ if (cond->cond == NULL)
+ cond->cond = (pthread_cond_t *) malloc (sizeof (pthread_cond_t));
+
+ lll_mutex_unlock (cond->lock);
+
+ if (cond->cond == NULL)
return ENOMEM;
- **realp = (struct pthread_cond_t) PTHREAD_COND_INITIALIZER;
+ *cond->cond = (struct pthread_cond_t) PTHREAD_COND_INITIALIZER;
}
- return __pthread_cond_signal (*realp);
+ return __pthread_cond_signal (cond->cond);
}
compat_symbol (libpthread, __pthread_cond_signal_2_0, pthread_cond_signal,
GLIBC_2_0);
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
#if SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_3_2)
int
-__old_pthread_cond_timedwait (cond, mutex, abstime)
- pthread_cond_t *cond;
+__pthread_cond_timedwait_2_0 (cond, mutex, abstime)
+ pthread_cond_2_0_t *cond;
pthread_mutex_t *mutex;
const struct timespec *abstime;
{
- pthread_cond_t **realp = (pthread_cond_t **) cond;
-
- if (*realp == NULL)
+ if (cond->cond == NULL)
{
- *realp = (pthread_cond_t *) malloc (sizeof (pthread_cond_t));
- if (*realp == NULL)
+ lll_mutex_lock (cond->lock);
+
+ /* Check whether the condvar is still not allocated. */
+ if (cond->cond == NULL)
+ cond->cond = (pthread_cond_t *) malloc (sizeof (pthread_cond_t));
+
+ lll_mutex_unlock (cond->lock);
+
+ if (cond->cond == NULL)
return ENOMEM;
- **realp = (struct pthread_cond_t) PTHREAD_COND_INITIALIZER;
+ *cond->cond = (struct pthread_cond_t) PTHREAD_COND_INITIALIZER;
}
- return __pthread_cond_timedwait (*realp, mutex, abstime);
+ return __pthread_cond_timedwait (cond->cond, mutex, abstime);
}
-compat_symbol (libpthread, __old_pthread_cond_timedwait,
+compat_symbol (libpthread, __pthread_cond_timedwait_2_0,
pthread_cond_timedwait, GLIBC_2_0);
#endif
#if SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_3_2)
int
__pthread_cond_wait_2_0 (cond, mutex)
- pthread_cond_t *cond;
+ pthread_cond_2_0_t *cond;
pthread_mutex_t *mutex;
{
- pthread_cond_t **realp = (pthread_cond_t **) cond;
-
- if (*realp == NULL)
+ if (cond->cond == NULL)
{
- *realp = (pthread_cond_t *) malloc (sizeof (pthread_cond_t));
- if (*realp == NULL)
+ lll_mutex_lock (cond->lock);
+
+ /* Check whether the condvar is still not allocated. */
+ if (cond->cond == NULL)
+ cond->cond = (pthread_cond_t *) malloc (sizeof (pthread_cond_t));
+
+ lll_mutex_unlock (cond->lock);
+
+ if (cond->cond == NULL)
return ENOMEM;
- **realp = (struct pthread_cond_t) PTHREAD_COND_INITIALIZER;
+ *cond->cond = (struct pthread_cond_t) PTHREAD_COND_INITIALIZER;
}
- return __pthread_cond_wait (*realp, mutex);
+ return __pthread_cond_wait (cond->cond, mutex);
}
compat_symbol (libpthread, __pthread_cond_wait_2_0, pthread_cond_wait,
GLIBC_2_0);
#define DEBUGGING_P __builtin_expect (__pthread_debug, 0)
+/* Compatibility type for old conditional variable interfaces. */
+typedef struct
+{
+ pthread_cond_t *cond;
+ lll_lock_t lock;
+} pthread_cond_2_0_t;
+
+
/* Data type shared with libc. The libc uses it to pass on calls to
the thread functions. */
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_broadcast_2_0) (pthread_cond_t *);
- int (*ptr___pthread_cond_destroy_2_0) (pthread_cond_t *);
- int (*ptr___pthread_cond_init_2_0) (pthread_cond_t *,
+ 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_t *);
- int (*ptr___pthread_cond_wait_2_0) (pthread_cond_t *, pthread_mutex_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_equal) (pthread_t, pthread_t);
void (*ptr___pthread_exit) (void *);
int (*ptr_pthread_getschedparam) (pthread_t, int *, struct sched_param *);
extern void __pthread_disable_asynccancel (int oldtype)
internal_function attribute_hidden;
-extern int __pthread_cond_broadcast_2_0 (pthread_cond_t *cond);
-extern int __pthread_cond_destroy_2_0 (pthread_cond_t *cond);
-extern int __pthread_cond_init_2_0 (pthread_cond_t *cond,
+extern int __pthread_cond_broadcast_2_0 (pthread_cond_2_0_t *cond);
+extern int __pthread_cond_destroy_2_0 (pthread_cond_2_0_t *cond);
+extern int __pthread_cond_init_2_0 (pthread_cond_2_0_t *cond,
const pthread_condattr_t *cond_attr);
-extern int __pthread_cond_signal_2_0 (pthread_cond_t *cond);
-extern int __old_pthread_cond_timedwait (pthread_cond_t *cond,
+extern int __pthread_cond_signal_2_0 (pthread_cond_2_0_t *cond);
+extern int __pthread_cond_timedwait_2_0 (pthread_cond_2_0_t *cond,
pthread_mutex_t *mutex,
const struct timespec *abstime);
-extern int __pthread_cond_wait_2_0 (pthread_cond_t *cond,
+extern int __pthread_cond_wait_2_0 (pthread_cond_2_0_t *cond,
pthread_mutex_t *mutex);
/* The two functions are in libc.so and not exported. */