]> gitweb.factorcode.org Git - factor.git/blob - basis/unix/ffi/linux/linux.factor
use radix literals
[factor.git] / basis / unix / ffi / linux / linux.factor
1 ! Copyright (C) 2010 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: alien.c-types alien.syntax classes.struct unix.types ;
4 IN: unix.ffi
5
6 CONSTANT: MAXPATHLEN 1024
7
8 CONSTANT: O_RDONLY   0x0000
9 CONSTANT: O_WRONLY   0x0001
10 CONSTANT: O_RDWR     0x0002
11 CONSTANT: O_CREAT    0x0040
12 CONSTANT: O_EXCL     0x0080
13 CONSTANT: O_NOCTTY   0x0100
14 CONSTANT: O_TRUNC    0x0200
15 CONSTANT: O_APPEND   0x0400
16 CONSTANT: O_NONBLOCK 0x0800
17
18 ALIAS: O_NDELAY O_NONBLOCK
19
20 CONSTANT: SOL_SOCKET 1
21
22 CONSTANT: FD_SETSIZE 1024
23
24 CONSTANT: SO_REUSEADDR 2
25 CONSTANT: SO_OOBINLINE 10
26 CONSTANT: SO_SNDTIMEO 0x15
27 CONSTANT: SO_RCVTIMEO 0x14
28
29 CONSTANT: F_SETFD 2
30 CONSTANT: FD_CLOEXEC 1
31
32 CONSTANT: F_SETFL 4
33
34 STRUCT: addrinfo
35     { flags int }
36     { family int }
37     { socktype int }
38     { protocol int }
39     { addrlen socklen_t }
40     { addr void* }
41     { canonname c-string }
42     { next addrinfo* } ;
43
44 STRUCT: sockaddr-in
45     { family ushort }
46     { port ushort }
47     { addr in_addr_t }
48     { unused longlong } ;
49
50 STRUCT: sockaddr-in6
51     { family ushort }
52     { port ushort }
53     { flowinfo uint }
54     { addr uchar[16] }
55     { scopeid uint } ;
56
57 CONSTANT: max-un-path 108
58
59 STRUCT: sockaddr-un
60     { family ushort }
61     { path { char max-un-path } } ;
62
63 CONSTANT: SOCK_STREAM 1
64 CONSTANT: SOCK_DGRAM 2
65 CONSTANT: SOCK_RAW 3
66
67 CONSTANT: AF_UNSPEC 0
68 CONSTANT: AF_UNIX 1
69 CONSTANT: AF_INET 2
70 CONSTANT: AF_INET6 10
71
72 ALIAS: PF_UNSPEC AF_UNSPEC
73 ALIAS: PF_UNIX AF_UNIX
74 ALIAS: PF_INET AF_INET
75 ALIAS: PF_INET6 AF_INET6
76
77 CONSTANT: IPPROTO_TCP 6
78 CONSTANT: IPPROTO_UDP 17
79
80 CONSTANT: AI_PASSIVE 1
81
82 CONSTANT: SEEK_SET 0
83 CONSTANT: SEEK_CUR 1
84 CONSTANT: SEEK_END 2
85
86 STRUCT: passwd
87     { pw_name c-string }
88     { pw_passwd c-string }
89     { pw_uid uid_t }
90     { pw_gid gid_t }
91     { pw_gecos c-string }
92     { pw_dir c-string }
93     { pw_shell c-string } ;
94
95 ! dirent64
96 STRUCT: dirent
97     { d_ino ulonglong }
98     { d_off longlong }
99     { d_reclen ushort }
100     { d_type uchar }
101     { d_name char[256] } ;
102
103 FUNCTION: int open64 ( c-string path, int flags, int prot ) ;
104 FUNCTION: dirent* readdir64 ( DIR* dirp ) ;
105 FUNCTION: int readdir64_r ( void* dirp, dirent* entry, dirent** result ) ;
106
107 CONSTANT: EPERM 1
108 CONSTANT: ENOENT 2
109 CONSTANT: ESRCH 3
110 CONSTANT: EINTR 4
111 CONSTANT: EIO 5
112 CONSTANT: ENXIO 6
113 CONSTANT: E2BIG 7
114 CONSTANT: ENOEXEC 8
115 CONSTANT: EBADF 9
116 CONSTANT: ECHILD 10
117 CONSTANT: EAGAIN 11
118 CONSTANT: ENOMEM 12
119 CONSTANT: EACCES 13
120 CONSTANT: EFAULT 14
121 CONSTANT: ENOTBLK 15
122 CONSTANT: EBUSY 16
123 CONSTANT: EEXIST 17
124 CONSTANT: EXDEV 18
125 CONSTANT: ENODEV 19
126 CONSTANT: ENOTDIR 20
127 CONSTANT: EISDIR 21
128 CONSTANT: EINVAL 22
129 CONSTANT: ENFILE 23
130 CONSTANT: EMFILE 24
131 CONSTANT: ENOTTY 25
132 CONSTANT: ETXTBSY 26
133 CONSTANT: EFBIG 27
134 CONSTANT: ENOSPC 28
135 CONSTANT: ESPIPE 29
136 CONSTANT: EROFS 30
137 CONSTANT: EMLINK 31
138 CONSTANT: EPIPE 32
139 CONSTANT: EDOM 33
140 CONSTANT: ERANGE 34
141 CONSTANT: EDEADLK 35
142 CONSTANT: ENAMETOOLONG 36
143 CONSTANT: ENOLCK 37
144 CONSTANT: ENOSYS 38
145 CONSTANT: ENOTEMPTY 39
146 CONSTANT: ELOOP 40
147 ALIAS: EWOULDBLOCK EAGAIN
148 CONSTANT: ENOMSG 42
149 CONSTANT: EIDRM 43
150 CONSTANT: ECHRNG 44
151 CONSTANT: EL2NSYNC 45
152 CONSTANT: EL3HLT 46
153 CONSTANT: EL3RST 47
154 CONSTANT: ELNRNG 48
155 CONSTANT: EUNATCH 49
156 CONSTANT: ENOCSI 50
157 CONSTANT: EL2HLT 51
158 CONSTANT: EBADE 52
159 CONSTANT: EBADR 53
160 CONSTANT: EXFULL 54
161 CONSTANT: ENOANO 55
162 CONSTANT: EBADRQC 56
163 CONSTANT: EBADSLT 57
164 ALIAS: EDEADLOCK EDEADLK
165 CONSTANT: EBFONT 59
166 CONSTANT: ENOSTR 60
167 CONSTANT: ENODATA 61
168 CONSTANT: ETIME 62
169 CONSTANT: ENOSR 63
170 CONSTANT: ENONET 64
171 CONSTANT: ENOPKG 65
172 CONSTANT: EREMOTE 66
173 CONSTANT: ENOLINK 67
174 CONSTANT: EADV 68
175 CONSTANT: ESRMNT 69
176 CONSTANT: ECOMM 70
177 CONSTANT: EPROTO 71
178 CONSTANT: EMULTIHOP 72
179 CONSTANT: EDOTDOT 73
180 CONSTANT: EBADMSG 74
181 CONSTANT: EOVERFLOW 75
182 CONSTANT: ENOTUNIQ 76
183 CONSTANT: EBADFD 77
184 CONSTANT: EREMCHG 78
185 CONSTANT: ELIBACC 79
186 CONSTANT: ELIBBAD 80
187 CONSTANT: ELIBSCN 81
188 CONSTANT: ELIBMAX 82
189 CONSTANT: ELIBEXEC 83
190 CONSTANT: EILSEQ 84
191 CONSTANT: ERESTART 85
192 CONSTANT: ESTRPIPE 86
193 CONSTANT: EUSERS 87
194 CONSTANT: ENOTSOCK 88
195 CONSTANT: EDESTADDRREQ 89
196 CONSTANT: EMSGSIZE 90
197 CONSTANT: EPROTOTYPE 91
198 CONSTANT: ENOPROTOOPT 92
199 CONSTANT: EPROTONOSUPPORT 93
200 CONSTANT: ESOCKTNOSUPPORT 94
201 CONSTANT: EOPNOTSUPP 95
202 CONSTANT: EPFNOSUPPORT 96
203 CONSTANT: EAFNOSUPPORT 97
204 CONSTANT: EADDRINUSE 98
205 CONSTANT: EADDRNOTAVAIL 99
206 CONSTANT: ENETDOWN 100
207 CONSTANT: ENETUNREACH 101
208 CONSTANT: ENETRESET 102
209 CONSTANT: ECONNABORTED 103
210 CONSTANT: ECONNRESET 104
211 CONSTANT: ENOBUFS 105
212 CONSTANT: EISCONN 106
213 CONSTANT: ENOTCONN 107
214 CONSTANT: ESHUTDOWN 108
215 CONSTANT: ETOOMANYREFS 109
216 CONSTANT: ETIMEDOUT 110
217 CONSTANT: ECONNREFUSED 111
218 CONSTANT: EHOSTDOWN 112
219 CONSTANT: EHOSTUNREACH 113
220 CONSTANT: EALREADY 114
221 CONSTANT: EINPROGRESS 115
222 CONSTANT: ESTALE 116
223 CONSTANT: EUCLEAN 117
224 CONSTANT: ENOTNAM 118
225 CONSTANT: ENAVAIL 119
226 CONSTANT: EISNAM 120
227 CONSTANT: EREMOTEIO 121
228 CONSTANT: EDQUOT 122
229 CONSTANT: ENOMEDIUM 123
230 CONSTANT: EMEDIUMTYPE 124
231 CONSTANT: ECANCELED 125
232 CONSTANT: ENOKEY 126
233 CONSTANT: EKEYEXPIRED 127
234 CONSTANT: EKEYREVOKED 128
235 CONSTANT: EKEYREJECTED 129
236 CONSTANT: EOWNERDEAD 130
237 CONSTANT: ENOTRECOVERABLE 131
238
239 CONSTANT: SIGHUP           1
240 CONSTANT: SIGINT           2
241 CONSTANT: SIGQUIT          3
242 CONSTANT: SIGILL           4
243 CONSTANT: SIGTRAP          5
244 CONSTANT: SIGABRT          6
245 CONSTANT: SIGIOT           6
246 CONSTANT: SIGBUS           7
247 CONSTANT: SIGFPE           8
248 CONSTANT: SIGKILL          9
249 CONSTANT: SIGUSR1         10
250 CONSTANT: SIGSEGV         11
251 CONSTANT: SIGUSR2         12
252 CONSTANT: SIGPIPE         13
253 CONSTANT: SIGALRM         14
254 CONSTANT: SIGTERM         15
255 CONSTANT: SIGSTKFLT       16
256 CONSTANT: SIGCHLD         17
257 ALIAS:    SIGCLD          SIGCHLD
258 CONSTANT: SIGCONT         18
259 CONSTANT: SIGSTOP         19
260 CONSTANT: SIGTSTP         20
261 CONSTANT: SIGTTIN         21
262 CONSTANT: SIGTTOU         22
263 CONSTANT: SIGURG          23
264 CONSTANT: SIGXCPU         24
265 CONSTANT: SIGXFSZ         25
266 CONSTANT: SIGVTALRM       26
267 CONSTANT: SIGPROF         27
268 CONSTANT: SIGWINCH        28
269 CONSTANT: SIGIO           29
270 ALIAS:    SIGPOLL         SIGIO
271 CONSTANT: SIGPWR          30
272 CONSTANT: SIGSYS          31