diff options
| author | hryx <codroid@gmail.com> | 2019-06-08 16:23:27 -0700 |
|---|---|---|
| committer | hryx <codroid@gmail.com> | 2019-06-08 16:23:27 -0700 |
| commit | ad0f0562d8103d65bd36eb12ead899f375bda3e0 (patch) | |
| tree | 97adb8031a0647becf1a8b638494d8a79264c9c3 /std/os | |
| parent | ed5b8335b564cc4372b12e1c1a1b459aa348a90d (diff) | |
| parent | 720ed74413f086a93f5ed66159300d8dd48e8034 (diff) | |
| download | zig-ad0f0562d8103d65bd36eb12ead899f375bda3e0.tar.gz zig-ad0f0562d8103d65bd36eb12ead899f375bda3e0.zip | |
Merge branch 'master' into translate-c-userland
Diffstat (limited to 'std/os')
| -rw-r--r-- | std/os/bits.zig | 2 | ||||
| -rw-r--r-- | std/os/bits/darwin.zig | 12 | ||||
| -rw-r--r-- | std/os/bits/freebsd.zig | 23 | ||||
| -rw-r--r-- | std/os/bits/linux.zig | 39 | ||||
| -rw-r--r-- | std/os/bits/linux/arm64.zig | 10 | ||||
| -rw-r--r-- | std/os/bits/netbsd.zig | 19 | ||||
| -rw-r--r-- | std/os/bits/windows.zig | 9 | ||||
| -rw-r--r-- | std/os/darwin.zig | 2 | ||||
| -rw-r--r-- | std/os/freebsd.zig | 2 | ||||
| -rw-r--r-- | std/os/linux.zig | 54 | ||||
| -rw-r--r-- | std/os/linux/test.zig | 39 | ||||
| -rw-r--r-- | std/os/linux/x86_64.zig | 2 | ||||
| -rw-r--r-- | std/os/netbsd.zig | 2 | ||||
| -rw-r--r-- | std/os/test.zig | 61 | ||||
| -rw-r--r-- | std/os/uefi.zig | 4 | ||||
| -rw-r--r-- | std/os/wasi.zig | 2 | ||||
| -rw-r--r-- | std/os/windows.zig | 16 | ||||
| -rw-r--r-- | std/os/windows/advapi32.zig | 2 | ||||
| -rw-r--r-- | std/os/windows/bits.zig | 14 | ||||
| -rw-r--r-- | std/os/windows/kernel32.zig | 4 | ||||
| -rw-r--r-- | std/os/windows/lang.zig | 140 | ||||
| -rw-r--r-- | std/os/windows/ntdll.zig | 2 | ||||
| -rw-r--r-- | std/os/windows/ole32.zig | 2 | ||||
| -rw-r--r-- | std/os/windows/shell32.zig | 2 | ||||
| -rw-r--r-- | std/os/windows/sublang.zig | 244 | ||||
| -rw-r--r-- | std/os/zen.zig | 2 |
26 files changed, 614 insertions, 96 deletions
diff --git a/std/os/bits.zig b/std/os/bits.zig index 7b87cc6e4d..f16da2487b 100644 --- a/std/os/bits.zig +++ b/std/os/bits.zig @@ -3,7 +3,7 @@ const builtin = @import("builtin"); -pub use switch (builtin.os) { +pub usingnamespace switch (builtin.os) { .macosx, .ios, .tvos, .watchos => @import("bits/darwin.zig"), .freebsd => @import("bits/freebsd.zig"), .linux => @import("bits/linux.zig"), diff --git a/std/os/bits/darwin.zig b/std/os/bits/darwin.zig index a685735da0..39dae6e7a1 100644 --- a/std/os/bits/darwin.zig +++ b/std/os/bits/darwin.zig @@ -1078,3 +1078,15 @@ pub const EQFULL = 106; /// Must be equal largest errno pub const ELAST = 106; + +pub const SIGSTKSZ = 131072; +pub const MINSIGSTKSZ = 32768; + +pub const SS_ONSTACK = 1; +pub const SS_DISABLE = 4; + +pub const stack_t = extern struct { + ss_sp: [*]u8, + ss_size: isize, + ss_flags: i32, +}; diff --git a/std/os/bits/freebsd.zig b/std/os/bits/freebsd.zig index 1925b75f3f..c73887d648 100644 --- a/std/os/bits/freebsd.zig +++ b/std/os/bits/freebsd.zig @@ -20,6 +20,13 @@ pub const pthread_attr_t = extern struct { __align: c_long, }; +pub const dl_phdr_info = extern struct { + dlpi_addr: usize, + dlpi_name: ?[*]const u8, + dlpi_phdr: [*]std.elf.Phdr, + dlpi_phnum: u16, +}; + pub const msghdr = extern struct { /// optional address msg_name: ?*sockaddr, @@ -835,3 +842,19 @@ pub const ENOTRECOVERABLE = 95; // State not recoverable pub const EOWNERDEAD = 96; // Previous owner died pub const ELAST = 96; // Must be equal largest errno + +pub const MINSIGSTKSZ = switch (builtin.arch) { + .i386, .x86_64 => 2048, + .arm, .aarch64 => 4096, + else => @compileError("MINSIGSTKSZ not defined for this architecture"), +}; +pub const SIGSTKSZ = MINSIGSTKSZ + 32768; + +pub const SS_ONSTACK = 1; +pub const SS_DISABLE = 4; + +pub const stack_t = extern struct { + ss_sp: [*]u8, + ss_size: isize, + ss_flags: i32, +}; diff --git a/std/os/bits/linux.zig b/std/os/bits/linux.zig index 6532e72362..ff541077d9 100644 --- a/std/os/bits/linux.zig +++ b/std/os/bits/linux.zig @@ -1,10 +1,10 @@ const builtin = @import("builtin"); const std = @import("../../std.zig"); const maxInt = std.math.maxInt; -use @import("../bits.zig"); +usingnamespace @import("../bits.zig"); -pub use @import("linux/errno.zig"); -pub use switch (builtin.arch) { +pub usingnamespace @import("linux/errno.zig"); +pub usingnamespace switch (builtin.arch) { .x86_64 => @import("linux/x86_64.zig"), .aarch64 => @import("linux/arm64.zig"), else => struct {}, @@ -762,16 +762,16 @@ pub const epoll_data = extern union { // On x86_64 the structure is packed so that it matches the definition of its // 32bit counterpart -pub const epoll_event = if (builtin.arch != .x86_64) - extern struct { +pub const epoll_event = switch (builtin.arch) { + .x86_64 => packed struct { events: u32, data: epoll_data, - } -else - packed struct { + }, + else => extern struct { events: u32, data: epoll_data, - }; + }, +}; pub const _LINUX_CAPABILITY_VERSION_1 = 0x19980330; pub const _LINUX_CAPABILITY_U32S_1 = 1; @@ -929,3 +929,24 @@ pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t { //#define CPU_COUNT(set) CPU_COUNT_S(sizeof(cpu_set_t),set) //#define CPU_ZERO(set) CPU_ZERO_S(sizeof(cpu_set_t),set) //#define CPU_EQUAL(s1,s2) CPU_EQUAL_S(sizeof(cpu_set_t),s1,s2) + +pub const MINSIGSTKSZ = switch (builtin.arch) { + .i386, .x86_64, .arm => 2048, + .aarch64 => 5120, + else => @compileError("MINSIGSTKSZ not defined for this architecture"), +}; +pub const SIGSTKSZ = switch (builtin.arch) { + .i386, .x86_64, .arm => 8192, + .aarch64 => 16384, + else => @compileError("SIGSTKSZ not defined for this architecture"), +}; + +pub const SS_ONSTACK = 1; +pub const SS_DISABLE = 2; +pub const SS_AUTODISARM = 1 << 31; + +pub const stack_t = extern struct { + ss_sp: [*]u8, + ss_flags: i32, + ss_size: isize, +}; diff --git a/std/os/bits/linux/arm64.zig b/std/os/bits/linux/arm64.zig index 8966df30d2..527b78bbcd 100644 --- a/std/os/bits/linux/arm64.zig +++ b/std/os/bits/linux/arm64.zig @@ -299,16 +299,16 @@ pub const O_NONBLOCK = 0o4000; pub const O_DSYNC = 0o10000; pub const O_SYNC = 0o4010000; pub const O_RSYNC = 0o4010000; -pub const O_DIRECTORY = 0o200000; -pub const O_NOFOLLOW = 0o400000; +pub const O_DIRECTORY = 0o40000; +pub const O_NOFOLLOW = 0o100000; pub const O_CLOEXEC = 0o2000000; pub const O_ASYNC = 0o20000; -pub const O_DIRECT = 0o40000; -pub const O_LARGEFILE = 0; +pub const O_DIRECT = 0o200000; +pub const O_LARGEFILE = 0o400000; pub const O_NOATIME = 0o1000000; pub const O_PATH = 0o10000000; -pub const O_TMPFILE = 0o20200000; +pub const O_TMPFILE = 0o20040000; pub const O_NDELAY = O_NONBLOCK; pub const F_DUPFD = 0; diff --git a/std/os/bits/netbsd.zig b/std/os/bits/netbsd.zig index fc4c2904e0..d83ea82b06 100644 --- a/std/os/bits/netbsd.zig +++ b/std/os/bits/netbsd.zig @@ -20,6 +20,13 @@ pub const pthread_attr_t = extern struct { pta_private: *c_void, }; +pub const dl_phdr_info = extern struct { + dlpi_addr: usize, + dlpi_name: ?[*]const u8, + dlpi_phdr: [*]std.elf.Phdr, + dlpi_phnum: u16, +}; + pub const msghdr = extern struct { /// optional address msg_name: ?*sockaddr, @@ -723,3 +730,15 @@ pub const ENOLINK = 95; // Link has been severed pub const EPROTO = 96; // Protocol error pub const ELAST = 96; // Must equal largest errno + +pub const MINSIGSTKSZ = 8192; +pub const SIGSTKSZ = MINSIGSTKSZ + 32768; + +pub const SS_ONSTACK = 1; +pub const SS_DISABLE = 4; + +pub const stack_t = extern struct { + ss_sp: [*]u8, + ss_size: isize, + ss_flags: i32, +}; diff --git a/std/os/bits/windows.zig b/std/os/bits/windows.zig index a242113ba0..fc148d812f 100644 --- a/std/os/bits/windows.zig +++ b/std/os/bits/windows.zig @@ -1,6 +1,6 @@ // The reference for these types and values is Microsoft Windows's ucrt (Universal C RunTime). -use @import("../windows/bits.zig"); +usingnamespace @import("../windows/bits.zig"); pub const fd_t = HANDLE; pub const pid_t = HANDLE; @@ -158,10 +158,3 @@ pub const EWOULDBLOCK = 140; pub const EDQUOT = 10069; pub const F_OK = 0; - -// These are workarounds for "use of undeclared identifier" compile errors -// TODO make the compiler even more lazy. don't emit "use of undeclared identifier" errors -// for if branches that aren't taken. -pub const SIGKILL = @compileError("Windows libc does not have this"); - - diff --git a/std/os/darwin.zig b/std/os/darwin.zig index d6e0a1b77c..67ce9a06cf 100644 --- a/std/os/darwin.zig +++ b/std/os/darwin.zig @@ -4,4 +4,4 @@ pub const is_the_target = switch (builtin.os) { .macosx, .tvos, .watchos, .ios => true, else => false, }; -pub use std.c; +pub usingnamespace std.c; diff --git a/std/os/freebsd.zig b/std/os/freebsd.zig index c0f3382bd0..d418ccd415 100644 --- a/std/os/freebsd.zig +++ b/std/os/freebsd.zig @@ -1,4 +1,4 @@ const std = @import("../std.zig"); const builtin = @import("builtin"); pub const is_the_target = builtin.os == .freebsd; -pub use std.c; +pub usingnamespace std.c; diff --git a/std/os/linux.zig b/std/os/linux.zig index 282aa19bf1..61a13ff164 100644 --- a/std/os/linux.zig +++ b/std/os/linux.zig @@ -14,12 +14,12 @@ const vdso = @import("linux/vdso.zig"); const dl = @import("../dynamic_library.zig"); pub const is_the_target = builtin.os == .linux; -pub use switch (builtin.arch) { +pub usingnamespace switch (builtin.arch) { .x86_64 => @import("linux/x86_64.zig"), .aarch64 => @import("linux/arm64.zig"), else => struct {}, }; -pub use @import("bits.zig"); +pub usingnamespace @import("bits.zig"); pub const tls = @import("linux/tls.zig"); /// Set by startup code, used by `getauxval`. @@ -131,7 +131,7 @@ pub fn readlink(noalias path: [*]const u8, noalias buf_ptr: [*]u8, buf_len: usiz if (@hasDecl(@This(), "SYS_readlink")) { return syscall3(SYS_readlink, @ptrToInt(path), @ptrToInt(buf_ptr), buf_len); } else { - return syscall4(SYS_readlinkat, AT_FDCWD, @ptrToInt(path), @ptrToInt(buf_ptr), buf_len); + return syscall4(SYS_readlinkat, @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(path), @ptrToInt(buf_ptr), buf_len); } } @@ -145,7 +145,7 @@ pub fn mkdir(path: [*]const u8, mode: u32) usize { if (@hasDecl(@This(), "SYS_mkdir")) { return syscall2(SYS_mkdir, @ptrToInt(path), mode); } else { - return syscall3(SYS_mkdirat, AT_FDCWD, @ptrToInt(path), mode); + return syscall3(SYS_mkdirat, @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(path), mode); } } @@ -206,7 +206,7 @@ pub fn rmdir(path: [*]const u8) usize { if (@hasDecl(@This(), "SYS_rmdir")) { return syscall1(SYS_rmdir, @ptrToInt(path)); } else { - return syscall3(SYS_unlinkat, AT_FDCWD, @ptrToInt(path), AT_REMOVEDIR); + return syscall3(SYS_unlinkat, @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(path), AT_REMOVEDIR); } } @@ -215,7 +215,7 @@ pub fn symlink(existing: [*]const u8, new: [*]const u8) usize { if (@hasDecl(@This(), "SYS_symlink")) { return syscall2(SYS_symlink, @ptrToInt(existing), @ptrToInt(new)); } else { - return syscall3(SYS_symlinkat, @ptrToInt(existing), AT_FDCWD, @ptrToInt(new)); + return syscall3(SYS_symlinkat, @ptrToInt(existing), @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(new)); } } @@ -231,12 +231,16 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: usize) usize { // TODO https://github.com/ziglang/zig/issues/265 pub fn access(path: [*]const u8, mode: u32) usize { - return syscall2(SYS_access, @ptrToInt(path), mode); + if (@hasDecl(@This(), "SYS_access")) { + return syscall2(SYS_access, @ptrToInt(path), mode); + } else { + return syscall4(SYS_faccessat, @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(path), mode, 0); + } } // TODO https://github.com/ziglang/zig/issues/265 -pub fn faccessat(dirfd: i32, path: [*]const u8, mode: u32) usize { - return syscall3(SYS_faccessat, @bitCast(usize, isize(dirfd)), @ptrToInt(path), mode); +pub fn faccessat(dirfd: i32, path: [*]const u8, mode: u32, flags: u32) usize { + return syscall4(SYS_faccessat, @bitCast(usize, isize(dirfd)), @ptrToInt(path), mode, flags); } pub fn pipe(fd: *[2]i32) usize { @@ -264,9 +268,9 @@ pub fn rename(old: [*]const u8, new: [*]const u8) usize { if (@hasDecl(@This(), "SYS_rename")) { return syscall2(SYS_rename, @ptrToInt(old), @ptrToInt(new)); } else if (@hasDecl(@This(), "SYS_renameat")) { - return syscall4(SYS_renameat, AT_FDCWD, @ptrToInt(old), AT_FDCWD, @ptrToInt(new)); + return syscall4(SYS_renameat, @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(old), @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(new)); } else { - return syscall5(SYS_renameat2, AT_FDCWD, @ptrToInt(old), AT_FDCWD, @ptrToInt(new), 0); + return syscall5(SYS_renameat2, @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(old), @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(new), 0); } } @@ -305,7 +309,17 @@ pub fn renameat2(oldfd: i32, oldpath: [*]const u8, newfd: i32, newpath: [*]const // TODO https://github.com/ziglang/zig/issues/265 pub fn open(path: [*]const u8, flags: u32, perm: usize) usize { - return syscall3(SYS_open, @ptrToInt(path), flags, perm); + if (@hasDecl(@This(), "SYS_open")) { + return syscall3(SYS_open, @ptrToInt(path), flags, perm); + } else { + return syscall4( + SYS_openat, + @bitCast(usize, isize(AT_FDCWD)), + @ptrToInt(path), + flags, + perm, + ); + } } // TODO https://github.com/ziglang/zig/issues/265 @@ -373,7 +387,7 @@ pub fn unlink(path: [*]const u8) usize { if (@hasDecl(@This(), "SYS_unlink")) { return syscall1(SYS_unlink, @ptrToInt(path)); } else { - return syscall3(SYS_unlinkat, AT_FDCWD, @ptrToInt(path), 0); + return syscall3(SYS_unlinkat, @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(path), 0); } } @@ -759,18 +773,12 @@ pub fn epoll_create1(flags: usize) usize { return syscall1(SYS_epoll_create1, flags); } -pub fn epoll_ctl(epoll_fd: i32, op: u32, fd: i32, ev: *epoll_event) usize { +pub fn epoll_ctl(epoll_fd: i32, op: u32, fd: i32, ev: ?*epoll_event) usize { return syscall4(SYS_epoll_ctl, @bitCast(usize, isize(epoll_fd)), @intCast(usize, op), @bitCast(usize, isize(fd)), @ptrToInt(ev)); } pub fn epoll_wait(epoll_fd: i32, events: [*]epoll_event, maxevents: u32, timeout: i32) usize { - return syscall4( - SYS_epoll_wait, - @bitCast(usize, isize(epoll_fd)), - @ptrToInt(events), - maxevents, - @bitCast(usize, isize(timeout)), - ); + return epoll_pwait(epoll_fd, events, maxevents, timeout, null); } pub fn epoll_pwait(epoll_fd: i32, events: [*]epoll_event, maxevents: u32, timeout: i32, sigmask: ?*sigset_t) usize { @@ -818,6 +826,10 @@ pub fn capset(hdrp: *cap_user_header_t, datap: *const cap_user_data_t) usize { return syscall2(SYS_capset, @ptrToInt(hdrp), @ptrToInt(datap)); } +pub fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) usize { + return syscall2(SYS_sigaltstack, @ptrToInt(ss), @ptrToInt(old_ss)); +} + // XXX: This should be weak extern const __ehdr_start: elf.Ehdr = undefined; diff --git a/std/os/linux/test.zig b/std/os/linux/test.zig index c78b071c74..637308638a 100644 --- a/std/os/linux/test.zig +++ b/std/os/linux/test.zig @@ -44,42 +44,3 @@ test "timer" { // TODO implicit cast from *[N]T to [*]T err = linux.epoll_wait(@intCast(i32, epoll_fd), @ptrCast([*]linux.epoll_event, &events), 8, -1); } - -export fn iter_fn(info: *linux.dl_phdr_info, size: usize, data: ?*usize) i32 { - var counter = data.?; - // Count how many libraries are loaded - counter.* += usize(1); - - // The image should contain at least a PT_LOAD segment - if (info.dlpi_phnum < 1) return -1; - - // Quick & dirty validation of the phdr pointers, make sure we're not - // pointing to some random gibberish - var i: usize = 0; - var found_load = false; - while (i < info.dlpi_phnum) : (i += 1) { - const phdr = info.dlpi_phdr[i]; - - if (phdr.p_type != elf.PT_LOAD) continue; - - // Find the ELF header - const elf_header = @intToPtr(*elf.Ehdr, phdr.p_vaddr - phdr.p_offset); - // Validate the magic - if (!mem.eql(u8, elf_header.e_ident[0..], "\x7fELF")) return -1; - // Consistency check - if (elf_header.e_phnum != info.dlpi_phnum) return -1; - - found_load = true; - break; - } - - if (!found_load) return -1; - - return 42; -} - -test "dl_iterate_phdr" { - var counter: usize = 0; - expect(linux.dl_iterate_phdr(usize, iter_fn, &counter) != 0); - expect(counter != 0); -} diff --git a/std/os/linux/x86_64.zig b/std/os/linux/x86_64.zig index fa866cff4c..82eed0256b 100644 --- a/std/os/linux/x86_64.zig +++ b/std/os/linux/x86_64.zig @@ -1,4 +1,4 @@ -use @import("../bits.zig"); +usingnamespace @import("../bits.zig"); pub fn syscall0(number: usize) usize { return asm volatile ("syscall" diff --git a/std/os/netbsd.zig b/std/os/netbsd.zig index 25e72c10a8..cd63e40f5c 100644 --- a/std/os/netbsd.zig +++ b/std/os/netbsd.zig @@ -1,4 +1,4 @@ const builtin = @import("builtin"); const std = @import("../std.zig"); pub const is_the_target = builtin.os == .netbsd; -pub use std.c; +pub usingnamespace std.c; diff --git a/std/os/test.zig b/std/os/test.zig index d4d662e97f..a821c5dd9f 100644 --- a/std/os/test.zig +++ b/std/os/test.zig @@ -5,6 +5,7 @@ const expect = std.testing.expect; const io = std.io; const fs = std.fs; const mem = std.mem; +const elf = std.elf; const File = std.fs.File; const Thread = std.Thread; @@ -149,3 +150,63 @@ test "realpath" { var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; testing.expectError(error.FileNotFound, fs.realpath("definitely_bogus_does_not_exist1234", &buf)); } + +test "sigaltstack" { + if (builtin.os == .windows or builtin.os == .wasi) return error.SkipZigTest; + + var st: os.stack_t = undefined; + try os.sigaltstack(null, &st); + // Setting a stack size less than MINSIGSTKSZ returns ENOMEM + st.ss_flags = 0; + st.ss_size = 1; + testing.expectError(error.SizeTooSmall, os.sigaltstack(&st, null)); +} + +// If the type is not available use void to avoid erroring out when `iter_fn` is +// analyzed +const dl_phdr_info = if (@hasDecl(os, "dl_phdr_info")) os.dl_phdr_info else c_void; + +export fn iter_fn(info: *dl_phdr_info, size: usize, data: ?*usize) i32 { + if (builtin.os == .windows or builtin.os == .wasi or builtin.os == .macosx) + return 0; + + var counter = data.?; + // Count how many libraries are loaded + counter.* += usize(1); + + // The image should contain at least a PT_LOAD segment + if (info.dlpi_phnum < 1) return -1; + + // Quick & dirty validation of the phdr pointers, make sure we're not + // pointing to some random gibberish + var i: usize = 0; + var found_load = false; + while (i < info.dlpi_phnum) : (i += 1) { + const phdr = info.dlpi_phdr[i]; + + if (phdr.p_type != elf.PT_LOAD) continue; + + // Find the ELF header + const elf_header = @intToPtr(*elf.Ehdr, phdr.p_vaddr - phdr.p_offset); + // Validate the magic + if (!mem.eql(u8, elf_header.e_ident[0..4], "\x7fELF")) return -1; + // Consistency check + if (elf_header.e_phnum != info.dlpi_phnum) return -1; + + found_load = true; + break; + } + + if (!found_load) return -1; + + return 42; +} + +test "dl_iterate_phdr" { + if (builtin.os == .windows or builtin.os == .wasi or builtin.os == .macosx) + return error.SkipZigTest; + + var counter: usize = 0; + expect(os.dl_iterate_phdr(usize, iter_fn, &counter) != 0); + expect(counter != 0); +} diff --git a/std/os/uefi.zig b/std/os/uefi.zig index 8ed60d9c9b..7102938d70 100644 --- a/std/os/uefi.zig +++ b/std/os/uefi.zig @@ -1,2 +1,6 @@ // TODO this is where the extern declarations go. For example, see // inc/efilib.h in gnu-efi-code + +const builtin = @import("builtin"); + +pub const is_the_target = builtin.os == .uefi; diff --git a/std/os/wasi.zig b/std/os/wasi.zig index adfe9e821d..57b708395c 100644 --- a/std/os/wasi.zig +++ b/std/os/wasi.zig @@ -5,7 +5,7 @@ const std = @import("std"); const assert = std.debug.assert; pub const is_the_target = builtin.os == .wasi; -pub use @import("bits.zig"); +pub usingnamespace @import("bits.zig"); comptime { assert(@alignOf(i8) == 1); diff --git a/std/os/windows.zig b/std/os/windows.zig index 526ac1cfd6..1b25f59a55 100644 --- a/std/os/windows.zig +++ b/std/os/windows.zig @@ -18,7 +18,7 @@ pub const ntdll = @import("windows/ntdll.zig"); pub const ole32 = @import("windows/ole32.zig"); pub const shell32 = @import("windows/shell32.zig"); -pub use @import("windows/bits.zig"); +pub usingnamespace @import("windows/bits.zig"); pub const CreateFileError = error{ SharingViolation, @@ -756,11 +756,23 @@ pub fn sliceToPrefixedSuffixedFileW(s: []const u8, comptime suffix: []const u16) return result; } +inline fn MAKELANGID(p: c_ushort, s: c_ushort) LANGID { + return (s << 10) | p; +} + /// Call this when you made a windows DLL call or something that does SetLastError /// and you get an unexpected error. pub fn unexpectedError(err: DWORD) std.os.UnexpectedError { if (std.os.unexpected_error_tracing) { - std.debug.warn("unexpected GetLastError(): {}\n", err); + // 614 is the length of the longest windows error desciption + var buf_u16: [614]u16 = undefined; + var buf_u8: [614]u8 = undefined; + var len = kernel32.FormatMessageW( + FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + null, err, MAKELANGID(LANG.NEUTRAL, SUBLANG.DEFAULT), + buf_u16[0..].ptr, buf_u16.len / @sizeOf(TCHAR), null); + _ = std.unicode.utf16leToUtf8(&buf_u8, buf_u16[0..len]) catch unreachable; + std.debug.warn("error.Unexpected: GetLastError({}): {}\n", err, buf_u8[0..len]); std.debug.dumpCurrentStackTrace(null); } return error.Unexpected; diff --git a/std/os/windows/advapi32.zig b/std/os/windows/advapi32.zig index df3220e24c..165a2c10a3 100644 --- a/std/os/windows/advapi32.zig +++ b/std/os/windows/advapi32.zig @@ -1,4 +1,4 @@ -use @import("bits.zig"); +usingnamespace @import("bits.zig"); pub extern "advapi32" stdcallcc fn RegOpenKeyExW( hKey: HKEY, diff --git a/std/os/windows/bits.zig b/std/os/windows/bits.zig index 0bf2991903..c99f3ae463 100644 --- a/std/os/windows/bits.zig +++ b/std/os/windows/bits.zig @@ -6,6 +6,8 @@ const assert = std.debug.assert; const maxInt = std.math.maxInt; pub const ERROR = @import("error.zig"); +pub const LANG = @import("lang.zig"); +pub const SUBLANG = @import("sublang.zig"); /// The standard input device. Initially, this is the console input buffer, CONIN$. pub const STD_INPUT_HANDLE = maxInt(DWORD) - 10 + 1; @@ -55,6 +57,10 @@ pub const ULONG = u32; pub const LONG = i32; pub const ULONGLONG = u64; pub const LONGLONG = i64; +pub const HLOCAL = HANDLE; +pub const LANGID = c_ushort; + +pub const va_list = *@OpaqueType(); pub const TRUE = 1; pub const FALSE = 0; @@ -525,3 +531,11 @@ pub const COINIT = extern enum { /// > this expansion applies to the total length. /// from https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#maximum-path-length-limitation pub const PATH_MAX_WIDE = 32767; + +pub const FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100; +pub const FORMAT_MESSAGE_ARGUMENT_ARRAY = 0x00002000; +pub const FORMAT_MESSAGE_FROM_HMODULE = 0x00000800; +pub const FORMAT_MESSAGE_FROM_STRING = 0x00000400; +pub const FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000; +pub const FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200; +pub const FORMAT_MESSAGE_MAX_WIDTH_MASK = 0x000000FF; diff --git a/std/os/windows/kernel32.zig b/std/os/windows/kernel32.zig index 2bd1824620..27516342ac 100644 --- a/std/os/windows/kernel32.zig +++ b/std/os/windows/kernel32.zig @@ -1,4 +1,4 @@ -use @import("bits.zig"); +usingnamespace @import("bits.zig"); pub extern "kernel32" stdcallcc fn CancelIoEx(hFile: HANDLE, lpOverlapped: LPOVERLAPPED) BOOL; @@ -50,6 +50,8 @@ pub extern "kernel32" stdcallcc fn FindFirstFileW(lpFileName: [*]const u16, lpFi pub extern "kernel32" stdcallcc fn FindClose(hFindFile: HANDLE) BOOL; pub extern "kernel32" stdcallcc fn FindNextFileW(hFindFile: HANDLE, lpFindFileData: *WIN32_FIND_DATAW) BOOL; +pub extern "kernel32" stdcallcc fn FormatMessageW(dwFlags: DWORD, lpSource: ?LPVOID, dwMessageId: DWORD, dwLanguageId: DWORD, lpBuffer: LPWSTR, nSize: DWORD, Arguments: ?*va_list) DWORD; + pub extern "kernel32" stdcallcc fn FreeEnvironmentStringsW(penv: [*]u16) BOOL; pub extern "kernel32" stdcallcc fn GetCommandLineA() LPSTR; diff --git a/std/os/windows/lang.zig b/std/os/windows/lang.zig new file mode 100644 index 0000000000..b173a62a73 --- /dev/null +++ b/std/os/windows/lang.zig @@ -0,0 +1,140 @@ +pub const NEUTRAL = 0x00; +pub const INVARIANT = 0x7f; +pub const AFRIKAANS = 0x36; +pub const ALBANIAN = 0x1c; +pub const ALSATIAN = 0x84; +pub const AMHARIC = 0x5e; +pub const ARABIC = 0x01; +pub const ARMENIAN = 0x2b; +pub const ASSAMESE = 0x4d; +pub const AZERI = 0x2c; +pub const AZERBAIJANI = 0x2c; +pub const BANGLA = 0x45; +pub const BASHKIR = 0x6d; +pub const BASQUE = 0x2d; +pub const BELARUSIAN = 0x23; +pub const BENGALI = 0x45; +pub const BRETON = 0x7e; +pub const BOSNIAN = 0x1a; +pub const BOSNIAN_NEUTRAL = 0x781a; +pub const BULGARIAN = 0x02; +pub const CATALAN = 0x03; +pub const CENTRAL_KURDISH = 0x92; +pub const CHEROKEE = 0x5c; +pub const CHINESE = 0x04; +pub const CHINESE_SIMPLIFIED = 0x04; +pub const CHINESE_TRADITIONAL = 0x7c04; +pub const CORSICAN = 0x83; +pub const CROATIAN = 0x1a; +pub const CZECH = 0x05; +pub const DANISH = 0x06; +pub const DARI = 0x8c; +pub const DIVEHI = 0x65; +pub const DUTCH = 0x13; +pub const ENGLISH = 0x09; +pub const ESTONIAN = 0x25; +pub const FAEROESE = 0x38; +pub const FARSI = 0x29; +pub const FILIPINO = 0x64; +pub const FINNISH = 0x0b; +pub const FRENCH = 0x0c; +pub const FRISIAN = 0x62; +pub const FULAH = 0x67; +pub const GALICIAN = 0x56; +pub const GEORGIAN = 0x37; +pub const GERMAN = 0x07; +pub const GREEK = 0x08; +pub const GREENLANDIC = 0x6f; +pub const GUJARATI = 0x47; +pub const HAUSA = 0x68; +pub const HAWAIIAN = 0x75; +pub const HEBREW = 0x0d; +pub const HINDI = 0x39; +pub const HUNGARIAN = 0x0e; +pub const ICELANDIC = 0x0f; +pub const IGBO = 0x70; +pub const INDONESIAN = 0x21; +pub const INUKTITUT = 0x5d; +pub const IRISH = 0x3c; +pub const ITALIAN = 0x10; +pub const JAPANESE = 0x11; +pub const KANNADA = 0x4b; +pub const KASHMIRI = 0x60; +pub const KAZAK = 0x3f; +pub const KHMER = 0x53; +pub const KICHE = 0x86; +pub const KINYARWANDA = 0x87; +pub const KONKANI = 0x57; +pub const KOREAN = 0x12; +pub const KYRGYZ = 0x40; +pub const LAO = 0x54; +pub const LATVIAN = 0x26; +pub const LITHUANIAN = 0x27; +pub const LOWER_SORBIAN = 0x2e; +pub const LUXEMBOURGISH = 0x6e; +pub const MACEDONIAN = 0x2f; +pub const MALAY = 0x3e; +pub const MALAYALAM = 0x4c; +pub const MALTESE = 0x3a; +pub const MANIPURI = 0x58; +pub const MAORI = 0x81; +pub const MAPUDUNGUN = 0x7a; +pub const MARATHI = 0x4e; +pub const MOHAWK = 0x7c; +pub const MONGOLIAN = 0x50; +pub const NEPALI = 0x61; +pub const NORWEGIAN = 0x14; +pub const OCCITAN = 0x82; +pub const ODIA = 0x48; +pub const ORIYA = 0x48; +pub const PASHTO = 0x63; +pub const PERSIAN = 0x29; +pub const POLISH = 0x15; +pub const PORTUGUESE = 0x16; +pub const PULAR = 0x67; +pub const PUNJABI = 0x46; +pub const QUECHUA = 0x6b; +pub const ROMANIAN = 0x18; +pub const ROMANSH = 0x17; +pub const RUSSIAN = 0x19; +pub const SAKHA = 0x85; +pub const SAMI = 0x3b; +pub const SANSKRIT = 0x4f; +pub const SCOTTISH_GAELIC = 0x91; +pub const SERBIAN = 0x1a; +pub const SERBIAN_NEUTRAL = 0x7c1a; +pub const SINDHI = 0x59; +pub const SINHALESE = 0x5b; +pub const SLOVAK = 0x1b; +pub const SLOVENIAN = 0x24; +pub const SOTHO = 0x6c; +pub const SPANISH = 0x0a; +pub const SWAHILI = 0x41; +pub const SWEDISH = 0x1d; +pub const SYRIAC = 0x5a; +pub const TAJIK = 0x28; +pub const TAMAZIGHT = 0x5f; +pub const TAMIL = 0x49; +pub const TATAR = 0x44; +pub const TELUGU = 0x4a; +pub const THAI = 0x1e; +pub const TIBETAN = 0x51; +pub const TIGRIGNA = 0x73; +pub const TIGRINYA = 0x73; +pub const TSWANA = 0x32; +pub const TURKISH = 0x1f; +pub const TURKMEN = 0x42; +pub const UIGHUR = 0x80; +pub const UKRAINIAN = 0x22; +pub const UPPER_SORBIAN = 0x2e; +pub const URDU = 0x20; +pub const UZBEK = 0x43; +pub const VALENCIAN = 0x03; +pub const VIETNAMESE = 0x2a; +pub const WELSH = 0x52; +pub const WOLOF = 0x88; +pub const XHOSA = 0x34; +pub const YAKUT = 0x85; +pub const YI = 0x78; +pub const YORUBA = 0x6a; +pub const ZULU = 0x35; diff --git a/std/os/windows/ntdll.zig b/std/os/windows/ntdll.zig index 60c03ffc07..e5469cdcf9 100644 --- a/std/os/windows/ntdll.zig +++ b/std/os/windows/ntdll.zig @@ -1,3 +1,3 @@ -use @import("bits.zig"); +usingnamespace @import("bits.zig"); pub extern "NtDll" stdcallcc fn RtlCaptureStackBackTrace(FramesToSkip: DWORD, FramesToCapture: DWORD, BackTrace: **c_void, BackTraceHash: ?*DWORD) WORD; diff --git a/std/os/windows/ole32.zig b/std/os/windows/ole32.zig index 80f5bebc36..39c12d074c 100644 --- a/std/os/windows/ole32.zig +++ b/std/os/windows/ole32.zig @@ -1,4 +1,4 @@ -use @import("bits.zig"); +usingnamespace @import("bits.zig"); pub extern "ole32" stdcallcc fn CoTaskMemFree(pv: LPVOID) void; pub extern "ole32" stdcallcc fn CoUninitialize() void; diff --git a/std/os/windows/shell32.zig b/std/os/windows/shell32.zig index 9f24acc5c4..c178997aad 100644 --- a/std/os/windows/shell32.zig +++ b/std/os/windows/shell32.zig @@ -1,3 +1,3 @@ -use @import("bits.zig"); +usingnamespace @import("bits.zig"); pub extern "shell32" stdcallcc fn SHGetKnownFolderPath(rfid: *const KNOWNFOLDERID, dwFlags: DWORD, hToken: ?HANDLE, ppszPath: *[*]WCHAR) HRESULT; diff --git a/std/os/windows/sublang.zig b/std/os/windows/sublang.zig new file mode 100644 index 0000000000..e9929c6d79 --- /dev/null +++ b/std/os/windows/sublang.zig @@ -0,0 +1,244 @@ +pub const NEUTRAL = 0x00; +pub const DEFAULT = 0x01; +pub const SYS_DEFAULT = 0x02; +pub const CUSTOM_DEFAULT = 0x03; +pub const CUSTOM_UNSPECIFIED = 0x04; +pub const UI_CUSTOM_DEFAULT = 0x05; +pub const AFRIKAANS_SOUTH_AFRICA = 0x01; +pub const ALBANIAN_ALBANIA = 0x01; +pub const ALSATIAN_FRANCE = 0x01; +pub const AMHARIC_ETHIOPIA = 0x01; +pub const ARABIC_SAUDI_ARABIA = 0x01; +pub const ARABIC_IRAQ = 0x02; +pub const ARABIC_EGYPT = 0x03; +pub const ARABIC_LIBYA = 0x04; +pub const ARABIC_ALGERIA = 0x05; +pub const ARABIC_MOROCCO = 0x06; +pub const ARABIC_TUNISIA = 0x07; +pub const ARABIC_OMAN = 0x08; +pub const ARABIC_YEMEN = 0x09; +pub const ARABIC_SYRIA = 0x0a; +pub const ARABIC_JORDAN = 0x0b; +pub const ARABIC_LEBANON = 0x0c; +pub const ARABIC_KUWAIT = 0x0d; +pub const ARABIC_UAE = 0x0e; +pub const ARABIC_BAHRAIN = 0x0f; +pub const ARABIC_QATAR = 0x10; +pub const ARMENIAN_ARMENIA = 0x01; +pub const ASSAMESE_INDIA = 0x01; +pub const AZERI_LATIN = 0x01; +pub const AZERI_CYRILLIC = 0x02; +pub const AZERBAIJANI_AZERBAIJAN_LATIN = 0x01; +pub const AZERBAIJANI_AZERBAIJAN_CYRILLIC = 0x02; +pub const BANGLA_INDIA = 0x01; +pub const BANGLA_BANGLADESH = 0x02; +pub const BASHKIR_RUSSIA = 0x01; +pub const BASQUE_BASQUE = 0x01; +pub const BELARUSIAN_BELARUS = 0x01; +pub const BENGALI_INDIA = 0x01; +pub const BENGALI_BANGLADESH = 0x02; +pub const BOSNIAN_BOSNIA_HERZEGOVINA_LATIN = 0x05; +pub const BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC = 0x08; +pub const BRETON_FRANCE = 0x01; +pub const BULGARIAN_BULGARIA = 0x01; +pub const CATALAN_CATALAN = 0x01; +pub const CENTRAL_KURDISH_IRAQ = 0x01; +pub const CHEROKEE_CHEROKEE = 0x01; +pub const CHINESE_TRADITIONAL = 0x01; +pub const CHINESE_SIMPLIFIED = 0x02; +pub const CHINESE_HONGKONG = 0x03; +pub const CHINESE_SINGAPORE = 0x04; +pub const CHINESE_MACAU = 0x05; +pub const CORSICAN_FRANCE = 0x01; +pub const CZECH_CZECH_REPUBLIC = 0x01; +pub const CROATIAN_CROATIA = 0x01; +pub const CROATIAN_BOSNIA_HERZEGOVINA_LATIN = 0x04; +pub const DANISH_DENMARK = 0x01; +pub const DARI_AFGHANISTAN = 0x01; +pub const DIVEHI_MALDIVES = 0x01; +pub const DUTCH = 0x01; +pub const DUTCH_BELGIAN = 0x02; +pub const ENGLISH_US = 0x01; +pub const ENGLISH_UK = 0x02; +pub const ENGLISH_AUS = 0x03; +pub const ENGLISH_CAN = 0x04; +pub const ENGLISH_NZ = 0x05; +pub const ENGLISH_EIRE = 0x06; +pub const ENGLISH_SOUTH_AFRICA = 0x07; +pub const ENGLISH_JAMAICA = 0x08; +pub const ENGLISH_CARIBBEAN = 0x09; +pub const ENGLISH_BELIZE = 0x0a; +pub const ENGLISH_TRINIDAD = 0x0b; +pub const ENGLISH_ZIMBABWE = 0x0c; +pub const ENGLISH_PHILIPPINES = 0x0d; +pub const ENGLISH_INDIA = 0x10; +pub const ENGLISH_MALAYSIA = 0x11; +pub const ENGLISH_SINGAPORE = 0x12; +pub const ESTONIAN_ESTONIA = 0x01; +pub const FAEROESE_FAROE_ISLANDS = 0x01; +pub const FILIPINO_PHILIPPINES = 0x01; +pub const FINNISH_FINLAND = 0x01; +pub const FRENCH = 0x01; +pub const FRENCH_BELGIAN = 0x02; +pub const FRENCH_CANADIAN = 0x03; +pub const FRENCH_SWISS = 0x04; +pub const FRENCH_LUXEMBOURG = 0x05; +pub const FRENCH_MONACO = 0x06; +pub const FRISIAN_NETHERLANDS = 0x01; +pub const FULAH_SENEGAL = 0x02; +pub const GALICIAN_GALICIAN = 0x01; +pub const GEORGIAN_GEORGIA = 0x01; +pub const GERMAN = 0x01; +pub const GERMAN_SWISS = 0x02; +pub const GERMAN_AUSTRIAN = 0x03; +pub const GERMAN_LUXEMBOURG = 0x04; +pub const GERMAN_LIECHTENSTEIN = 0x05; +pub const GREEK_GREECE = 0x01; +pub const GREENLANDIC_GREENLAND = 0x01; +pub const GUJARATI_INDIA = 0x01; +pub const HAUSA_NIGERIA_LATIN = 0x01; +pub const HAWAIIAN_US = 0x01; +pub const HEBREW_ISRAEL = 0x01; +pub const HINDI_INDIA = 0x01; +pub const HUNGARIAN_HUNGARY = 0x01; +pub const ICELANDIC_ICELAND = 0x01; +pub const IGBO_NIGERIA = 0x01; +pub const INDONESIAN_INDONESIA = 0x01; +pub const INUKTITUT_CANADA = 0x01; +pub const INUKTITUT_CANADA_LATIN = 0x02; +pub const IRISH_IRELAND = 0x02; +pub const ITALIAN = 0x01; +pub const ITALIAN_SWISS = 0x02; +pub const JAPANESE_JAPAN = 0x01; +pub const KANNADA_INDIA = 0x01; +pub const KASHMIRI_SASIA = 0x02; +pub const KASHMIRI_INDIA = 0x02; +pub const KAZAK_KAZAKHSTAN = 0x01; +pub const KHMER_CAMBODIA = 0x01; +pub const KICHE_GUATEMALA = 0x01; +pub const KINYARWANDA_RWANDA = 0x01; +pub const KONKANI_INDIA = 0x01; +pub const KOREAN = 0x01; +pub const KYRGYZ_KYRGYZSTAN = 0x01; +pub const LAO_LAO = 0x01; +pub const LATVIAN_LATVIA = 0x01; +pub const LITHUANIAN = 0x01; +pub const LOWER_SORBIAN_GERMANY = 0x02; +pub const LUXEMBOURGISH_LUXEMBOURG = 0x01; +pub const MACEDONIAN_MACEDONIA = 0x01; +pub const MALAY_MALAYSIA = 0x01; +pub const MALAY_BRUNEI_DARUSSALAM = 0x02; +pub const MALAYALAM_INDIA = 0x01; +pub const MALTESE_MALTA = 0x01; +pub const MAORI_NEW_ZEALAND = 0x01; +pub const MAPUDUNGUN_CHILE = 0x01; +pub const MARATHI_INDIA = 0x01; +pub const MOHAWK_MOHAWK = 0x01; +pub const MONGOLIAN_CYRILLIC_MONGOLIA = 0x01; +pub const MONGOLIAN_PRC = 0x02; +pub const NEPALI_INDIA = 0x02; +pub const NEPALI_NEPAL = 0x01; +pub const NORWEGIAN_BOKMAL = 0x01; +pub const NORWEGIAN_NYNORSK = 0x02; +pub const OCCITAN_FRANCE = 0x01; +pub const ODIA_INDIA = 0x01; +pub const ORIYA_INDIA = 0x01; +pub const PASHTO_AFGHANISTAN = 0x01; +pub const PERSIAN_IRAN = 0x01; +pub const POLISH_POLAND = 0x01; +pub const PORTUGUESE = 0x02; +pub const PORTUGUESE_BRAZILIAN = 0x01; +pub const PULAR_SENEGAL = 0x02; +pub const PUNJABI_INDIA = 0x01; +pub const PUNJABI_PAKISTAN = 0x02; +pub const QUECHUA_BOLIVIA = 0x01; +pub const QUECHUA_ECUADOR = 0x02; +pub const QUECHUA_PERU = 0x03; +pub const ROMANIAN_ROMANIA = 0x01; +pub const ROMANSH_SWITZERLAND = 0x01; +pub const RUSSIAN_RUSSIA = 0x01; +pub const SAKHA_RUSSIA = 0x01; +pub const SAMI_NORTHERN_NORWAY = 0x01; +pub const SAMI_NORTHERN_SWEDEN = 0x02; +pub const SAMI_NORTHERN_FINLAND = 0x03; +pub const SAMI_LULE_NORWAY = 0x04; +pub const SAMI_LULE_SWEDEN = 0x05; +pub const SAMI_SOUTHERN_NORWAY = 0x06; +pub const SAMI_SOUTHERN_SWEDEN = 0x07; +pub const SAMI_SKOLT_FINLAND = 0x08; +pub const SAMI_INARI_FINLAND = 0x09; +pub const SANSKRIT_INDIA = 0x01; +pub const SCOTTISH_GAELIC = 0x01; +pub const SERBIAN_BOSNIA_HERZEGOVINA_LATIN = 0x06; +pub const SERBIAN_BOSNIA_HERZEGOVINA_CYRILLIC = 0x07; +pub const SERBIAN_MONTENEGRO_LATIN = 0x0b; +pub const SERBIAN_MONTENEGRO_CYRILLIC = 0x0c; +pub const SERBIAN_SERBIA_LATIN = 0x09; +pub const SERBIAN_SERBIA_CYRILLIC = 0x0a; +pub const SERBIAN_CROATIA = 0x01; +pub const SERBIAN_LATIN = 0x02; +pub const SERBIAN_CYRILLIC = 0x03; +pub const SINDHI_INDIA = 0x01; +pub const SINDHI_PAKISTAN = 0x02; +pub const SINDHI_AFGHANISTAN = 0x02; +pub const SINHALESE_SRI_LANKA = 0x01; +pub const SOTHO_NORTHERN_SOUTH_AFRICA = 0x01; +pub const SLOVAK_SLOVAKIA = 0x01; +pub const SLOVENIAN_SLOVENIA = 0x01; +pub const SPANISH = 0x01; +pub const SPANISH_MEXICAN = 0x02; +pub const SPANISH_MODERN = 0x03; +pub const SPANISH_GUATEMALA = 0x04; +pub const SPANISH_COSTA_RICA = 0x05; +pub const SPANISH_PANAMA = 0x06; +pub const SPANISH_DOMINICAN_REPUBLIC = 0x07; +pub const SPANISH_VENEZUELA = 0x08; +pub const SPANISH_COLOMBIA = 0x09; +pub const SPANISH_PERU = 0x0a; +pub const SPANISH_ARGENTINA = 0x0b; +pub const SPANISH_ECUADOR = 0x0c; +pub const SPANISH_CHILE = 0x0d; +pub const SPANISH_URUGUAY = 0x0e; +pub const SPANISH_PARAGUAY = 0x0f; +pub const SPANISH_BOLIVIA = 0x10; +pub const SPANISH_EL_SALVADOR = 0x11; +pub const SPANISH_HONDURAS = 0x12; +pub const SPANISH_NICARAGUA = 0x13; +pub const SPANISH_PUERTO_RICO = 0x14; +pub const SPANISH_US = 0x15; +pub const SWAHILI_KENYA = 0x01; +pub const SWEDISH = 0x01; +pub const SWEDISH_FINLAND = 0x02; +pub const SYRIAC_SYRIA = 0x01; +pub const TAJIK_TAJIKISTAN = 0x01; +pub const TAMAZIGHT_ALGERIA_LATIN = 0x02; +pub const TAMAZIGHT_MOROCCO_TIFINAGH = 0x04; +pub const TAMIL_INDIA = 0x01; +pub const TAMIL_SRI_LANKA = 0x02; +pub const TATAR_RUSSIA = 0x01; +pub const TELUGU_INDIA = 0x01; +pub const THAI_THAILAND = 0x01; +pub const TIBETAN_PRC = 0x01; +pub const TIGRIGNA_ERITREA = 0x02; +pub const TIGRINYA_ERITREA = 0x02; +pub const TIGRINYA_ETHIOPIA = 0x01; +pub const TSWANA_BOTSWANA = 0x02; +pub const TSWANA_SOUTH_AFRICA = 0x01; +pub const TURKISH_TURKEY = 0x01; +pub const TURKMEN_TURKMENISTAN = 0x01; +pub const UIGHUR_PRC = 0x01; +pub const UKRAINIAN_UKRAINE = 0x01; +pub const UPPER_SORBIAN_GERMANY = 0x01; +pub const URDU_PAKISTAN = 0x01; +pub const URDU_INDIA = 0x02; +pub const UZBEK_LATIN = 0x01; +pub const UZBEK_CYRILLIC = 0x02; +pub const VALENCIAN_VALENCIA = 0x02; +pub const VIETNAMESE_VIETNAM = 0x01; +pub const WELSH_UNITED_KINGDOM = 0x01; +pub const WOLOF_SENEGAL = 0x01; +pub const XHOSA_SOUTH_AFRICA = 0x01; +pub const YAKUT_RUSSIA = 0x01; +pub const YI_PRC = 0x01; +pub const YORUBA_NIGERIA = 0x01; +pub const ZULU_SOUTH_AFRICA = 0x01; diff --git a/std/os/zen.zig b/std/os/zen.zig index 8d2f963486..727f55fa6d 100644 --- a/std/os/zen.zig +++ b/std/os/zen.zig @@ -80,7 +80,7 @@ pub const STDOUT_FILENO = 1; pub const STDERR_FILENO = 2; // FIXME: let's borrow Linux's error numbers for now. -use @import("bits/linux/errno.zig"); +usingnamespace @import("bits/linux/errno.zig"); // Get the errno from a syscall return value, or 0 for no error. pub fn getErrno(r: usize) usize { const signed_r = @bitCast(isize, r); |
