@@ -116,6 +116,7 @@ struct timespec {
116
116
117
117
void win_pthread_init (void );
118
118
int win_pthread_setspecific (void * A ,void * B ,uint length );
119
+ int win_pthread_mutex_trylock (pthread_mutex_t * mutex );
119
120
int pthread_create (pthread_t * ,pthread_attr_t * ,pthread_handler ,void * );
120
121
int pthread_cond_init (pthread_cond_t * cond , const pthread_condattr_t * attr );
121
122
int pthread_cond_wait (pthread_cond_t * cond , pthread_mutex_t * mutex );
@@ -176,7 +177,7 @@ extern int pthread_mutex_destroy (pthread_mutex_t *);
176
177
#else
177
178
#define pthread_mutex_init (A ,B ) (InitializeCriticalSection(A),0)
178
179
#define pthread_mutex_lock (A ) (EnterCriticalSection(A),0)
179
- #define pthread_mutex_trylock (A ) (WaitForSingleObject((A), 0) == WAIT_TIMEOUT )
180
+ #define pthread_mutex_trylock (A ) win_pthread_mutex_trylock((A) )
180
181
#define pthread_mutex_unlock (A ) LeaveCriticalSection(A)
181
182
#define pthread_mutex_destroy (A ) DeleteCriticalSection(A)
182
183
#define my_pthread_setprio (A ,B ) SetThreadPriority(GetCurrentThread(), (B))
@@ -574,7 +575,7 @@ typedef struct st_safe_mutex_info_t
574
575
575
576
int safe_mutex_init (safe_mutex_t * mp , const pthread_mutexattr_t * attr ,
576
577
const char * file , uint line );
577
- int safe_mutex_lock (safe_mutex_t * mp ,const char * file , uint line );
578
+ int safe_mutex_lock (safe_mutex_t * mp , my_bool try_lock , const char * file , uint line );
578
579
int safe_mutex_unlock (safe_mutex_t * mp ,const char * file , uint line );
579
580
int safe_mutex_destroy (safe_mutex_t * mp ,const char * file , uint line );
580
581
int safe_cond_wait (pthread_cond_t * cond , safe_mutex_t * mp ,const char * file ,
@@ -597,12 +598,12 @@ void safe_mutex_end(FILE *file);
597
598
#undef pthread_cond_timedwait
598
599
#undef pthread_mutex_trylock
599
600
#define pthread_mutex_init (A ,B ) safe_mutex_init((A),(B),__FILE__,__LINE__)
600
- #define pthread_mutex_lock (A ) safe_mutex_lock((A),__FILE__,__LINE__)
601
+ #define pthread_mutex_lock (A ) safe_mutex_lock((A), FALSE, __FILE__, __LINE__)
601
602
#define pthread_mutex_unlock (A ) safe_mutex_unlock((A),__FILE__,__LINE__)
602
603
#define pthread_mutex_destroy (A ) safe_mutex_destroy((A),__FILE__,__LINE__)
603
604
#define pthread_cond_wait (A ,B ) safe_cond_wait((A),(B),__FILE__,__LINE__)
604
605
#define pthread_cond_timedwait (A ,B ,C ) safe_cond_timedwait((A),(B),(C),__FILE__,__LINE__)
605
- #define pthread_mutex_trylock (A ) pthread_mutex_lock(A )
606
+ #define pthread_mutex_trylock (A ) safe_mutex_lock((A), TRUE, __FILE__, __LINE__ )
606
607
#define pthread_mutex_t safe_mutex_t
607
608
#define safe_mutex_assert_owner (mp ) \
608
609
DBUG_ASSERT((mp)->count > 0 && \
0 commit comments