mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
std.os.windows: avoid dragging in baggage on non-windows
particularly noticeable when usize is not 4 or 8 bytes
This commit is contained in:
parent
ec36e0609f
commit
fc23fe90ce
1 changed files with 22 additions and 19 deletions
|
|
@ -4621,25 +4621,28 @@ pub const TEB = extern struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
comptime {
|
comptime {
|
||||||
// Offsets taken from WinDbg info and Geoff Chappell[1] (RIP)
|
// This file may be referenced for its error sets, so we must not assume target windows here.
|
||||||
// [1]: https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/api/pebteb/teb/index.htm
|
if (builtin.os.tag == .windows) {
|
||||||
assert(@offsetOf(TEB, "NtTib") == 0x00);
|
// Offsets taken from WinDbg info and Geoff Chappell[1] (RIP)
|
||||||
if (@sizeOf(usize) == 4) {
|
// [1]: https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/api/pebteb/teb/index.htm
|
||||||
assert(@offsetOf(TEB, "EnvironmentPointer") == 0x1C);
|
assert(@offsetOf(TEB, "NtTib") == 0x00);
|
||||||
assert(@offsetOf(TEB, "ClientId") == 0x20);
|
if (@sizeOf(usize) == 4) {
|
||||||
assert(@offsetOf(TEB, "ActiveRpcHandle") == 0x28);
|
assert(@offsetOf(TEB, "EnvironmentPointer") == 0x1C);
|
||||||
assert(@offsetOf(TEB, "ThreadLocalStoragePointer") == 0x2C);
|
assert(@offsetOf(TEB, "ClientId") == 0x20);
|
||||||
assert(@offsetOf(TEB, "ProcessEnvironmentBlock") == 0x30);
|
assert(@offsetOf(TEB, "ActiveRpcHandle") == 0x28);
|
||||||
assert(@offsetOf(TEB, "LastErrorValue") == 0x34);
|
assert(@offsetOf(TEB, "ThreadLocalStoragePointer") == 0x2C);
|
||||||
assert(@offsetOf(TEB, "TlsSlots") == 0xe10);
|
assert(@offsetOf(TEB, "ProcessEnvironmentBlock") == 0x30);
|
||||||
} else if (@sizeOf(usize) == 8) {
|
assert(@offsetOf(TEB, "LastErrorValue") == 0x34);
|
||||||
assert(@offsetOf(TEB, "EnvironmentPointer") == 0x38);
|
assert(@offsetOf(TEB, "TlsSlots") == 0xe10);
|
||||||
assert(@offsetOf(TEB, "ClientId") == 0x40);
|
} else if (@sizeOf(usize) == 8) {
|
||||||
assert(@offsetOf(TEB, "ActiveRpcHandle") == 0x50);
|
assert(@offsetOf(TEB, "EnvironmentPointer") == 0x38);
|
||||||
assert(@offsetOf(TEB, "ThreadLocalStoragePointer") == 0x58);
|
assert(@offsetOf(TEB, "ClientId") == 0x40);
|
||||||
assert(@offsetOf(TEB, "ProcessEnvironmentBlock") == 0x60);
|
assert(@offsetOf(TEB, "ActiveRpcHandle") == 0x50);
|
||||||
assert(@offsetOf(TEB, "LastErrorValue") == 0x68);
|
assert(@offsetOf(TEB, "ThreadLocalStoragePointer") == 0x58);
|
||||||
assert(@offsetOf(TEB, "TlsSlots") == 0x1480);
|
assert(@offsetOf(TEB, "ProcessEnvironmentBlock") == 0x60);
|
||||||
|
assert(@offsetOf(TEB, "LastErrorValue") == 0x68);
|
||||||
|
assert(@offsetOf(TEB, "TlsSlots") == 0x1480);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue