-
Notifications
You must be signed in to change notification settings - Fork 4
/
errno.jou
35 lines (33 loc) · 1 KB
/
errno.jou
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
# C's errno is actually a macro that expands to a function call.
# The function name varies by platform.
if WINDOWS:
declare _errno() -> int*
elif MACOS:
declare __error() -> int*
elif NETBSD:
declare __errno() -> int*
else:
declare __errno_location() -> int*
# TODO: Ideally we would be able to place the if statements inside the functions.
if WINDOWS:
def set_errno(value: int) -> None:
*_errno() = value
def get_errno() -> int:
return *_errno()
elif MACOS:
def set_errno(value: int) -> None:
*__error() = value
def get_errno() -> int:
return *__error()
elif NETBSD:
def set_errno(value: int) -> None:
*__errno() = value
def get_errno() -> int:
return *__errno()
else:
def set_errno(value: int) -> None:
*__errno_location() = value
def get_errno() -> int:
return *__errno_location()
# Convert an error code into a string. Do not modify or free() the returned string.
declare strerror(errno_value: int) -> byte*