2
0

sdl_thread.odin 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package sdl2
  2. import "core:c"
  3. when ODIN_OS == .Windows {
  4. @(ignore_duplicates)
  5. foreign import lib "SDL2.lib"
  6. } else {
  7. @(ignore_duplicates)
  8. foreign import lib "system:SDL2"
  9. }
  10. Thread :: struct {}
  11. threadID :: distinct c.ulong
  12. TLSID :: distinct c.uint
  13. ThreadPriority :: enum c.int {
  14. LOW,
  15. NORMAL,
  16. HIGH,
  17. TIME_CRITICAL,
  18. }
  19. ThreadFunction :: proc "c" (data: rawptr) -> c.int
  20. @(default_calling_convention="c", link_prefix="SDL_")
  21. foreign lib {
  22. CreateThread :: proc(fn: ThreadFunction, name: cstring, data: rawptr) -> ^Thread ---
  23. CreateThreadWithStackSize :: proc(fn: ThreadFunction, name: cstring, stacksize: c.size_t, data: rawptr) -> ^Thread ---
  24. GetThreadName :: proc(thread: ^Thread) -> cstring ---
  25. ThreadID :: proc() -> threadID ---
  26. GetThreadID :: proc(thread: ^Thread) -> threadID ---
  27. SetThreadPriority :: proc(priority: ThreadPriority) -> c.int ---
  28. WaitThread :: proc(thread: ^Thread, status: ^c.int) ---
  29. DetachThread :: proc(thread: ^Thread) ---
  30. TLSCreate :: proc() -> TLSID ---
  31. TLSGet :: proc(id: TLSID) -> rawptr ---
  32. TLSSet :: proc(id: TLSID, value: rawptr, destructor: proc "c" (rawptr)) -> c.int ---
  33. TLSCleanup :: proc() ---
  34. }