| 357 | } |
| 358 | |
| 359 | int pthread_mutex_trylock(pthread_mutex_t *mutex) |
| 360 | { |
| 361 | const char *myname = "pthread_mutex_trylock"; |
| 362 | DWORD ret; |
| 363 | |
| 364 | if (mutex == NULL) { |
| 365 | msg_error("%s, %s(%d): input invalid", |
| 366 | __FILE__, myname, __LINE__); |
| 367 | return -1; |
| 368 | } |
| 369 | |
| 370 | ret = WaitForSingleObject(mutex->id, 0); |
| 371 | if (ret == WAIT_TIMEOUT) { |
| 372 | return FIBER_ETIME; |
| 373 | } else if (ret == WAIT_FAILED) { |
| 374 | msg_error("%s, %s(%d): WaitForSingleObject error(%s)", |
| 375 | __FILE__, myname, __LINE__, last_serror()); |
| 376 | return -1; |
| 377 | } |
| 378 | |
| 379 | return 0; |
| 380 | } |
| 381 | |
| 382 | int pthread_mutex_unlock(pthread_mutex_t *mutex) |
| 383 | { |
searching dependent graphs…