source: azure_iot_hub/trunk/musl-1.1.18/src/thread/mtx_trylock.c@ 388

Last change on this file since 388 was 388, checked in by coas-nagasima, 5 years ago

Azure IoT Hub Device C SDK を使ったサンプルの追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-csrc
File size: 390 bytes
Line 
1#include "pthread_impl.h"
2#include <threads.h>
3
4int __pthread_mutex_trylock(mtx_t *);
5
6int mtx_trylock(mtx_t *m)
7{
8 if (m->_m_type == PTHREAD_MUTEX_NORMAL)
9 return (a_cas(&m->_m_lock, 0, EBUSY) & EBUSY) ? thrd_busy : thrd_success;
10
11 int ret = __pthread_mutex_trylock(m);
12 switch (ret) {
13 default: return thrd_error;
14 case 0: return thrd_success;
15 case EBUSY: return thrd_busy;
16 }
17}
Note: See TracBrowser for help on using the repository browser.