#include #include #include int mtx_timedlock(mtx_t *restrict m, const struct timespec *restrict ts) { int ret = pthread_mutex_clocklock((pthread_mutex_t *)m, CLOCK_REALTIME, ts); switch (ret) { default: return thrd_error; case 0: return thrd_success; case ETIMEDOUT: return thrd_timedout; } }