| ... | @@ -183,7 +183,7 @@ pub fn abort() noreturn { | ... | @@ -183,7 +183,7 @@ pub fn abort() noreturn { |
| 183 | exit(127); | 183 | exit(127); |
| 184 | } | 184 | } |
| 185 | | 185 | |
| 186 | pub const RaiseError = error{Unexpected}; | 186 | pub const RaiseError = UnexpectedError; |
| 187 | | 187 | |
| 188 | pub fn raise(sig: u8) RaiseError!void { | 188 | pub fn raise(sig: u8) RaiseError!void { |
| 189 | if (builtin.link_libc) { | 189 | if (builtin.link_libc) { |
| ... | @@ -215,10 +215,7 @@ pub fn raise(sig: u8) RaiseError!void { | ... | @@ -215,10 +215,7 @@ pub fn raise(sig: u8) RaiseError!void { |
| 215 | @compileError("std.os.raise unimplemented for this target"); | 215 | @compileError("std.os.raise unimplemented for this target"); |
| 216 | } | 216 | } |
| 217 | | 217 | |
| 218 | pub const KillError = error{ | 218 | pub const KillError = error{PermissionDenied} || UnexpectedError; |
| 219 | PermissionDenied, | | |
| 220 | Unexpected, | | |
| 221 | }; | | |
| 222 | | 219 | |
| 223 | pub fn kill(pid: pid_t, sig: u8) KillError!void { | 220 | pub fn kill(pid: pid_t, sig: u8) KillError!void { |
| 224 | switch (errno(system.kill(pid, sig))) { | 221 | switch (errno(system.kill(pid, sig))) { |
| ... | @@ -266,9 +263,7 @@ pub const ReadError = error{ | ... | @@ -266,9 +263,7 @@ pub const ReadError = error{ |
| 266 | /// This error occurs when no global event loop is configured, | 263 | /// This error occurs when no global event loop is configured, |
| 267 | /// and reading from the file descriptor would block. | 264 | /// and reading from the file descriptor would block. |
| 268 | WouldBlock, | 265 | WouldBlock, |
| 269 | | 266 | } || UnexpectedError; |
| 270 | Unexpected, | | |
| 271 | }; | | |
| 272 | | 267 | |
| 273 | /// Returns the number of bytes that were read, which can be less than | 268 | /// Returns the number of bytes that were read, which can be less than |
| 274 | /// buf.len. If 0 bytes were read, that means EOF. | 269 | /// buf.len. If 0 bytes were read, that means EOF. |
| ... | @@ -385,8 +380,7 @@ pub const WriteError = error{ | ... | @@ -385,8 +380,7 @@ pub const WriteError = error{ |
| 385 | BrokenPipe, | 380 | BrokenPipe, |
| 386 | SystemResources, | 381 | SystemResources, |
| 387 | OperationAborted, | 382 | OperationAborted, |
| 388 | Unexpected, | 383 | } || UnexpectedError; |
| 389 | }; | | |
| 390 | | 384 | |
| 391 | /// Write to a file descriptor. Keeps trying if it gets interrupted. | 385 | /// Write to a file descriptor. Keeps trying if it gets interrupted. |
| 392 | /// This function is for blocking file descriptors only. | 386 | /// This function is for blocking file descriptors only. |
| ... | @@ -548,8 +542,7 @@ pub const OpenError = error{ | ... | @@ -548,8 +542,7 @@ pub const OpenError = error{ |
| 548 | NotDir, | 542 | NotDir, |
| 549 | PathAlreadyExists, | 543 | PathAlreadyExists, |
| 550 | DeviceBusy, | 544 | DeviceBusy, |
| 551 | Unexpected, | 545 | } || UnexpectedError; |
| 552 | }; | | |
| 553 | | 546 | |
| 554 | /// Open and possibly create a file. Keeps trying if it gets interrupted. | 547 | /// Open and possibly create a file. Keeps trying if it gets interrupted. |
| 555 | /// See also `openC`. | 548 | /// See also `openC`. |
| ... | @@ -748,9 +741,7 @@ pub const ExecveError = error{ | ... | @@ -748,9 +741,7 @@ pub const ExecveError = error{ |
| 748 | ProcessFdQuotaExceeded, | 741 | ProcessFdQuotaExceeded, |
| 749 | SystemFdQuotaExceeded, | 742 | SystemFdQuotaExceeded, |
| 750 | NameTooLong, | 743 | NameTooLong, |
| 751 | | 744 | } || UnexpectedError; |
| 752 | Unexpected, | | |
| 753 | }; | | |
| 754 | | 745 | |
| 755 | fn execveErrnoToErr(err: usize) ExecveError { | 746 | fn execveErrnoToErr(err: usize) ExecveError { |
| 756 | assert(err > 0); | 747 | assert(err > 0); |
| ... | @@ -808,8 +799,7 @@ pub fn getenvC(key: [*]const u8) ?[]const u8 { | ... | @@ -808,8 +799,7 @@ pub fn getenvC(key: [*]const u8) ?[]const u8 { |
| 808 | pub const GetCwdError = error{ | 799 | pub const GetCwdError = error{ |
| 809 | NameTooLong, | 800 | NameTooLong, |
| 810 | CurrentWorkingDirectoryUnlinked, | 801 | CurrentWorkingDirectoryUnlinked, |
| 811 | Unexpected, | 802 | } || UnexpectedError; |
| 812 | }; | | |
| 813 | | 803 | |
| 814 | /// The result is a slice of out_buffer, indexed from 0. | 804 | /// The result is a slice of out_buffer, indexed from 0. |
| 815 | pub fn getcwd(out_buffer: []u8) GetCwdError![]u8 { | 805 | pub fn getcwd(out_buffer: []u8) GetCwdError![]u8 { |
| ... | @@ -846,8 +836,7 @@ pub const SymLinkError = error{ | ... | @@ -846,8 +836,7 @@ pub const SymLinkError = error{ |
| 846 | NameTooLong, | 836 | NameTooLong, |
| 847 | InvalidUtf8, | 837 | InvalidUtf8, |
| 848 | BadPathName, | 838 | BadPathName, |
| 849 | Unexpected, | 839 | } || UnexpectedError; |
| 850 | }; | | |
| 851 | | 840 | |
| 852 | /// Creates a symbolic link named `sym_link_path` which contains the string `target_path`. | 841 | /// Creates a symbolic link named `sym_link_path` which contains the string `target_path`. |
| 853 | /// A symbolic link (also known as a soft link) may point to an existing file or to a nonexistent | 842 | /// A symbolic link (also known as a soft link) may point to an existing file or to a nonexistent |
| ... | @@ -932,7 +921,6 @@ pub const UnlinkError = error{ | ... | @@ -932,7 +921,6 @@ pub const UnlinkError = error{ |
| 932 | NotDir, | 921 | NotDir, |
| 933 | SystemResources, | 922 | SystemResources, |
| 934 | ReadOnlyFileSystem, | 923 | ReadOnlyFileSystem, |
| 935 | Unexpected, | | |
| 936 | | 924 | |
| 937 | /// On Windows, file paths must be valid Unicode. | 925 | /// On Windows, file paths must be valid Unicode. |
| 938 | InvalidUtf8, | 926 | InvalidUtf8, |
| ... | @@ -940,7 +928,7 @@ pub const UnlinkError = error{ | ... | @@ -940,7 +928,7 @@ pub const UnlinkError = error{ |
| 940 | /// On Windows, file paths cannot contain these characters: | 928 | /// On Windows, file paths cannot contain these characters: |
| 941 | /// '/', '*', '?', '"', '<', '>', '|' | 929 | /// '/', '*', '?', '"', '<', '>', '|' |
| 942 | BadPathName, | 930 | BadPathName, |
| 943 | }; | 931 | } || UnexpectedError; |
| 944 | | 932 | |
| 945 | /// Delete a name and possibly the file it refers to. | 933 | /// Delete a name and possibly the file it refers to. |
| 946 | /// See also `unlinkC`. | 934 | /// See also `unlinkC`. |
| ... | @@ -996,8 +984,7 @@ const RenameError = error{ | ... | @@ -996,8 +984,7 @@ const RenameError = error{ |
| 996 | RenameAcrossMountPoints, | 984 | RenameAcrossMountPoints, |
| 997 | InvalidUtf8, | 985 | InvalidUtf8, |
| 998 | BadPathName, | 986 | BadPathName, |
| 999 | Unexpected, | 987 | } || UnexpectedError; |
| 1000 | }; | | |
| 1001 | | 988 | |
| 1002 | /// Change the name or location of a file. | 989 | /// Change the name or location of a file. |
| 1003 | pub fn rename(old_path: []const u8, new_path: []const u8) RenameError!void { | 990 | pub fn rename(old_path: []const u8, new_path: []const u8) RenameError!void { |
| ... | @@ -1064,8 +1051,7 @@ pub const MakeDirError = error{ | ... | @@ -1064,8 +1051,7 @@ pub const MakeDirError = error{ |
| 1064 | ReadOnlyFileSystem, | 1051 | ReadOnlyFileSystem, |
| 1065 | InvalidUtf8, | 1052 | InvalidUtf8, |
| 1066 | BadPathName, | 1053 | BadPathName, |
| 1067 | Unexpected, | 1054 | } || UnexpectedError; |
| 1068 | }; | | |
| 1069 | | 1055 | |
| 1070 | /// Create a directory. | 1056 | /// Create a directory. |
| 1071 | /// `mode` is ignored on Windows. | 1057 | /// `mode` is ignored on Windows. |
| ... | @@ -1116,8 +1102,7 @@ pub const DeleteDirError = error{ | ... | @@ -1116,8 +1102,7 @@ pub const DeleteDirError = error{ |
| 1116 | ReadOnlyFileSystem, | 1102 | ReadOnlyFileSystem, |
| 1117 | InvalidUtf8, | 1103 | InvalidUtf8, |
| 1118 | BadPathName, | 1104 | BadPathName, |
| 1119 | Unexpected, | 1105 | } || UnexpectedError; |
| 1120 | }; | | |
| 1121 | | 1106 | |
| 1122 | /// Deletes an empty directory. | 1107 | /// Deletes an empty directory. |
| 1123 | pub fn rmdir(dir_path: []const u8) DeleteDirError!void { | 1108 | pub fn rmdir(dir_path: []const u8) DeleteDirError!void { |
| ... | @@ -1163,8 +1148,7 @@ pub const ChangeCurDirError = error{ | ... | @@ -1163,8 +1148,7 @@ pub const ChangeCurDirError = error{ |
| 1163 | FileNotFound, | 1148 | FileNotFound, |
| 1164 | SystemResources, | 1149 | SystemResources, |
| 1165 | NotDir, | 1150 | NotDir, |
| 1166 | Unexpected, | 1151 | } || UnexpectedError; |
| 1167 | }; | | |
| 1168 | | 1152 | |
| 1169 | /// Changes the current working directory of the calling process. | 1153 | /// Changes the current working directory of the calling process. |
| 1170 | /// `dir_path` is recommended to be a UTF-8 encoded string. | 1154 | /// `dir_path` is recommended to be a UTF-8 encoded string. |
| ... | @@ -1206,8 +1190,7 @@ pub const ReadLinkError = error{ | ... | @@ -1206,8 +1190,7 @@ pub const ReadLinkError = error{ |
| 1206 | FileNotFound, | 1190 | FileNotFound, |
| 1207 | SystemResources, | 1191 | SystemResources, |
| 1208 | NotDir, | 1192 | NotDir, |
| 1209 | Unexpected, | 1193 | } || UnexpectedError; |
| 1210 | }; | | |
| 1211 | | 1194 | |
| 1212 | /// Read value of a symbolic link. | 1195 | /// Read value of a symbolic link. |
| 1213 | /// The return value is a slice of `out_buffer` from index 0. | 1196 | /// The return value is a slice of `out_buffer` from index 0. |
| ... | @@ -1247,8 +1230,7 @@ pub const SetIdError = error{ | ... | @@ -1247,8 +1230,7 @@ pub const SetIdError = error{ |
| 1247 | ResourceLimitReached, | 1230 | ResourceLimitReached, |
| 1248 | InvalidUserId, | 1231 | InvalidUserId, |
| 1249 | PermissionDenied, | 1232 | PermissionDenied, |
| 1250 | Unexpected, | 1233 | } || UnexpectedError; |
| 1251 | }; | | |
| 1252 | | 1234 | |
| 1253 | pub fn setuid(uid: u32) SetIdError!void { | 1235 | pub fn setuid(uid: u32) SetIdError!void { |
| 1254 | switch (errno(system.setuid(uid))) { | 1236 | switch (errno(system.setuid(uid))) { |
| ... | @@ -1357,9 +1339,7 @@ pub const SocketError = error{ | ... | @@ -1357,9 +1339,7 @@ pub const SocketError = error{ |
| 1357 | | 1339 | |
| 1358 | /// The protocol type or the specified protocol is not supported within this domain. | 1340 | /// The protocol type or the specified protocol is not supported within this domain. |
| 1359 | ProtocolNotSupported, | 1341 | ProtocolNotSupported, |
| 1360 | | 1342 | } || UnexpectedError; |
| 1361 | Unexpected, | | |
| 1362 | }; | | |
| 1363 | | 1343 | |
| 1364 | pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!i32 { | 1344 | pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!i32 { |
| 1365 | const rc = system.socket(domain, socket_type, protocol); | 1345 | const rc = system.socket(domain, socket_type, protocol); |
| ... | @@ -1409,9 +1389,7 @@ pub const BindError = error{ | ... | @@ -1409,9 +1389,7 @@ pub const BindError = error{ |
| 1409 | | 1389 | |
| 1410 | /// The socket inode would reside on a read-only filesystem. | 1390 | /// The socket inode would reside on a read-only filesystem. |
| 1411 | ReadOnlyFileSystem, | 1391 | ReadOnlyFileSystem, |
| 1412 | | 1392 | } || UnexpectedError; |
| 1413 | Unexpected, | | |
| 1414 | }; | | |
| 1415 | | 1393 | |
| 1416 | /// addr is `*const T` where T is one of the sockaddr | 1394 | /// addr is `*const T` where T is one of the sockaddr |
| 1417 | pub fn bind(fd: i32, addr: *const sockaddr) BindError!void { | 1395 | pub fn bind(fd: i32, addr: *const sockaddr) BindError!void { |
| ... | @@ -1448,9 +1426,7 @@ const ListenError = error{ | ... | @@ -1448,9 +1426,7 @@ const ListenError = error{ |
| 1448 | | 1426 | |
| 1449 | /// The socket is not of a type that supports the listen() operation. | 1427 | /// The socket is not of a type that supports the listen() operation. |
| 1450 | OperationNotSupported, | 1428 | OperationNotSupported, |
| 1451 | | 1429 | } || UnexpectedError; |
| 1452 | Unexpected, | | |
| 1453 | }; | | |
| 1454 | | 1430 | |
| 1455 | pub fn listen(sockfd: i32, backlog: u32) ListenError!void { | 1431 | pub fn listen(sockfd: i32, backlog: u32) ListenError!void { |
| 1456 | const rc = system.listen(sockfd, backlog); | 1432 | const rc = system.listen(sockfd, backlog); |
| ... | @@ -1487,9 +1463,7 @@ pub const AcceptError = error{ | ... | @@ -1487,9 +1463,7 @@ pub const AcceptError = error{ |
| 1487 | | 1463 | |
| 1488 | /// Firewall rules forbid connection. | 1464 | /// Firewall rules forbid connection. |
| 1489 | BlockedByFirewall, | 1465 | BlockedByFirewall, |
| 1490 | | 1466 | } || UnexpectedError; |
| 1491 | Unexpected, | | |
| 1492 | }; | | |
| 1493 | | 1467 | |
| 1494 | /// Accept a connection on a socket. `fd` must be opened in blocking mode. | 1468 | /// Accept a connection on a socket. `fd` must be opened in blocking mode. |
| 1495 | /// See also `accept4_async`. | 1469 | /// See also `accept4_async`. |
| ... | @@ -1559,9 +1533,7 @@ pub const EpollCreateError = error{ | ... | @@ -1559,9 +1533,7 @@ pub const EpollCreateError = error{ |
| 1559 | | 1533 | |
| 1560 | /// There was insufficient memory to create the kernel object. | 1534 | /// There was insufficient memory to create the kernel object. |
| 1561 | SystemResources, | 1535 | SystemResources, |
| 1562 | | 1536 | } || UnexpectedError; |
| 1563 | Unexpected, | | |
| 1564 | }; | | |
| 1565 | | 1537 | |
| 1566 | pub fn epoll_create1(flags: u32) EpollCreateError!i32 { | 1538 | pub fn epoll_create1(flags: u32) EpollCreateError!i32 { |
| 1567 | const rc = system.epoll_create1(flags); | 1539 | const rc = system.epoll_create1(flags); |
| ... | @@ -1600,9 +1572,7 @@ pub const EpollCtlError = error{ | ... | @@ -1600,9 +1572,7 @@ pub const EpollCtlError = error{ |
| 1600 | /// The target file fd does not support epoll. This error can occur if fd refers to, | 1572 | /// The target file fd does not support epoll. This error can occur if fd refers to, |
| 1601 | /// for example, a regular file or a directory. | 1573 | /// for example, a regular file or a directory. |
| 1602 | FileDescriptorIncompatibleWithEpoll, | 1574 | FileDescriptorIncompatibleWithEpoll, |
| 1603 | | 1575 | } || UnexpectedError; |
| 1604 | Unexpected, | | |
| 1605 | }; | | |
| 1606 | | 1576 | |
| 1607 | pub fn epoll_ctl(epfd: i32, op: u32, fd: i32, event: ?*epoll_event) EpollCtlError!void { | 1577 | pub fn epoll_ctl(epfd: i32, op: u32, fd: i32, event: ?*epoll_event) EpollCtlError!void { |
| 1608 | const rc = system.epoll_ctl(epfd, op, fd, event); | 1578 | const rc = system.epoll_ctl(epfd, op, fd, event); |
| ... | @@ -1643,8 +1613,7 @@ pub const EventFdError = error{ | ... | @@ -1643,8 +1613,7 @@ pub const EventFdError = error{ |
| 1643 | SystemResources, | 1613 | SystemResources, |
| 1644 | ProcessFdQuotaExceeded, | 1614 | ProcessFdQuotaExceeded, |
| 1645 | SystemFdQuotaExceeded, | 1615 | SystemFdQuotaExceeded, |
| 1646 | Unexpected, | 1616 | } || UnexpectedError; |
| 1647 | }; | | |
| 1648 | | 1617 | |
| 1649 | pub fn eventfd(initval: u32, flags: u32) EventFdError!i32 { | 1618 | pub fn eventfd(initval: u32, flags: u32) EventFdError!i32 { |
| 1650 | const rc = system.eventfd(initval, flags); | 1619 | const rc = system.eventfd(initval, flags); |
| ... | @@ -1663,9 +1632,7 @@ pub fn eventfd(initval: u32, flags: u32) EventFdError!i32 { | ... | @@ -1663,9 +1632,7 @@ pub fn eventfd(initval: u32, flags: u32) EventFdError!i32 { |
| 1663 | pub const GetSockNameError = error{ | 1632 | pub const GetSockNameError = error{ |
| 1664 | /// Insufficient resources were available in the system to perform the operation. | 1633 | /// Insufficient resources were available in the system to perform the operation. |
| 1665 | SystemResources, | 1634 | SystemResources, |
| 1666 | | 1635 | } || UnexpectedError; |
| 1667 | Unexpected, | | |
| 1668 | }; | | |
| 1669 | | 1636 | |
| 1670 | pub fn getsockname(sockfd: i32) GetSockNameError!sockaddr { | 1637 | pub fn getsockname(sockfd: i32) GetSockNameError!sockaddr { |
| 1671 | var addr: sockaddr = undefined; | 1638 | var addr: sockaddr = undefined; |
| ... | @@ -1714,9 +1681,7 @@ pub const ConnectError = error{ | ... | @@ -1714,9 +1681,7 @@ pub const ConnectError = error{ |
| 1714 | /// Timeout while attempting connection. The server may be too busy to accept new connections. Note | 1681 | /// Timeout while attempting connection. The server may be too busy to accept new connections. Note |
| 1715 | /// that for IP sockets the timeout may be very long when syncookies are enabled on the server. | 1682 | /// that for IP sockets the timeout may be very long when syncookies are enabled on the server. |
| 1716 | ConnectionTimedOut, | 1683 | ConnectionTimedOut, |
| 1717 | | 1684 | } || UnexpectedError; |
| 1718 | Unexpected, | | |
| 1719 | }; | | |
| 1720 | | 1685 | |
| 1721 | /// Initiate a connection on a socket. | 1686 | /// Initiate a connection on a socket. |
| 1722 | /// This is for blocking file descriptors only. | 1687 | /// This is for blocking file descriptors only. |
| ... | @@ -1824,10 +1789,7 @@ pub fn waitpid(pid: i32, flags: u32) u32 { | ... | @@ -1824,10 +1789,7 @@ pub fn waitpid(pid: i32, flags: u32) u32 { |
| 1824 | } | 1789 | } |
| 1825 | } | 1790 | } |
| 1826 | | 1791 | |
| 1827 | pub const FStatError = error{ | 1792 | pub const FStatError = error{SystemResources} || UnexpectedError; |
| 1828 | SystemResources, | | |
| 1829 | Unexpected, | | |
| 1830 | }; | | |
| 1831 | | 1793 | |
| 1832 | pub fn fstat(fd: fd_t) FStatError!Stat { | 1794 | pub fn fstat(fd: fd_t) FStatError!Stat { |
| 1833 | var stat: Stat = undefined; | 1795 | var stat: Stat = undefined; |
| ... | @@ -1856,9 +1818,7 @@ pub const KQueueError = error{ | ... | @@ -1856,9 +1818,7 @@ pub const KQueueError = error{ |
| 1856 | | 1818 | |
| 1857 | /// The system-wide limit on the total number of open files has been reached. | 1819 | /// The system-wide limit on the total number of open files has been reached. |
| 1858 | SystemFdQuotaExceeded, | 1820 | SystemFdQuotaExceeded, |
| 1859 | | 1821 | } || UnexpectedError; |
| 1860 | Unexpected, | | |
| 1861 | }; | | |
| 1862 | | 1822 | |
| 1863 | pub fn kqueue() KQueueError!i32 { | 1823 | pub fn kqueue() KQueueError!i32 { |
| 1864 | const rc = system.kqueue(); | 1824 | const rc = system.kqueue(); |
| ... | @@ -1922,8 +1882,7 @@ pub const INotifyInitError = error{ | ... | @@ -1922,8 +1882,7 @@ pub const INotifyInitError = error{ |
| 1922 | ProcessFdQuotaExceeded, | 1882 | ProcessFdQuotaExceeded, |
| 1923 | SystemFdQuotaExceeded, | 1883 | SystemFdQuotaExceeded, |
| 1924 | SystemResources, | 1884 | SystemResources, |
| 1925 | Unexpected, | 1885 | } || UnexpectedError; |
| 1926 | }; | | |
| 1927 | | 1886 | |
| 1928 | /// initialize an inotify instance | 1887 | /// initialize an inotify instance |
| 1929 | pub fn inotify_init1(flags: u32) INotifyInitError!i32 { | 1888 | pub fn inotify_init1(flags: u32) INotifyInitError!i32 { |
| ... | @@ -1944,8 +1903,7 @@ pub const INotifyAddWatchError = error{ | ... | @@ -1944,8 +1903,7 @@ pub const INotifyAddWatchError = error{ |
| 1944 | FileNotFound, | 1903 | FileNotFound, |
| 1945 | SystemResources, | 1904 | SystemResources, |
| 1946 | UserResourceLimitReached, | 1905 | UserResourceLimitReached, |
| 1947 | Unexpected, | 1906 | } || UnexpectedError; |
| 1948 | }; | | |
| 1949 | | 1907 | |
| 1950 | /// add a watch to an initialized inotify instance | 1908 | /// add a watch to an initialized inotify instance |
| 1951 | pub fn inotify_add_watch(inotify_fd: i32, pathname: []const u8, mask: u32) INotifyAddWatchError!i32 { | 1909 | pub fn inotify_add_watch(inotify_fd: i32, pathname: []const u8, mask: u32) INotifyAddWatchError!i32 { |
| ... | @@ -1992,8 +1950,7 @@ pub const MProtectError = error{ | ... | @@ -1992,8 +1950,7 @@ pub const MProtectError = error{ |
| 1992 | /// dle of a region currently protected as PROT_READ|PROT_WRITE would result in three map‐ | 1950 | /// dle of a region currently protected as PROT_READ|PROT_WRITE would result in three map‐ |
| 1993 | /// pings: two read/write mappings at each end and a read-only mapping in the middle.) | 1951 | /// pings: two read/write mappings at each end and a read-only mapping in the middle.) |
| 1994 | OutOfMemory, | 1952 | OutOfMemory, |
| 1995 | Unexpected, | 1953 | } || UnexpectedError; |
| 1996 | }; | | |
| 1997 | | 1954 | |
| 1998 | /// `memory.len` must be page-aligned. | 1955 | /// `memory.len` must be page-aligned. |
| 1999 | pub fn mprotect(memory: []align(mem.page_size) u8, protection: u32) MProtectError!void { | 1956 | pub fn mprotect(memory: []align(mem.page_size) u8, protection: u32) MProtectError!void { |
| ... | @@ -2007,10 +1964,7 @@ pub fn mprotect(memory: []align(mem.page_size) u8, protection: u32) MProtectErro | ... | @@ -2007,10 +1964,7 @@ pub fn mprotect(memory: []align(mem.page_size) u8, protection: u32) MProtectErro |
| 2007 | } | 1964 | } |
| 2008 | } | 1965 | } |
| 2009 | | 1966 | |
| 2010 | pub const ForkError = error{ | 1967 | pub const ForkError = error{SystemResources} || UnexpectedError; |
| 2011 | SystemResources, | | |
| 2012 | Unexpected, | | |
| 2013 | }; | | |
| 2014 | | 1968 | |
| 2015 | pub fn fork() ForkError!pid_t { | 1969 | pub fn fork() ForkError!pid_t { |
| 2016 | const rc = system.fork(); | 1970 | const rc = system.fork(); |
| ... | @@ -2037,8 +1991,7 @@ pub const MMapError = error{ | ... | @@ -2037,8 +1991,7 @@ pub const MMapError = error{ |
| 2037 | PermissionDenied, | 1991 | PermissionDenied, |
| 2038 | LockedMemoryLimitExceeded, | 1992 | LockedMemoryLimitExceeded, |
| 2039 | OutOfMemory, | 1993 | OutOfMemory, |
| 2040 | Unexpected, | 1994 | } || UnexpectedError; |
| 2041 | }; | | |
| 2042 | | 1995 | |
| 2043 | /// Map files or devices into memory. | 1996 | /// Map files or devices into memory. |
| 2044 | /// Use of a mapped region can result in these signals: | 1997 | /// Use of a mapped region can result in these signals: |
| ... | @@ -2101,9 +2054,7 @@ pub const AccessError = error{ | ... | @@ -2101,9 +2054,7 @@ pub const AccessError = error{ |
| 2101 | | 2054 | |
| 2102 | /// On Windows, file paths must be valid Unicode. | 2055 | /// On Windows, file paths must be valid Unicode. |
| 2103 | InvalidUtf8, | 2056 | InvalidUtf8, |
| 2104 | | 2057 | } || UnexpectedError; |
| 2105 | Unexpected, | | |
| 2106 | }; | | |
| 2107 | | 2058 | |
| 2108 | /// check user's permissions for a file | 2059 | /// check user's permissions for a file |
| 2109 | /// TODO currently this assumes `mode` is `F_OK` on Windows. | 2060 | /// TODO currently this assumes `mode` is `F_OK` on Windows. |
| ... | @@ -2161,8 +2112,7 @@ pub fn accessW(path: [*]const u16, mode: u32) windows.GetFileAttributesError!voi | ... | @@ -2161,8 +2112,7 @@ pub fn accessW(path: [*]const u16, mode: u32) windows.GetFileAttributesError!voi |
| 2161 | pub const PipeError = error{ | 2112 | pub const PipeError = error{ |
| 2162 | SystemFdQuotaExceeded, | 2113 | SystemFdQuotaExceeded, |
| 2163 | ProcessFdQuotaExceeded, | 2114 | ProcessFdQuotaExceeded, |
| 2164 | Unexpected, | 2115 | } || UnexpectedError; |
| 2165 | }; | | |
| 2166 | | 2116 | |
| 2167 | /// Creates a unidirectional data channel that can be used for interprocess communication. | 2117 | /// Creates a unidirectional data channel that can be used for interprocess communication. |
| 2168 | pub fn pipe() PipeError![2]fd_t { | 2118 | pub fn pipe() PipeError![2]fd_t { |
| ... | @@ -2193,8 +2143,7 @@ pub const SysCtlError = error{ | ... | @@ -2193,8 +2143,7 @@ pub const SysCtlError = error{ |
| 2193 | PermissionDenied, | 2143 | PermissionDenied, |
| 2194 | SystemResources, | 2144 | SystemResources, |
| 2195 | NameTooLong, | 2145 | NameTooLong, |
| 2196 | Unexpected, | 2146 | } || UnexpectedError; |
| 2197 | }; | | |
| 2198 | | 2147 | |
| 2199 | pub fn sysctl( | 2148 | pub fn sysctl( |
| 2200 | name: []const c_int, | 2149 | name: []const c_int, |
| ... | @@ -2237,10 +2186,7 @@ pub fn gettimeofday(tv: ?*timeval, tz: ?*timezone) void { | ... | @@ -2237,10 +2186,7 @@ pub fn gettimeofday(tv: ?*timeval, tz: ?*timezone) void { |
| 2237 | } | 2186 | } |
| 2238 | } | 2187 | } |
| 2239 | | 2188 | |
| 2240 | pub const SeekError = error{ | 2189 | pub const SeekError = error{Unseekable} || UnexpectedError; |
| 2241 | Unseekable, | | |
| 2242 | Unexpected, | | |
| 2243 | }; | | |
| 2244 | | 2190 | |
| 2245 | /// Repositions read/write file offset relative to the beginning. | 2191 | /// Repositions read/write file offset relative to the beginning. |
| 2246 | pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void { | 2192 | pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void { |
| ... | @@ -2382,9 +2328,7 @@ pub const RealPathError = error{ | ... | @@ -2382,9 +2328,7 @@ pub const RealPathError = error{ |
| 2382 | InvalidUtf8, | 2328 | InvalidUtf8, |
| 2383 | | 2329 | |
| 2384 | PathAlreadyExists, | 2330 | PathAlreadyExists, |
| 2385 | | 2331 | } || UnexpectedError; |
| 2386 | Unexpected, | | |
| 2387 | }; | | |
| 2388 | | 2332 | |
| 2389 | /// Return the canonicalized absolute pathname. | 2333 | /// Return the canonicalized absolute pathname. |
| 2390 | /// Expands all symbolic links and resolves references to `.`, `..`, and | 2334 | /// Expands all symbolic links and resolves references to `.`, `..`, and |
| ... | @@ -2548,10 +2492,7 @@ pub fn dl_iterate_phdr(comptime T: type, callback: extern fn (info: *dl_phdr_inf | ... | @@ -2548,10 +2492,7 @@ pub fn dl_iterate_phdr(comptime T: type, callback: extern fn (info: *dl_phdr_inf |
| 2548 | return last_r; | 2492 | return last_r; |
| 2549 | } | 2493 | } |
| 2550 | | 2494 | |
| 2551 | pub const ClockGetTimeError = error{ | 2495 | pub const ClockGetTimeError = error{UnsupportedClock} || UnexpectedError; |
| 2552 | UnsupportedClock, | | |
| 2553 | Unexpected, | | |
| 2554 | }; | | |
| 2555 | | 2496 | |
| 2556 | pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void { | 2497 | pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void { |
| 2557 | switch (errno(system.clock_gettime(clk_id, tp))) { | 2498 | switch (errno(system.clock_gettime(clk_id, tp))) { |
| ... | @@ -2571,10 +2512,7 @@ pub fn clock_getres(clk_id: i32, res: *timespec) ClockGetTimeError!void { | ... | @@ -2571,10 +2512,7 @@ pub fn clock_getres(clk_id: i32, res: *timespec) ClockGetTimeError!void { |
| 2571 | } | 2512 | } |
| 2572 | } | 2513 | } |
| 2573 | | 2514 | |
| 2574 | pub const SchedGetAffinityError = error{ | 2515 | pub const SchedGetAffinityError = error{PermissionDenied} || UnexpectedError; |
| 2575 | PermissionDenied, | | |
| 2576 | Unexpected, | | |
| 2577 | }; | | |
| 2578 | | 2516 | |
| 2579 | pub fn sched_getaffinity(pid: pid_t) SchedGetAffinityError!cpu_set_t { | 2517 | pub fn sched_getaffinity(pid: pid_t) SchedGetAffinityError!cpu_set_t { |
| 2580 | var set: cpu_set_t = undefined; | 2518 | var set: cpu_set_t = undefined; |
| ... | @@ -2628,8 +2566,7 @@ pub const SigaltstackError = error{ | ... | @@ -2628,8 +2566,7 @@ pub const SigaltstackError = error{ |
| 2628 | | 2566 | |
| 2629 | /// Attempted to change the signal stack while it was active. | 2567 | /// Attempted to change the signal stack while it was active. |
| 2630 | PermissionDenied, | 2568 | PermissionDenied, |
| 2631 | Unexpected, | 2569 | } || UnexpectedError; |
| 2632 | }; | | |
| 2633 | | 2570 | |
| 2634 | pub fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) SigaltstackError!void { | 2571 | pub fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) SigaltstackError!void { |
| 2635 | if (windows.is_the_target or uefi.is_the_target or wasi.is_the_target) | 2572 | if (windows.is_the_target or uefi.is_the_target or wasi.is_the_target) |
| ... | @@ -2677,9 +2614,7 @@ pub const FutimensError = error{ | ... | @@ -2677,9 +2614,7 @@ pub const FutimensError = error{ |
| 2677 | PermissionDenied, | 2614 | PermissionDenied, |
| 2678 | | 2615 | |
| 2679 | ReadOnlyFileSystem, | 2616 | ReadOnlyFileSystem, |
| 2680 | | 2617 | } || UnexpectedError; |
| 2681 | Unexpected, | | |
| 2682 | }; | | |
| 2683 | | 2618 | |
| 2684 | pub fn futimens(fd: fd_t, times: *const [2]timespec) FutimensError!void { | 2619 | pub fn futimens(fd: fd_t, times: *const [2]timespec) FutimensError!void { |
| 2685 | switch (errno(system.futimens(fd, times))) { | 2620 | switch (errno(system.futimens(fd, times))) { |
| ... | @@ -2694,10 +2629,7 @@ pub fn futimens(fd: fd_t, times: *const [2]timespec) FutimensError!void { | ... | @@ -2694,10 +2629,7 @@ pub fn futimens(fd: fd_t, times: *const [2]timespec) FutimensError!void { |
| 2694 | } | 2629 | } |
| 2695 | } | 2630 | } |
| 2696 | | 2631 | |
| 2697 | pub const GetHostNameError = error{ | 2632 | pub const GetHostNameError = error{PermissionDenied} || UnexpectedError; |
| 2698 | PermissionDenied, | | |
| 2699 | Unexpected, | | |
| 2700 | }; | | |
| 2701 | | 2633 | |
| 2702 | pub fn gethostname(name_buffer: *[HOST_NAME_MAX]u8) GetHostNameError![]u8 { | 2634 | pub fn gethostname(name_buffer: *[HOST_NAME_MAX]u8) GetHostNameError![]u8 { |
| 2703 | if (builtin.link_libc) { | 2635 | if (builtin.link_libc) { |