_Posix.dcl 2.91 KB
Newer Older
1
definition module System._Posix
2

3 4
from System._Pointer import :: Pointer
from System.Time import :: Tm
5

Bas Lijnse's avatar
Bas Lijnse committed
6 7
WNOHANG		:==	0x00000001  
WUNTRACED	:== 0x00000002
8 9 10
MAXPATHLEN	:== 1024

DIRENT_D_NAME_OFFSET	:== 8
11

12 13 14 15 16 17 18 19 20 21
S_IFMT		:== 0170000
S_IFIFO		:== 0010000
S_IFCHR		:== 0020000
S_IFDIR		:== 0040000
S_IFBLK		:== 0060000
S_IFREG		:== 0100000
S_IFLNK		:== 0120000
S_IFSOCK	:== 0140000
S_IFWHT		:== 0160000

22 23 24 25
STDIN_FILENO  :== 0
STDOUT_FILENO :== 1
STDERR_FILENO :== 2

Mart Lubbers's avatar
Mart Lubbers committed
26
FIONREAD   :== 0x4004667F
27

28 29
F_SETFD    :== 2
FD_CLOEXEC :== 1
Steffen Michels's avatar
Steffen Michels committed
30

Mart Lubbers's avatar
Mart Lubbers committed
31 32
O_RDWR     :== 02
O_NOCTTY   :== 0400
33

Mart Lubbers's avatar
Mart Lubbers committed
34 35 36 37 38 39
TCSANOW    :== 0
TIOCSCTTY  :== 0x540E

ECHO       :== 0x8
ECHONL     :== 0x40
ICANON     :== 0x2
Mart Lubbers's avatar
Mart Lubbers committed
40

Bas Lijnse's avatar
Bas Lijnse committed
41
//Posix API calls
42
errno		:: !*w -> (!Int,!*w)
43
strerr		:: !Int -> Pointer
44 45 46 47 48 49 50 51 52 53 54 55 56 57
stat		:: !{#Char} !{#Char} !*w -> (!Int,!*w)
unlink		:: !{#Char} !*w -> (!Int,!*w)
fork		:: !*w -> (!Int,!*w)
execvp		:: !{#Char} !{#Pointer} !*w -> (!Int,!*w)
waitpid		:: !Int !{#Int} !Int !*w -> (!Int,!*w)
exit		:: !Int !*w -> (!.a,!*w) 
getcwd		:: !{#Char} !Int !*w -> (!Pointer,!*w)
chdir		:: !{#Char} !*w -> (!Int,!*w)
mkdir		:: !{#Char} !Int !*w -> (!Int,!*w)
rmdir		:: !{#Char} !*w -> (!Int,!*w)
rename		:: !{#Char} !{#Char} !*w -> (!Int,!*w)
opendir		:: !{#Char} !*w -> (!Pointer,!*w)
closedir	:: !Pointer !*w -> (!Int,!*w)
readdir		:: !Pointer !*w -> (!Pointer,!*w)
58
pipe        :: !Pointer !*w -> (!Int, !*w)
59 60 61 62 63
posix_openpt :: !Int !*w -> (!Int, !*w)
grantpt     :: !Int !*w -> (!Int, !*w)
unlockpt    :: !Int !*w -> (!Int, !*w)
ptsname     :: !Int !*w -> (!Pointer, !*w)
open        :: !Pointer !Int !*w -> (!Int, !*w)
Mart Lubbers's avatar
Mart Lubbers committed
64
tcgetattr   :: !Int !Pointer !*w -> (!Int, !*w)
65 66
cfmakeraw   :: !Pointer !*w -> *w
setsid      :: !*w -> *w
Mart Lubbers's avatar
Mart Lubbers committed
67
tcsetattr   :: !Int !Int !Pointer !*w -> (!Int, !*w)
68 69
dup2        :: !Int !Int !*w -> (!Int, !*w)
close       :: !Int !*w -> (!Int, !*w)
70
ioctl       :: !Int !Int !Pointer !*w -> (!Int, !*w)
Steffen Michels's avatar
Steffen Michels committed
71 72
// variant requiring an argument as third parameter
fcntlArg    :: !Int !Int !Int !*w -> (!Int, !*w)
73 74 75
read        :: !Int !Pointer !Int !*w -> (!Int, !*w)
write       :: !Int !{#Char} !Int !*w -> (!Int, !*w)
select_     :: !Int !Pointer !Pointer !Pointer !Pointer !*w -> (!Int, !*w)
76
kill        :: !Int !Int !*w -> (!Int, !*w)
Steffen Michels's avatar
Steffen Michels committed
77
timegm      :: !{#Int} -> Int
78
clock_gettime :: !Int !Pointer !*w -> (!Int, !*w)
79
nanosleep :: !Pointer !Pointer !*w -> (!Int, !*w)
Bas Lijnse's avatar
Bas Lijnse committed
80 81 82

//Memory (impure)
malloc	:: !Int -> Pointer
83
mallocSt	:: !Int !*w -> (!Pointer, !*w)
Bas Lijnse's avatar
Bas Lijnse committed
84
free	:: !Pointer -> Int
85
freeSt  :: !Pointer !*w -> *w
Bas Lijnse's avatar
Bas Lijnse committed
86
memcpy_string_to_pointer :: !Pointer !{#Char} !Int -> Pointer
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109

//Posix datastructures
:: Stat =
	{ st_dev			:: !Int
	, st_ino			:: !Int
	, st_mode			:: !Int
	, st_nlink			:: !Int
	, st_uid			:: !Int
	, st_gid			:: !Int
	, st_rdev			:: !Int
	, st_atimespec		:: !Int
	, st_mtimespec		:: !Int
	, st_ctimespec		:: !Int
	, st_birthtimespec	:: !Int
	, st_size			:: !Int
	, st_blocks			:: !Int
	, st_blksize		:: !Int
	, st_flags			:: !Int
	, st_gen			:: !Int
	}
//Mapping to/from byte arrays
unpackStat	:: !{#Char} -> Stat
sizeOfStat	:: Int