hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

types.ha (11845B)


      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: u64 = 0x0001;
     29 export def SA_RESTART: u64 = 0x0002;
     30 export def SA_RESETHAND: u64 = 0x0004;
     31 export def SA_NOCLDSTOP: u64 = 0x0008;
     32 export def SA_NODEFER: u64 = 0x0010;
     33 export def SA_NOCLDWAIT: u64 = 0x0020;
     34 export def SA_SIGINFO: u64 = 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: *fn (int) void,
     45 		sa_sigaction: *fn (int, *siginfo, *opaque) void,
     46 	},
     47 	sa_flags: int,
     48 	sa_mask: sigset,
     49 };
     50 
     51 export def SIG_BLOCK: int = 1;
     52 export def SIG_UNBLOCK: int = 2;
     53 export def SIG_SETMASK: int = 3;
     54 
     55 export type sigval = union {
     56 	sival_t: int,
     57 	sival_ptr: *opaque,
     58 };
     59 
     60 export type stack_t = struct {
     61 	ss_sp: *opaque,
     62 	ss_size: size,
     63 	ss_flags: int,
     64 };
     65 
     66 export type pollfd = struct {
     67 	fd: int,
     68 	events: i16,
     69 	revents: i16,
     70 };
     71 
     72 export type timespec = struct {
     73 	tv_sec: time_t,
     74 	tv_nsec: i64,
     75 };
     76 
     77 export def UTIME_OMIT = -0x2;
     78 
     79 export type timeval = struct {
     80 	tv_sec: time_t,
     81 	tv_usec: suseconds_t,
     82 };
     83 
     84 export type st_flock = struct {
     85 	l_start: off_t,
     86 	l_len: off_t,
     87 	l_pid: pid_t,
     88 	l_type: i16,
     89 	l_whence: i16,
     90 	l_sysid: int,
     91 };
     92 
     93 export type st = struct {
     94 	dev: dev_t,
     95 	ino: ino_t,
     96 	nlink: nlink_t,
     97 	mode: mode_t,
     98 	uid: uid_t,
     99 	gid: gid_t,
    100 	rdev: dev_t,
    101 	atime: timespec,
    102 	mtime: timespec,
    103 	ctime: timespec,
    104 	btime: timespec,
    105 	sz: off_t,
    106 	blocks: blkcnt_t,
    107 	blksz: blksize_t,
    108 	flags: fflags_t,
    109 };
    110 
    111 export type freebsd11_stat = struct {
    112 	st_dev: u32,
    113 	st_ino: u32,
    114 	st_mode: mode_t,
    115 	st_nlink: u16,
    116 	st_uid: uid_t,
    117 	st_gid: gid_t,
    118 	st_rdev: u32,
    119 	st_atim: timespec,
    120 	st_mtim: timespec,
    121 	st_ctim: timespec,
    122 	st_size: off_t,
    123 	st_blocks: blkcnt_t,
    124 	st_blksize: blksize_t,
    125 	st_flags: fflags_t,
    126 	st_gen: u32,
    127 	st_lspare: u32,
    128 	st_birthtim: timespec,
    129 };
    130 
    131 export type freebsd11_dirent = struct {
    132 	d_fileno: u32,
    133 	d_reclen: u16,
    134 	d_type: u8,
    135 	d_namlen: u8,
    136 	d_name: [*]u8,
    137 };
    138 
    139 export type iovec = struct {
    140 	iov_base: *opaque,
    141 	iov_len: size
    142 };
    143 
    144 export type winsize = struct {
    145 	ws_row: u16,
    146 	ws_col: u16,
    147 	ws_xpixel: u16,
    148 	ws_ypixel: u16,
    149 };
    150 
    151 export type termios = struct {
    152 	c_iflag: tcflag,
    153 	c_oflag: tcflag,
    154 	c_cflag: tcflag,
    155 	c_lflag: tcflag,
    156 	c_cc: [NCCS]cc,
    157 };
    158 
    159 export def NCCS: size = 20;
    160 
    161 export type tcflag = enum uint {
    162 	// c_iflag bits
    163 	IGNBRK  = 0x00000001,
    164 	BRKINT  = 0x00000002,
    165 	IGNPAR  = 0x00000004,
    166 	PARMRK  = 0x00000008,
    167 	INPCK   = 0x00000010,
    168 	ISTRIP  = 0x00000020,
    169 	INLCR   = 0x00000040,
    170 	IGNCR   = 0x00000080,
    171 	ICRNL   = 0x00000100,
    172 	IXON    = 0x00000200,
    173 	IXOFF   = 0x00000400,
    174 	IXANY   = 0x00000800,
    175 	IMAXBEL = 0x00002000,
    176 
    177 	// c_oflag bits
    178 	OPOST  = 0x00000001,
    179 	ONLCR  = 0x00000002,
    180 	TABDLY = 0x00000004,
    181 	TAB0   = 0x00000000,
    182 	TAB3   = 0x00000004,
    183 	ONOEOT = 0x00000008,
    184 	OCRNL  = 0x00000010,
    185 	ONOCR  = 0x00000020,
    186 	ONLRET = 0x00000040,
    187 
    188 	// c_cflag bits
    189 	CIGNORE    = 0x00000001,
    190 	CSIZE      = 0x00000300,
    191 	CS5        = 0x00000000,
    192 	CS6        = 0x00000100,
    193 	CS7        = 0x00000200,
    194 	CS8        = 0x00000300,
    195 	CSTOPB     = 0x00000400,
    196 	CREAD      = 0x00000800,
    197 	PARENB     = 0x00001000,
    198 	PARODD     = 0x00002000,
    199 	HUPCL      = 0x00004000,
    200 	CLOCAL     = 0x00008000,
    201 	CCTS_OFLOW = 0x00010000,
    202 	CRTS_IFLOW = 0x00020000,
    203 	CRTSCTS    = (CCTS_OFLOW | CRTS_IFLOW),
    204 	CDTR_IFLOW = 0x00040000,
    205 	CDSR_OFLOW = 0x00080000,
    206 	CCAR_OFLOW = 0x00100000,
    207 	CNO_RTSDTR = 0x00200000,
    208 
    209 	// c_lflag bits
    210 	ECHOKE     = 0x00000001,
    211 	ECHOE      = 0x00000002,
    212 	ECHOK      = 0x00000004,
    213 	ECHO       = 0x00000008,
    214 	ECHONL     = 0x00000010,
    215 	ECHOPRT    = 0x00000020,
    216 	ECHOCTL    = 0x00000040,
    217 	ISIG       = 0x00000080,
    218 	ICANON     = 0x00000100,
    219 	ALTWERASE  = 0x00000200,
    220 	IEXTEN     = 0x00000400,
    221 	EXTPROC    = 0x00000800,
    222 	TOSTOP     = 0x00400000,
    223 	FLUSHO     = 0x00800000,
    224 	NOKERNINFO = 0x02000000,
    225 	PENDIN     = 0x20000000,
    226 	NOFLSH     = 0x80000000,
    227 };
    228 
    229 export type cc = enum u8 {
    230 	VEOF      = 0,
    231 	VEOL      = 1,
    232 	VEOL2     = 2,
    233 	VERASE    = 3,
    234 	VWERASE   = 4,
    235 	VKILL     = 5,
    236 	VREPRINT  = 6,
    237 	VERASE2   = 7,
    238 	VINTR     = 8,
    239 	VQUIT     = 9,
    240 	VSUSP     = 10,
    241 	VDSUSP    = 11,
    242 	VSTART    = 12,
    243 	VSTOP     = 13,
    244 	VLNEXT    = 14,
    245 	VDISCARD  = 15,
    246 	VMIN      = 16,
    247 	VTIME     = 17,
    248 	VSTATUS   = 18,
    249 };
    250 
    251 export def TIOCGWINSZ: u64 = 0x40087468;
    252 export def TIOCSWINSZ: u64 = 0x80087467;
    253 export def TIOCGETA: u64 = 0x402c7413;
    254 export def TIOCSETA: u64 = 0x802c7414;
    255 export def TIOCPTMASTER: u64 = 0x2000741c;
    256 export def TIOCSPGRP: u64 = 0x80047476;
    257 export def FIODGNAME: u64 = 0x80106678;
    258 
    259 export type rusage = struct {
    260 	ru_utime: timeval,
    261 	ru_stime: timeval,
    262 	ru_maxrss: i64,
    263 	ru_ixrss: i64,
    264 	ru_idrss: i64,
    265 	ru_isrss: i64,
    266 	ru_minflt: i64,
    267 	ru_majflt: i64,
    268 	ru_nswap: i64,
    269 	ru_inblock: i64,
    270 	ru_oublock: i64,
    271 	ru_msgsnd: i64,
    272 	ru_msgrcv: i64,
    273 	ru_nsignals: i64,
    274 	ru_nvcsw: i64,
    275 	ru_nivcsw: i64,
    276 };
    277 
    278 export def DT_UNKNOWN: u8 = 0;
    279 export def DT_FIFO: u8 = 1;
    280 export def DT_CHR: u8 = 2;
    281 export def DT_DIR: u8 = 4;
    282 export def DT_BLK: u8 = 6;
    283 export def DT_REG: u8 = 8;
    284 export def DT_LNK: u8 = 10;
    285 export def DT_SOCK: u8 = 12;
    286 export def DT_WHT: u8 = 14;
    287 
    288 export def O_RDONLY: int = 0x0000;
    289 export def O_WRONLY: int = 0x0001;
    290 export def O_RDWR: int = 0x0002;
    291 export def O_ACCMODE: int = 0x0003;
    292 export def O_NONBLOCK: int = 0x0004;
    293 export def O_APPEND: int = 0x0008;
    294 export def O_SHLOCK: int = 0x0010;
    295 export def O_EXLOCK: int = 0x0020;
    296 export def O_ASYNC: int = 0x0040;
    297 export def O_FSYNC: int = 0x0080;
    298 export def O_SYNC: int = 0x0080;
    299 export def O_NOFOLLOW: int = 0x0100;
    300 export def O_CREAT: int = 0x0200;
    301 export def O_TRUNC: int = 0x0400;
    302 export def O_EXCL: int = 0x0800;
    303 export def O_NOCTTY: int = 0x8000;
    304 export def O_DIRECT: int = 0x00010000;
    305 export def O_DIRECTORY: int = 0x00020000;
    306 export def O_EXEC: int = 0x00040000;
    307 export def O_TTY_INIT: int = 0x00080000;
    308 export def O_CLOEXEC: int = 0x00100000;
    309 export def O_DSYNC: int = 0x01000000;
    310 
    311 export def AT_FDCWD: int = -100;
    312 export def AT_EACCESS: int = 0x0100;
    313 export def AT_SYMLINK_NOFOLLOW: int = 0x0200;
    314 export def AT_SYMLINK_FOLLOW: int = 0x0400;
    315 export def AT_REMOVEDIR: int = 0x0800;
    316 export def AT_RESOLVE_BENEATH: int = 0x2000;
    317 export def AT_EMPTY_PATH: int = 0x4000;
    318 
    319 export def S_IFIFO: mode_t = 0o010000;
    320 export def S_IFCHR: mode_t = 0o020000;
    321 export def S_IFDIR: mode_t = 0o040000;
    322 export def S_IFBLK: mode_t = 0o060000;
    323 export def S_IFREG: mode_t = 0o100000;
    324 export def S_IFLNK: mode_t = 0o120000;
    325 export def S_IFSOCK: mode_t = 0o140000;
    326 
    327 export def MAP_SHARED: uint = 0x0001;
    328 export def MAP_PRIVATE: uint = 0x0002;
    329 export def MAP_FIXED: uint = 0x0010;
    330 export def MAP_HASSEMAPHORE: uint = 0x0200;
    331 export def MAP_STACK: uint = 0x0400;
    332 export def MAP_NOSYNC: uint = 0x0800;
    333 export def MAP_FILE: uint = 0x0000;
    334 export def MAP_ANON: uint = 0x1000;
    335 export def MAP_GUARD: uint = 0x00002000;
    336 export def MAP_EXCL: uint = 0x00004000;
    337 export def MAP_NOCORE: uint = 0x00020000;
    338 export def MAP_PREFAULT_READ: uint = 0x00040000;
    339 export def MAP_32BIT: uint = 0x00080000;
    340 
    341 export def PROT_NONE: uint = 0x00;
    342 export def PROT_READ: uint = 0x01;
    343 export def PROT_WRITE: uint = 0x02;
    344 export def PROT_EXEC: uint = 0x04;
    345 
    346 export def SIGHUP: int = 1;
    347 export def SIGINT: int = 2;
    348 export def SIGQUIT: int = 3;
    349 export def SIGILL: int = 4;
    350 export def SIGTRAP: int = 5;
    351 export def SIGABRT: int = 6;
    352 export def SIGIOT: int = SIGABRT;
    353 export def SIGEMT: int = 7;
    354 export def SIGFPE: int = 8;
    355 export def SIGKILL: int = 9;
    356 export def SIGBUS: int = 10;
    357 export def SIGSEGV: int = 11;
    358 export def SIGSYS: int = 12;
    359 export def SIGPIPE: int = 13;
    360 export def SIGALRM: int = 14;
    361 export def SIGTERM: int = 15;
    362 export def SIGURG: int = 16;
    363 export def SIGSTOP: int = 17;
    364 export def SIGTSTP: int = 18;
    365 export def SIGCONT: int = 19;
    366 export def SIGCHLD: int = 20;
    367 export def SIGTTIN: int = 21;
    368 export def SIGTTOU: int = 22;
    369 export def SIGIO: int = 23;
    370 export def SIGXCPU: int = 24;
    371 export def SIGXFSZ: int = 25;
    372 export def SIGVTALRM: int = 26;
    373 export def SIGPROF: int = 27;
    374 export def SIGWINCH: int = 28;
    375 export def SIGINFO: int = 29;
    376 export def SIGUSR1: int = 30;
    377 export def SIGUSR2: int = 31;
    378 export def SIGTHR: int = 32;
    379 export def SIGLWP: int = SIGTHR;
    380 export def SIGLIBRT: int = 33;
    381 
    382 export def F_DUPFD: int = 0;
    383 export def F_GETFD: int = 1;
    384 export def F_SETFD: int = 2;
    385 export def F_GETFL: int = 3;
    386 export def F_SETFL: int = 4;
    387 export def F_GETOWN: int = 5;
    388 export def F_SETOWN: int = 6;
    389 export def F_OGETLK: int = 7;
    390 export def F_OSETLK: int = 8;
    391 export def F_OSETLKW: int = 9;
    392 export def F_DUP2FD: int = 10;
    393 export def F_GETLK: int = 11;
    394 export def F_SETLK: int = 12;
    395 export def F_SETLKW: int = 13;
    396 export def F_SETLK_REMOTE: int = 14;
    397 export def F_READAHEAD: int = 15;
    398 export def F_RDAHEAD: int = 16;
    399 export def F_DUPFD_CLOEXEC: int = 17;
    400 export def F_DUP2FD_CLOEXEC: int = 18;
    401 export def F_ADD_SEALS: int = 19;
    402 export def F_GET_SEALS: int = 20;
    403 export def F_ISUNIONSTACK: int = 21;
    404 
    405 export def F_SEAL_SEAL: int = 0x0001;
    406 export def F_SEAL_SHRINK: int = 0x0002;
    407 export def F_SEAL_GROW: int = 0x0004;
    408 export def F_SEAL_WRITE: int = 0x0008;
    409 
    410 export def FD_CLOEXEC: int = 1;
    411 export def F_UNLCKSYS: int = 4;
    412 export def F_CANCEL: int = 5;
    413 
    414 export def F_RDLCK: i16 = 1;
    415 export def F_UNLCK: i16 = 2;
    416 export def F_WRLCK: i16 = 3;
    417 
    418 export def PRIO_PROCESS: int = 0;
    419 export def PRIO_PGRP: int = 1;
    420 export def PRIO_USER: int = 2;
    421 
    422 export def F_OK: int = 0;
    423 export def X_OK: int = 0x01;
    424 export def W_OK: int = 0x02;
    425 export def R_OK: int = 0x04;
    426 
    427 export def CLOCK_REALTIME: int = 0;
    428 export def CLOCK_MONOTONIC: int = 4;
    429 export def CLOCK_VIRTUAL: int = 1;
    430 export def CLOCK_PROF: int = 2;
    431 export def CLOCK_UPTIME: int = 5;
    432 export def CLOCK_UPTIME_PRECISE: int = 7;
    433 export def CLOCK_UPTIME_FAST: int = 8;
    434 export def CLOCK_REALTIME_PRECISE: int = 9;
    435 export def CLOCK_REALTIME_FAST: int = 10;
    436 export def CLOCK_MONOTONIC_PRECISE: int = 11;
    437 export def CLOCK_MONOTONIC_FAST: int = 12;
    438 export def CLOCK_SECOND: int = 13;
    439 export def CLOCK_THREAD_CPUTIME_ID: int = 14;
    440 export def CLOCK_PROCESS_CPUTIME_ID: int = 15;
    441 
    442 export def WNOHANG: int = 1;
    443 export def WUNTRACED: int = 2;
    444 export def WSTOPPED: int = WUNTRACED;
    445 export def WCONTINUED: int = 4;
    446 export def WNOWAIT: int = 8;
    447 export def WEXITED: int = 16;
    448 export def WTRAPPED: int = 32;
    449 
    450 export def STDIN_FILENO: int = 0;
    451 export def STDOUT_FILENO: int = 1;
    452 export def STDERR_FILENO: int = 2;
    453 
    454 export def SEEK_SET: int = 0;
    455 export def SEEK_CUR: int = 1;
    456 export def SEEK_END: int = 2;
    457 
    458 // Flock operations
    459 export def LOCK_SH: int = 1;
    460 export def LOCK_EX: int = 2;
    461 export def LOCK_NB: int = 4;
    462 export def LOCK_UN: int = 8;
    463 
    464 export type rlimit = struct {
    465 	rlim_cur: rlim_t,
    466 	rlim_max: rlim_t,
    467 };
    468 
    469 export def RLIM_INFINITY: rlim_t = -1;
    470 
    471 export def RLIMIT_CPU: int		= 0;
    472 export def RLIMIT_FSIZE: int		= 1;
    473 export def RLIMIT_DATA: int		= 2;
    474 export def RLIMIT_STACK: int		= 3;
    475 export def RLIMIT_CORE: int		= 4;
    476 export def RLIMIT_RSS: int		= 5;
    477 export def RLIMIT_MEMLOCK: int		= 6;
    478 export def RLIMIT_NPROC: int		= 7;
    479 export def RLIMIT_NOFILE: int		= 8;
    480 export def RLIMIT_SBSIZE: int		= 9;
    481 export def RLIMIT_VMEM: int		= 10;
    482 export def RLIMIT_AS: int		= RLIMIT_VMEM;
    483 export def RLIMIT_NPTS: int		= 11;
    484 export def RLIMIT_SWAP: int		= 12;
    485 export def RLIMIT_KQUEUES: int		= 13;
    486 export def RLIMIT_UMTXP: int		= 14;
    487 
    488 export def SHUT_RD: int = 0;
    489 export def SHUT_WR: int = 1;
    490 export def SHUT_RDWR: int = 2;