hare

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

errno.ha (12415B)


      1 // SPDX-License-Identifier: MPL-2.0
      2 // (c) Hare authors <https://harelang.org>
      3 
      4 //	$OpenBSD: errno.h,v 1.25 2017/09/05 03:06:26 jsg Exp $
      5 
      6 // Represents an error returned from the OpenBSD kernel.
      7 export type errno = !int;
      8 
      9 // Obtains a human-friendly reading of an [[errno]] (e.g. "Operation not
     10 // permitted").
     11 export fn strerror(err: errno) str = {
     12 	switch (err) {
     13 	case EPERM =>
     14 		return "Operation not permitted";
     15 	case ENOENT =>
     16 		return "No such file or directory";
     17 	case ESRCH =>
     18 		return "No such process";
     19 	case EINTR =>
     20 		return "Interrupted system call";
     21 	case EIO =>
     22 		return "Input/output error";
     23 	case ENXIO =>
     24 		return "Device not configured";
     25 	case E2BIG =>
     26 		return "Argument list too long";
     27 	case ENOEXEC =>
     28 		return "Exec format error";
     29 	case EBADF =>
     30 		return "Bad file descriptor";
     31 	case ECHILD =>
     32 		return "No child processes";
     33 	case EDEADLK =>
     34 		return "Resource deadlock avoided";
     35 	case ENOMEM =>
     36 		return "Cannot allocate memory";
     37 	case EACCES =>
     38 		return "Permission denied";
     39 	case EFAULT =>
     40 		return "Bad address";
     41 	case ENOTBLK =>
     42 		return "Block device required";
     43 	case EBUSY =>
     44 		return "Device busy";
     45 	case EEXIST =>
     46 		return "File exists";
     47 	case EXDEV =>
     48 		return "Cross-device link";
     49 	case ENODEV =>
     50 		return "Operation not supported by device";
     51 	case ENOTDIR =>
     52 		return "Not a directory";
     53 	case EISDIR =>
     54 		return "Is a directory";
     55 	case EINVAL =>
     56 		return "Invalid argument";
     57 	case ENFILE =>
     58 		return "Too many open files in system";
     59 	case EMFILE =>
     60 		return "Too many open files";
     61 	case ENOTTY =>
     62 		return "Inappropriate ioctl for device";
     63 	case ETXTBSY =>
     64 		return "Text file busy";
     65 	case EFBIG =>
     66 		return "File too large";
     67 	case ENOSPC =>
     68 		return "No space left on device";
     69 	case ESPIPE =>
     70 		return "Illegal seek";
     71 	case EROFS =>
     72 		return "Read-only file system";
     73 	case EMLINK =>
     74 		return "Too many links";
     75 	case EPIPE =>
     76 		return "Broken pipe";
     77 	case EDOM =>
     78 		return "Numerical argument out of domain";
     79 	case ERANGE =>
     80 		return "Result too large";
     81 	case EAGAIN =>
     82 		return "Resource temporarily unavailable";
     83 	case EINPROGRESS =>
     84 		return "Operation now in progress";
     85 	case EALREADY =>
     86 		return "Operation already in progress";
     87 	case ENOTSOCK =>
     88 		return "Socket operation on non-socket";
     89 	case EDESTADDRREQ =>
     90 		return "Destination address required";
     91 	case EMSGSIZE =>
     92 		return "Message too long";
     93 	case EPROTOTYPE =>
     94 		return "Protocol wrong type for socket";
     95 	case ENOPROTOOPT =>
     96 		return "Protocol not available";
     97 	case EPROTONOSUPPORT =>
     98 		return "Protocol not supported";
     99 	case ESOCKTNOSUPPORT =>
    100 		return "Socket type not supported";
    101 	case EOPNOTSUPP =>
    102 		return "Operation not supported";
    103 	case EPFNOSUPPORT =>
    104 		return "Protocol family not supported";
    105 	case EAFNOSUPPORT =>
    106 		return "Address family not supported by protocol family";
    107 	case EADDRINUSE =>
    108 		return "Address already in use";
    109 	case EADDRNOTAVAIL =>
    110 		return "Can't assign requested address";
    111 	case ENETDOWN =>
    112 		return "Network is down";
    113 	case ENETUNREACH =>
    114 		return "Network is unreachable";
    115 	case ENETRESET =>
    116 		return "Network dropped connection on reset";
    117 	case ECONNABORTED =>
    118 		return "Software caused connection abort";
    119 	case ECONNRESET =>
    120 		return "Connection reset by peer";
    121 	case ENOBUFS =>
    122 		return "No buffer space available";
    123 	case EISCONN =>
    124 		return "Socket is already connected";
    125 	case ENOTCONN =>
    126 		return "Socket is not connected";
    127 	case ESHUTDOWN =>
    128 		return "Can't send after socket shutdown";
    129 	case ETOOMANYREFS =>
    130 		return "Too many references: can't splice";
    131 	case ETIMEDOUT =>
    132 		return "Operation timed out";
    133 	case ECONNREFUSED =>
    134 		return "Connection refused";
    135 	case ELOOP =>
    136 		return "Too many levels of symbolic links";
    137 	case ENAMETOOLONG =>
    138 		return "File name too long";
    139 	case EHOSTDOWN =>
    140 		return "Host is down";
    141 	case EHOSTUNREACH =>
    142 		return "No route to host";
    143 	case ENOTEMPTY =>
    144 		return "Directory not empty";
    145 	case EPROCLIM =>
    146 		return "Too many processes";
    147 	case EUSERS =>
    148 		return "Too many users";
    149 	case EDQUOT =>
    150 		return "Disk quota exceeded";
    151 	case ESTALE =>
    152 		return "Stale NFS file handle";
    153 	case EREMOTE =>
    154 		return "Too many levels of remote in path";
    155 	case EBADRPC =>
    156 		return "RPC struct is bad";
    157 	case ERPCMISMATCH =>
    158 		return "RPC version wrong";
    159 	case EPROGUNAVAIL =>
    160 		return "RPC program not available";
    161 	case EPROGMISMATCH =>
    162 		return "Program version wrong";
    163 	case EPROCUNAVAIL =>
    164 		return "Bad procedure for program";
    165 	case ENOLCK =>
    166 		return "No locks available";
    167 	case ENOSYS =>
    168 		return "Function not implemented";
    169 	case EFTYPE =>
    170 		return "Inappropriate file type or format";
    171 	case EAUTH =>
    172 		return "Authentication error";
    173 	case ENEEDAUTH =>
    174 		return "Need authenticator";
    175 	case EIPSEC =>
    176 		return "IPsec processing failure";
    177 	case ENOATTR =>
    178 		return "Attribute not found";
    179 	case EILSEQ =>
    180 		return "Illegal byte sequence";
    181 	case ENOMEDIUM =>
    182 		return "No medium found";
    183 	case EMEDIUMTYPE =>
    184 		return "Wrong medium type";
    185 	case EOVERFLOW =>
    186 		return "Value too large to be stored in data type";
    187 	case ECANCELED =>
    188 		return "Operation canceled";
    189 	case EIDRM =>
    190 		return "Identifier removed";
    191 	case ENOMSG =>
    192 		return "No message of desired type";
    193 	case ENOTSUP =>
    194 		return "Not supported";
    195 	case EBADMSG =>
    196 		return "Bad message";
    197 	case ENOTRECOVERABLE =>
    198 		return "State not recoverable";
    199 	case EOWNERDEAD =>
    200 		return "Previous owner died";
    201 	case EPROTO =>
    202 		return "Protocol error";
    203 	case =>
    204 		return unknown_errno(err);
    205 	};
    206 };
    207 
    208 // Gets the programmer-friendly name for an [[errno]] (e.g. EPERM).
    209 export fn errname(err: errno) str = {
    210 	switch (err) {
    211 	case EPERM =>
    212 		return "EPERM";
    213 	case ENOENT =>
    214 		return "ENOENT";
    215 	case ESRCH =>
    216 		return "ESRCH";
    217 	case EINTR =>
    218 		return "EINTR";
    219 	case EIO =>
    220 		return "EIO";
    221 	case ENXIO =>
    222 		return "ENXIO";
    223 	case E2BIG =>
    224 		return "E2BIG";
    225 	case ENOEXEC =>
    226 		return "ENOEXEC";
    227 	case EBADF =>
    228 		return "EBADF";
    229 	case ECHILD =>
    230 		return "ECHILD";
    231 	case EDEADLK =>
    232 		return "EDEADLK";
    233 	case ENOMEM =>
    234 		return "ENOMEM";
    235 	case EACCES =>
    236 		return "EACCES";
    237 	case EFAULT =>
    238 		return "EFAULT";
    239 	case ENOTBLK =>
    240 		return "ENOTBLK";
    241 	case EBUSY =>
    242 		return "EBUSY";
    243 	case EEXIST =>
    244 		return "EEXIST";
    245 	case EXDEV =>
    246 		return "EXDEV";
    247 	case ENODEV =>
    248 		return "ENODEV";
    249 	case ENOTDIR =>
    250 		return "ENOTDIR";
    251 	case EISDIR =>
    252 		return "EISDIR";
    253 	case EINVAL =>
    254 		return "EINVAL";
    255 	case ENFILE =>
    256 		return "ENFILE";
    257 	case EMFILE =>
    258 		return "EMFILE";
    259 	case ENOTTY =>
    260 		return "ENOTTY";
    261 	case ETXTBSY =>
    262 		return "ETXTBSY";
    263 	case EFBIG =>
    264 		return "EFBIG";
    265 	case ENOSPC =>
    266 		return "ENOSPC";
    267 	case ESPIPE =>
    268 		return "ESPIPE";
    269 	case EROFS =>
    270 		return "EROFS";
    271 	case EMLINK =>
    272 		return "EMLINK";
    273 	case EPIPE =>
    274 		return "EPIPE";
    275 	case EDOM =>
    276 		return "EDOM";
    277 	case ERANGE =>
    278 		return "ERANGE";
    279 	case EAGAIN =>
    280 		return "EAGAIN";
    281 	case EINPROGRESS =>
    282 		return "EINPROGRESS";
    283 	case EALREADY =>
    284 		return "EALREADY";
    285 	case ENOTSOCK =>
    286 		return "ENOTSOCK";
    287 	case EDESTADDRREQ =>
    288 		return "EDESTADDRREQ";
    289 	case EMSGSIZE =>
    290 		return "EMSGSIZE";
    291 	case EPROTOTYPE =>
    292 		return "EPROTOTYPE";
    293 	case ENOPROTOOPT =>
    294 		return "ENOPROTOOPT";
    295 	case EPROTONOSUPPORT =>
    296 		return "EPROTONOSUPPORT";
    297 	case ESOCKTNOSUPPORT =>
    298 		return "ESOCKTNOSUPPORT";
    299 	case EOPNOTSUPP =>
    300 		return "EOPNOTSUPP";
    301 	case EPFNOSUPPORT =>
    302 		return "EPFNOSUPPORT";
    303 	case EAFNOSUPPORT =>
    304 		return "EAFNOSUPPORT";
    305 	case EADDRINUSE =>
    306 		return "EADDRINUSE";
    307 	case EADDRNOTAVAIL =>
    308 		return "EADDRNOTAVAIL";
    309 	case ENETDOWN =>
    310 		return "ENETDOWN";
    311 	case ENETUNREACH =>
    312 		return "ENETUNREACH";
    313 	case ENETRESET =>
    314 		return "ENETRESET";
    315 	case ECONNABORTED =>
    316 		return "ECONNABORTED";
    317 	case ECONNRESET =>
    318 		return "ECONNRESET";
    319 	case ENOBUFS =>
    320 		return "ENOBUFS";
    321 	case EISCONN =>
    322 		return "EISCONN";
    323 	case ENOTCONN =>
    324 		return "ENOTCONN";
    325 	case ESHUTDOWN =>
    326 		return "ESHUTDOWN";
    327 	case ETOOMANYREFS =>
    328 		return "ETOOMANYREFS";
    329 	case ETIMEDOUT =>
    330 		return "ETIMEDOUT";
    331 	case ECONNREFUSED =>
    332 		return "ECONNREFUSED";
    333 	case ELOOP =>
    334 		return "ELOOP";
    335 	case ENAMETOOLONG =>
    336 		return "ENAMETOOLONG";
    337 	case EHOSTDOWN =>
    338 		return "EHOSTDOWN";
    339 	case EHOSTUNREACH =>
    340 		return "EHOSTUNREACH";
    341 	case ENOTEMPTY =>
    342 		return "ENOTEMPTY";
    343 	case EPROCLIM =>
    344 		return "EPROCLIM";
    345 	case EUSERS =>
    346 		return "EUSERS";
    347 	case EDQUOT =>
    348 		return "EDQUOT";
    349 	case ESTALE =>
    350 		return "ESTALE";
    351 	case EREMOTE =>
    352 		return "EREMOTE";
    353 	case EBADRPC =>
    354 		return "EBADRPC";
    355 	case ERPCMISMATCH =>
    356 		return "ERPCMISMATCH";
    357 	case EPROGUNAVAIL =>
    358 		return "EPROGUNAVAIL";
    359 	case EPROGMISMATCH =>
    360 		return "EPROGMISMATCH";
    361 	case EPROCUNAVAIL =>
    362 		return "EPROCUNAVAIL";
    363 	case ENOLCK =>
    364 		return "ENOLCK";
    365 	case ENOSYS =>
    366 		return "ENOSYS";
    367 	case EFTYPE =>
    368 		return "EFTYPE";
    369 	case EAUTH =>
    370 		return "EAUTH";
    371 	case ENEEDAUTH =>
    372 		return "ENEEDAUTH";
    373 	case EIPSEC =>
    374 		return "EIPSEC";
    375 	case ENOATTR =>
    376 		return "ENOATTR";
    377 	case EILSEQ =>
    378 		return "EILSEQ";
    379 	case ENOMEDIUM =>
    380 		return "ENOMEDIUM";
    381 	case EMEDIUMTYPE =>
    382 		return "EMEDIUMTYPE";
    383 	case EOVERFLOW =>
    384 		return "EOVERFLOW";
    385 	case ECANCELED =>
    386 		return "ECANCELED";
    387 	case EIDRM =>
    388 		return "EIDRM";
    389 	case ENOMSG =>
    390 		return "ENOMSG";
    391 	case ENOTSUP =>
    392 		return "ENOTSUP";
    393 	case EBADMSG =>
    394 		return "EBADMSG";
    395 	case ENOTRECOVERABLE =>
    396 		return "ENOTRECOVERABLE";
    397 	case EOWNERDEAD =>
    398 		return "EOWNERDEAD";
    399 	case EPROTO =>
    400 		return "EPROTO";
    401 	case =>
    402 		return unknown_errno(err);
    403 	};
    404 };
    405 
    406 export def EPERM: errno = 1;
    407 export def ENOENT: errno = 2;
    408 export def ESRCH: errno = 3;
    409 export def EINTR: errno = 4;
    410 export def EIO: errno = 5;
    411 export def ENXIO: errno = 6;
    412 export def E2BIG: errno = 7;
    413 export def ENOEXEC: errno = 8;
    414 export def EBADF: errno = 9;
    415 export def ECHILD: errno = 10;
    416 export def EDEADLK: errno = 11;
    417 export def ENOMEM: errno = 12;
    418 export def EACCES: errno = 13;
    419 export def EFAULT: errno = 14;
    420 export def ENOTBLK: errno = 15;
    421 export def EBUSY: errno = 16;
    422 export def EEXIST: errno = 17;
    423 export def EXDEV: errno = 18;
    424 export def ENODEV: errno = 19;
    425 export def ENOTDIR: errno = 20;
    426 export def EISDIR: errno = 21;
    427 export def EINVAL: errno = 22;
    428 export def ENFILE: errno = 23;
    429 export def EMFILE: errno = 24;
    430 export def ENOTTY: errno = 25;
    431 export def ETXTBSY: errno = 26;
    432 export def EFBIG: errno = 27;
    433 export def ENOSPC: errno = 28;
    434 export def ESPIPE: errno = 29;
    435 export def EROFS: errno = 30;
    436 export def EMLINK: errno = 31;
    437 export def EPIPE: errno = 32;
    438 export def EDOM: errno = 33;
    439 export def ERANGE: errno = 34;
    440 export def EAGAIN: errno = 35;
    441 export def EWOULDBLOCK: errno = EAGAIN;
    442 export def EINPROGRESS: errno = 36;
    443 export def EALREADY: errno = 37;
    444 export def ENOTSOCK: errno = 38;
    445 export def EDESTADDRREQ: errno = 39;
    446 export def EMSGSIZE: errno = 40;
    447 export def EPROTOTYPE: errno = 41;
    448 export def ENOPROTOOPT: errno = 42;
    449 export def EPROTONOSUPPORT: errno = 43;
    450 export def ESOCKTNOSUPPORT: errno = 44;
    451 export def EOPNOTSUPP: errno = 45;
    452 export def EPFNOSUPPORT: errno = 46;
    453 export def EAFNOSUPPORT: errno = 47;
    454 export def EADDRINUSE: errno = 48;
    455 export def EADDRNOTAVAIL: errno = 49;
    456 export def ENETDOWN: errno = 50;
    457 export def ENETUNREACH: errno = 51;
    458 export def ENETRESET: errno = 52;
    459 export def ECONNABORTED: errno = 53;
    460 export def ECONNRESET: errno = 54;
    461 export def ENOBUFS: errno = 55;
    462 export def EISCONN: errno = 56;
    463 export def ENOTCONN: errno = 57;
    464 export def ESHUTDOWN: errno = 58;
    465 export def ETOOMANYREFS: errno = 59;
    466 export def ETIMEDOUT: errno = 60;
    467 export def ECONNREFUSED: errno = 61;
    468 export def ELOOP: errno = 62;
    469 export def ENAMETOOLONG: errno = 63;
    470 export def EHOSTDOWN: errno = 64;
    471 export def EHOSTUNREACH: errno = 65;
    472 export def ENOTEMPTY: errno = 66;
    473 export def EPROCLIM: errno = 67;
    474 export def EUSERS: errno = 68;
    475 export def EDQUOT: errno = 69;
    476 export def ESTALE: errno = 70;
    477 export def EREMOTE: errno = 71;
    478 export def EBADRPC: errno = 72;
    479 export def ERPCMISMATCH: errno = 73;
    480 export def EPROGUNAVAIL: errno = 74;
    481 export def EPROGMISMATCH: errno = 75;
    482 export def EPROCUNAVAIL: errno = 76;
    483 export def ENOLCK: errno = 77;
    484 export def ENOSYS: errno = 78;
    485 export def EFTYPE: errno = 79;
    486 export def EAUTH: errno = 80;
    487 export def ENEEDAUTH: errno = 81;
    488 export def EIPSEC: errno = 82;
    489 export def ENOATTR: errno = 83;
    490 export def EILSEQ: errno = 84;
    491 export def ENOMEDIUM: errno = 85;
    492 export def EMEDIUMTYPE: errno = 86;
    493 export def EOVERFLOW: errno = 87;
    494 export def ECANCELED: errno = 88;
    495 export def EIDRM: errno = 89;
    496 export def ENOMSG: errno = 90;
    497 export def ENOTSUP: errno = 91;
    498 export def EBADMSG: errno = 92;
    499 export def ENOTRECOVERABLE: errno = 93;
    500 export def EOWNERDEAD: errno = 94;
    501 export def EPROTO: errno = 95;