- if (abstime)
- wait_result = lck_mtx_sleep_deadline(mtx, (dropmutex) ? LCK_SLEEP_UNLOCK : 0,
- chan, (catch) ? THREAD_ABORTSAFE : THREAD_UNINT, abstime);
- else
- wait_result = lck_mtx_sleep(mtx, (dropmutex) ? LCK_SLEEP_UNLOCK : 0,
- chan, (catch) ? THREAD_ABORTSAFE : THREAD_UNINT);
- }
- else {
- if (chan != NULL)
- assert_wait_deadline(chan, (catch) ? THREAD_ABORTSAFE : THREAD_UNINT, abstime);
- if (mtx)
+ if (dropmutex) {
+ flags = LCK_SLEEP_UNLOCK;
+ } else {
+ flags = LCK_SLEEP_DEFAULT;
+ }
+
+ if (spinmutex) {
+ flags |= LCK_SLEEP_SPIN;
+ }
+
+ if (abstime) {
+ wait_result = lck_mtx_sleep_deadline(mtx, flags, chan, catch, abstime);
+ } else {
+ wait_result = lck_mtx_sleep(mtx, flags, chan, catch);
+ }
+ } else {
+ if (chan != NULL) {
+ assert_wait_deadline(chan, catch, abstime);
+ }
+ if (mtx) {