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_wait_2_0 (cond, mutex)
30: pthread_cond_2_0_t *cond;
31: pthread_mutex_t *mutex;
32: {
33: if (cond->cond == NULL)
34: {
35: pthread_cond_t *newcond;
36:
37: #if LLL_LOCK_INITIALIZER == 0
38: newcond = (pthread_cond_t *) calloc (sizeof (pthread_cond_t), 1);
39: if (newcond == NULL)
40: return ENOMEM;
41: #else
42: newcond = (pthread_cond_t *) malloc (sizeof (pthread_cond_t));
43: if (newcond == NULL)
44: return ENOMEM;
45:
46:
47: (void) pthread_cond_init (newcond, NULL);
48: #endif
49:
50: if (atomic_compare_and_exchange_bool_acq (&cond->cond, newcond, NULL))
51:
52: free (newcond);
53: }
54:
55: return __pthread_cond_wait (cond->cond, mutex);
56: }
57: compat_symbol (libpthread, __pthread_cond_wait_2_0, pthread_cond_wait,
58: GLIBC_2_0);
59: #endif