var/const decl; remove : from parameter lists

This commit is contained in:
Ginger Bill
2016-12-18 21:50:14 +00:00
parent 5217eb55b4
commit e370337f97
15 changed files with 2009 additions and 1989 deletions
+10 -10
View File
@@ -17,35 +17,35 @@ proc current_thread_id() -> i32 {
return win32.GetCurrentThreadId() as i32;
}
proc semaphore_init(s: ^Semaphore) {
proc semaphore_init(s ^Semaphore) {
s.handle = win32.CreateSemaphoreA(nil, 0, 1<<31-1, nil);
}
proc semaphore_destroy(s: ^Semaphore) {
proc semaphore_destroy(s ^Semaphore) {
win32.CloseHandle(s.handle);
}
proc semaphore_post(s: ^Semaphore, count: int) {
proc semaphore_post(s ^Semaphore, count int) {
win32.ReleaseSemaphore(s.handle, count as i32, nil);
}
proc semaphore_release(s: ^Semaphore) #inline { semaphore_post(s, 1); }
proc semaphore_release(s ^Semaphore) #inline { semaphore_post(s, 1); }
proc semaphore_wait(s: ^Semaphore) {
proc semaphore_wait(s ^Semaphore) {
win32.WaitForSingleObject(s.handle, win32.INFINITE);
}
proc mutex_init(m: ^Mutex) {
proc mutex_init(m ^Mutex) {
atomic.store32(^m.counter, 0);
atomic.store32(^m.owner, current_thread_id());
semaphore_init(^m.semaphore);
m.recursion = 0;
}
proc mutex_destroy(m: ^Mutex) {
proc mutex_destroy(m ^Mutex) {
semaphore_destroy(^m.semaphore);
}
proc mutex_lock(m: ^Mutex) {
proc mutex_lock(m ^Mutex) {
thread_id := current_thread_id();
if atomic.fetch_add32(^m.counter, 1) > 0 {
if thread_id != atomic.load32(^m.owner) {
@@ -55,7 +55,7 @@ proc mutex_lock(m: ^Mutex) {
atomic.store32(^m.owner, thread_id);
m.recursion++;
}
proc mutex_try_lock(m: ^Mutex) -> bool {
proc mutex_try_lock(m ^Mutex) -> bool {
thread_id := current_thread_id();
if atomic.load32(^m.owner) == thread_id {
atomic.fetch_add32(^m.counter, 1);
@@ -72,7 +72,7 @@ proc mutex_try_lock(m: ^Mutex) -> bool {
m.recursion++;
return true;
}
proc mutex_unlock(m: ^Mutex) {
proc mutex_unlock(m ^Mutex) {
recursion: i32;
thread_id := current_thread_id();
assert(thread_id == atomic.load32(^m.owner));