sdl_thread.odin 1.2 KB

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