aboutsummaryrefslogtreecommitdiff
path: root/vendor/sdl2/sdl_thread.odin
blob: 84516e26bd7a76a048b2c981d386356fb5694cc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package sdl2

import "core:c"

when ODIN_OS == .Windows {
	@(ignore_duplicates)
	foreign import lib "SDL2.lib"
} else {
	@(ignore_duplicates)
	foreign import lib "system:SDL2"
}

Thread :: struct {}

threadID :: distinct c.ulong
TLSID :: distinct c.uint

ThreadPriority :: enum c.int {
	LOW,
	NORMAL,
	HIGH,
	TIME_CRITICAL,
}

ThreadFunction :: proc "c" (data: rawptr) -> c.int

@(default_calling_convention="c", link_prefix="SDL_")
foreign lib {
	CreateThread              :: proc(fn: ThreadFunction, name: cstring, data: rawptr) -> ^Thread ---
	CreateThreadWithStackSize :: proc(fn: ThreadFunction, name: cstring, stacksize: c.size_t, data: rawptr) -> ^Thread ---
	GetThreadName             :: proc(thread: ^Thread) -> cstring ---
	ThreadID                  :: proc() -> threadID ---
	GetThreadID               :: proc(thread: ^Thread) -> threadID ---
	SetThreadPriority         :: proc(priority: ThreadPriority) -> c.int ---
	WaitThread                :: proc(thread: ^Thread, status: ^c.int) ---
	DetachThread              :: proc(thread: ^Thread) ---
	TLSCreate                 :: proc() -> TLSID ---
	TLSGet                    :: proc(id: TLSID) -> rawptr ---
	TLSSet                    :: proc(id: TLSID, value: rawptr, destructor: proc "c" (rawptr)) -> c.int ---
	TLSCleanup                :: proc() ---
}