#include "pthread_impl.h"
+#ifdef __wasilibc_unmodified_upstream
#define IS32BIT(x) !((x)+0x80000000ULL>>32)
#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))
while (e != ETIMEDOUT);
return e;
}
+#endif
int __pthread_mutex_timedlock(pthread_mutex_t *restrict m, const struct timespec *restrict at)
{
r = __pthread_mutex_trylock(m);
if (r != EBUSY) return r;
+#ifdef __wasilibc_unmodified_upstream
if (type&8) return pthread_mutex_timedlock_pi(m, at);
-
+#endif
+
int spins = 100;
while (spins-- && m->_m_lock && !m->_m_waiters) a_spin();