aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-01-02 16:11:17 -0500
committerGitHub <noreply@github.com>2023-01-02 16:11:17 -0500
commit4c1007fc044689b8cbc20634d73debb43df8efe1 (patch)
tree967e4bd30091e0d28816febe1c9fea1b761b9a94 /lib/std/os
parent4172c2916684655a9742de99384be8110922ed07 (diff)
parent23b1544f6c17dd1111ba8791189a7290581f945e (diff)
downloadzig-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.zig33
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,