1#include <runtime/mutex.h>
2#include <threads.h>
3
4int mtx_trylock(mtx_t* m) {
5    zx_status_t status = zxr_mutex_trylock((zxr_mutex_t*)&m->__i);
6    switch (status) {
7    default:
8        return thrd_error;
9    case 0:
10        return thrd_success;
11    case ZX_ERR_BAD_STATE:
12        return thrd_busy;
13    }
14}
15