Commit: 40828a532e3a9b43d257cee0d73acba51dff37b7
Parent: 84a0929c638a45db0d27910d291a68bae52d2492
Author: Randy Palamar
Date:   Sun, 25 May 2025 16:47:59 -0600
cleanup w32 compilation problems
Diffstat:
3 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/build.c b/build.c
@@ -195,7 +195,8 @@ enum {
 };
 
 W32(b32) CreateProcessA(u8 *, u8 *, sptr, sptr, b32, u32, sptr, u8 *, sptr, sptr);
-W32(b32) GetExitCodeProcess(iptr handle, u32 *);
+W32(b32) DeleteFileA(c8 *);
+W32(b32) GetExitCodeProcess(sptr handle, u32 *);
 W32(b32) GetFileTime(sptr, sptr, sptr, sptr);
 W32(b32) MoveFileExA(c8 *, c8 *, u32);
 W32(u32) WaitForSingleObject(sptr, u32);
@@ -218,10 +219,10 @@ function u64
 os_get_filetime(char *file)
 {
 	u64 result = (u64)-1;
-	iptr h = CreateFileA(file, 0, 0, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
+	sptr h = CreateFileA(file, 0, 0, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
 	if (h != INVALID_FILE) {
 		struct { u32 low, high; } w32_filetime;
-		GetFileTime(h, 0, 0, (iptr)&w32_filetime);
+		GetFileTime(h, 0, 0, (sptr)&w32_filetime);
 		result = (u64)w32_filetime.high << 32ULL | w32_filetime.low;
 		CloseHandle(h);
 	}
@@ -248,7 +249,7 @@ os_spawn_process(CommandList *cmd, Stream sb)
 	};
 
 	struct {
-		iptr phandle, thandle;
+		sptr phandle, thandle;
 		u32  pid, tid;
 	} w32_process_info = {0};
 
@@ -257,9 +258,9 @@ os_spawn_process(CommandList *cmd, Stream sb)
 	if (sb.widx < sb.cap) sb.data[sb.widx]     = 0;
 	else                  sb.data[sb.widx - 1] = 0;
 
-	iptr result = INVALID_FILE;
-	if (CreateProcessA(0, sb.data, 0, 0, 1, 0, 0, 0, (iptr)&w32_startup_info,
-	                   (iptr)&w32_process_info))
+	sptr result = INVALID_FILE;
+	if (CreateProcessA(0, sb.data, 0, 0, 1, 0, 0, 0, (sptr)&w32_startup_info,
+	                   (sptr)&w32_process_info))
 	{
 		CloseHandle(w32_process_info.thandle);
 		result = w32_process_info.phandle;
@@ -268,7 +269,7 @@ os_spawn_process(CommandList *cmd, Stream sb)
 }
 
 function b32
-os_wait_close_process(iptr handle)
+os_wait_close_process(sptr handle)
 {
 	b32 result = WaitForSingleObject(handle, -1) != 0xFFFFFFFFUL;
 	if (result) {
@@ -319,6 +320,7 @@ check_rebuild_self(Arena arena, s32 argc, char *argv[])
 
 		CommandList c = {0};
 		cmd_append(&arena, &c, COMPILER, "-march=native", "-O3", COMMON_FLAGS);
+		if (is_w32 && is_clang) cmd_append(&arena, &c, "-fms-extensions");
 		cmd_append(&arena, &c, "-Wno-unused-function", __FILE__, "-o", binary, (void *)0);
 		if (!run_synchronous(arena, &c)) {
 			os_rename_file(old_name, binary);
@@ -439,7 +441,7 @@ main(s32 argc, char *argv[])
 
 	CommandList c = cmd_base(&arena, &options);
 	if (is_unix) cmd_append(&arena, &c, "-D_GLFW_X11");
-	cmd_append(&arena, &c,  "-I external/include", "-I external/glfw/include");
+	cmd_append(&arena, &c, "-Iexternal/glfw/include");
 
 	cmd_append(&arena, &c, OS_MAIN, "external/rglfw.c", "-o", "volviewer");
 	cmd_append_ldflags(&arena, &c, options.debug);
diff --git a/main_w32.c b/main_w32.c
@@ -11,7 +11,7 @@
 function void
 dispatch_file_watch(OS *os, FileWatchDirectory *fw_dir, u8 *buf, Arena arena)
 {
-	i64 offset = 0;
+	s64 offset = 0;
 	Arena start_arena = arena;
 	w32_file_notify_info *fni = (w32_file_notify_info *)buf;
 	do {
@@ -20,10 +20,10 @@ dispatch_file_watch(OS *os, FileWatchDirectory *fw_dir, u8 *buf, Arena arena)
 		Stream path = {.data = arena_commit(&arena, KB(1)), .cap = KB(1)};
 
 		if (fni->action != FILE_ACTION_MODIFIED) {
-			stream_append_s8(&path, s8("unknown file watch event: "));
+			stream_append_str8(&path, str8("unknown file watch event: "));
 			stream_append_u64(&path, fni->action);
 			stream_append_byte(&path, '\n');
-			os->write_file(os->error_handle, stream_to_s8(&path));
+			os_write_file(os->error_handle, stream_to_str8(&path));
 			stream_reset(&path, 0);
 		}
 
@@ -55,7 +55,7 @@ clear_io_queue(OS *os, Arena arena)
 {
 	w32_context *ctx = (w32_context *)os->context;
 
-	iptr handle = ctx->io_completion_handle;
+	sptr handle = ctx->io_completion_handle;
 	w32_overlapped *overlapped;
 	u32  bytes_read;
 	uptr user_data;
@@ -74,7 +74,7 @@ clear_io_queue(OS *os, Arena arena)
 	}
 }
 
-extern i32
+extern s32
 main(void)
 {
 	Arena memory       = os_alloc_arena(GB(1));
diff --git a/os_win32.c b/os_win32.c
@@ -86,7 +86,7 @@ W32(sptr)   CreateFileA(c8 *, u32, u32, void *, u32, u32, void *);
 W32(sptr)   CreateFileMappingA(sptr, void *, u32, u32, u32, c8 *);
 W32(sptr)   CreateIoCompletionPort(sptr, sptr, uptr, u32);
 W32(sptr)   CreateThread(sptr, uz, sptr, sptr, u32, u32 *);
-W32(void)   ExitProcess(i32);
+W32(void)   ExitProcess(s32);
 W32(b32)    GetFileInformationByHandle(sptr, void *);
 W32(s32)    GetLastError(void);
 W32(b32)    GetQueuedCompletionStatus(sptr, u32 *, uptr *, w32_overlapped **, u32);
@@ -224,7 +224,8 @@ function OS_ADD_FILE_WATCH_FN(os_add_file_watch)
 		event->context = (sptr)dir;
 		CreateIoCompletionPort(dir->handle, ctx->io_completion_handle, (uptr)event, 0);
 
-		dir->buffer = sub_arena(a, 4096 + sizeof(w32_overlapped), 64);
+		dir->buffer.beg = arena_alloc(a, 4096 + sizeof(w32_overlapped), 64, 1);
+		dir->buffer.end = dir->buffer.beg + 4096 + sizeof(w32_overlapped);
 		w32_overlapped *overlapped = (w32_overlapped *)(dir->buffer.beg + 4096);
 		zero_struct(overlapped);