1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20: #include <errno.h>
21: #include <stdlib.h>
22: #include "pthreadP.h"
23: #include <atomic.h>
24: #include <shlib-compat.h>
25:
26:
27: #if SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_3_2)
28: int
29: __pthread_cond_timedwait_2_0 (cond, mutex, abstime)
30: pthread_cond_2_0_t *cond;
31: pthread_mutex_t *mutex;
32: const struct timespec *abstime;
33: {
34: if (cond->cond == NULL)
35: {
36: pthread_cond_t *newcond;
37:
38: #if LLL_LOCK_INITIALIZER == 0
39: newcond = (pthread_cond_t *) calloc (sizeof (pthread_cond_t), 1);
40: if (newcond == NULL)
41: return ENOMEM;
42: #else
43: newcond = (pthread_cond_t *) malloc (sizeof (pthread_cond_t));
44: if (newcond == NULL)
45: return ENOMEM;
46:
47:
48: (void) pthread_cond_init (newcond, NULL);
49: #endif
50:
51: if (atomic_compare_and_exchange_bool_acq (&cond->cond, newcond, NULL))
52:
53: free (newcond);
54: }
55:
56: return __pthread_cond_timedwait (cond->cond, mutex, abstime);
57: }
58: compat_symbol (libpthread, __pthread_cond_timedwait_2_0,
59: pthread_cond_timedwait, GLIBC_2_0);
60: #endif