aboutsummaryrefslogtreecommitdiff
path: root/core/c/libc/signal.odin
blob: cddf069163868428cd6e0b328e5e2e737fd6337a (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
42
43
44
45
46
47
48
package libc

// 7.14 Signal handling

when ODIN_OS == .Windows {
	foreign import libc "system:libucrt.lib"
} else when ODIN_OS == .Darwin {
	foreign import libc "system:System"
} else {
	foreign import libc "system:c"
}

sig_atomic_t :: distinct atomic_int

SIG_ATOMIC_MIN :: min(sig_atomic_t)
SIG_ATOMIC_MAX :: max(sig_atomic_t)

@(default_calling_convention="c")
foreign libc {
	signal :: proc(sig: int, func: proc "c" (int)) -> proc "c" (int) ---
	raise  :: proc(sig: int) -> int ---
}

when ODIN_OS == .Windows {
	SIG_ERR :: rawptr(~uintptr(0)) 
	SIG_DFL :: rawptr(uintptr(0))
	SIG_IGN :: rawptr(uintptr(1))

	SIGABRT :: 22
	SIGFPE  :: 8
	SIGILL  :: 4
	SIGINT  :: 2
	SIGSEGV :: 11
	SIGTERM :: 15
}

when ODIN_OS == .Linux || ODIN_OS == .FreeBSD || ODIN_OS == .Haiku || ODIN_OS == .OpenBSD || ODIN_OS == .NetBSD || ODIN_OS == .Darwin {
	SIG_ERR  :: rawptr(~uintptr(0))
	SIG_DFL  :: rawptr(uintptr(0))
	SIG_IGN  :: rawptr(uintptr(1)) 

	SIGABRT  :: 6
	SIGFPE   :: 8
	SIGILL   :: 4
	SIGINT   :: 2
	SIGSEGV  :: 11
	SIGTERM  :: 15
}