diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-01-02 16:11:17 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-02 16:11:17 -0500 |
| commit | 4c1007fc044689b8cbc20634d73debb43df8efe1 (patch) | |
| tree | 967e4bd30091e0d28816febe1c9fea1b761b9a94 /lib/std/os | |
| parent | 4172c2916684655a9742de99384be8110922ed07 (diff) | |
| parent | 23b1544f6c17dd1111ba8791189a7290581f945e (diff) | |
| download | zig-4c1007fc044689b8cbc20634d73debb43df8efe1.tar.gz zig-4c1007fc044689b8cbc20634d73debb43df8efe1.zip | |
Merge pull request #14002 from kcbanner/cbe_msvc_compatibility
CBE: MSVC-compatible code generation, and fixes to get behaviour tests passing and zig2.c building
Diffstat (limited to 'lib/std/os')
| -rw-r--r-- | lib/std/os/windows.zig | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/lib/std/os/windows.zig b/lib/std/os/windows.zig index f261b9cae1..2a4d0d9a9b 100644 --- a/lib/std/os/windows.zig +++ b/lib/std/os/windows.zig @@ -1776,16 +1776,26 @@ pub fn UnlockFile( } } +/// This is a workaround for the C backend until zig has the ability to put +/// C code in inline assembly. +extern fn zig_x86_64_windows_teb() callconv(.C) *anyopaque; + pub fn teb() *TEB { return switch (native_arch) { .x86 => asm volatile ( \\ movl %%fs:0x18, %[ptr] : [ptr] "=r" (-> *TEB), ), - .x86_64 => asm volatile ( - \\ movq %%gs:0x30, %[ptr] - : [ptr] "=r" (-> *TEB), - ), + .x86_64 => blk: { + if (builtin.zig_backend == .stage2_c) { + break :blk @ptrCast(*TEB, @alignCast(@alignOf(TEB), zig_x86_64_windows_teb())); + } else { + break :blk asm volatile ( + \\ movq %%gs:0x30, %[ptr] + : [ptr] "=r" (-> *TEB), + ); + } + }, .aarch64 => asm volatile ( \\ mov %[ptr], x18 : [ptr] "=r" (-> *TEB), @@ -3455,6 +3465,21 @@ pub const ASSEMBLY_STORAGE_MAP = opaque {}; pub const FLS_CALLBACK_INFO = opaque {}; pub const RTL_BITMAP = opaque {}; pub const KAFFINITY = usize; +pub const KPRIORITY = i32; + +pub const CLIENT_ID = extern struct { + UniqueProcess: HANDLE, + UniqueThread: HANDLE, +}; + +pub const THREAD_BASIC_INFORMATION = extern struct { + ExitStatus: NTSTATUS, + TebBaseAddress: PVOID, + ClientId: CLIENT_ID, + AffinityMask: KAFFINITY, + Priority: KPRIORITY, + BasePriority: KPRIORITY, +}; pub const TEB = extern struct { Reserved1: [12]PVOID, |
