hare

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

types.ha (10136B)


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