Debian Codegraph @

rt/+dragonfly/types.ha

raw
1 // SPDX-License-Identifier: MPL-2.0
2 // (c) Hare authors <https://harelang.org>
3
4 export type time_t = i64;
5 export type suseconds_t = i64;
6 export type dev_t = u32;
7 export type ino_t = u64;
8 export type nlink_t = u32;
9 export type id_t = i64; // general id, can hold gid/pid/uid_t
10 export type pid_t = i32;
11 export type uid_t = u32;
12 export type gid_t = u32;
13 export type off_t = i64;
14 export type blkcnt_t = i64;
15 export type blksize_t = i64;
16 export type fflags_t = u32;
17 export type mode_t = u16;
18 export type nfds_t = uint;
19 export type rlim_t = i64;
20
21 export type intptr_t = i64;
22 export type c_long = i64;
23
24 export def NGROUPS_MAX: size = 16;
25 export def NSIG: int = 64;
26
27 export type sigset = struct {
28 __bits: [4]uint,
29 };
30
31 // Named "struct sigaction" in DragonFly.
32 export type sigact = struct {
33 union {
34 sa_handler: nullable *fn (_: int) void,
35 sa_sigaction: nullable *fn (_: int,
36 _: *siginfo, _: *opaque) void,
37 },
38 sa_flags: int,
39 sa_mask: sigset,
40 };
41
42 export type kevent_t = struct {
43 ident: uintptr,
44 filter: i16,
45 flags: u16,
46 fflags: uint,
47 data: intptr_t,
48 udata: *opaque,
49 };
50
51 export type sigval = union {
52 sival_int: int,
53 sival_ptr: *opaque,
54 };
55
56 export type stack_t = struct {
57 ss_sp: *opaque,
58 ss_size: size,
59 ss_flags: int,
60 };
61
62 export type pollfd = struct {
63 fd: int,
64 events: i16,
65 revents: i16,
66 };
67
68 export type timespec = struct {
69 tv_sec: time_t, // seconds
70 tv_nsec: c_long, // and nanoseconds
71 };
72
73 export def UTIME_OMIT = -2;
74
75 export type timeval = struct {
76 tv_sec: time_t,
77 tv_usec: suseconds_t,
78 };
79
80 //
81 // Advisory file segment locking data type -
82 // information passed to system by user
83 //
84 // (struct flock in DragonFly)
85 //
86 export type st_flock = struct {
87 l_start: off_t, // starting offset
88 l_len: off_t, // len = 0 means until end of file
89 l_pid: pid_t, // lock owner
90 l_type: i16, // lock type: read/write, etc.
91 l_whence: i16, // type of l_start
92 };
93
94 export type st = struct {
95 ino: ino_t,
96 nlink: nlink_t,
97 dev: dev_t,
98 mode: mode_t,
99 uid: uid_t,
100 gid: gid_t,
101 rdev: dev_t,
102 atime: timespec,
103 mtime: timespec,
104 ctime: timespec,
105 sz: off_t,
106 blocks: blkcnt_t,
107 blksz: blksize_t,
108 flags: fflags_t,
109 };
110
111 export type dragonfly_stat = struct {
112 st_ino: ino_t, // inode's number
113 st_nlink: nlink_t, // number of hard links
114 st_dev: dev_t, // inode's device
115 st_mode: mode_t, // inode protection mode
116 _: u16, // padding
117 st_uid: uid_t, // user ID of the file's owner
118 st_gid: gid_t, // group ID of the file's owner
119 st_rdev: dev_t, // device type
120 st_atim: timespec, // time of last access
121 st_mtim: timespec, // time of last modification
122 st_ctim: timespec, // time of last file status change
123 st_size: off_t, // file size, in bytes
124 st_blocks: blkcnt_t, // blocks allocated for file
125 __old_st_blksize: u32, // old ABI compatibility only
126 st_flags: u32, // user defined flags for file
127 st_gen: u32, // file generation number
128 st_lspare: i32,
129 st_blksize: blksize_t, // optimal blocksize for I/O
130 st_qspare2: i64,
131 };
132
133 export type dragonfly_dirent = struct {
134 d_fileno: ino_t, // file number of entry
135 d_namlen: u16, // strlen(d_name)
136 d_type: u8, // file type
137 _: u8, // padding, reserved
138 _: u32, // reserved
139 d_name: [255+1]u8, // name, NUL-terminated
140 };
141
142 // offset of "d_name" field + namelen + padding to 8 bytes boundary
143 export fn DIRENT_RECLEN(namelen: u64) u64 = {
144 const offsetof_d_name: u64 = 16;
145 return ((offsetof_d_name + (namelen) + 1 + 7) & ~7u64);
146 };
147
148 export type iovec = struct {
149 iov_base: nullable *opaque, // Base address
150 iov_len: size // Length
151 };
152
153 export type winsize = struct {
154 ws_row: u16, // rows, in characters
155 ws_col: u16, // columns, in characters
156 ws_xpixel: u16, // horizontal size, pixels
157 ws_ypixel: u16, // vertical size, pixels
158 };
159
160 export type termios = struct {
161 c_iflag: tcflag, // input flags
162 c_oflag: tcflag, // output flags
163 c_cflag: tcflag, // control flags
164 c_lflag: tcflag, // local flags
165 c_cc: [NCCS]cc, // control chars
166 c_ispeed: speed, // input speed
167 c_ospeed: speed, // output speed
168 };
169
170 export def NCCS: size = 20;
171
172 export type speed = enum uint {
173 B0 = 0,
174 B50 = 50,
175 B75 = 75,
176 B110 = 110,
177 B134 = 134,
178 B150 = 150,
179 B200 = 200,
180 B300 = 300,
181 B600 = 600,
182 B1200 = 1200,
183 B1800 = 1800,
184 B2400 = 2400,
185 B4800 = 4800,
186 B9600 = 9600,
187 B19200 = 19200,
188 B38400 = 38400,
189
190 B7200 = 7200,
191 B14400 = 14400,
192 B28800 = 28800,
193 B57600 = 57600,
194 B76800 = 76800,
195 B115200 = 115200,
196 B230400 = 230400,
197 B460800 = 460800,
198 B921600 = 921600,
199 EXTA = 19200,
200 EXTB = 38400,
201 };
202
203 export type tcflag = enum uint {
204 // Input flags - software input processing
205 // (c_iflag bits)
206 IGNBRK = 0x00000001, // ignore BREAK condition
207 BRKINT = 0x00000002, // map BREAK to SIGINTR
208 IGNPAR = 0x00000004, // ignore (discard) parity errors
209 PARMRK = 0x00000008, // mark parity and framing errors
210 INPCK = 0x00000010, // enable checking of parity errors
211 ISTRIP = 0x00000020, // strip 8th bit off chars
212 INLCR = 0x00000040, // map NL into CR
213 IGNCR = 0x00000080, // ignore CR
214 ICRNL = 0x00000100, // map CR to NL (ala CRMOD)
215 IXON = 0x00000200, // enable output flow control
216 IXOFF = 0x00000400, // enable input flow control
217 IXANY = 0x00000800, // any char will restart after stop
218 IMAXBEL = 0x00002000, // ring bell on input queue full
219
220 // Output flags - software output processing
221 // (c_oflag bits)
222 OPOST = 0x00000001, // enable following output processing
223 ONLCR = 0x00000002, // map NL to CR-NL (ala CRMOD)
224 TABDLY = 0x00000004, // tab delay mask
225 TAB0 = 0x00000000, // no tab delay and expansion
226 TAB3 = 0x00000004, // expand tabs to spaces
227 ONOEOT = 0x00000008, // discard EOT's (^D) on output
228 OCRNL = 0x00000010, // map CR to NL on output
229 ONOCR = 0x00000020, // no CR output at column 0
230 ONLRET = 0x00000040, // NL performs CR function
231
232 // Control flags - hardware control of terminal
233 // (c_cflag bits)
234 CIGNORE = 0x00000001, // ignore control flags
235 CSIZE = 0x00000300, // character size mask
236 CS5 = 0x00000000, // 5 bits (pseudo)
237 CS6 = 0x00000100, // 6 bits
238 CS7 = 0x00000200, // 7 bits
239 CS8 = 0x00000300, // 8 bits
240 CSTOPB = 0x00000400, // send 2 stop bits
241 CREAD = 0x00000800, // enable receiver
242 PARENB = 0x00001000, // parity enable
243 PARODD = 0x00002000, // odd parity, else even
244 HUPCL = 0x00004000, // hang up on last close
245 CLOCAL = 0x00008000, // ignore modem status lines
246 CCTS_OFLOW = 0x00010000, // CTS flow control of output
247 CRTS_IFLOW = 0x00020000, // RTS flow control of input
248 CRTSCTS = (CCTS_OFLOW | CRTS_IFLOW),
249 CDTR_IFLOW = 0x00040000, // DTR flow control of input
250 CDSR_OFLOW = 0x00080000, // DSR flow control of output
251 CCAR_OFLOW = 0x00100000, // DCD flow control of output
252
253 // "Local" flags - dumping ground for other state
254 // (c_lflag bits)
255 ECHOKE = 0x00000001, // visual erase for line kill
256 ECHOE = 0x00000002, // visual erase chars
257 ECHOK = 0x00000004, // echo NL after line kill
258 ECHO = 0x00000008, // enable echoing
259 ECHONL = 0x00000010, // echo NL even if ECHO is off
260 ECHOPRT = 0x00000020, // visual erase mode for hardcopy
261 ECHOCTL = 0x00000040, // echo control chars as ^(Char)
262 ISIG = 0x00000080, // enable signals INTR, QUIT, [D]SUSP
263 ICANON = 0x00000100, // canonicalize input lines
264 ALTWERASE = 0x00000200, // use alternate WERASE algorithm
265 IEXTEN = 0x00000400, // enable DISCARD and LNEXT
266 EXTPROC = 0x00000800, // external processing
267 TOSTOP = 0x00400000, // stop background jobs from output
268 FLUSHO = 0x00800000, // output being flushed (state)
269 NOKERNINFO = 0x02000000, // no kernel output from VSTATUS
270 PENDIN = 0x20000000, // XXX: retype pending input (state)
271 NOFLSH = 0x80000000, // don't flush after interrupt
272 };
273
274 export type cc = enum u8 {
275 VEOF = 0,
276 VEOL = 1,
277 VEOL2 = 2,
278 VERASE = 3,
279 VWERASE = 4,
280 VKILL = 5,
281 VREPRINT = 6,
282 VERASE2 = 7,
283 VINTR = 8,
284 VQUIT = 9,
285 VSUSP = 10,
286 VDSUSP = 11,
287 VSTART = 12,
288 VSTOP = 13,
289 VLNEXT = 14,
290 VDISCARD = 15,
291 VMIN = 16,
292 VTIME = 17,
293 VSTATUS = 18,
294 VCHECKPT = 19,
295 };
296
297
298 export def TIOCGWINSZ: u64 = 0x40087468; // get window size
299 export def TIOCSWINSZ: u64 = 0x80087467; // set window size
300 export def TIOCGETA: u64 = 0x402c7413; // get termios struct
301 export def TIOCSETA: u64 = 0x802c7414; // set termios struct
302 export def TIOCISPTMASTER: u64 = 0x20007455; // is pty master
303 export def TIOCSPGRP: u64 = 0x80047476; // set pgrp on tty
304 export def TIOCGPGRP: u64 = 0x40047477; // get pgrp on tty
305 export def FIODNAME: u64 = 0x80106678; // get name of device on that fildesc
306
307 // argument for ioctl FIODNAME
308 export type fiodname_args = struct {
309 name: *opaque,
310 length: uint,
311 };
312
313 export type rusage = struct {
314 ru_utime: timeval, // user time used
315 ru_stime: timeval, // system time used
316 ru_maxrss: i64, // max resident set size
317 ru_ixrss: i64, // integral shared memory size
318 ru_idrss: i64, // integral unshared data size
319 ru_isrss: i64, // integral unshared stack size
320 ru_minflt: i64, // page reclaims
321 ru_majflt: i64, // page faults
322 ru_nswap: i64, // swaps
323 ru_inblock: i64, // block input operations
324 ru_oublock: i64, // block output operations
325 ru_msgsnd: i64, // messages sent
326 ru_msgrcv: i64, // messages received
327 ru_nsignals: i64, // signals received
328 ru_nvcsw: i64, // voluntary context switches
329 ru_nivcsw: i64, // involuntary context switches
330 };
331
332 export def DT_UNKNOWN: u8 = 0;
333 export def DT_FIFO: u8 = 1;
334 export def DT_CHR: u8 = 2;
335 export def DT_DIR: u8 = 4;
336 export def DT_BLK: u8 = 6;
337 export def DT_REG: u8 = 8;
338 export def DT_LNK: u8 = 10;
339 export def DT_SOCK: u8 = 12;
340 export def DT_WHT: u8 = 14;
341 export def DT_DBF: u8 = 15; // database record file
342
343 export def O_RDONLY: int = 0x0000; // open for reading only
344 export def O_WRONLY: int = 0x0001; // open for writing only
345 export def O_RDWR: int = 0x0002; // open for reading and writing
346 export def O_ACCMODE: int = 0x0003; // mask for above modes
347 export def O_NONBLOCK: int = 0x0004; // no delay
348 export def O_APPEND: int = 0x0008; // set append mode
349 export def O_SHLOCK: int = 0x0010; // open with shared file lock
350 export def O_EXLOCK: int = 0x0020; // open with exclusive file lock
351 export def O_ASYNC: int = 0x0040; // signal pgrp when data ready
352 export def O_FSYNC: int = 0x0080; // synchronous writes
353 export def O_SYNC: int = 0x0080; // same as O_FSYNC, but POSIX
354 export def O_NOFOLLOW: int = 0x0100; // don't follow symlinks
355 export def O_CREAT: int = 0x0200; // create if nonexistent
356 export def O_TRUNC: int = 0x0400; // truncate to zero length
357 export def O_EXCL: int = 0x0800; // error if already exists
358 export def O_NOCTTY: int = 0x8000; // don't assign controlling terminal
359
360 export def O_DIRECT: int = 0x00010000; // attempt to bypass the buffer cache
361 export def O_CLOEXEC: int = 0x00020000; // atomically set FD_CLOEXEC
362
363 export def O_FBLOCKING: int = 0x00040000; // force blocking I/O
364 export def O_FNONBLOCKING: int = 0x00080000; // force non-blocking I/O
365 export def O_FAPPEND: int = 0x00100000; // force append mode for write
366 export def O_FOFFSET: int = 0x00200000; // force append mode for write
367 export def O_FSYNCWRITE: int = 0x00400000; // force synchronous write
368 export def O_FASYNCWRITE: int = 0x00800000; // force asynchronous write
369 export def O_CLOFORK: int = 0x01000000; // atomically set FD_CLOFORK
370 export def O_DIRECTORY: int = 0x08000000; // error if not a directory
371
372 export def AT_FDCWD: int = -328243; // 0xFFFA_FDCD;
373 export def AT_SYMLINK_NOFOLLOW: int = 1;
374 export def AT_REMOVEDIR: int = 2;
375 export def AT_EACCESS: int = 4;
376 export def AT_SYMLINK_FOLLOW: int = 8;
377
378 export def S_IFMT: mode_t = 0o170000; // type of file mask
379 export def S_IFIFO: mode_t = 0o010000; // named pipe (fifo)
380 export def S_IFCHR: mode_t = 0o020000; // character special
381 export def S_IFDIR: mode_t = 0o040000; // directory
382 export def S_IFBLK: mode_t = 0o060000; // block special
383 export def S_IFREG: mode_t = 0o100000; // regular
384 export def S_IFLNK: mode_t = 0o120000; // symbolic link
385 export def S_IFSOCK: mode_t = 0o140000; // socket
386 export def S_ISVTX: mode_t = 0o0001000; // save swapped text even after use
387
388 export def MAP_SHARED: uint = 0x0001; // share changes
389 export def MAP_PRIVATE: uint = 0x0002; // changes are private
390 export def MAP_FIXED: uint = 0x0010; // map addr must be exactly as requested
391
392 export def MAP_INHERIT: uint = 0x0080; // region is retained after exec
393 export def MAP_HASSEMAPHORE: uint = 0x0200; // region may contain semaphores
394 export def MAP_STACK: uint = 0x0400; // region grows down, like a stack
395 export def MAP_NOSYNC: uint = 0x0800; // page to but do not sync underlying file
396
397 export def MAP_FILE: uint = 0x0000; // map from file (default)
398 export def MAP_ANON: uint = 0x1000; // allocated from memory, swap space
399 export def MAP_VPAGETABLE: uint = 0x2000;// manage with virtualized page table
400
401
402 export def MAP_TRYFIXED: uint = 0x00010000; // attempt hint address, even within heap
403 export def MAP_NOCORE: uint = 0x00020000; // dont include these pages in a coredump
404 export def MAP_SIZEALIGN: uint = 0x00040000; // size is also an alignment requirement
405 export def MAP_32BIT: uint = 0x00080000; // allocate from 32-bit addr space only
406
407 export def PROT_NONE: uint = 0x00; // no permissions
408 export def PROT_READ: uint = 0x01; // pages can be read
409 export def PROT_WRITE: uint = 0x02; // pages can be written
410 export def PROT_EXEC: uint = 0x04; // pages can be executed
411
412 //
413 // sys/signal.h
414 //
415
416 export def SIGHUP: int = 1; // hangup
417 export def SIGINT: int = 2; // interrupt
418 export def SIGQUIT: int = 3; // quit
419 export def SIGILL: int = 4; // illegal instr. (not reset when caught)
420 export def SIGTRAP: int = 5; // trace trap (not reset when caught)
421 export def SIGABRT: int = 6; // abort()
422 export def SIGIOT: int = SIGABRT; // compatibility
423 export def SIGEMT: int = 7; // EMT instruction
424 export def SIGFPE: int = 8; // floating point exception
425 export def SIGKILL: int = 9; // kill (cannot be caught or ignored)
426 export def SIGBUS: int = 10; // bus error
427 export def SIGSEGV: int = 11; // segmentation violation
428 export def SIGSYS: int = 12; // non-existent system call invoked
429 export def SIGPIPE: int = 13; // write on a pipe with no one to read it
430 export def SIGALRM: int = 14; // alarm clock
431 export def SIGTERM: int = 15; // software termination signal from kill
432 export def SIGURG: int = 16; // urgent condition on IO channel
433 export def SIGSTOP: int = 17; // sendable stop signal not from tty
434 export def SIGTSTP: int = 18; // stop signal from tty
435 export def SIGCONT: int = 19; // continue a stopped process
436 export def SIGCHLD: int = 20; // to parent on child stop or exit
437 export def SIGTTIN: int = 21; // to readers pgrp upon background tty read
438 export def SIGTTOU: int = 22; // like TTIN if (tp->t_local&LTOSTOP)
439 export def SIGIO: int = 23; // input/output possible signal
440 export def SIGXCPU: int = 24; // exceeded CPU time limit
441 export def SIGXFSZ: int = 25; // exceeded file size limit
442 export def SIGVTALRM: int = 26; // virtual time alarm
443 export def SIGPROF: int = 27; // profiling time alarm
444 export def SIGWINCH: int = 28; // window size changes
445 export def SIGINFO: int = 29; // information request
446 export def SIGUSR1: int = 30; // user defined signal 1
447 export def SIGUSR2: int = 31; // user defined signal 2
448 export def SIGTHR: int = 32; // Thread interrupt (FreeBSD-5 reserved)
449 export def SIGCKPT: int = 33; // checkpoint and continue
450 export def SIGCKPTEXIT: int = 34; // checkpoint and exit
451
452 export def SIG_ERR: uintptr = -1;
453 export def SIG_DFL: uintptr = 0;
454 export def SIG_IGN: uintptr = 1;
455 export def SIG_CATCH: uintptr = 2;
456 export def SIG_HOLD: uintptr = 3;
457
458 export def SA_ONSTACK: int = 0x0001; // take signal on signal stack
459 export def SA_RESTART: int = 0x0002; // restart system call on signal return
460 export def SA_RESETHAND: int = 0x0004; // reset to SIG_DFL when taking signal
461 export def SA_NOCLDSTOP: int = 0x0008; // do not generate SIGCHLD on child stop
462 export def SA_NODEFER: int = 0x0010; // don't mask the signal we're delivering
463 export def SA_NOCLDWAIT: int = 0x0020; // don't keep zombies around
464 export def SA_SIGINFO: int = 0x0040; // signal handler with SA_SIGINFO args
465
466 //
467 // Flags for sigprocmask:
468 //
469 export def SIG_BLOCK: int = 1; // block specified signal set
470 export def SIG_UNBLOCK: int = 2; // unblock specified signal set
471 export def SIG_SETMASK: int = 3; // set specified signal set
472
473 export def SIGEV_NONE: int = 0; // No async notification
474 export def SIGEV_SIGNAL: int = 1; // Generate a queued signal
475 export def SIGEV_THREAD: int = 2; // Call back in a pthread
476 export def SIGEV_KEVENT: int = 3; // Generate a kevent
477 export def MINSIGSTKSZ: int = 8192; // minimum allowable stack
478 export def SIGSTKSZ: int = MINSIGSTKSZ + 32768; // recommended stack size
479
480 export def F_DUPFD: int = 0; // duplicate file descriptor
481 export def F_GETFD: int = 1; // get file descriptor flags
482 export def F_SETFD: int = 2; // set file descriptor flags
483 export def F_GETFL: int = 3; // get file status flags
484 export def F_SETFL: int = 4; // set file status flags
485 export def F_GETOWN: int = 5; // get SIGIO/SIGURG proc/pgrp
486 export def F_SETOWN: int = 6; // set SIGIO/SIGURG proc/pgrp
487 export def F_GETLK: int = 7; // get record locking information
488 export def F_SETLK: int = 8; // set record locking information
489 export def F_SETLKW: int = 9; // F_SETLK; wait if blocked
490 export def F_DUP2FD: int = 10; // duplicate file descriptor to arg
491 export def F_DUPFD_CLOEXEC: int = 17; // Like F_DUPFD with FD_CLOEXEC set
492 export def F_DUP2FD_CLOEXEC: int = 18; // Like F_DUP2FD with FD_CLOEXEC set
493 export def F_GETPATH: int = 19; // retrieve full path to file associated with fd
494 export def F_MAXFD: int = 20; // return the max open fd
495 export def F_DUPFD_CLOFORK: int = 21; // Like F_DUPFD with FD_CLOFORK set
496 export def F_DUP2FD_CLOFORK: int = 22; // Like F_DUP2FD with FD_CLOFORK set
497 export def F_DUP3FD: int = 23; // Used for dup3()
498 export def F_DUP3FD_SHIFT: int = 16; // Shift used for F_DUP3FD
499 export def F_RDLCK: int = 1; // shared or read lock
500 export def F_UNLCK: int = 2; // unlock
501 export def F_WRLCK: int = 3; // exclusive or write lock
502 export def F_WAIT: int = 0x010; // Wait until lock is granted
503 export def F_UNUSED020: int = 0x020; //
504 export def F_POSIX: int = 0x040; // Use POSIX semantics for lock
505 export def F_NOEND: int = 0x080; // l_len = 0, internally used
506
507 export def FD_CLOEXEC: int = 1; // close-on-exec flag
508
509 export def PRIO_MIN: int = -20;
510 export def PRIO_MAX: int = 20;
511 export def PRIO_PROCESS: int = 0;
512 export def PRIO_PGRP: int = 1;
513 export def PRIO_USER: int = 2;
514
515 export def F_OK: int = 0;
516 export def X_OK: int = 0x01;
517 export def W_OK: int = 0x02;
518 export def R_OK: int = 0x04;
519
520 export def CLOCK_REALTIME: int = 0;
521 export def CLOCK_VIRTUAL: int = 1;
522 export def CLOCK_PROF: int = 2;
523 export def CLOCK_MONOTONIC: int = 4;
524 export def CLOCK_UPTIME: int = 5;
525 export def CLOCK_UPTIME_PRECISE: int = 7;
526 export def CLOCK_UPTIME_FAST: int = 8;
527 export def CLOCK_REALTIME_PRECISE: int = 9;
528 export def CLOCK_REALTIME_FAST: int = 10;
529 export def CLOCK_MONOTONIC_PRECISE: int = 11;
530 export def CLOCK_MONOTONIC_FAST: int = 12;
531 export def CLOCK_SECOND: int = 13;
532 export def CLOCK_THREAD_CPUTIME_ID: int = 14;
533 export def CLOCK_PROCESS_CPUTIME_ID: int = 15;
534
535 export def TIMER_ABSTIME: int = 1;
536
537 export def WNOHANG: int = 1; // don't hang in wait
538 export def WUNTRACED: int = 2; // tell about stopped, untraced children
539 export def WCONTINUED: int = 4; // Report a job control continued process.
540 export def WSTOPPED: int = WUNTRACED;
541 export def WNOWAIT: int = 8;
542 export def WEXITED: int = 16;
543 export def WTRAPPED: int = 32;
544
545 //
546 // Tokens for special values of the "pid" parameter to wait4.
547 //
548
549 export def WAIT_ANY: int = -1; // any process
550 export def WAIT_MYPGRP: int = 0; // any process in my process group
551
552 export def STDIN_FILENO: int = 0;
553 export def STDOUT_FILENO: int = 1;
554 export def STDERR_FILENO: int = 2;
555
556 export def SEEK_SET: int = 0; // set file offset to offset
557 export def SEEK_CUR: int = 1; // set file offset to current plus offset
558 export def SEEK_END: int = 2; // set file offset to EOF plus offset
559
560 // Flock operations
561 export def LOCK_SH: int = 1; // shared file lock
562 export def LOCK_EX: int = 2; // exclusive file lock
563 export def LOCK_NB: int = 4; // don't block when locking
564 export def LOCK_UN: int = 8; // unlock file
565
566 export type rlimit = struct {
567 rlim_cur: rlim_t,
568 rlim_max: rlim_t,
569 };
570
571 export def RLIM_INFINITY: rlim_t = -1; // no limit
572 export def RLIMIT_CPU: int = 0; // cpu time in milliseconds
573 export def RLIMIT_FSIZE: int = 1; // maximum file size
574 export def RLIMIT_DATA: int = 2; // data size
575 export def RLIMIT_STACK: int = 3; // stack size
576 export def RLIMIT_CORE: int = 4; // core file size
577 export def RLIMIT_RSS: int = 5; // resident set size
578 export def RLIMIT_MEMLOCK: int = 6; // locked-in-memory address space
579 export def RLIMIT_NPROC: int = 7; // number of processes
580 export def RLIMIT_NOFILE: int = 8; // number of open files
581 export def RLIMIT_SBSIZE: int = 9; // maximum size of all socket buffers
582 export def RLIMIT_AS: int = 10; // standard name for address space size
583 export def RLIMIT_VMEM: int = RLIMIT_AS;// virtual process size (inclusive of mmap)
584 export def RLIMIT_POSIXLOCKS: int = 11; // maximum number of POSIX locks per user
585
586 // howto arguments for shutdown(2), specified by Posix.1g.
587 export def SHUT_RD: int = 0; // shut down the reading side
588 export def SHUT_WR: int = 1; // shut down the writing side
589 export def SHUT_RDWR: int = 2; // shut down both sides
590
591 // Scheduling policies
592 // These policy constants are notably different from linux.
593 export def SCHED_FIFO: int = 1;
594 export def SCHED_OTHER: int = 2;
595 export def SCHED_RR: int = 3;
596 export type sched_param = struct {
597 sched_priority: int
598 };
599
600 export def EVFILT_READ: int = (-1);
601 export def EVFILT_WRITE: int = (-2);
602 export def EVFILT_AIO: int = (-3); // attached to aio requests
603 export def EVFILT_VNODE: int = (-4); // attached to vnodes
604 export def EVFILT_PROC: int = (-5); // attached to struct proc
605 export def EVFILT_SIGNAL: int = (-6); // attached to struct proc
606 export def EVFILT_TIMER: int = (-7); // timers
607 export def EVFILT_EXCEPT: int = (-8); // exceptional conditions
608 export def EVFILT_USER: int = (-9); // user events
609 export def EVFILT_FS: int = (-10); // filesystem events
610
611 export def EVFILT_SYSCOUNT: int = 10;
612
613 export def EV_ADD: u16 = 0x0001; // add event to kq (implies enable)
614 export def EV_DELETE: u16 = 0x0002; // delete event from kq
615 export def EV_ENABLE: u16 = 0x0004; // enable event
616 export def EV_DISABLE: u16 = 0x0008; // disable event (not reported)
617 export def EV_ONESHOT: u16 = 0x0010; // only report one occurrence
618 export def EV_CLEAR: u16 = 0x0020; // clear event state after reporting
619 export def EV_RECEIPT: u16 = 0x0040; // force EV_ERROR on success, data=0
620 export def EV_DISPATCH: u16 = 0x0080; // disable event after reporting
621 export def EV_SYSFLAGS: u16 = 0xF800; // reserved by system
622 export def EV_FLAG1: u16 = 0x2000; // filter-specific flag
623 export def EV_HUP: u16 = 0x0800; // complete peer disconnect
624 export def EV_EOF: u16 = 0x8000; // EOF detected
625 export def EV_ERROR: u16 = 0x4000; // error, data contains errno
626 export def EV_NODATA: u16 = 0x1000; // EOF and no more data
627
628 export def NOTE_FFNOP: u32 = 0x00000000; // ignore input fflags
629 export def NOTE_FFAND: u32 = 0x40000000; // AND fflags
630 export def NOTE_FFOR: u32 = 0x80000000; // OR fflags
631 export def NOTE_FFCOPY: u32 = 0xc0000000; // copy fflags
632 export def NOTE_FFCTRLMASK: u32 = 0xc0000000; // masks for operations
633 export def NOTE_FFLAGSMASK: u32 = 0x00ffffff; //
634 export def NOTE_TRIGGER: u32 = 0x01000000; // trigger for output
635 export def NOTE_LOWAT: u32 = 0x0001; // low water mark
636 export def NOTE_OOB: u32 = 0x0002; // OOB data on a socket
637 export def NOTE_DELETE: u32 = 0x0001; // vnode was removed
638 export def NOTE_WRITE: u32 = 0x0002; // data contents changed
639 export def NOTE_EXTEND: u32 = 0x0004; // size increased
640 export def NOTE_ATTRIB: u32 = 0x0008; // attributes changed
641 export def NOTE_LINK: u32 = 0x0010; // link count changed
642 export def NOTE_RENAME: u32 = 0x0020; // vnode was renamed
643 export def NOTE_REVOKE: u32 = 0x0040; // vnode access was revoked
644 export def NOTE_EXIT: u32 = 0x80000000; // process exited
645 export def NOTE_FORK: u32 = 0x40000000; // process forked
646 export def NOTE_EXEC: u32 = 0x20000000; // process exec'd
647 export def NOTE_PCTRLMASK: u32 = 0xf0000000; // mask for hint bits
648 export def NOTE_PDATAMASK: u32 = 0x000fffff; // mask for pid
649 export def NOTE_TRACK: u32 = 0x00000001; // follow across forks
650 export def NOTE_TRACKERR: u32 = 0x00000002; // could not track child
651 export def NOTE_CHILD: u32 = 0x00000004; // am a child process
652 export def NOTE_SIGNAL: u32 = 0x08000000; //
653 export def NOTE_OLDAPI: u32 = 0x04000000; // select/poll note
654 export def NOTE_HUPONLY: u32 = 0x02000000; // select/poll note