@@ -101,6 +101,7 @@ struct timespec {
101
101
102
102
void win_pthread_init (void );
103
103
int win_pthread_setspecific (void * A ,void * B ,uint length );
104
+ int win_pthread_mutex_trylock (pthread_mutex_t * mutex );
104
105
int pthread_create (pthread_t * ,pthread_attr_t * ,pthread_handler ,void * );
105
106
int pthread_cond_init (pthread_cond_t * cond , const pthread_condattr_t * attr );
106
107
int pthread_cond_wait (pthread_cond_t * cond , pthread_mutex_t * mutex );
@@ -156,7 +157,7 @@ void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/
156
157
#define pthread_equal (A ,B ) ((A) == (B))
157
158
#define pthread_mutex_init (A ,B ) (InitializeCriticalSection(A),0)
158
159
#define pthread_mutex_lock (A ) (EnterCriticalSection(A),0)
159
- #define pthread_mutex_trylock (A ) (WaitForSingleObject((A), 0) == WAIT_TIMEOUT )
160
+ #define pthread_mutex_trylock (A ) win_pthread_mutex_trylock((A) )
160
161
#define pthread_mutex_unlock (A ) LeaveCriticalSection(A)
161
162
#define pthread_mutex_destroy (A ) DeleteCriticalSection(A)
162
163
#define my_pthread_setprio (A ,B ) SetThreadPriority(GetCurrentThread(), (B))
@@ -472,7 +473,7 @@ typedef struct st_safe_mutex_info_t
472
473
473
474
int safe_mutex_init (safe_mutex_t * mp , const pthread_mutexattr_t * attr ,
474
475
const char * file , uint line );
475
- int safe_mutex_lock (safe_mutex_t * mp ,const char * file , uint line );
476
+ int safe_mutex_lock (safe_mutex_t * mp , my_bool try_lock , const char * file , uint line );
476
477
int safe_mutex_unlock (safe_mutex_t * mp ,const char * file , uint line );
477
478
int safe_mutex_destroy (safe_mutex_t * mp ,const char * file , uint line );
478
479
int safe_cond_wait (pthread_cond_t * cond , safe_mutex_t * mp ,const char * file ,
@@ -495,12 +496,12 @@ void safe_mutex_end(FILE *file);
495
496
#undef pthread_cond_timedwait
496
497
#undef pthread_mutex_trylock
497
498
#define pthread_mutex_init (A ,B ) safe_mutex_init((A),(B),__FILE__,__LINE__)
498
- #define pthread_mutex_lock (A ) safe_mutex_lock((A),__FILE__,__LINE__)
499
+ #define pthread_mutex_lock (A ) safe_mutex_lock((A), FALSE, __FILE__, __LINE__)
499
500
#define pthread_mutex_unlock (A ) safe_mutex_unlock((A),__FILE__,__LINE__)
500
501
#define pthread_mutex_destroy (A ) safe_mutex_destroy((A),__FILE__,__LINE__)
501
502
#define pthread_cond_wait (A ,B ) safe_cond_wait((A),(B),__FILE__,__LINE__)
502
503
#define pthread_cond_timedwait (A ,B ,C ) safe_cond_timedwait((A),(B),(C),__FILE__,__LINE__)
503
- #define pthread_mutex_trylock (A ) pthread_mutex_lock(A )
504
+ #define pthread_mutex_trylock (A ) safe_mutex_lock((A), TRUE, __FILE__, __LINE__ )
504
505
#define pthread_mutex_t safe_mutex_t
505
506
#define safe_mutex_assert_owner (mp ) \
506
507
DBUG_ASSERT((mp)->count > 0 && \
0 commit comments