blob: d22f49a96e5972a6f68d1a6be1bbca6a7113cc71 (
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
|
package posix
import "core:c"
when ODIN_OS == .Darwin {
foreign import lib "system:System.framework"
} else {
foreign import lib "system:c"
}
// string.h - string operations
// NOTE: most of the symbols in this header are not useful in Odin and have been left out.
foreign lib {
/*
Map the error number to a locale-dependent error message string.
Returns: a string that may be invalidated by subsequent calls
[[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/strerror.html ]]
*/
@(link_name="strerror")
_strerror :: proc(errnum: Errno) -> cstring ---
/*
Map the error number to a locale-dependent error message string and put it in the buffer.
Returns: ERANGE if the buffer is not big enough
[[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/strerror_r.html ]]
*/
strerror_r :: proc(errnum: Errno, strerrbuf: [^]byte, buflen: c.size_t) -> Errno ---
/*
Map the signal number to an implementation-defined string.
Returns: a string that may be invalidated by subsequent calls
[[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/strsignal.html ]]
*/
strsignal :: proc(sig: Signal) -> cstring ---
}
strerror :: #force_inline proc "contextless" (errnum: Maybe(Errno) = nil) -> cstring {
return _strerror(errnum.? or_else errno())
}
|