sdl_thread.odin 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. Thread :: struct {}
  8. threadID :: distinct c.ulong
  9. TLSID :: distinct c.uint
  10. ThreadPriority :: enum c.int {
  11. LOW,
  12. NORMAL,
  13. HIGH,
  14. TIME_CRITICAL,
  15. }
  16. ThreadFunction :: proc "c" (data: rawptr) -> c.int
  17. @(default_calling_convention="c", link_prefix="SDL_")
  18. foreign lib {
  19. CreateThread :: proc(fn: ThreadFunction, name: cstring, data: rawptr) -> ^Thread ---
  20. CreateThreadWithStackSize :: proc(fn: ThreadFunction, name: cstring, stacksize: c.size_t, data: rawptr) -> ^Thread ---
  21. GetThreadName :: proc(thread: ^Thread) -> cstring ---
  22. ThreadID :: proc() -> threadID ---
  23. GetThreadID :: proc(thread: ^Thread) -> threadID ---
  24. SetThreadPriority :: proc(priority: ThreadPriority) -> c.int ---
  25. WaitThread :: proc(thread: ^Thread, status: ^c.int) ---
  26. DetachThread :: proc(thread: ^Thread) ---
  27. TLSCreate :: proc() -> TLSID ---
  28. TLSGet :: proc(id: TLSID) -> rawptr ---
  29. TLSSet :: proc(id: TLSID, value: rawptr, destructor: proc "c" (rawptr)) -> c.int ---
  30. TLSCleanup :: proc() ---
  31. }