diff options
Diffstat (limited to 'src/pkg/runtime/lock_futex.c')
-rw-r--r-- | src/pkg/runtime/lock_futex.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/pkg/runtime/lock_futex.c b/src/pkg/runtime/lock_futex.c index 9b1f5f6db..3c2ef4ede 100644 --- a/src/pkg/runtime/lock_futex.c +++ b/src/pkg/runtime/lock_futex.c @@ -41,7 +41,7 @@ runtime·lock(Lock *l) runtime·throw("runtime·lock: lock count"); // Speculative grab for lock. - v = runtime·xchg(&l->key, MUTEX_LOCKED); + v = runtime·xchg((uint32*)&l->key, MUTEX_LOCKED); if(v == MUTEX_UNLOCKED) return; @@ -64,7 +64,7 @@ runtime·lock(Lock *l) // Try for lock, spinning. for(i = 0; i < spin; i++) { while(l->key == MUTEX_UNLOCKED) - if(runtime·cas(&l->key, MUTEX_UNLOCKED, wait)) + if(runtime·cas((uint32*)&l->key, MUTEX_UNLOCKED, wait)) return; runtime·procyield(ACTIVE_SPIN_CNT); } @@ -72,17 +72,17 @@ runtime·lock(Lock *l) // Try for lock, rescheduling. for(i=0; i < PASSIVE_SPIN; i++) { while(l->key == MUTEX_UNLOCKED) - if(runtime·cas(&l->key, MUTEX_UNLOCKED, wait)) + if(runtime·cas((uint32*)&l->key, MUTEX_UNLOCKED, wait)) return; runtime·osyield(); } // Sleep. - v = runtime·xchg(&l->key, MUTEX_SLEEPING); + v = runtime·xchg((uint32*)&l->key, MUTEX_SLEEPING); if(v == MUTEX_UNLOCKED) return; wait = MUTEX_SLEEPING; - runtime·futexsleep(&l->key, MUTEX_SLEEPING, -1); + runtime·futexsleep((uint32*)&l->key, MUTEX_SLEEPING, -1); } } @@ -94,11 +94,11 @@ runtime·unlock(Lock *l) if(--m->locks < 0) runtime·throw("runtime·unlock: lock count"); - v = runtime·xchg(&l->key, MUTEX_UNLOCKED); + v = runtime·xchg((uint32*)&l->key, MUTEX_UNLOCKED); if(v == MUTEX_UNLOCKED) runtime·throw("unlock of unlocked lock"); if(v == MUTEX_SLEEPING) - runtime·futexwakeup(&l->key, 1); + runtime·futexwakeup((uint32*)&l->key, 1); } // One-time notifications. @@ -111,9 +111,9 @@ runtime·noteclear(Note *n) void runtime·notewakeup(Note *n) { - if(runtime·xchg(&n->key, 1)) + if(runtime·xchg((uint32*)&n->key, 1)) runtime·throw("notewakeup - double wakeup"); - runtime·futexwakeup(&n->key, 1); + runtime·futexwakeup((uint32*)&n->key, 1); } void @@ -121,8 +121,8 @@ runtime·notesleep(Note *n) { if(m->profilehz > 0) runtime·setprof(false); - while(runtime·atomicload(&n->key) == 0) - runtime·futexsleep(&n->key, 0, -1); + while(runtime·atomicload((uint32*)&n->key) == 0) + runtime·futexsleep((uint32*)&n->key, 0, -1); if(m->profilehz > 0) runtime·setprof(true); } @@ -137,15 +137,15 @@ runtime·notetsleep(Note *n, int64 ns) return; } - if(runtime·atomicload(&n->key) != 0) + if(runtime·atomicload((uint32*)&n->key) != 0) return; if(m->profilehz > 0) runtime·setprof(false); deadline = runtime·nanotime() + ns; for(;;) { - runtime·futexsleep(&n->key, 0, ns); - if(runtime·atomicload(&n->key) != 0) + runtime·futexsleep((uint32*)&n->key, 0, ns); + if(runtime·atomicload((uint32*)&n->key) != 0) break; now = runtime·nanotime(); if(now >= deadline) |