Debian Codegraph @

rt/+freebsd/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 = u64;
7 export type ino_t = u64;
8 export type nlink_t = u64;
9 export type id_t = uint;
10 export type pid_t = uint;
11 export type uid_t = uint;
12 export type gid_t = uint;
13 export type off_t = i64;
14 export type blkcnt_t = i64;
15 export type blksize_t = i32;
16 export type fflags_t = u32;
17 export type mode_t = u16;
18 export type nfds_t = uint;
19 export type rlim_t = u64;
20
21 export def NGROUPS_MAX: size = 1023;
22 export def NSIG: int = 32;
23
24 export type sigset = struct {
25 __bits: [4]u32,
26 };
27
28 export def SA_ONSTACK: int = 0x0001;
29 export def SA_RESTART: int = 0x0002;
30 export def SA_RESETHAND: int = 0x0004;
31 export def SA_NOCLDSTOP: int = 0x0008;
32 export def SA_NODEFER: int = 0x0010;
33 export def SA_NOCLDWAIT: int = 0x0020;
34 export def SA_SIGINFO: int = 0x0040;
35
36 export def SIG_ERR: uintptr = -1;
37 export def SIG_DFL: uintptr = 0;
38 export def SIG_IGN: uintptr = 1;
39 export def SIG_CATCH: uintptr = 2;
40 export def SIG_HOLD: uintptr = 3;
41
42 export type sigact = struct {
43 union {
44 sa_handler: nullable *fn (_: int) void,
45 sa_sigaction: nullable *fn (_: int,
46 _: *siginfo, _: *opaque) void,
47 },
48 sa_flags: int,
49 sa_mask: sigset,
50 };
51
52 export type kevent_t = struct {
53 ident: uintptr,
54 filter: i16,
55 flags: i16,
56 fflags: uint,
57 data: i64,
58 udata: *opaque,
59 ext: [4]u64,
60 };
61
62 export def SIG_BLOCK: int = 1;
63 export def SIG_UNBLOCK: int = 2;
64 export def SIG_SETMASK: int = 3;
65
66 export type sigval = union {
67 sival_int: int,
68 sival_ptr: *opaque,
69 };
70
71 export type stack_t = struct {
72 ss_sp: *opaque,
73 ss_size: size,
74 ss_flags: int,
75 };
76
77 export type pollfd = struct {
78 fd: int,
79 events: i16,
80 revents: i16,
81 };
82
83 export type timespec = struct {
84 tv_sec: time_t,
85 tv_nsec: i64,
86 };
87
88 export def UTIME_OMIT = -0x2;
89
90 export type timeval = struct {
91 tv_sec: time_t,
92 tv_usec: suseconds_t,
93 };
94
95 export type st_flock = struct {
96 l_start: off_t,
97 l_len: off_t,
98 l_pid: pid_t,
99 l_type: i16,
100 l_whence: i16,
101 l_sysid: int,
102 };
103
104 export type st = struct {
105 dev: dev_t,
106 ino: ino_t,
107 nlink: nlink_t,
108 mode: mode_t,
109 uid: uid_t,
110 gid: gid_t,
111 rdev: dev_t,
112 atime: timespec,
113 mtime: timespec,
114 ctime: timespec,
115 btime: timespec,
116 sz: off_t,
117 blocks: blkcnt_t,
118 blksz: blksize_t,
119 flags: fflags_t,
120 };
121
122 export type freebsd11_stat = struct {
123 st_dev: u32,
124 st_ino: u32,
125 st_mode: mode_t,
126 st_nlink: u16,
127 st_uid: uid_t,
128 st_gid: gid_t,
129 st_rdev: u32,
130 st_atim: timespec,
131 st_mtim: timespec,
132 st_ctim: timespec,
133 st_size: off_t,
134 st_blocks: blkcnt_t,
135 st_blksize: blksize_t,
136 st_flags: fflags_t,
137 st_gen: u32,
138 st_lspare: u32,
139 st_birthtim: timespec,
140 };
141
142 export type freebsd11_dirent = struct {
143 d_fileno: u32,
144 d_reclen: u16,
145 d_type: u8,
146 d_namlen: u8,
147 d_name: [*]u8,
148 };
149
150 export type iovec = struct {
151 iov_base: nullable *opaque,
152 iov_len: size
153 };
154
155 export type winsize = struct {
156 ws_row: u16,
157 ws_col: u16,
158 ws_xpixel: u16,
159 ws_ypixel: u16,
160 };
161
162 export type termios = struct {
163 c_iflag: tcflag,
164 c_oflag: tcflag,
165 c_cflag: tcflag,
166 c_lflag: tcflag,
167 c_cc: [NCCS]cc,
168 };
169
170 export def NCCS: size = 20;
171
172 export type tcflag = enum uint {
173 // c_iflag bits
174 IGNBRK = 0x00000001,
175 BRKINT = 0x00000002,
176 IGNPAR = 0x00000004,
177 PARMRK = 0x00000008,
178 INPCK = 0x00000010,
179 ISTRIP = 0x00000020,
180 INLCR = 0x00000040,
181 IGNCR = 0x00000080,
182 ICRNL = 0x00000100,
183 IXON = 0x00000200,
184 IXOFF = 0x00000400,
185 IXANY = 0x00000800,
186 IMAXBEL = 0x00002000,
187
188 // c_oflag bits
189 OPOST = 0x00000001,
190 ONLCR = 0x00000002,
191 TABDLY = 0x00000004,
192 TAB0 = 0x00000000,
193 TAB3 = 0x00000004,
194 ONOEOT = 0x00000008,
195 OCRNL = 0x00000010,
196 ONOCR = 0x00000020,
197 ONLRET = 0x00000040,
198
199 // c_cflag bits
200 CIGNORE = 0x00000001,
201 CSIZE = 0x00000300,
202 CS5 = 0x00000000,
203 CS6 = 0x00000100,
204 CS7 = 0x00000200,
205 CS8 = 0x00000300,
206 CSTOPB = 0x00000400,
207 CREAD = 0x00000800,
208 PARENB = 0x00001000,
209 PARODD = 0x00002000,
210 HUPCL = 0x00004000,
211 CLOCAL = 0x00008000,
212 CCTS_OFLOW = 0x00010000,
213 CRTS_IFLOW = 0x00020000,
214 CRTSCTS = (CCTS_OFLOW | CRTS_IFLOW),
215 CDTR_IFLOW = 0x00040000,
216 CDSR_OFLOW = 0x00080000,
217 CCAR_OFLOW = 0x00100000,
218 CNO_RTSDTR = 0x00200000,
219
220 // c_lflag bits
221 ECHOKE = 0x00000001,
222 ECHOE = 0x00000002,
223 ECHOK = 0x00000004,
224 ECHO = 0x00000008,
225 ECHONL = 0x00000010,
226 ECHOPRT = 0x00000020,
227 ECHOCTL = 0x00000040,
228 ISIG = 0x00000080,
229 ICANON = 0x00000100,
230 ALTWERASE = 0x00000200,
231 IEXTEN = 0x00000400,
232 EXTPROC = 0x00000800,
233 TOSTOP = 0x00400000,
234 FLUSHO = 0x00800000,
235 NOKERNINFO = 0x02000000,
236 PENDIN = 0x20000000,
237 NOFLSH = 0x80000000,
238 };
239
240 export type cc = enum u8 {
241 VEOF = 0,
242 VEOL = 1,
243 VEOL2 = 2,
244 VERASE = 3,
245 VWERASE = 4,
246 VKILL = 5,
247 VREPRINT = 6,
248 VERASE2 = 7,
249 VINTR = 8,
250 VQUIT = 9,
251 VSUSP = 10,
252 VDSUSP = 11,
253 VSTART = 12,
254 VSTOP = 13,
255 VLNEXT = 14,
256 VDISCARD = 15,
257 VMIN = 16,
258 VTIME = 17,
259 VSTATUS = 18,
260 };
261
262 export def TIOCGWINSZ: u64 = 0x40087468;
263 export def TIOCSWINSZ: u64 = 0x80087467;
264 export def TIOCGETA: u64 = 0x402c7413;
265 export def TIOCSETA: u64 = 0x802c7414;
266 export def TIOCPTMASTER: u64 = 0x2000741c;
267 export def TIOCSPGRP: u64 = 0x80047476;
268 export def TIOCGPGRP: u64 = 0x40047477;
269 export def FIODGNAME: u64 = 0x80106678;
270
271 export type rusage = struct {
272 ru_utime: timeval,
273 ru_stime: timeval,
274 ru_maxrss: i64,
275 ru_ixrss: i64,
276 ru_idrss: i64,
277 ru_isrss: i64,
278 ru_minflt: i64,
279 ru_majflt: i64,
280 ru_nswap: i64,
281 ru_inblock: i64,
282 ru_oublock: i64,
283 ru_msgsnd: i64,
284 ru_msgrcv: i64,
285 ru_nsignals: i64,
286 ru_nvcsw: i64,
287 ru_nivcsw: i64,
288 };
289
290 export def DT_UNKNOWN: u8 = 0;
291 export def DT_FIFO: u8 = 1;
292 export def DT_CHR: u8 = 2;
293 export def DT_DIR: u8 = 4;
294 export def DT_BLK: u8 = 6;
295 export def DT_REG: u8 = 8;
296 export def DT_LNK: u8 = 10;
297 export def DT_SOCK: u8 = 12;
298 export def DT_WHT: u8 = 14;
299
300 export def O_RDONLY: int = 0x0000;
301 export def O_WRONLY: int = 0x0001;
302 export def O_RDWR: int = 0x0002;
303 export def O_ACCMODE: int = 0x0003;
304 export def O_NONBLOCK: int = 0x0004;
305 export def O_APPEND: int = 0x0008;
306 export def O_SHLOCK: int = 0x0010;
307 export def O_EXLOCK: int = 0x0020;
308 export def O_ASYNC: int = 0x0040;
309 export def O_FSYNC: int = 0x0080;
310 export def O_SYNC: int = 0x0080;
311 export def O_NOFOLLOW: int = 0x0100;
312 export def O_CREAT: int = 0x0200;
313 export def O_TRUNC: int = 0x0400;
314 export def O_EXCL: int = 0x0800;
315 export def O_NOCTTY: int = 0x8000;
316 export def O_DIRECT: int = 0x00010000;
317 export def O_DIRECTORY: int = 0x00020000;
318 export def O_EXEC: int = 0x00040000;
319 export def O_TTY_INIT: int = 0x00080000;
320 export def O_CLOEXEC: int = 0x00100000;
321 export def O_DSYNC: int = 0x01000000;
322
323 export def AT_FDCWD: int = -100;
324 export def AT_EACCESS: int = 0x0100;
325 export def AT_SYMLINK_NOFOLLOW: int = 0x0200;
326 export def AT_SYMLINK_FOLLOW: int = 0x0400;
327 export def AT_REMOVEDIR: int = 0x0800;
328 export def AT_RESOLVE_BENEATH: int = 0x2000;
329 export def AT_EMPTY_PATH: int = 0x4000;
330
331 export def S_IFIFO: mode_t = 0o010000;
332 export def S_IFCHR: mode_t = 0o020000;
333 export def S_IFDIR: mode_t = 0o040000;
334 export def S_IFBLK: mode_t = 0o060000;
335 export def S_IFREG: mode_t = 0o100000;
336 export def S_IFLNK: mode_t = 0o120000;
337 export def S_IFSOCK: mode_t = 0o140000;
338
339 export def MAP_SHARED: uint = 0x0001;
340 export def MAP_PRIVATE: uint = 0x0002;
341 export def MAP_FIXED: uint = 0x0010;
342 export def MAP_HASSEMAPHORE: uint = 0x0200;
343 export def MAP_STACK: uint = 0x0400;
344 export def MAP_NOSYNC: uint = 0x0800;
345 export def MAP_FILE: uint = 0x0000;
346 export def MAP_ANON: uint = 0x1000;
347 export def MAP_GUARD: uint = 0x00002000;
348 export def MAP_EXCL: uint = 0x00004000;
349 export def MAP_NOCORE: uint = 0x00020000;
350 export def MAP_PREFAULT_READ: uint = 0x00040000;
351 export def MAP_32BIT: uint = 0x00080000;
352
353 export def PROT_NONE: uint = 0x00;
354 export def PROT_READ: uint = 0x01;
355 export def PROT_WRITE: uint = 0x02;
356 export def PROT_EXEC: uint = 0x04;
357
358 export def SIGHUP: int = 1;
359 export def SIGINT: int = 2;
360 export def SIGQUIT: int = 3;
361 export def SIGILL: int = 4;
362 export def SIGTRAP: int = 5;
363 export def SIGABRT: int = 6;
364 export def SIGIOT: int = SIGABRT;
365 export def SIGEMT: int = 7;
366 export def SIGFPE: int = 8;
367 export def SIGKILL: int = 9;
368 export def SIGBUS: int = 10;
369 export def SIGSEGV: int = 11;
370 export def SIGSYS: int = 12;
371 export def SIGPIPE: int = 13;
372 export def SIGALRM: int = 14;
373 export def SIGTERM: int = 15;
374 export def SIGURG: int = 16;
375 export def SIGSTOP: int = 17;
376 export def SIGTSTP: int = 18;
377 export def SIGCONT: int = 19;
378 export def SIGCHLD: int = 20;
379 export def SIGTTIN: int = 21;
380 export def SIGTTOU: int = 22;
381 export def SIGIO: int = 23;
382 export def SIGXCPU: int = 24;
383 export def SIGXFSZ: int = 25;
384 export def SIGVTALRM: int = 26;
385 export def SIGPROF: int = 27;
386 export def SIGWINCH: int = 28;
387 export def SIGINFO: int = 29;
388 export def SIGUSR1: int = 30;
389 export def SIGUSR2: int = 31;
390 export def SIGTHR: int = 32;
391 export def SIGLWP: int = SIGTHR;
392 export def SIGLIBRT: int = 33;
393
394 export def F_DUPFD: int = 0;
395 export def F_GETFD: int = 1;
396 export def F_SETFD: int = 2;
397 export def F_GETFL: int = 3;
398 export def F_SETFL: int = 4;
399 export def F_GETOWN: int = 5;
400 export def F_SETOWN: int = 6;
401 export def F_OGETLK: int = 7;
402 export def F_OSETLK: int = 8;
403 export def F_OSETLKW: int = 9;
404 export def F_DUP2FD: int = 10;
405 export def F_GETLK: int = 11;
406 export def F_SETLK: int = 12;
407 export def F_SETLKW: int = 13;
408 export def F_SETLK_REMOTE: int = 14;
409 export def F_READAHEAD: int = 15;
410 export def F_RDAHEAD: int = 16;
411 export def F_DUPFD_CLOEXEC: int = 17;
412 export def F_DUP2FD_CLOEXEC: int = 18;
413 export def F_ADD_SEALS: int = 19;
414 export def F_GET_SEALS: int = 20;
415 export def F_ISUNIONSTACK: int = 21;
416
417 export def F_SEAL_SEAL: int = 0x0001;
418 export def F_SEAL_SHRINK: int = 0x0002;
419 export def F_SEAL_GROW: int = 0x0004;
420 export def F_SEAL_WRITE: int = 0x0008;
421
422 export def FD_CLOEXEC: int = 1;
423 export def F_UNLCKSYS: int = 4;
424 export def F_CANCEL: int = 5;
425
426 export def F_RDLCK: i16 = 1;
427 export def F_UNLCK: i16 = 2;
428 export def F_WRLCK: i16 = 3;
429
430 export def PRIO_PROCESS: int = 0;
431 export def PRIO_PGRP: int = 1;
432 export def PRIO_USER: int = 2;
433
434 export def F_OK: int = 0;
435 export def X_OK: int = 0x01;
436 export def W_OK: int = 0x02;
437 export def R_OK: int = 0x04;
438
439 export def CLOCK_REALTIME: int = 0;
440 export def CLOCK_MONOTONIC: int = 4;
441 export def CLOCK_VIRTUAL: int = 1;
442 export def CLOCK_PROF: int = 2;
443 export def CLOCK_UPTIME: int = 5;
444 export def CLOCK_UPTIME_PRECISE: int = 7;
445 export def CLOCK_UPTIME_FAST: int = 8;
446 export def CLOCK_REALTIME_PRECISE: int = 9;
447 export def CLOCK_REALTIME_FAST: int = 10;
448 export def CLOCK_MONOTONIC_PRECISE: int = 11;
449 export def CLOCK_MONOTONIC_FAST: int = 12;
450 export def CLOCK_SECOND: int = 13;
451 export def CLOCK_THREAD_CPUTIME_ID: int = 14;
452 export def CLOCK_PROCESS_CPUTIME_ID: int = 15;
453
454 export def TIMER_ABSTIME: int = 1;
455
456 export def WNOHANG: int = 1;
457 export def WUNTRACED: int = 2;
458 export def WSTOPPED: int = WUNTRACED;
459 export def WCONTINUED: int = 4;
460 export def WNOWAIT: int = 8;
461 export def WEXITED: int = 16;
462 export def WTRAPPED: int = 32;
463
464 export def STDIN_FILENO: int = 0;
465 export def STDOUT_FILENO: int = 1;
466 export def STDERR_FILENO: int = 2;
467
468 export def SEEK_SET: int = 0;
469 export def SEEK_CUR: int = 1;
470 export def SEEK_END: int = 2;
471
472 // Flock operations
473 export def LOCK_SH: int = 1;
474 export def LOCK_EX: int = 2;
475 export def LOCK_NB: int = 4;
476 export def LOCK_UN: int = 8;
477
478 export type rlimit = struct {
479 rlim_cur: rlim_t,
480 rlim_max: rlim_t,
481 };
482
483 export def RLIM_INFINITY: rlim_t = -1;
484
485 export def RLIMIT_CPU: int = 0;
486 export def RLIMIT_FSIZE: int = 1;
487 export def RLIMIT_DATA: int = 2;
488 export def RLIMIT_STACK: int = 3;
489 export def RLIMIT_CORE: int = 4;
490 export def RLIMIT_RSS: int = 5;
491 export def RLIMIT_MEMLOCK: int = 6;
492 export def RLIMIT_NPROC: int = 7;
493 export def RLIMIT_NOFILE: int = 8;
494 export def RLIMIT_SBSIZE: int = 9;
495 export def RLIMIT_VMEM: int = 10;
496 export def RLIMIT_AS: int = RLIMIT_VMEM;
497 export def RLIMIT_NPTS: int = 11;
498 export def RLIMIT_SWAP: int = 12;
499 export def RLIMIT_KQUEUES: int = 13;
500 export def RLIMIT_UMTXP: int = 14;
501 export def RLIMIT_PIPEBUF: int = 15;
502
503 export def SHUT_RD: int = 0;
504 export def SHUT_WR: int = 1;
505 export def SHUT_RDWR: int = 2;
506
507 export let SHM_ANON: *const u8 = 1: uintptr: *const u8;
508
509 export def SHM_ALLOW_SEALING: int = 0x00000001;
510 export def SHM_GROW_ON_WRITE: int = 0x00000002;
511 export def SHM_LARGEPAGE: int = 0x00000004;
512
513 export def SHM_LARGEPAGE_ALLOC_DEFAULT: int = 0;
514 export def SHM_LARGEPAGE_ALLOC_NOWAIT: int = 1;
515 export def SHM_LARGEPAGE_ALLOC_HARD: int = 2;
516
517 // Scheduling
518 // These policy constants are notably different from linux.
519 export def SCHED_FIFO: int = 1;
520 export def SCHED_OTHER: int = 2;
521 export def SCHED_RR: int = 3;
522 export type sched_param = struct {
523 sched_priority: int
524 };
525
526 export def EVFILT_READ: int = (-1);
527 export def EVFILT_WRITE: int = (-2);
528 export def EVFILT_AIO: int = (-3);
529 export def EVFILT_VNODE: int = (-4);
530 export def EVFILT_PROC: int = (-5);
531 export def EVFILT_SIGNAL: int = (-6);
532 export def EVFILT_TIMER: int = (-7);
533 export def EVFILT_PROCDESC: int = (-8);
534 export def EVFILT_FS: int = (-9);
535 export def EVFILT_LIO: int = (-10);
536 export def EVFILT_USER: int = (-11);
537 export def EVFILT_SENDFILE: int = (-12);
538 export def EVFILT_EMPTY: int = (-13);
539 export def EVFILT_SYSCOUNT: int = 13;
540
541 export def EV_ADD: u16 = 0x0001;
542 export def EV_DELETE: u16 = 0x0002;
543 export def EV_ENABLE: u16 = 0x0004;
544 export def EV_DISABLE: u16 = 0x0008;
545 export def EV_FORCEONESHOT: u16 = 0x0100;
546 export def EV_KEEPUDATA: u16 = 0x0200;
547
548 export def EV_ONESHOT: u16 = 0x0010;
549 export def EV_CLEAR: u16 = 0x0020;
550 export def EV_RECEIPT: u16 = 0x0040;
551 export def EV_DISPATCH: u16 = 0x0080;
552
553 export def EV_SYSFLAGS: u16 = 0xF000;
554 export def EV_DROP: u16 = 0x1000;
555 export def EV_FLAG1: u16 = 0x2000;
556 export def EV_FLAG2: u16 = 0x4000;
557
558 export def EV_EOF: u16 = 0x8000;
559 export def EV_ERROR: u16 = 0x4000;
560
561 export def NOTE_FFNOP: u32 = 0x00000000;
562 export def NOTE_FFAND: u32 = 0x40000000;
563 export def NOTE_FFOR: u32 = 0x80000000;
564 export def NOTE_FFCOPY: u32 = 0xc0000000;
565 export def NOTE_FFCTRLMASK: u32 = 0xc0000000;
566 export def NOTE_FFLAGSMASK: u32 = 0x00ffffff;
567
568 export def NOTE_TRIGGER: u32 = 0x01000000;
569
570 export def NOTE_LOWAT: u16 = 0x0001;
571 export def NOTE_FILE_POLL: u16 = 0x0002;
572
573 export def NOTE_DELETE: u16 = 0x0001;
574 export def NOTE_WRITE: u16 = 0x0002;
575 export def NOTE_EXTEND: u16 = 0x0004;
576 export def NOTE_ATTRIB: u16 = 0x0008;
577 export def NOTE_LINK: u16 = 0x0010;
578 export def NOTE_RENAME: u16 = 0x0020;
579 export def NOTE_REVOKE: u16 = 0x0040;
580 export def NOTE_OPEN: u16 = 0x0080;
581 export def NOTE_CLOSE: u16 = 0x0100;
582 export def NOTE_CLOSE_WRITE: u16 = 0x0200;
583 export def NOTE_READ: u16 = 0x0400;
584
585 export def NOTE_EXIT: u32 = 0x80000000;
586 export def NOTE_FORK: u32 = 0x40000000;
587 export def NOTE_EXEC: u32 = 0x20000000;
588 export def NOTE_PCTRLMASK: u32 = 0xf0000000;
589 export def NOTE_PDATAMASK: u32 = 0x000fffff;
590
591 export def NOTE_TRACK: u32 = 0x00000001;
592 export def NOTE_TRACKERR: u32 = 0x00000002;
593 export def NOTE_CHILD: u32 = 0x00000004;
594
595 export def NOTE_SECONDS: u32 = 0x00000001;
596 export def NOTE_MSECONDS: u32 = 0x00000002;
597 export def NOTE_USECONDS: u32 = 0x00000004;
598 export def NOTE_NSECONDS: u32 = 0x00000008;
599 export def NOTE_ABSTIME: u32 = 0x00000010;
600
601 export def KQUEUE_CLOEXEC: u32 = 0x00000001;