mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 09:02:32 +00:00
a9b68308b9
- cbe: Implement linksection support, to support TLS when not linking libc - cbe: Support under-aligned variables / struct fields - cbe: Support packed structs (in the C definition of packed) - windows: Fix regression with x86 _tls_array - compiler_rt: Add 128-bit atomics to compiler_rt - tests: Re-enable threadlocal tests on cbe+windows, and llvm+x86 - tests: Re-enable f80 tests that now pass - ci: change windows ci to run the CBE behaviour tests with -lc, to match how the compiler is bootstrapped - update zig1.wasm
49 lines
1.8 KiB
Zig
49 lines
1.8 KiB
Zig
const std = @import("std");
|
|
const builtin = @import("builtin");
|
|
|
|
export var _tls_index: u32 = std.os.windows.TLS_OUT_OF_INDEXES;
|
|
export var _tls_start: u8 linksection(".tls") = 0;
|
|
export var _tls_end: u8 linksection(".tls$ZZZ") = 0;
|
|
export var __xl_a: std.os.windows.PIMAGE_TLS_CALLBACK linksection(".CRT$XLA") = null;
|
|
export var __xl_z: std.os.windows.PIMAGE_TLS_CALLBACK linksection(".CRT$XLZ") = null;
|
|
|
|
comptime {
|
|
if (builtin.target.cpu.arch == .x86 and builtin.zig_backend != .stage2_c) {
|
|
// The __tls_array is the offset of the ThreadLocalStoragePointer field
|
|
// in the TEB block whose base address held in the %fs segment.
|
|
asm (
|
|
\\ .global __tls_array
|
|
\\ __tls_array = 0x2C
|
|
);
|
|
}
|
|
}
|
|
|
|
// TODO this is how I would like it to be expressed
|
|
// TODO also note, ReactOS has a +1 on StartAddressOfRawData and AddressOfCallBacks. Investigate
|
|
// why they do that.
|
|
//export const _tls_used linksection(".rdata$T") = std.os.windows.IMAGE_TLS_DIRECTORY {
|
|
// .StartAddressOfRawData = @ptrToInt(&_tls_start),
|
|
// .EndAddressOfRawData = @ptrToInt(&_tls_end),
|
|
// .AddressOfIndex = @ptrToInt(&_tls_index),
|
|
// .AddressOfCallBacks = @ptrToInt(__xl_a),
|
|
// .SizeOfZeroFill = 0,
|
|
// .Characteristics = 0,
|
|
//};
|
|
// This is the workaround because we can't do @ptrToInt at comptime like that.
|
|
pub const IMAGE_TLS_DIRECTORY = extern struct {
|
|
StartAddressOfRawData: *anyopaque,
|
|
EndAddressOfRawData: *anyopaque,
|
|
AddressOfIndex: *anyopaque,
|
|
AddressOfCallBacks: *anyopaque,
|
|
SizeOfZeroFill: u32,
|
|
Characteristics: u32,
|
|
};
|
|
export const _tls_used linksection(".rdata$T") = IMAGE_TLS_DIRECTORY{
|
|
.StartAddressOfRawData = &_tls_start,
|
|
.EndAddressOfRawData = &_tls_end,
|
|
.AddressOfIndex = &_tls_index,
|
|
.AddressOfCallBacks = @ptrCast(*anyopaque, &__xl_a),
|
|
.SizeOfZeroFill = 0,
|
|
.Characteristics = 0,
|
|
};
|