| author | |
| committer | |
| log | ff2c7946128fac8488e393655e1a3371983b7620 |
| tree | 15119490155b6f5dd5dd047f2194c0318e3a3a51 |
| parent | 91536813ec5d159ed4bea857621ed10a1216411a |
See #27317 files changed, 488 insertions(+), 333 deletions(-)
CMakeLists.txt+2-1| ... | ... | @@ -297,9 +297,10 @@ install(FILES "${CMAKE_SOURCE_DIR}/std/mem.zig" DESTINATION "${ZIG_STD_DEST}") |
| 297 | 297 | install(FILES "${CMAKE_SOURCE_DIR}/std/net.zig" DESTINATION "${ZIG_STD_DEST}") |
| 298 | 298 | install(FILES "${CMAKE_SOURCE_DIR}/std/os/child_process.zig" DESTINATION "${ZIG_STD_DEST}/os") |
| 299 | 299 | install(FILES "${CMAKE_SOURCE_DIR}/std/os/darwin.zig" DESTINATION "${ZIG_STD_DEST}/os") |
| 300 | install(FILES "${CMAKE_SOURCE_DIR}/std/os/errno.zig" DESTINATION "${ZIG_STD_DEST}/os") | |
| 300 | install(FILES "${CMAKE_SOURCE_DIR}/std/os/darwin_errno.zig" DESTINATION "${ZIG_STD_DEST}/os") | |
| 301 | 301 | install(FILES "${CMAKE_SOURCE_DIR}/std/os/index.zig" DESTINATION "${ZIG_STD_DEST}/os") |
| 302 | 302 | install(FILES "${CMAKE_SOURCE_DIR}/std/os/linux.zig" DESTINATION "${ZIG_STD_DEST}/os") |
| 303 | install(FILES "${CMAKE_SOURCE_DIR}/std/os/linux_errno.zig" DESTINATION "${ZIG_STD_DEST}/os") | |
| 303 | 304 | install(FILES "${CMAKE_SOURCE_DIR}/std/os/linux_i386.zig" DESTINATION "${ZIG_STD_DEST}/os") |
| 304 | 305 | install(FILES "${CMAKE_SOURCE_DIR}/std/os/linux_x86_64.zig" DESTINATION "${ZIG_STD_DEST}/os") |
| 305 | 306 | install(FILES "${CMAKE_SOURCE_DIR}/std/os/path.zig" DESTINATION "${ZIG_STD_DEST}/os") |
ci/travis_osx_script+3-1| ... | ... | @@ -12,5 +12,7 @@ cd build |
| 12 | 12 | cmake .. -DCMAKE_PREFIX_PATH=$PREFIX_DIR -DCMAKE_INSTALL_PREFIX=$(pwd) -DZIG_LIBC_LIB_DIR=$(dirname $($CC -print-file-name=crt1.o)) -DZIG_LIBC_INCLUDE_DIR=$(echo -n | $CC -E -x c - -v 2>&1 | grep -B1 "End of search list." | head -n1 | cut -c 2- | sed "s/ .*//") -DZIG_LIBC_STATIC_LIB_DIR=$(dirname $($CC -print-file-name=crtbegin.o)) |
| 13 | 13 | make VERBOSE=1 |
| 14 | 14 | make install |
| 15 | # TODO get tests passing on macos | |
| 15 | # TODO get full test suite passing on macos | |
| 16 | ./zig test ../test/behavior.zig | |
| 17 | ./zig test ../test/behavior.zig --release-fast | |
| 16 | 18 | # ./zig build --build-file ../build.zig test |
src/link.cpp+4| ... | ... | @@ -325,6 +325,10 @@ static void construct_linker_job_elf(LinkJob *lj) { |
| 325 | 325 | lj->args.append(get_libc_static_file(g, "crtend.o")); |
| 326 | 326 | lj->args.append(get_libc_file(g, "crtn.o")); |
| 327 | 327 | } |
| 328 | ||
| 329 | if (!g->is_native_target) { | |
| 330 | lj->args.append("--allow-shlib-undefined"); | |
| 331 | } | |
| 328 | 332 | } |
| 329 | 333 | |
| 330 | 334 | static bool is_target_cyg_mingw(const ZigTarget *target) { |
std/c/darwin.zig+2| ... | ... | @@ -1,5 +1,7 @@ |
| 1 | 1 | extern "c" fn __error() -> &c_int; |
| 2 | 2 | |
| 3 | pub use @import("../os/darwin_errno.zig"); | |
| 4 | ||
| 3 | 5 | pub const _errno = __error; |
| 4 | 6 | |
| 5 | 7 | /// Renamed to Stat to not conflict with the stat function. |
std/c/index.zig-1| ... | ... | @@ -1,4 +1,3 @@ |
| 1 | pub use @import("../os/errno.zig"); | |
| 2 | 1 | const builtin = @import("builtin"); |
| 3 | 2 | const Os = builtin.Os; |
| 4 | 3 |
std/c/linux.zig+2| ... | ... | @@ -1,3 +1,5 @@ |
| 1 | pub use @import("../os/linux_errno.zig"); | |
| 2 | ||
| 1 | 3 | pub extern "c" fn getrandom(buf_ptr: &u8, buf_len: usize, flags: c_uint) -> c_int; |
| 2 | 4 | extern "c" fn __errno_location() -> &c_int; |
| 3 | 5 | pub const _errno = __errno_location; |
std/io.zig+22-23| ... | ... | @@ -8,7 +8,6 @@ const system = switch(builtin.os) { |
| 8 | 8 | }; |
| 9 | 9 | const c = @import("c/index.zig"); |
| 10 | 10 | |
| 11 | const errno = @import("os/errno.zig"); | |
| 12 | 11 | const math = @import("math/index.zig"); |
| 13 | 12 | const debug = @import("debug.zig"); |
| 14 | 13 | const assert = debug.assert; |
| ... | ... | @@ -269,11 +268,11 @@ pub const InStream = struct { |
| 269 | 268 | const read_err = system.getErrno(amt_read); |
| 270 | 269 | if (read_err > 0) { |
| 271 | 270 | switch (read_err) { |
| 272 | errno.EINTR => continue, | |
| 273 | errno.EINVAL => unreachable, | |
| 274 | errno.EFAULT => unreachable, | |
| 275 | errno.EBADF => return error.BadFd, | |
| 276 | errno.EIO => return error.Io, | |
| 271 | system.EINTR => continue, | |
| 272 | system.EINVAL => unreachable, | |
| 273 | system.EFAULT => unreachable, | |
| 274 | system.EBADF => return error.BadFd, | |
| 275 | system.EIO => return error.Io, | |
| 277 | 276 | else => return error.Unexpected, |
| 278 | 277 | } |
| 279 | 278 | } |
| ... | ... | @@ -335,11 +334,11 @@ pub const InStream = struct { |
| 335 | 334 | const err = system.getErrno(result); |
| 336 | 335 | if (err > 0) { |
| 337 | 336 | return switch (err) { |
| 338 | errno.EBADF => error.BadFd, | |
| 339 | errno.EINVAL => error.Unseekable, | |
| 340 | errno.EOVERFLOW => error.Unseekable, | |
| 341 | errno.ESPIPE => error.Unseekable, | |
| 342 | errno.ENXIO => error.Unseekable, | |
| 337 | system.EBADF => error.BadFd, | |
| 338 | system.EINVAL => error.Unseekable, | |
| 339 | system.EOVERFLOW => error.Unseekable, | |
| 340 | system.ESPIPE => error.Unseekable, | |
| 341 | system.ENXIO => error.Unseekable, | |
| 343 | 342 | else => error.Unexpected, |
| 344 | 343 | }; |
| 345 | 344 | } |
| ... | ... | @@ -355,11 +354,11 @@ pub const InStream = struct { |
| 355 | 354 | const err = system.getErrno(result); |
| 356 | 355 | if (err > 0) { |
| 357 | 356 | return switch (err) { |
| 358 | errno.EBADF => error.BadFd, | |
| 359 | errno.EINVAL => error.Unseekable, | |
| 360 | errno.EOVERFLOW => error.Unseekable, | |
| 361 | errno.ESPIPE => error.Unseekable, | |
| 362 | errno.ENXIO => error.Unseekable, | |
| 357 | system.EBADF => error.BadFd, | |
| 358 | system.EINVAL => error.Unseekable, | |
| 359 | system.EOVERFLOW => error.Unseekable, | |
| 360 | system.ESPIPE => error.Unseekable, | |
| 361 | system.ENXIO => error.Unseekable, | |
| 363 | 362 | else => error.Unexpected, |
| 364 | 363 | }; |
| 365 | 364 | } |
| ... | ... | @@ -375,11 +374,11 @@ pub const InStream = struct { |
| 375 | 374 | const err = system.getErrno(result); |
| 376 | 375 | if (err > 0) { |
| 377 | 376 | return switch (err) { |
| 378 | errno.EBADF => error.BadFd, | |
| 379 | errno.EINVAL => error.Unseekable, | |
| 380 | errno.EOVERFLOW => error.Unseekable, | |
| 381 | errno.ESPIPE => error.Unseekable, | |
| 382 | errno.ENXIO => error.Unseekable, | |
| 377 | system.EBADF => error.BadFd, | |
| 378 | system.EINVAL => error.Unseekable, | |
| 379 | system.EOVERFLOW => error.Unseekable, | |
| 380 | system.ESPIPE => error.Unseekable, | |
| 381 | system.ENXIO => error.Unseekable, | |
| 383 | 382 | else => error.Unexpected, |
| 384 | 383 | }; |
| 385 | 384 | } |
| ... | ... | @@ -394,8 +393,8 @@ pub const InStream = struct { |
| 394 | 393 | const err = system.getErrno(system.fstat(is.fd, &stat)); |
| 395 | 394 | if (err > 0) { |
| 396 | 395 | return switch (err) { |
| 397 | errno.EBADF => error.BadFd, | |
| 398 | errno.ENOMEM => error.NoMem, | |
| 396 | system.EBADF => error.BadFd, | |
| 397 | system.ENOMEM => error.NoMem, | |
| 399 | 398 | else => error.Unexpected, |
| 400 | 399 | } |
| 401 | 400 | } |
std/net.zig+15-16| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | 1 | const linux = @import("os/linux.zig"); |
| 2 | const errno = @import("os/errno.zig"); | |
| 3 | 2 | const assert = @import("debug.zig").assert; |
| 4 | 3 | const endian = @import("endian.zig"); |
| 5 | 4 | |
| ... | ... | @@ -21,10 +20,10 @@ const Connection = struct { |
| 21 | 20 | const send_err = linux.getErrno(send_ret); |
| 22 | 21 | switch (send_err) { |
| 23 | 22 | 0 => return send_ret, |
| 24 | errno.EINVAL => unreachable, | |
| 25 | errno.EFAULT => unreachable, | |
| 26 | errno.ECONNRESET => return error.ConnectionReset, | |
| 27 | errno.EINTR => return error.SigInterrupt, | |
| 23 | linux.EINVAL => unreachable, | |
| 24 | linux.EFAULT => unreachable, | |
| 25 | linux.ECONNRESET => return error.ConnectionReset, | |
| 26 | linux.EINTR => return error.SigInterrupt, | |
| 28 | 27 | // TODO there are more possible errors |
| 29 | 28 | else => return error.Unexpected, |
| 30 | 29 | } |
| ... | ... | @@ -35,13 +34,13 @@ const Connection = struct { |
| 35 | 34 | const recv_err = linux.getErrno(recv_ret); |
| 36 | 35 | switch (recv_err) { |
| 37 | 36 | 0 => return buf[0..recv_ret], |
| 38 | errno.EINVAL => unreachable, | |
| 39 | errno.EFAULT => unreachable, | |
| 40 | errno.ENOTSOCK => return error.NotSocket, | |
| 41 | errno.EINTR => return error.SigInterrupt, | |
| 42 | errno.ENOMEM => return error.NoMem, | |
| 43 | errno.ECONNREFUSED => return error.ConnectionRefused, | |
| 44 | errno.EBADF => return error.BadFd, | |
| 37 | linux.EINVAL => unreachable, | |
| 38 | linux.EFAULT => unreachable, | |
| 39 | linux.ENOTSOCK => return error.NotSocket, | |
| 40 | linux.EINTR => return error.SigInterrupt, | |
| 41 | linux.ENOMEM => return error.NoMem, | |
| 42 | linux.ECONNREFUSED => return error.ConnectionRefused, | |
| 43 | linux.EBADF => return error.BadFd, | |
| 45 | 44 | // TODO more error values |
| 46 | 45 | else => return error.Unexpected, |
| 47 | 46 | } |
| ... | ... | @@ -50,9 +49,9 @@ const Connection = struct { |
| 50 | 49 | pub fn close(c: Connection) -> %void { |
| 51 | 50 | switch (linux.getErrno(linux.close(c.socket_fd))) { |
| 52 | 51 | 0 => return, |
| 53 | errno.EBADF => unreachable, | |
| 54 | errno.EINTR => return error.SigInterrupt, | |
| 55 | errno.EIO => return error.Io, | |
| 52 | linux.EBADF => unreachable, | |
| 53 | linux.EINTR => return error.SigInterrupt, | |
| 54 | linux.EIO => return error.Io, | |
| 56 | 55 | else => return error.Unexpected, |
| 57 | 56 | } |
| 58 | 57 | } |
| ... | ... | @@ -119,7 +118,7 @@ pub fn connectAddr(addr: &Address, port: u16) -> %Connection { |
| 119 | 118 | const connect_err = linux.getErrno(connect_ret); |
| 120 | 119 | if (connect_err > 0) { |
| 121 | 120 | switch (connect_err) { |
| 122 | errno.ETIMEDOUT => return error.TimedOut, | |
| 121 | linux.ETIMEDOUT => return error.TimedOut, | |
| 123 | 122 | else => { |
| 124 | 123 | // TODO figure out possible errors from connect() |
| 125 | 124 | return error.Unexpected; |
std/os/child_process.zig+4-5| ... | ... | @@ -3,7 +3,6 @@ const os = @import("index.zig"); |
| 3 | 3 | const posix = os.posix; |
| 4 | 4 | const mem = @import("../mem.zig"); |
| 5 | 5 | const Allocator = mem.Allocator; |
| 6 | const errno = @import("errno.zig"); | |
| 7 | 6 | const debug = @import("../debug.zig"); |
| 8 | 7 | const assert = debug.assert; |
| 9 | 8 | const BufMap = @import("../buf_map.zig").BufMap; |
| ... | ... | @@ -56,8 +55,8 @@ pub const ChildProcess = struct { |
| 56 | 55 | const err = posix.getErrno(posix.waitpid(self.pid, &status, 0)); |
| 57 | 56 | if (err > 0) { |
| 58 | 57 | switch (err) { |
| 59 | errno.EINVAL, errno.ECHILD => unreachable, | |
| 60 | errno.EINTR => continue, | |
| 58 | posix.EINVAL, posix.ECHILD => unreachable, | |
| 59 | posix.EINTR => continue, | |
| 61 | 60 | else => { |
| 62 | 61 | if (self.stdin) |*stdin| { stdin.close(); } |
| 63 | 62 | if (self.stdout) |*stdout| { stdout.close(); } |
| ... | ... | @@ -130,7 +129,7 @@ pub const ChildProcess = struct { |
| 130 | 129 | const pid_err = posix.getErrno(pid); |
| 131 | 130 | if (pid_err > 0) { |
| 132 | 131 | return switch (pid_err) { |
| 133 | errno.EAGAIN, errno.ENOMEM, errno.ENOSYS => error.SystemResources, | |
| 132 | posix.EAGAIN, posix.ENOMEM, posix.ENOSYS => error.SystemResources, | |
| 134 | 133 | else => error.Unexpected, |
| 135 | 134 | }; |
| 136 | 135 | } |
| ... | ... | @@ -209,7 +208,7 @@ fn makePipe() -> %[2]i32 { |
| 209 | 208 | const err = posix.getErrno(posix.pipe(&fds)); |
| 210 | 209 | if (err > 0) { |
| 211 | 210 | return switch (err) { |
| 212 | errno.EMFILE, errno.ENFILE => error.SystemResources, | |
| 211 | posix.EMFILE, posix.ENFILE => error.SystemResources, | |
| 213 | 212 | else => error.Unexpected, |
| 214 | 213 | } |
| 215 | 214 | } |
std/os/darwin.zig+2| ... | ... | @@ -1,6 +1,8 @@ |
| 1 | 1 | const c = @import("../c/index.zig"); |
| 2 | 2 | const assert = @import("../debug.zig").assert; |
| 3 | 3 | |
| 4 | pub use @import("darwin_errno.zig"); | |
| 5 | ||
| 4 | 6 | pub const STDIN_FILENO = 0; |
| 5 | 7 | pub const STDOUT_FILENO = 1; |
| 6 | 8 | pub const STDERR_FILENO = 2; |
std/os/darwin_errno.zig created+142| ... | ... | @@ -0,0 +1,142 @@ |
| 1 | ||
| 2 | pub const EPERM = 1; /// Operation not permitted | |
| 3 | pub const ENOENT = 2; /// No such file or directory | |
| 4 | pub const ESRCH = 3; /// No such process | |
| 5 | pub const EINTR = 4; /// Interrupted system call | |
| 6 | pub const EIO = 5; /// Input/output error | |
| 7 | pub const ENXIO = 6; /// Device not configured | |
| 8 | pub const E2BIG = 7; /// Argument list too long | |
| 9 | pub const ENOEXEC = 8; /// Exec format error | |
| 10 | pub const EBADF = 9; /// Bad file descriptor | |
| 11 | pub const ECHILD = 10; /// No child processes | |
| 12 | pub const EDEADLK = 11; /// Resource deadlock avoided | |
| 13 | ||
| 14 | pub const ENOMEM = 12; /// Cannot allocate memory | |
| 15 | pub const EACCES = 13; /// Permission denied | |
| 16 | pub const EFAULT = 14; /// Bad address | |
| 17 | pub const ENOTBLK = 15; /// Block device required | |
| 18 | pub const EBUSY = 16; /// Device / Resource busy | |
| 19 | pub const EEXIST = 17; /// File exists | |
| 20 | pub const EXDEV = 18; /// Cross-device link | |
| 21 | pub const ENODEV = 19; /// Operation not supported by device | |
| 22 | pub const ENOTDIR = 20; /// Not a directory | |
| 23 | pub const EISDIR = 21; /// Is a directory | |
| 24 | pub const EINVAL = 22; /// Invalid argument | |
| 25 | pub const ENFILE = 23; /// Too many open files in system | |
| 26 | pub const EMFILE = 24; /// Too many open files | |
| 27 | pub const ENOTTY = 25; /// Inappropriate ioctl for device | |
| 28 | pub const ETXTBSY = 26; /// Text file busy | |
| 29 | pub const EFBIG = 27; /// File too large | |
| 30 | pub const ENOSPC = 28; /// No space left on device | |
| 31 | pub const ESPIPE = 29; /// Illegal seek | |
| 32 | pub const EROFS = 30; /// Read-only file system | |
| 33 | pub const EMLINK = 31; /// Too many links | |
| 34 | pub const EPIPE = 32; /// Broken pipe | |
| 35 | ||
| 36 | // math software | |
| 37 | pub const EDOM = 33; /// Numerical argument out of domain | |
| 38 | pub const ERANGE = 34; /// Result too large | |
| 39 | ||
| 40 | // non-blocking and interrupt i/o | |
| 41 | pub const EAGAIN = 35; /// Resource temporarily unavailable | |
| 42 | pub const EWOULDBLOCK = EAGAIN; /// Operation would block | |
| 43 | pub const EINPROGRESS = 36; /// Operation now in progress | |
| 44 | pub const EALREADY = 37; /// Operation already in progress | |
| 45 | ||
| 46 | // ipc/network software -- argument errors | |
| 47 | pub const ENOTSOCK = 38; /// Socket operation on non-socket | |
| 48 | pub const EDESTADDRREQ = 39; /// Destination address required | |
| 49 | pub const EMSGSIZE = 40; /// Message too long | |
| 50 | pub const EPROTOTYPE = 41; /// Protocol wrong type for socket | |
| 51 | pub const ENOPROTOOPT = 42; /// Protocol not available | |
| 52 | pub const EPROTONOSUPPORT = 43; /// Protocol not supported | |
| 53 | ||
| 54 | pub const ESOCKTNOSUPPORT = 44; /// Socket type not supported | |
| 55 | ||
| 56 | pub const ENOTSUP = 45; /// Operation not supported | |
| 57 | ||
| 58 | pub const EPFNOSUPPORT = 46; /// Protocol family not supported | |
| 59 | pub const EAFNOSUPPORT = 47; /// Address family not supported by protocol family | |
| 60 | pub const EADDRINUSE = 48; /// Address already in use | |
| 61 | pub const EADDRNOTAVAIL = 49; /// Can't assign requested address | |
| 62 | ||
| 63 | // ipc/network software -- operational errors | |
| 64 | pub const ENETDOWN = 50; /// Network is down | |
| 65 | pub const ENETUNREACH = 51; /// Network is unreachable | |
| 66 | pub const ENETRESET = 52; /// Network dropped connection on reset | |
| 67 | pub const ECONNABORTED = 53; /// Software caused connection abort | |
| 68 | pub const ECONNRESET = 54; /// Connection reset by peer | |
| 69 | pub const ENOBUFS = 55; /// No buffer space available | |
| 70 | pub const EISCONN = 56; /// Socket is already connected | |
| 71 | pub const ENOTCONN = 57; /// Socket is not connected | |
| 72 | ||
| 73 | pub const ESHUTDOWN = 58; /// Can't send after socket shutdown | |
| 74 | pub const ETOOMANYREFS = 59; /// Too many references: can't splice | |
| 75 | ||
| 76 | pub const ETIMEDOUT = 60; /// Operation timed out | |
| 77 | pub const ECONNREFUSED = 61; /// Connection refused | |
| 78 | ||
| 79 | pub const ELOOP = 62; /// Too many levels of symbolic links | |
| 80 | pub const ENAMETOOLONG = 63; /// File name too long | |
| 81 | ||
| 82 | pub const EHOSTDOWN = 64; /// Host is down | |
| 83 | pub const EHOSTUNREACH = 65; /// No route to host | |
| 84 | pub const ENOTEMPTY = 66; /// Directory not empty | |
| 85 | ||
| 86 | // quotas & mush | |
| 87 | pub const EPROCLIM = 67; /// Too many processes | |
| 88 | pub const EUSERS = 68; /// Too many users | |
| 89 | pub const EDQUOT = 69; /// Disc quota exceeded | |
| 90 | ||
| 91 | // Network File System | |
| 92 | pub const ESTALE = 70; /// Stale NFS file handle | |
| 93 | pub const EREMOTE = 71; /// Too many levels of remote in path | |
| 94 | pub const EBADRPC = 72; /// RPC struct is bad | |
| 95 | pub const ERPCMISMATCH = 73; /// RPC version wrong | |
| 96 | pub const EPROGUNAVAIL = 74; /// RPC prog. not avail | |
| 97 | pub const EPROGMISMATCH = 75; /// Program version wrong | |
| 98 | pub const EPROCUNAVAIL = 76; /// Bad procedure for program | |
| 99 | ||
| 100 | pub const ENOLCK = 77; /// No locks available | |
| 101 | pub const ENOSYS = 78; /// Function not implemented | |
| 102 | ||
| 103 | pub const EFTYPE = 79; /// Inappropriate file type or format | |
| 104 | pub const EAUTH = 80; /// Authentication error | |
| 105 | pub const ENEEDAUTH = 81; /// Need authenticator | |
| 106 | ||
| 107 | // Intelligent device errors | |
| 108 | pub const EPWROFF = 82; /// Device power is off | |
| 109 | pub const EDEVERR = 83; /// Device error, e.g. paper out | |
| 110 | ||
| 111 | pub const EOVERFLOW = 84; /// Value too large to be stored in data type | |
| 112 | ||
| 113 | // Program loading errors | |
| 114 | pub const EBADEXEC = 85; /// Bad executable | |
| 115 | pub const EBADARCH = 86; /// Bad CPU type in executable | |
| 116 | pub const ESHLIBVERS = 87; /// Shared library version mismatch | |
| 117 | pub const EBADMACHO = 88; /// Malformed Macho file | |
| 118 | ||
| 119 | pub const ECANCELED = 89; /// Operation canceled | |
| 120 | ||
| 121 | pub const EIDRM = 90; /// Identifier removed | |
| 122 | pub const ENOMSG = 91; /// No message of desired type | |
| 123 | pub const EILSEQ = 92; /// Illegal byte sequence | |
| 124 | pub const ENOATTR = 93; /// Attribute not found | |
| 125 | ||
| 126 | pub const EBADMSG = 94; /// Bad message | |
| 127 | pub const EMULTIHOP = 95; /// Reserved | |
| 128 | pub const ENODATA = 96; /// No message available on STREAM | |
| 129 | pub const ENOLINK = 97; /// Reserved | |
| 130 | pub const ENOSR = 98; /// No STREAM resources | |
| 131 | pub const ENOSTR = 99; /// Not a STREAM | |
| 132 | pub const EPROTO = 100; /// Protocol error | |
| 133 | pub const ETIME = 101; /// STREAM ioctl timeout | |
| 134 | ||
| 135 | pub const ENOPOLICY = 103; /// No such policy registered | |
| 136 | ||
| 137 | pub const ENOTRECOVERABLE = 104; /// State not recoverable | |
| 138 | pub const EOWNERDEAD = 105; /// Previous owner died | |
| 139 | ||
| 140 | pub const EQFULL = 106; /// Interface output queue is full | |
| 141 | pub const ELAST = 106; /// Must be equal largest errno | |
| 142 |
std/os/errno.zig deleted-146| ... | ... | @@ -1,146 +0,0 @@ |
| 1 | pub const EPERM = 1; /// Operation not permitted | |
| 2 | pub const ENOENT = 2; /// No such file or directory | |
| 3 | pub const ESRCH = 3; /// No such process | |
| 4 | pub const EINTR = 4; /// Interrupted system call | |
| 5 | pub const EIO = 5; /// I/O error | |
| 6 | pub const ENXIO = 6; /// No such device or address | |
| 7 | pub const E2BIG = 7; /// Arg list too long | |
| 8 | pub const ENOEXEC = 8; /// Exec format error | |
| 9 | pub const EBADF = 9; /// Bad file number | |
| 10 | pub const ECHILD = 10; /// No child processes | |
| 11 | pub const EAGAIN = 11; /// Try again | |
| 12 | pub const ENOMEM = 12; /// Out of memory | |
| 13 | pub const EACCES = 13; /// Permission denied | |
| 14 | pub const EFAULT = 14; /// Bad address | |
| 15 | pub const ENOTBLK = 15; /// Block device required | |
| 16 | pub const EBUSY = 16; /// Device or resource busy | |
| 17 | pub const EEXIST = 17; /// File exists | |
| 18 | pub const EXDEV = 18; /// Cross-device link | |
| 19 | pub const ENODEV = 19; /// No such device | |
| 20 | pub const ENOTDIR = 20; /// Not a directory | |
| 21 | pub const EISDIR = 21; /// Is a directory | |
| 22 | pub const EINVAL = 22; /// Invalid argument | |
| 23 | pub const ENFILE = 23; /// File table overflow | |
| 24 | pub const EMFILE = 24; /// Too many open files | |
| 25 | pub const ENOTTY = 25; /// Not a typewriter | |
| 26 | pub const ETXTBSY = 26; /// Text file busy | |
| 27 | pub const EFBIG = 27; /// File too large | |
| 28 | pub const ENOSPC = 28; /// No space left on device | |
| 29 | pub const ESPIPE = 29; /// Illegal seek | |
| 30 | pub const EROFS = 30; /// Read-only file system | |
| 31 | pub const EMLINK = 31; /// Too many links | |
| 32 | pub const EPIPE = 32; /// Broken pipe | |
| 33 | pub const EDOM = 33; /// Math argument out of domain of func | |
| 34 | pub const ERANGE = 34; /// Math result not representable | |
| 35 | pub const EDEADLK = 35; /// Resource deadlock would occur | |
| 36 | pub const ENAMETOOLONG = 36; /// File name too long | |
| 37 | pub const ENOLCK = 37; /// No record locks available | |
| 38 | pub const ENOSYS = 38; /// Function not implemented | |
| 39 | pub const ENOTEMPTY = 39; /// Directory not empty | |
| 40 | pub const ELOOP = 40; /// Too many symbolic links encountered | |
| 41 | pub const EWOULDBLOCK = EAGAIN; /// Operation would block | |
| 42 | pub const ENOMSG = 42; /// No message of desired type | |
| 43 | pub const EIDRM = 43; /// Identifier removed | |
| 44 | pub const ECHRNG = 44; /// Channel number out of range | |
| 45 | pub const EL2NSYNC = 45; /// Level 2 not synchronized | |
| 46 | pub const EL3HLT = 46; /// Level 3 halted | |
| 47 | pub const EL3RST = 47; /// Level 3 reset | |
| 48 | pub const ELNRNG = 48; /// Link number out of range | |
| 49 | pub const EUNATCH = 49; /// Protocol driver not attached | |
| 50 | pub const ENOCSI = 50; /// No CSI structure available | |
| 51 | pub const EL2HLT = 51; /// Level 2 halted | |
| 52 | pub const EBADE = 52; /// Invalid exchange | |
| 53 | pub const EBADR = 53; /// Invalid request descriptor | |
| 54 | pub const EXFULL = 54; /// Exchange full | |
| 55 | pub const ENOANO = 55; /// No anode | |
| 56 | pub const EBADRQC = 56; /// Invalid request code | |
| 57 | pub const EBADSLT = 57; /// Invalid slot | |
| 58 | ||
| 59 | pub const EBFONT = 59; /// Bad font file format | |
| 60 | pub const ENOSTR = 60; /// Device not a stream | |
| 61 | pub const ENODATA = 61; /// No data available | |
| 62 | pub const ETIME = 62; /// Timer expired | |
| 63 | pub const ENOSR = 63; /// Out of streams resources | |
| 64 | pub const ENONET = 64; /// Machine is not on the network | |
| 65 | pub const ENOPKG = 65; /// Package not installed | |
| 66 | pub const EREMOTE = 66; /// Object is remote | |
| 67 | pub const ENOLINK = 67; /// Link has been severed | |
| 68 | pub const EADV = 68; /// Advertise error | |
| 69 | pub const ESRMNT = 69; /// Srmount error | |
| 70 | pub const ECOMM = 70; /// Communication error on send | |
| 71 | pub const EPROTO = 71; /// Protocol error | |
| 72 | pub const EMULTIHOP = 72; /// Multihop attempted | |
| 73 | pub const EDOTDOT = 73; /// RFS specific error | |
| 74 | pub const EBADMSG = 74; /// Not a data message | |
| 75 | pub const EOVERFLOW = 75; /// Value too large for defined data type | |
| 76 | pub const ENOTUNIQ = 76; /// Name not unique on network | |
| 77 | pub const EBADFD = 77; /// File descriptor in bad state | |
| 78 | pub const EREMCHG = 78; /// Remote address changed | |
| 79 | pub const ELIBACC = 79; /// Can not access a needed shared library | |
| 80 | pub const ELIBBAD = 80; /// Accessing a corrupted shared library | |
| 81 | pub const ELIBSCN = 81; /// .lib section in a.out corrupted | |
| 82 | pub const ELIBMAX = 82; /// Attempting to link in too many shared libraries | |
| 83 | pub const ELIBEXEC = 83; /// Cannot exec a shared library directly | |
| 84 | pub const EILSEQ = 84; /// Illegal byte sequence | |
| 85 | pub const ERESTART = 85; /// Interrupted system call should be restarted | |
| 86 | pub const ESTRPIPE = 86; /// Streams pipe error | |
| 87 | pub const EUSERS = 87; /// Too many users | |
| 88 | pub const ENOTSOCK = 88; /// Socket operation on non-socket | |
| 89 | pub const EDESTADDRREQ = 89; /// Destination address required | |
| 90 | pub const EMSGSIZE = 90; /// Message too long | |
| 91 | pub const EPROTOTYPE = 91; /// Protocol wrong type for socket | |
| 92 | pub const ENOPROTOOPT = 92; /// Protocol not available | |
| 93 | pub const EPROTONOSUPPORT = 93; /// Protocol not supported | |
| 94 | pub const ESOCKTNOSUPPORT = 94; /// Socket type not supported | |
| 95 | pub const EOPNOTSUPP = 95; /// Operation not supported on transport endpoint | |
| 96 | pub const EPFNOSUPPORT = 96; /// Protocol family not supported | |
| 97 | pub const EAFNOSUPPORT = 97; /// Address family not supported by protocol | |
| 98 | pub const EADDRINUSE = 98; /// Address already in use | |
| 99 | pub const EADDRNOTAVAIL = 99; /// Cannot assign requested address | |
| 100 | pub const ENETDOWN = 100; /// Network is down | |
| 101 | pub const ENETUNREACH = 101; /// Network is unreachable | |
| 102 | pub const ENETRESET = 102; /// Network dropped connection because of reset | |
| 103 | pub const ECONNABORTED = 103; /// Software caused connection abort | |
| 104 | pub const ECONNRESET = 104; /// Connection reset by peer | |
| 105 | pub const ENOBUFS = 105; /// No buffer space available | |
| 106 | pub const EISCONN = 106; /// Transport endpoint is already connected | |
| 107 | pub const ENOTCONN = 107; /// Transport endpoint is not connected | |
| 108 | pub const ESHUTDOWN = 108; /// Cannot send after transport endpoint shutdown | |
| 109 | pub const ETOOMANYREFS = 109; /// Too many references: cannot splice | |
| 110 | pub const ETIMEDOUT = 110; /// Connection timed out | |
| 111 | pub const ECONNREFUSED = 111; /// Connection refused | |
| 112 | pub const EHOSTDOWN = 112; /// Host is down | |
| 113 | pub const EHOSTUNREACH = 113; /// No route to host | |
| 114 | pub const EALREADY = 114; /// Operation already in progress | |
| 115 | pub const EINPROGRESS = 115; /// Operation now in progress | |
| 116 | pub const ESTALE = 116; /// Stale NFS file handle | |
| 117 | pub const EUCLEAN = 117; /// Structure needs cleaning | |
| 118 | pub const ENOTNAM = 118; /// Not a XENIX named type file | |
| 119 | pub const ENAVAIL = 119; /// No XENIX semaphores available | |
| 120 | pub const EISNAM = 120; /// Is a named type file | |
| 121 | pub const EREMOTEIO = 121; /// Remote I/O error | |
| 122 | pub const EDQUOT = 122; /// Quota exceeded | |
| 123 | ||
| 124 | pub const ENOMEDIUM = 123; /// No medium found | |
| 125 | pub const EMEDIUMTYPE = 124; /// Wrong medium type | |
| 126 | ||
| 127 | // nameserver query return codes | |
| 128 | pub const ENSROK = 0; /// DNS server returned answer with no data | |
| 129 | pub const ENSRNODATA = 160; /// DNS server returned answer with no data | |
| 130 | pub const ENSRFORMERR = 161; /// DNS server claims query was misformatted | |
| 131 | pub const ENSRSERVFAIL = 162; /// DNS server returned general failure | |
| 132 | pub const ENSRNOTFOUND = 163; /// Domain name not found | |
| 133 | pub const ENSRNOTIMP = 164; /// DNS server does not implement requested operation | |
| 134 | pub const ENSRREFUSED = 165; /// DNS server refused query | |
| 135 | pub const ENSRBADQUERY = 166; /// Misformatted DNS query | |
| 136 | pub const ENSRBADNAME = 167; /// Misformatted domain name | |
| 137 | pub const ENSRBADFAMILY = 168; /// Unsupported address family | |
| 138 | pub const ENSRBADRESP = 169; /// Misformatted DNS reply | |
| 139 | pub const ENSRCONNREFUSED = 170; /// Could not contact DNS servers | |
| 140 | pub const ENSRTIMEOUT = 171; /// Timeout while contacting DNS servers | |
| 141 | pub const ENSROF = 172; /// End of file | |
| 142 | pub const ENSRFILE = 173; /// Error reading file | |
| 143 | pub const ENSRNOMEM = 174; /// Out of memory | |
| 144 | pub const ENSRDESTRUCTION = 175; /// Application terminated lookup | |
| 145 | pub const ENSRQUERYDOMAINTOOLONG = 176; /// Domain name is too long | |
| 146 | pub const ENSRCNAMELOOP = 177; /// Domain name is too long |
std/os/index.zig+133-134| ... | ... | @@ -23,7 +23,6 @@ pub const page_size = 4 * 1024; |
| 23 | 23 | const debug = @import("../debug.zig"); |
| 24 | 24 | const assert = debug.assert; |
| 25 | 25 | |
| 26 | const errno = @import("errno.zig"); | |
| 27 | 26 | const c = @import("../c/index.zig"); |
| 28 | 27 | |
| 29 | 28 | const mem = @import("../mem.zig"); |
| ... | ... | @@ -63,9 +62,9 @@ pub fn getRandomBytes(buf: []u8) -> %void { |
| 63 | 62 | const err = posix.getErrno(posix.getrandom(buf.ptr, buf.len, 0)); |
| 64 | 63 | if (err > 0) { |
| 65 | 64 | return switch (err) { |
| 66 | errno.EINVAL => unreachable, | |
| 67 | errno.EFAULT => unreachable, | |
| 68 | errno.EINTR => continue, | |
| 65 | posix.EINVAL => unreachable, | |
| 66 | posix.EFAULT => unreachable, | |
| 67 | posix.EINTR => continue, | |
| 69 | 68 | else => error.Unexpected, |
| 70 | 69 | } |
| 71 | 70 | } |
| ... | ... | @@ -117,7 +116,7 @@ pub coldcc fn abort() -> noreturn { |
| 117 | 116 | pub fn posixClose(fd: i32) { |
| 118 | 117 | while (true) { |
| 119 | 118 | const err = posix.getErrno(posix.close(fd)); |
| 120 | if (err == errno.EINTR) { | |
| 119 | if (err == posix.EINTR) { | |
| 121 | 120 | continue; |
| 122 | 121 | } else { |
| 123 | 122 | return; |
| ... | ... | @@ -133,13 +132,13 @@ pub fn posixRead(fd: i32, buf: []u8) -> %void { |
| 133 | 132 | const err = posix.getErrno(amt_written); |
| 134 | 133 | if (err > 0) { |
| 135 | 134 | return switch (err) { |
| 136 | errno.EINTR => continue, | |
| 137 | errno.EINVAL, errno.EFAULT => unreachable, | |
| 138 | errno.EAGAIN => error.WouldBlock, | |
| 139 | errno.EBADF => error.FileClosed, | |
| 140 | errno.EIO => error.InputOutput, | |
| 141 | errno.EISDIR => error.IsDir, | |
| 142 | errno.ENOBUFS, errno.ENOMEM => error.SystemResources, | |
| 135 | posix.EINTR => continue, | |
| 136 | posix.EINVAL, posix.EFAULT => unreachable, | |
| 137 | posix.EAGAIN => error.WouldBlock, | |
| 138 | posix.EBADF => error.FileClosed, | |
| 139 | posix.EIO => error.InputOutput, | |
| 140 | posix.EISDIR => error.IsDir, | |
| 141 | posix.ENOBUFS, posix.ENOMEM => error.SystemResources, | |
| 143 | 142 | else => return error.Unexpected, |
| 144 | 143 | } |
| 145 | 144 | } |
| ... | ... | @@ -164,17 +163,17 @@ pub fn posixWrite(fd: i32, bytes: []const u8) -> %void { |
| 164 | 163 | const write_err = posix.getErrno(write_ret); |
| 165 | 164 | if (write_err > 0) { |
| 166 | 165 | return switch (write_err) { |
| 167 | errno.EINTR => continue, | |
| 168 | errno.EINVAL, errno.EFAULT => unreachable, | |
| 169 | errno.EAGAIN => error.WouldBlock, | |
| 170 | errno.EBADF => error.FileClosed, | |
| 171 | errno.EDESTADDRREQ => error.DestinationAddressRequired, | |
| 172 | errno.EDQUOT => error.DiskQuota, | |
| 173 | errno.EFBIG => error.FileTooBig, | |
| 174 | errno.EIO => error.InputOutput, | |
| 175 | errno.ENOSPC => error.NoSpaceLeft, | |
| 176 | errno.EPERM => error.AccessDenied, | |
| 177 | errno.EPIPE => error.BrokenPipe, | |
| 166 | posix.EINTR => continue, | |
| 167 | posix.EINVAL, posix.EFAULT => unreachable, | |
| 168 | posix.EAGAIN => error.WouldBlock, | |
| 169 | posix.EBADF => error.FileClosed, | |
| 170 | posix.EDESTADDRREQ => error.DestinationAddressRequired, | |
| 171 | posix.EDQUOT => error.DiskQuota, | |
| 172 | posix.EFBIG => error.FileTooBig, | |
| 173 | posix.EIO => error.InputOutput, | |
| 174 | posix.ENOSPC => error.NoSpaceLeft, | |
| 175 | posix.EPERM => error.AccessDenied, | |
| 176 | posix.EPIPE => error.BrokenPipe, | |
| 178 | 177 | else => error.Unexpected, |
| 179 | 178 | } |
| 180 | 179 | } |
| ... | ... | @@ -256,23 +255,23 @@ pub fn posixOpen(file_path: []const u8, flags: u32, perm: usize, allocator: ?&Al |
| 256 | 255 | const err = posix.getErrno(result); |
| 257 | 256 | if (err > 0) { |
| 258 | 257 | return switch (err) { |
| 259 | errno.EINTR => continue, | |
| 260 | ||
| 261 | errno.EFAULT => unreachable, | |
| 262 | errno.EINVAL => unreachable, | |
| 263 | errno.EACCES => error.AccessDenied, | |
| 264 | errno.EFBIG, errno.EOVERFLOW => error.FileTooBig, | |
| 265 | errno.EISDIR => error.IsDir, | |
| 266 | errno.ELOOP => error.SymLinkLoop, | |
| 267 | errno.EMFILE => error.ProcessFdQuotaExceeded, | |
| 268 | errno.ENAMETOOLONG => error.NameTooLong, | |
| 269 | errno.ENFILE => error.SystemFdQuotaExceeded, | |
| 270 | errno.ENODEV => error.NoDevice, | |
| 271 | errno.ENOENT => error.PathNotFound, | |
| 272 | errno.ENOMEM => error.SystemResources, | |
| 273 | errno.ENOSPC => error.NoSpaceLeft, | |
| 274 | errno.ENOTDIR => error.NotDir, | |
| 275 | errno.EPERM => error.AccessDenied, | |
| 258 | posix.EINTR => continue, | |
| 259 | ||
| 260 | posix.EFAULT => unreachable, | |
| 261 | posix.EINVAL => unreachable, | |
| 262 | posix.EACCES => error.AccessDenied, | |
| 263 | posix.EFBIG, posix.EOVERFLOW => error.FileTooBig, | |
| 264 | posix.EISDIR => error.IsDir, | |
| 265 | posix.ELOOP => error.SymLinkLoop, | |
| 266 | posix.EMFILE => error.ProcessFdQuotaExceeded, | |
| 267 | posix.ENAMETOOLONG => error.NameTooLong, | |
| 268 | posix.ENFILE => error.SystemFdQuotaExceeded, | |
| 269 | posix.ENODEV => error.NoDevice, | |
| 270 | posix.ENOENT => error.PathNotFound, | |
| 271 | posix.ENOMEM => error.SystemResources, | |
| 272 | posix.ENOSPC => error.NoSpaceLeft, | |
| 273 | posix.ENOTDIR => error.NotDir, | |
| 274 | posix.EPERM => error.AccessDenied, | |
| 276 | 275 | else => error.Unexpected, |
| 277 | 276 | } |
| 278 | 277 | } |
| ... | ... | @@ -285,9 +284,9 @@ pub fn posixDup2(old_fd: i32, new_fd: i32) -> %void { |
| 285 | 284 | const err = posix.getErrno(posix.dup2(old_fd, new_fd)); |
| 286 | 285 | if (err > 0) { |
| 287 | 286 | return switch (err) { |
| 288 | errno.EBUSY, errno.EINTR => continue, | |
| 289 | errno.EMFILE => error.ProcessFdQuotaExceeded, | |
| 290 | errno.EINVAL => unreachable, | |
| 287 | posix.EBUSY, posix.EINTR => continue, | |
| 288 | posix.EMFILE => error.ProcessFdQuotaExceeded, | |
| 289 | posix.EINVAL => unreachable, | |
| 291 | 290 | else => error.Unexpected, |
| 292 | 291 | }; |
| 293 | 292 | } |
| ... | ... | @@ -381,14 +380,14 @@ pub fn posixExecve(exe_path: []const u8, argv: []const []const u8, env_map: &con |
| 381 | 380 | path_buf[search_path.len + exe_path.len + 1] = 0; |
| 382 | 381 | err = posix.getErrno(posix.execve(path_buf.ptr, argv_buf.ptr, envp_buf.ptr)); |
| 383 | 382 | assert(err > 0); |
| 384 | if (err == errno.EACCES) { | |
| 383 | if (err == posix.EACCES) { | |
| 385 | 384 | seen_eacces = true; |
| 386 | } else if (err != errno.ENOENT) { | |
| 385 | } else if (err != posix.ENOENT) { | |
| 387 | 386 | return posixExecveErrnoToErr(err); |
| 388 | 387 | } |
| 389 | 388 | } |
| 390 | 389 | if (seen_eacces) { |
| 391 | err = errno.EACCES; | |
| 390 | err = posix.EACCES; | |
| 392 | 391 | } |
| 393 | 392 | return posixExecveErrnoToErr(err); |
| 394 | 393 | } |
| ... | ... | @@ -396,15 +395,15 @@ pub fn posixExecve(exe_path: []const u8, argv: []const []const u8, env_map: &con |
| 396 | 395 | fn posixExecveErrnoToErr(err: usize) -> error { |
| 397 | 396 | assert(err > 0); |
| 398 | 397 | return switch (err) { |
| 399 | errno.EFAULT => unreachable, | |
| 400 | errno.E2BIG, errno.EMFILE, errno.ENAMETOOLONG, errno.ENFILE, errno.ENOMEM => error.SystemResources, | |
| 401 | errno.EACCES, errno.EPERM => error.AccessDenied, | |
| 402 | errno.EINVAL, errno.ENOEXEC => error.InvalidExe, | |
| 403 | errno.EIO, errno.ELOOP => error.FileSystem, | |
| 404 | errno.EISDIR => error.IsDir, | |
| 405 | errno.ENOENT => error.FileNotFound, | |
| 406 | errno.ENOTDIR => error.NotDir, | |
| 407 | errno.ETXTBSY => error.FileBusy, | |
| 398 | posix.EFAULT => unreachable, | |
| 399 | posix.E2BIG, posix.EMFILE, posix.ENAMETOOLONG, posix.ENFILE, posix.ENOMEM => error.SystemResources, | |
| 400 | posix.EACCES, posix.EPERM => error.AccessDenied, | |
| 401 | posix.EINVAL, posix.ENOEXEC => error.InvalidExe, | |
| 402 | posix.EIO, posix.ELOOP => error.FileSystem, | |
| 403 | posix.EISDIR => error.IsDir, | |
| 404 | posix.ENOENT => error.FileNotFound, | |
| 405 | posix.ENOTDIR => error.NotDir, | |
| 406 | posix.ETXTBSY => error.FileBusy, | |
| 408 | 407 | else => error.Unexpected, |
| 409 | 408 | }; |
| 410 | 409 | } |
| ... | ... | @@ -464,7 +463,7 @@ pub fn getCwd(allocator: &Allocator) -> %[]u8 { |
| 464 | 463 | %defer allocator.free(buf); |
| 465 | 464 | while (true) { |
| 466 | 465 | const err = posix.getErrno(posix.getcwd(buf.ptr, buf.len)); |
| 467 | if (err == errno.ERANGE) { | |
| 466 | if (err == posix.ERANGE) { | |
| 468 | 467 | buf = %return allocator.realloc(u8, buf, buf.len * 2); |
| 469 | 468 | continue; |
| 470 | 469 | } else if (err > 0) { |
| ... | ... | @@ -490,18 +489,18 @@ pub fn symLink(allocator: &Allocator, existing_path: []const u8, new_path: []con |
| 490 | 489 | const err = posix.getErrno(posix.symlink(existing_buf.ptr, new_buf.ptr)); |
| 491 | 490 | if (err > 0) { |
| 492 | 491 | return switch (err) { |
| 493 | errno.EFAULT, errno.EINVAL => unreachable, | |
| 494 | errno.EACCES, errno.EPERM => error.AccessDenied, | |
| 495 | errno.EDQUOT => error.DiskQuota, | |
| 496 | errno.EEXIST => error.PathAlreadyExists, | |
| 497 | errno.EIO => error.FileSystem, | |
| 498 | errno.ELOOP => error.SymLinkLoop, | |
| 499 | errno.ENAMETOOLONG => error.NameTooLong, | |
| 500 | errno.ENOENT => error.FileNotFound, | |
| 501 | errno.ENOTDIR => error.NotDir, | |
| 502 | errno.ENOMEM => error.SystemResources, | |
| 503 | errno.ENOSPC => error.NoSpaceLeft, | |
| 504 | errno.EROFS => error.ReadOnlyFileSystem, | |
| 492 | posix.EFAULT, posix.EINVAL => unreachable, | |
| 493 | posix.EACCES, posix.EPERM => error.AccessDenied, | |
| 494 | posix.EDQUOT => error.DiskQuota, | |
| 495 | posix.EEXIST => error.PathAlreadyExists, | |
| 496 | posix.EIO => error.FileSystem, | |
| 497 | posix.ELOOP => error.SymLinkLoop, | |
| 498 | posix.ENAMETOOLONG => error.NameTooLong, | |
| 499 | posix.ENOENT => error.FileNotFound, | |
| 500 | posix.ENOTDIR => error.NotDir, | |
| 501 | posix.ENOMEM => error.SystemResources, | |
| 502 | posix.ENOSPC => error.NoSpaceLeft, | |
| 503 | posix.EROFS => error.ReadOnlyFileSystem, | |
| 505 | 504 | else => error.Unexpected, |
| 506 | 505 | }; |
| 507 | 506 | } |
| ... | ... | @@ -549,17 +548,17 @@ pub fn deleteFile(allocator: &Allocator, file_path: []const u8) -> %void { |
| 549 | 548 | const err = posix.getErrno(posix.unlink(buf.ptr)); |
| 550 | 549 | if (err > 0) { |
| 551 | 550 | return switch (err) { |
| 552 | errno.EACCES, errno.EPERM => error.AccessDenied, | |
| 553 | errno.EBUSY => error.FileBusy, | |
| 554 | errno.EFAULT, errno.EINVAL => unreachable, | |
| 555 | errno.EIO => error.FileSystem, | |
| 556 | errno.EISDIR => error.IsDir, | |
| 557 | errno.ELOOP => error.SymLinkLoop, | |
| 558 | errno.ENAMETOOLONG => error.NameTooLong, | |
| 559 | errno.ENOENT => error.FileNotFound, | |
| 560 | errno.ENOTDIR => error.NotDir, | |
| 561 | errno.ENOMEM => error.SystemResources, | |
| 562 | errno.EROFS => error.ReadOnlyFileSystem, | |
| 551 | posix.EACCES, posix.EPERM => error.AccessDenied, | |
| 552 | posix.EBUSY => error.FileBusy, | |
| 553 | posix.EFAULT, posix.EINVAL => unreachable, | |
| 554 | posix.EIO => error.FileSystem, | |
| 555 | posix.EISDIR => error.IsDir, | |
| 556 | posix.ELOOP => error.SymLinkLoop, | |
| 557 | posix.ENAMETOOLONG => error.NameTooLong, | |
| 558 | posix.ENOENT => error.FileNotFound, | |
| 559 | posix.ENOTDIR => error.NotDir, | |
| 560 | posix.ENOMEM => error.SystemResources, | |
| 561 | posix.EROFS => error.ReadOnlyFileSystem, | |
| 563 | 562 | else => error.Unexpected, |
| 564 | 563 | }; |
| 565 | 564 | } |
| ... | ... | @@ -612,21 +611,21 @@ pub fn rename(allocator: &Allocator, old_path: []const u8, new_path: []const u8) |
| 612 | 611 | const err = posix.getErrno(posix.rename(old_buf.ptr, new_buf.ptr)); |
| 613 | 612 | if (err > 0) { |
| 614 | 613 | return switch (err) { |
| 615 | errno.EACCES, errno.EPERM => error.AccessDenied, | |
| 616 | errno.EBUSY => error.FileBusy, | |
| 617 | errno.EDQUOT => error.DiskQuota, | |
| 618 | errno.EFAULT, errno.EINVAL => unreachable, | |
| 619 | errno.EISDIR => error.IsDir, | |
| 620 | errno.ELOOP => error.SymLinkLoop, | |
| 621 | errno.EMLINK => error.LinkQuotaExceeded, | |
| 622 | errno.ENAMETOOLONG => error.NameTooLong, | |
| 623 | errno.ENOENT => error.FileNotFound, | |
| 624 | errno.ENOTDIR => error.NotDir, | |
| 625 | errno.ENOMEM => error.SystemResources, | |
| 626 | errno.ENOSPC => error.NoSpaceLeft, | |
| 627 | errno.EEXIST, errno.ENOTEMPTY => error.PathAlreadyExists, | |
| 628 | errno.EROFS => error.ReadOnlyFileSystem, | |
| 629 | errno.EXDEV => error.RenameAcrossMountPoints, | |
| 614 | posix.EACCES, posix.EPERM => error.AccessDenied, | |
| 615 | posix.EBUSY => error.FileBusy, | |
| 616 | posix.EDQUOT => error.DiskQuota, | |
| 617 | posix.EFAULT, posix.EINVAL => unreachable, | |
| 618 | posix.EISDIR => error.IsDir, | |
| 619 | posix.ELOOP => error.SymLinkLoop, | |
| 620 | posix.EMLINK => error.LinkQuotaExceeded, | |
| 621 | posix.ENAMETOOLONG => error.NameTooLong, | |
| 622 | posix.ENOENT => error.FileNotFound, | |
| 623 | posix.ENOTDIR => error.NotDir, | |
| 624 | posix.ENOMEM => error.SystemResources, | |
| 625 | posix.ENOSPC => error.NoSpaceLeft, | |
| 626 | posix.EEXIST, posix.ENOTEMPTY => error.PathAlreadyExists, | |
| 627 | posix.EROFS => error.ReadOnlyFileSystem, | |
| 628 | posix.EXDEV => error.RenameAcrossMountPoints, | |
| 630 | 629 | else => error.Unexpected, |
| 631 | 630 | }; |
| 632 | 631 | } |
| ... | ... | @@ -642,18 +641,18 @@ pub fn makeDir(allocator: &Allocator, dir_path: []const u8) -> %void { |
| 642 | 641 | const err = posix.getErrno(posix.mkdir(path_buf.ptr, 0o755)); |
| 643 | 642 | if (err > 0) { |
| 644 | 643 | return switch (err) { |
| 645 | errno.EACCES, errno.EPERM => error.AccessDenied, | |
| 646 | errno.EDQUOT => error.DiskQuota, | |
| 647 | errno.EEXIST => error.PathAlreadyExists, | |
| 648 | errno.EFAULT => unreachable, | |
| 649 | errno.ELOOP => error.SymLinkLoop, | |
| 650 | errno.EMLINK => error.LinkQuotaExceeded, | |
| 651 | errno.ENAMETOOLONG => error.NameTooLong, | |
| 652 | errno.ENOENT => error.FileNotFound, | |
| 653 | errno.ENOMEM => error.SystemResources, | |
| 654 | errno.ENOSPC => error.NoSpaceLeft, | |
| 655 | errno.ENOTDIR => error.NotDir, | |
| 656 | errno.EROFS => error.ReadOnlyFileSystem, | |
| 644 | posix.EACCES, posix.EPERM => error.AccessDenied, | |
| 645 | posix.EDQUOT => error.DiskQuota, | |
| 646 | posix.EEXIST => error.PathAlreadyExists, | |
| 647 | posix.EFAULT => unreachable, | |
| 648 | posix.ELOOP => error.SymLinkLoop, | |
| 649 | posix.EMLINK => error.LinkQuotaExceeded, | |
| 650 | posix.ENAMETOOLONG => error.NameTooLong, | |
| 651 | posix.ENOENT => error.FileNotFound, | |
| 652 | posix.ENOMEM => error.SystemResources, | |
| 653 | posix.ENOSPC => error.NoSpaceLeft, | |
| 654 | posix.ENOTDIR => error.NotDir, | |
| 655 | posix.EROFS => error.ReadOnlyFileSystem, | |
| 657 | 656 | else => error.Unexpected, |
| 658 | 657 | }; |
| 659 | 658 | } |
| ... | ... | @@ -709,16 +708,16 @@ pub fn deleteDir(allocator: &Allocator, dir_path: []const u8) -> %void { |
| 709 | 708 | const err = posix.getErrno(posix.rmdir(path_buf.ptr)); |
| 710 | 709 | if (err > 0) { |
| 711 | 710 | return switch (err) { |
| 712 | errno.EACCES, errno.EPERM => error.AccessDenied, | |
| 713 | errno.EBUSY => error.FileBusy, | |
| 714 | errno.EFAULT, errno.EINVAL => unreachable, | |
| 715 | errno.ELOOP => error.SymLinkLoop, | |
| 716 | errno.ENAMETOOLONG => error.NameTooLong, | |
| 717 | errno.ENOENT => error.FileNotFound, | |
| 718 | errno.ENOMEM => error.SystemResources, | |
| 719 | errno.ENOTDIR => error.NotDir, | |
| 720 | errno.EEXIST, errno.ENOTEMPTY => error.DirNotEmpty, | |
| 721 | errno.EROFS => error.ReadOnlyFileSystem, | |
| 711 | posix.EACCES, posix.EPERM => error.AccessDenied, | |
| 712 | posix.EBUSY => error.FileBusy, | |
| 713 | posix.EFAULT, posix.EINVAL => unreachable, | |
| 714 | posix.ELOOP => error.SymLinkLoop, | |
| 715 | posix.ENAMETOOLONG => error.NameTooLong, | |
| 716 | posix.ENOENT => error.FileNotFound, | |
| 717 | posix.ENOMEM => error.SystemResources, | |
| 718 | posix.ENOTDIR => error.NotDir, | |
| 719 | posix.EEXIST, posix.ENOTEMPTY => error.DirNotEmpty, | |
| 720 | posix.EROFS => error.ReadOnlyFileSystem, | |
| 722 | 721 | else => error.Unexpected, |
| 723 | 722 | }; |
| 724 | 723 | } |
| ... | ... | @@ -825,8 +824,8 @@ pub const Dir = struct { |
| 825 | 824 | const err = linux.getErrno(result); |
| 826 | 825 | if (err > 0) { |
| 827 | 826 | switch (err) { |
| 828 | errno.EBADF, errno.EFAULT, errno.ENOTDIR => unreachable, | |
| 829 | errno.EINVAL => { | |
| 827 | posix.EBADF, posix.EFAULT, posix.ENOTDIR => unreachable, | |
| 828 | posix.EINVAL => { | |
| 830 | 829 | self.buf = %return self.allocator.realloc(u8, self.buf, self.buf.len * 2); |
| 831 | 830 | continue; |
| 832 | 831 | }, |
| ... | ... | @@ -879,14 +878,14 @@ pub fn changeCurDir(allocator: &Allocator, dir_path: []const u8) -> %void { |
| 879 | 878 | const err = posix.getErrno(posix.chdir(path_buf.ptr)); |
| 880 | 879 | if (err > 0) { |
| 881 | 880 | return switch (err) { |
| 882 | errno.EACCES => error.AccessDenied, | |
| 883 | errno.EFAULT => unreachable, | |
| 884 | errno.EIO => error.FileSystem, | |
| 885 | errno.ELOOP => error.SymLinkLoop, | |
| 886 | errno.ENAMETOOLONG => error.NameTooLong, | |
| 887 | errno.ENOENT => error.FileNotFound, | |
| 888 | errno.ENOMEM => error.SystemResources, | |
| 889 | errno.ENOTDIR => error.NotDir, | |
| 881 | posix.EACCES => error.AccessDenied, | |
| 882 | posix.EFAULT => unreachable, | |
| 883 | posix.EIO => error.FileSystem, | |
| 884 | posix.ELOOP => error.SymLinkLoop, | |
| 885 | posix.ENAMETOOLONG => error.NameTooLong, | |
| 886 | posix.ENOENT => error.FileNotFound, | |
| 887 | posix.ENOMEM => error.SystemResources, | |
| 888 | posix.ENOTDIR => error.NotDir, | |
| 890 | 889 | else => error.Unexpected, |
| 891 | 890 | }; |
| 892 | 891 | } |
| ... | ... | @@ -907,14 +906,14 @@ pub fn readLink(allocator: &Allocator, pathname: []const u8) -> %[]u8 { |
| 907 | 906 | const err = posix.getErrno(ret_val); |
| 908 | 907 | if (err > 0) { |
| 909 | 908 | return switch (err) { |
| 910 | errno.EACCES => error.AccessDenied, | |
| 911 | errno.EFAULT, errno.EINVAL => unreachable, | |
| 912 | errno.EIO => error.FileSystem, | |
| 913 | errno.ELOOP => error.SymLinkLoop, | |
| 914 | errno.ENAMETOOLONG => error.NameTooLong, | |
| 915 | errno.ENOENT => error.FileNotFound, | |
| 916 | errno.ENOMEM => error.SystemResources, | |
| 917 | errno.ENOTDIR => error.NotDir, | |
| 909 | posix.EACCES => error.AccessDenied, | |
| 910 | posix.EFAULT, posix.EINVAL => unreachable, | |
| 911 | posix.EIO => error.FileSystem, | |
| 912 | posix.ELOOP => error.SymLinkLoop, | |
| 913 | posix.ENAMETOOLONG => error.NameTooLong, | |
| 914 | posix.ENOENT => error.FileNotFound, | |
| 915 | posix.ENOMEM => error.SystemResources, | |
| 916 | posix.ENOTDIR => error.NotDir, | |
| 918 | 917 | else => error.Unexpected, |
| 919 | 918 | }; |
| 920 | 919 | } |
std/os/linux.zig+1-1| ... | ... | @@ -4,7 +4,7 @@ const arch = switch (builtin.arch) { |
| 4 | 4 | builtin.Arch.i386 => @import("linux_i386.zig"), |
| 5 | 5 | else => @compileError("unsupported arch"), |
| 6 | 6 | }; |
| 7 | const errno = @import("errno.zig"); | |
| 7 | pub use @import("linux_errno.zig"); | |
| 8 | 8 | |
| 9 | 9 | pub const STDIN_FILENO = 0; |
| 10 | 10 | pub const STDOUT_FILENO = 1; |
std/os/linux_errno.zig created+146| ... | ... | @@ -0,0 +1,146 @@ |
| 1 | pub const EPERM = 1; /// Operation not permitted | |
| 2 | pub const ENOENT = 2; /// No such file or directory | |
| 3 | pub const ESRCH = 3; /// No such process | |
| 4 | pub const EINTR = 4; /// Interrupted system call | |
| 5 | pub const EIO = 5; /// I/O error | |
| 6 | pub const ENXIO = 6; /// No such device or address | |
| 7 | pub const E2BIG = 7; /// Arg list too long | |
| 8 | pub const ENOEXEC = 8; /// Exec format error | |
| 9 | pub const EBADF = 9; /// Bad file number | |
| 10 | pub const ECHILD = 10; /// No child processes | |
| 11 | pub const EAGAIN = 11; /// Try again | |
| 12 | pub const ENOMEM = 12; /// Out of memory | |
| 13 | pub const EACCES = 13; /// Permission denied | |
| 14 | pub const EFAULT = 14; /// Bad address | |
| 15 | pub const ENOTBLK = 15; /// Block device required | |
| 16 | pub const EBUSY = 16; /// Device or resource busy | |
| 17 | pub const EEXIST = 17; /// File exists | |
| 18 | pub const EXDEV = 18; /// Cross-device link | |
| 19 | pub const ENODEV = 19; /// No such device | |
| 20 | pub const ENOTDIR = 20; /// Not a directory | |
| 21 | pub const EISDIR = 21; /// Is a directory | |
| 22 | pub const EINVAL = 22; /// Invalid argument | |
| 23 | pub const ENFILE = 23; /// File table overflow | |
| 24 | pub const EMFILE = 24; /// Too many open files | |
| 25 | pub const ENOTTY = 25; /// Not a typewriter | |
| 26 | pub const ETXTBSY = 26; /// Text file busy | |
| 27 | pub const EFBIG = 27; /// File too large | |
| 28 | pub const ENOSPC = 28; /// No space left on device | |
| 29 | pub const ESPIPE = 29; /// Illegal seek | |
| 30 | pub const EROFS = 30; /// Read-only file system | |
| 31 | pub const EMLINK = 31; /// Too many links | |
| 32 | pub const EPIPE = 32; /// Broken pipe | |
| 33 | pub const EDOM = 33; /// Math argument out of domain of func | |
| 34 | pub const ERANGE = 34; /// Math result not representable | |
| 35 | pub const EDEADLK = 35; /// Resource deadlock would occur | |
| 36 | pub const ENAMETOOLONG = 36; /// File name too long | |
| 37 | pub const ENOLCK = 37; /// No record locks available | |
| 38 | pub const ENOSYS = 38; /// Function not implemented | |
| 39 | pub const ENOTEMPTY = 39; /// Directory not empty | |
| 40 | pub const ELOOP = 40; /// Too many symbolic links encountered | |
| 41 | pub const EWOULDBLOCK = EAGAIN; /// Operation would block | |
| 42 | pub const ENOMSG = 42; /// No message of desired type | |
| 43 | pub const EIDRM = 43; /// Identifier removed | |
| 44 | pub const ECHRNG = 44; /// Channel number out of range | |
| 45 | pub const EL2NSYNC = 45; /// Level 2 not synchronized | |
| 46 | pub const EL3HLT = 46; /// Level 3 halted | |
| 47 | pub const EL3RST = 47; /// Level 3 reset | |
| 48 | pub const ELNRNG = 48; /// Link number out of range | |
| 49 | pub const EUNATCH = 49; /// Protocol driver not attached | |
| 50 | pub const ENOCSI = 50; /// No CSI structure available | |
| 51 | pub const EL2HLT = 51; /// Level 2 halted | |
| 52 | pub const EBADE = 52; /// Invalid exchange | |
| 53 | pub const EBADR = 53; /// Invalid request descriptor | |
| 54 | pub const EXFULL = 54; /// Exchange full | |
| 55 | pub const ENOANO = 55; /// No anode | |
| 56 | pub const EBADRQC = 56; /// Invalid request code | |
| 57 | pub const EBADSLT = 57; /// Invalid slot | |
| 58 | ||
| 59 | pub const EBFONT = 59; /// Bad font file format | |
| 60 | pub const ENOSTR = 60; /// Device not a stream | |
| 61 | pub const ENODATA = 61; /// No data available | |
| 62 | pub const ETIME = 62; /// Timer expired | |
| 63 | pub const ENOSR = 63; /// Out of streams resources | |
| 64 | pub const ENONET = 64; /// Machine is not on the network | |
| 65 | pub const ENOPKG = 65; /// Package not installed | |
| 66 | pub const EREMOTE = 66; /// Object is remote | |
| 67 | pub const ENOLINK = 67; /// Link has been severed | |
| 68 | pub const EADV = 68; /// Advertise error | |
| 69 | pub const ESRMNT = 69; /// Srmount error | |
| 70 | pub const ECOMM = 70; /// Communication error on send | |
| 71 | pub const EPROTO = 71; /// Protocol error | |
| 72 | pub const EMULTIHOP = 72; /// Multihop attempted | |
| 73 | pub const EDOTDOT = 73; /// RFS specific error | |
| 74 | pub const EBADMSG = 74; /// Not a data message | |
| 75 | pub const EOVERFLOW = 75; /// Value too large for defined data type | |
| 76 | pub const ENOTUNIQ = 76; /// Name not unique on network | |
| 77 | pub const EBADFD = 77; /// File descriptor in bad state | |
| 78 | pub const EREMCHG = 78; /// Remote address changed | |
| 79 | pub const ELIBACC = 79; /// Can not access a needed shared library | |
| 80 | pub const ELIBBAD = 80; /// Accessing a corrupted shared library | |
| 81 | pub const ELIBSCN = 81; /// .lib section in a.out corrupted | |
| 82 | pub const ELIBMAX = 82; /// Attempting to link in too many shared libraries | |
| 83 | pub const ELIBEXEC = 83; /// Cannot exec a shared library directly | |
| 84 | pub const EILSEQ = 84; /// Illegal byte sequence | |
| 85 | pub const ERESTART = 85; /// Interrupted system call should be restarted | |
| 86 | pub const ESTRPIPE = 86; /// Streams pipe error | |
| 87 | pub const EUSERS = 87; /// Too many users | |
| 88 | pub const ENOTSOCK = 88; /// Socket operation on non-socket | |
| 89 | pub const EDESTADDRREQ = 89; /// Destination address required | |
| 90 | pub const EMSGSIZE = 90; /// Message too long | |
| 91 | pub const EPROTOTYPE = 91; /// Protocol wrong type for socket | |
| 92 | pub const ENOPROTOOPT = 92; /// Protocol not available | |
| 93 | pub const EPROTONOSUPPORT = 93; /// Protocol not supported | |
| 94 | pub const ESOCKTNOSUPPORT = 94; /// Socket type not supported | |
| 95 | pub const EOPNOTSUPP = 95; /// Operation not supported on transport endpoint | |
| 96 | pub const EPFNOSUPPORT = 96; /// Protocol family not supported | |
| 97 | pub const EAFNOSUPPORT = 97; /// Address family not supported by protocol | |
| 98 | pub const EADDRINUSE = 98; /// Address already in use | |
| 99 | pub const EADDRNOTAVAIL = 99; /// Cannot assign requested address | |
| 100 | pub const ENETDOWN = 100; /// Network is down | |
| 101 | pub const ENETUNREACH = 101; /// Network is unreachable | |
| 102 | pub const ENETRESET = 102; /// Network dropped connection because of reset | |
| 103 | pub const ECONNABORTED = 103; /// Software caused connection abort | |
| 104 | pub const ECONNRESET = 104; /// Connection reset by peer | |
| 105 | pub const ENOBUFS = 105; /// No buffer space available | |
| 106 | pub const EISCONN = 106; /// Transport endpoint is already connected | |
| 107 | pub const ENOTCONN = 107; /// Transport endpoint is not connected | |
| 108 | pub const ESHUTDOWN = 108; /// Cannot send after transport endpoint shutdown | |
| 109 | pub const ETOOMANYREFS = 109; /// Too many references: cannot splice | |
| 110 | pub const ETIMEDOUT = 110; /// Connection timed out | |
| 111 | pub const ECONNREFUSED = 111; /// Connection refused | |
| 112 | pub const EHOSTDOWN = 112; /// Host is down | |
| 113 | pub const EHOSTUNREACH = 113; /// No route to host | |
| 114 | pub const EALREADY = 114; /// Operation already in progress | |
| 115 | pub const EINPROGRESS = 115; /// Operation now in progress | |
| 116 | pub const ESTALE = 116; /// Stale NFS file handle | |
| 117 | pub const EUCLEAN = 117; /// Structure needs cleaning | |
| 118 | pub const ENOTNAM = 118; /// Not a XENIX named type file | |
| 119 | pub const ENAVAIL = 119; /// No XENIX semaphores available | |
| 120 | pub const EISNAM = 120; /// Is a named type file | |
| 121 | pub const EREMOTEIO = 121; /// Remote I/O error | |
| 122 | pub const EDQUOT = 122; /// Quota exceeded | |
| 123 | ||
| 124 | pub const ENOMEDIUM = 123; /// No medium found | |
| 125 | pub const EMEDIUMTYPE = 124; /// Wrong medium type | |
| 126 | ||
| 127 | // nameserver query return codes | |
| 128 | pub const ENSROK = 0; /// DNS server returned answer with no data | |
| 129 | pub const ENSRNODATA = 160; /// DNS server returned answer with no data | |
| 130 | pub const ENSRFORMERR = 161; /// DNS server claims query was misformatted | |
| 131 | pub const ENSRSERVFAIL = 162; /// DNS server returned general failure | |
| 132 | pub const ENSRNOTFOUND = 163; /// Domain name not found | |
| 133 | pub const ENSRNOTIMP = 164; /// DNS server does not implement requested operation | |
| 134 | pub const ENSRREFUSED = 165; /// DNS server refused query | |
| 135 | pub const ENSRBADQUERY = 166; /// Misformatted DNS query | |
| 136 | pub const ENSRBADNAME = 167; /// Misformatted domain name | |
| 137 | pub const ENSRBADFAMILY = 168; /// Unsupported address family | |
| 138 | pub const ENSRBADRESP = 169; /// Misformatted DNS reply | |
| 139 | pub const ENSRCONNREFUSED = 170; /// Could not contact DNS servers | |
| 140 | pub const ENSRTIMEOUT = 171; /// Timeout while contacting DNS servers | |
| 141 | pub const ENSROF = 172; /// End of file | |
| 142 | pub const ENSRFILE = 173; /// Error reading file | |
| 143 | pub const ENSRNOMEM = 174; /// Out of memory | |
| 144 | pub const ENSRDESTRUCTION = 175; /// Application terminated lookup | |
| 145 | pub const ENSRQUERYDOMAINTOOLONG = 176; /// Domain name is too long | |
| 146 | pub const ENSRCNAMELOOP = 177; /// Domain name is too long |
std/special/builtin.zig+7-2| ... | ... | @@ -30,16 +30,21 @@ export fn __stack_chk_fail() { |
| 30 | 30 | @panic("stack smashing detected"); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | const math = @import("../math/index.zig"); | |
| 34 | ||
| 33 | 35 | export fn fmodf(x: f32, y: f32) -> f32 { generic_fmod(f32, x, y) } |
| 34 | 36 | export fn fmod(x: f64, y: f64) -> f64 { generic_fmod(f64, x, y) } |
| 35 | 37 | |
| 36 | const Log2Int = @import("../math/index.zig").Log2Int; | |
| 38 | // TODO add intrinsics for these (and probably the double version too) | |
| 39 | // and have the math stuff use the intrinsic. same as @mod and @rem | |
| 40 | export fn floorf(x: f32) -> f32 { math.floor(x) } | |
| 41 | export fn ceilf(x: f32) -> f32 { math.ceil(x) } | |
| 37 | 42 | |
| 38 | 43 | fn generic_fmod(comptime T: type, x: T, y: T) -> T { |
| 39 | 44 | @setDebugSafety(this, false); |
| 40 | 45 | |
| 41 | 46 | const uint = @IntType(false, T.bit_count); |
| 42 | const log2uint = Log2Int(uint); | |
| 47 | const log2uint = math.Log2Int(uint); | |
| 43 | 48 | const digits = if (T == f32) 23 else 52; |
| 44 | 49 | const exp_bits = if (T == f32) 9 else 12; |
| 45 | 50 | const bits_minus_1 = T.bit_count - 1; |
test/cases/switch.zig+3-3| ... | ... | @@ -72,7 +72,7 @@ fn nonConstSwitch(foo: SwitchStatmentFoo) { |
| 72 | 72 | SwitchStatmentFoo.C => 3, |
| 73 | 73 | SwitchStatmentFoo.D => 4, |
| 74 | 74 | }; |
| 75 | if (val != 3) unreachable; | |
| 75 | assert(val == 3); | |
| 76 | 76 | } |
| 77 | 77 | const SwitchStatmentFoo = enum { |
| 78 | 78 | A, |
| ... | ... | @@ -95,10 +95,10 @@ const SwitchProngWithVarEnum = enum { |
| 95 | 95 | fn switchProngWithVarFn(a: &const SwitchProngWithVarEnum) { |
| 96 | 96 | switch(*a) { |
| 97 | 97 | SwitchProngWithVarEnum.One => |x| { |
| 98 | if (x != 13) unreachable; | |
| 98 | assert(x == 13); | |
| 99 | 99 | }, |
| 100 | 100 | SwitchProngWithVarEnum.Two => |x| { |
| 101 | if (x != 13.0) unreachable; | |
| 101 | assert(x == 13.0); | |
| 102 | 102 | }, |
| 103 | 103 | SwitchProngWithVarEnum.Meh => |x| { |
| 104 | 104 | const v: void = x; |