@@ -54,15 +54,16 @@ static Bucket buckets[NUM_BUCKETS] = {
54
54
&& !defined(_Py_USE_SEMAPHORES )
55
55
#define CONDATTR_MONOTONIC
56
56
#endif
57
-
58
- // Condattr for monotonic clock types
57
+ struct condattr_inst {
59
58
#if defined(_POSIX_THREADS )
60
- static pthread_condattr_t * condattr_ptr ;
59
+ pthread_condattr_t * condattr_ptr ;
61
60
#endif
62
-
63
61
#if defined(CONDATTR_MONOTONIC )
64
- static pthread_condattr_t condattr ;
62
+ pthread_condattr_t condattr ;
65
63
#endif
64
+ };
65
+
66
+ struct condattr_inst condattr_ ;
66
67
67
68
void
68
69
_PySemaphore_Init (_PySemaphore * sema )
@@ -84,15 +85,19 @@ _PySemaphore_Init(_PySemaphore *sema)
84
85
#else
85
86
#if defined(CONDATTR_MONOTONIC )
86
87
if (!condattr_ptr ){
87
- pthread_condattr_init (& condattr );
88
- pthread_condattr_setclock (& condattr , CLOCK_MONOTONIC );
89
- condattr_ptr = & condattr ;
88
+ // pthread_condattr_init(&condattr);
89
+ // pthread_condattr_setclock(&condattr, CLOCK_MONOTONIC);
90
+ // condattr_ptr = &condattr;
91
+ condattr_ptr = & condattr_ .condattr ;
92
+ pthread_condattr_init (condattr_ptr );
93
+ pthread_condattr_setclock (condattr_ptr , CLOCK_MONOTONIC );
94
+ condattr_ .condattr_ptr = condattr_ptr ;
90
95
}
91
96
#endif
92
97
if (pthread_mutex_init (& sema -> mutex , NULL ) != 0 ) {
93
98
Py_FatalError ("parking_lot: pthread_mutex_init failed" );
94
99
}
95
- if (pthread_cond_init (& sema -> cond , condattr_ptr )) {
100
+ if (pthread_cond_init (& sema -> cond , condattr_ . condattr_ptr )) {
96
101
Py_FatalError ("parking_lot: pthread_cond_init failed" );
97
102
}
98
103
sema -> counter = 0 ;
0 commit comments