sdl_mutex.odin 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package sdl2
  2. import "core:c"
  3. when ODIN_OS == "windows" { foreign import lib "SDL2.lib" }
  4. when ODIN_OS == "linux" { foreign import lib "system:SDL2" }
  5. when ODIN_OS == "darwin" { foreign import lib "system:SDL2" }
  6. when ODIN_OS == "freebsd" { foreign import lib "system:SDL2" }
  7. MUTEX_TIMEDOUT :: 1
  8. MUTEX_MAXWAIT :: ~u32(0)
  9. mutex :: struct {}
  10. semaphore :: struct {}
  11. sem :: semaphore
  12. cond :: struct {}
  13. mutexP :: LockMutex
  14. mutexV :: UnlockMutex
  15. @(default_calling_convention="c", link_prefix="SDL_")
  16. foreign lib {
  17. CreateMutex :: proc() -> ^mutex ---
  18. LockMutex :: proc(m: ^mutex) -> c.int ---
  19. TryLockMutex :: proc(m: ^mutex) -> c.int ---
  20. UnlockMutex :: proc(m: ^mutex) -> c.int ---
  21. DestroyMutex :: proc(m: ^mutex) ---
  22. CreateSemaphore :: proc(initial_value: u32) -> ^sem ---
  23. DestroySemaphore :: proc(s: ^sem) ---
  24. SemWait :: proc(s: ^sem) -> c.int ---
  25. SemTryWait :: proc(s: ^sem) -> c.int ---
  26. SemWaitTimeout :: proc(s: ^sem, ms: u32) -> c.int ---
  27. SemValue :: proc(s: ^sem) -> u32 ---
  28. CreateCond :: proc() -> ^cond ---
  29. DestroyCond :: proc(cv: ^cond) ---
  30. CondSignal :: proc(cv: ^cond) -> c.int ---
  31. CondBroadcast :: proc(cv: ^cond) -> c.int ---
  32. CondWait :: proc(cv: ^cond, m: ^mutex) -> c.int ---
  33. CondWaitTimeout :: proc(cv: ^cond, m: ^mutex, ms: u32) -> c.int ---
  34. }