Skip to content

Commit 0296246

Browse files
committed
str
1 parent 43ee7f6 commit 0296246

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

Python/parking_lot.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,16 @@ static Bucket buckets[NUM_BUCKETS] = {
5454
&& !defined(_Py_USE_SEMAPHORES)
5555
#define CONDATTR_MONOTONIC
5656
#endif
57-
58-
// Condattr for monotonic clock types
57+
struct condattr_inst {
5958
#if defined(_POSIX_THREADS)
60-
static pthread_condattr_t *condattr_ptr;
59+
pthread_condattr_t *condattr_ptr;
6160
#endif
62-
6361
#if defined(CONDATTR_MONOTONIC)
64-
static pthread_condattr_t condattr;
62+
pthread_condattr_t condattr;
6563
#endif
64+
};
65+
66+
struct condattr_inst condattr_;
6667

6768
void
6869
_PySemaphore_Init(_PySemaphore *sema)
@@ -84,15 +85,19 @@ _PySemaphore_Init(_PySemaphore *sema)
8485
#else
8586
#if defined(CONDATTR_MONOTONIC)
8687
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;
9095
}
9196
#endif
9297
if (pthread_mutex_init(&sema->mutex, NULL) != 0) {
9398
Py_FatalError("parking_lot: pthread_mutex_init failed");
9499
}
95-
if (pthread_cond_init(&sema->cond, condattr_ptr)) {
100+
if (pthread_cond_init(&sema->cond, condattr_.condattr_ptr)) {
96101
Py_FatalError("parking_lot: pthread_cond_init failed");
97102
}
98103
sema->counter = 0;

0 commit comments

Comments
 (0)