| author | |
| committer | |
| log | caa008505729f9511f6f0b070636013e9597b3f7 |
| tree | 976dcc5d0c2c5bb4a51bbf5636f1ef489dbe5219 |
| parent | a0c564d7621c1bf3f83be59d6f91056b0cfe1e16 |
4 files changed, 31 insertions(+), 2 deletions(-)
std/event.zig+3| ... | ... | @@ -142,6 +142,9 @@ pub const Loop = struct { |
| 142 | 142 | epoll_op: u32, |
| 143 | 143 | eventfd: i32, |
| 144 | 144 | }, |
| 145 | builtin.Os.windows => struct { | |
| 146 | base: ResumeNode, | |
| 147 | }, | |
| 145 | 148 | else => @compileError("unsupported OS"), |
| 146 | 149 | }; |
| 147 | 150 |
std/heap.zig+2-2| ... | ... | @@ -96,12 +96,12 @@ pub const DirectAllocator = struct { |
| 96 | 96 | }, |
| 97 | 97 | Os.windows => { |
| 98 | 98 | const amt = n + alignment + @sizeOf(usize); |
| 99 | const optional_heap_handle = @atomicLoad(?HeapHandle, ?self.heap_handle, builtin.AtomicOrder.SeqCst); | |
| 99 | const optional_heap_handle = @atomicLoad(?HeapHandle, &self.heap_handle, builtin.AtomicOrder.SeqCst); | |
| 100 | 100 | const heap_handle = optional_heap_handle orelse blk: { |
| 101 | 101 | const hh = os.windows.HeapCreate(os.windows.HEAP_NO_SERIALIZE, amt, 0) orelse return error.OutOfMemory; |
| 102 | 102 | const other_hh = @cmpxchgStrong(?HeapHandle, &self.heap_handle, null, hh, builtin.AtomicOrder.SeqCst, builtin.AtomicOrder.SeqCst) orelse break :blk hh; |
| 103 | 103 | _ = os.windows.HeapDestroy(hh); |
| 104 | break :blk other_hh; | |
| 104 | break :blk other_hh.?; // can't be null because of the cmpxchg | |
| 105 | 105 | }; |
| 106 | 106 | const ptr = os.windows.HeapAlloc(heap_handle, 0, amt) orelse return error.OutOfMemory; |
| 107 | 107 | const root_addr = @ptrToInt(ptr); |
std/os/index.zig+5| ... | ... | @@ -2806,6 +2806,11 @@ pub fn cpuCount(fallback_allocator: *mem.Allocator) CpuCountError!usize { |
| 2806 | 2806 | } |
| 2807 | 2807 | } |
| 2808 | 2808 | }, |
| 2809 | builtin.Os.windows => { | |
| 2810 | var system_info: windows.SYSTEM_INFO = undefined; | |
| 2811 | windows.GetSystemInfo(&system_info); | |
| 2812 | return @intCast(usize, system_info.dwNumberOfProcessors); | |
| 2813 | }, | |
| 2809 | 2814 | else => @compileError("unsupported OS"), |
| 2810 | 2815 | } |
| 2811 | 2816 | } |
std/os/windows/index.zig+21| ... | ... | @@ -107,6 +107,7 @@ pub extern "kernel32" stdcallcc fn GetFinalPathNameByHandleA( |
| 107 | 107 | |
| 108 | 108 | pub extern "kernel32" stdcallcc fn GetProcessHeap() ?HANDLE; |
| 109 | 109 | |
| 110 | pub extern "kernel32" stdcallcc fn GetSystemInfo(lpSystemInfo: *SYSTEM_INFO) void; | |
| 110 | 111 | pub extern "kernel32" stdcallcc fn GetSystemTimeAsFileTime(*FILETIME) void; |
| 111 | 112 | |
| 112 | 113 | pub extern "kernel32" stdcallcc fn HeapCreate(flOptions: DWORD, dwInitialSize: SIZE_T, dwMaximumSize: SIZE_T) ?HANDLE; |
| ... | ... | @@ -204,6 +205,7 @@ pub const SIZE_T = usize; |
| 204 | 205 | pub const TCHAR = if (UNICODE) WCHAR else u8; |
| 205 | 206 | pub const UINT = c_uint; |
| 206 | 207 | pub const ULONG_PTR = usize; |
| 208 | pub const DWORD_PTR = ULONG_PTR; | |
| 207 | 209 | pub const UNICODE = false; |
| 208 | 210 | pub const WCHAR = u16; |
| 209 | 211 | pub const WORD = u16; |
| ... | ... | @@ -413,3 +415,22 @@ pub const FILETIME = extern struct { |
| 413 | 415 | dwLowDateTime: DWORD, |
| 414 | 416 | dwHighDateTime: DWORD, |
| 415 | 417 | }; |
| 418 | ||
| 419 | pub const SYSTEM_INFO = extern struct { | |
| 420 | anon1: extern union { | |
| 421 | dwOemId: DWORD, | |
| 422 | anon2: extern struct { | |
| 423 | wProcessorArchitecture: WORD, | |
| 424 | wReserved: WORD, | |
| 425 | }, | |
| 426 | }, | |
| 427 | dwPageSize: DWORD, | |
| 428 | lpMinimumApplicationAddress: LPVOID, | |
| 429 | lpMaximumApplicationAddress: LPVOID, | |
| 430 | dwActiveProcessorMask: DWORD_PTR, | |
| 431 | dwNumberOfProcessors: DWORD, | |
| 432 | dwProcessorType: DWORD, | |
| 433 | dwAllocationGranularity: DWORD, | |
| 434 | wProcessorLevel: WORD, | |
| 435 | wProcessorRevision: WORD, | |
| 436 | }; |