From 762895bc45f852e2c2554ade23e4399496f12f53 Mon Sep 17 00:00:00 2001 From: Josh Engler Date: Fri, 3 Jun 2022 07:40:45 -0400 Subject: [PATCH 01/22] - Added EnumDisplaySettingsW and friends. - Added additional file access/security/sharing attributes --- core/sys/windows/types.odin | 87 ++++++++++++++++++++++++++++++++---- core/sys/windows/user32.odin | 2 + 2 files changed, 80 insertions(+), 9 deletions(-) diff --git a/core/sys/windows/types.odin b/core/sys/windows/types.odin index a0649c5f3..2e04ec0f0 100644 --- a/core/sys/windows/types.odin +++ b/core/sys/windows/types.odin @@ -187,18 +187,33 @@ OPEN_ALWAYS: DWORD : 4 OPEN_EXISTING: DWORD : 3 TRUNCATE_EXISTING: DWORD : 5 +FILE_READ_DATA : DWORD : 0x00000001 +FILE_LIST_DIRECTORY : DWORD : 0x00000001 +FILE_WRITE_DATA : DWORD : 0x00000002 +FILE_ADD_FILE : DWORD : 0x00000002 +FILE_APPEND_DATA : DWORD : 0x00000004 +FILE_ADD_SUBDIRECTORY : DWORD : 0x00000004 +FILE_CREATE_PIPE_INSTANCE : DWORD : 0x00000004 +FILE_READ_EA : DWORD : 0x00000008 +FILE_WRITE_EA : DWORD : 0x00000010 +FILE_EXECUTE : DWORD : 0x00000020 +FILE_TRAVERSE : DWORD : 0x00000020 +FILE_DELETE_CHILD : DWORD : 0x00000040 +FILE_READ_ATTRIBUTES : DWORD : 0x00000080 +FILE_WRITE_ATTRIBUTES : DWORD : 0x00000100 - -FILE_WRITE_DATA: DWORD : 0x00000002 -FILE_APPEND_DATA: DWORD : 0x00000004 -FILE_WRITE_EA: DWORD : 0x00000010 -FILE_WRITE_ATTRIBUTES: DWORD : 0x00000100 -FILE_READ_ATTRIBUTES: DWORD : 0x000000080 READ_CONTROL: DWORD : 0x00020000 SYNCHRONIZE: DWORD : 0x00100000 -GENERIC_READ: DWORD : 0x80000000 -GENERIC_WRITE: DWORD : 0x40000000 -STANDARD_RIGHTS_WRITE: DWORD : READ_CONTROL + +GENERIC_READ : DWORD : 0x80000000 +GENERIC_WRITE : DWORD : 0x40000000 +GENERIC_EXECUTE : DWORD : 0x20000000 +GENERIC_ALL : DWORD : 0x10000000 + +STANDARD_RIGHTS_READ : DWORD : READ_CONTROL +STANDARD_RIGHTS_WRITE : DWORD : READ_CONTROL +STANDARD_RIGHTS_EXECUTE : DWORD : READ_CONTROL + FILE_GENERIC_WRITE: DWORD : STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES | @@ -244,6 +259,9 @@ DIAGNOSTIC_REASON_SIMPLE_STRING :: 0x00000001 DIAGNOSTIC_REASON_DETAILED_STRING :: 0x00000002 DIAGNOSTIC_REASON_NOT_SPECIFIED :: 0x80000000 +ENUM_CURRENT_SETTINGS : DWORD : 4294967295 // (DWORD)-1 +ENUM_REGISTRY_SETTINGS : DWORD : 4294967294 // (DWORD)-2 + // Defines for power request APIs POWER_REQUEST_CONTEXT_VERSION :: DIAGNOSTIC_REASON_VERSION @@ -414,6 +432,57 @@ CREATESTRUCTW:: struct { dwExStyle: DWORD, } +DEVMODEW :: struct { + dmDeviceName: [32]wchar_t, + dmSpecVersion: WORD, + dmDriverVersion: WORD, + dmSize: WORD, + dmDriverExtra: WORD, + dmFields: DWORD, + using _: struct #raw_union { + // Printer only fields. + using _: struct { + dmOrientation: c_short, + dmPaperSize: c_short, + dmPaperLength: c_short, + dmPaperWidth: c_short, + dmScale: c_short, + dmCopies: c_short, + dmDefaultSource: c_short, + dmPrintQuality: c_short, + }, + // Display only fields. + using _: struct { + dmPosition: POINT, + dmDisplayOrientation: DWORD, + dmDisplayFixedOutput: DWORD, + }, + }, + dmColor: c_short, + dmDuplex: c_short, + dmYResolution: c_short, + dmTTOption: c_short, + dmCollate: c_short, + dmFormName: [32]wchar_t, + dmLogPixels: WORD, + dmBitsPerPel: DWORD, + dmPelsWidth: DWORD, + dmPelsHeight: DWORD, + using _: struct #raw_union { + dmDisplayFlags: DWORD, + dmNup: DWORD, + }, + dmDisplayFrequency: DWORD, + dmICMMethod: DWORD, + dmICMIntent: DWORD, + dmMediaType: DWORD, + dmDitherType: DWORD, + dmReserved1: DWORD, + dmReserved2: DWORD, + dmPanningWidth: DWORD, + dmPanningHeight: DWORD, +} + // MessageBox() Flags MB_OK :: 0x00000000 MB_OKCANCEL :: 0x00000001 diff --git a/core/sys/windows/user32.odin b/core/sys/windows/user32.odin index 1b6d23ba4..4f31a2585 100644 --- a/core/sys/windows/user32.odin +++ b/core/sys/windows/user32.odin @@ -134,6 +134,8 @@ foreign user32 { GetCursorPos :: proc(lpPoint: LPPOINT) -> BOOL --- SetCursorPos :: proc(X: c_int, Y: c_int) -> BOOL --- SetCursor :: proc(hCursor: HCURSOR) -> HCURSOR --- + + EnumDisplaySettingsW :: proc(lpszDeviceName: LPCWSTR, iModeNum: DWORD, lpDevMode: ^DEVMODEW) -> BOOL --- } CreateWindowW :: #force_inline proc "stdcall" ( From 50cbb8a1fce5fb25ee2076d85c43845e1fdfacbc Mon Sep 17 00:00:00 2001 From: Josh Engler Date: Sun, 12 Jun 2022 15:55:38 -0400 Subject: [PATCH 02/22] Fix tab spacing. --- core/sys/windows/types.odin | 50 ++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/core/sys/windows/types.odin b/core/sys/windows/types.odin index 570969a78..ad2ab7b37 100644 --- a/core/sys/windows/types.odin +++ b/core/sys/windows/types.odin @@ -816,12 +816,12 @@ CREATESTRUCTW:: struct { } DEVMODEW :: struct { - dmDeviceName: [32]wchar_t, - dmSpecVersion: WORD, - dmDriverVersion: WORD, - dmSize: WORD, - dmDriverExtra: WORD, - dmFields: DWORD, + dmDeviceName: [32]wchar_t, + dmSpecVersion: WORD, + dmDriverVersion: WORD, + dmSize: WORD, + dmDriverExtra: WORD, + dmFields: DWORD, using _: struct #raw_union { // Printer only fields. using _: struct { @@ -841,29 +841,29 @@ DEVMODEW :: struct { dmDisplayFixedOutput: DWORD, }, }, - dmColor: c_short, - dmDuplex: c_short, - dmYResolution: c_short, - dmTTOption: c_short, - dmCollate: c_short, - dmFormName: [32]wchar_t, - dmLogPixels: WORD, - dmBitsPerPel: DWORD, - dmPelsWidth: DWORD, - dmPelsHeight: DWORD, + dmColor: c_short, + dmDuplex: c_short, + dmYResolution: c_short, + dmTTOption: c_short, + dmCollate: c_short, + dmFormName: [32]wchar_t, + dmLogPixels: WORD, + dmBitsPerPel: DWORD, + dmPelsWidth: DWORD, + dmPelsHeight: DWORD, using _: struct #raw_union { dmDisplayFlags: DWORD, dmNup: DWORD, }, - dmDisplayFrequency: DWORD, - dmICMMethod: DWORD, - dmICMIntent: DWORD, - dmMediaType: DWORD, - dmDitherType: DWORD, - dmReserved1: DWORD, - dmReserved2: DWORD, - dmPanningWidth: DWORD, - dmPanningHeight: DWORD, + dmDisplayFrequency: DWORD, + dmICMMethod: DWORD, + dmICMIntent: DWORD, + dmMediaType: DWORD, + dmDitherType: DWORD, + dmReserved1: DWORD, + dmReserved2: DWORD, + dmPanningWidth: DWORD, + dmPanningHeight: DWORD, } // MessageBox() Flags From 665db0f7780ed6c89736b91e164af61f694e6da9 Mon Sep 17 00:00:00 2001 From: hikari Date: Thu, 16 Jun 2022 22:54:59 +0300 Subject: [PATCH 03/22] sys/windows: add RegSetKeyValueW --- core/sys/windows/advapi32.odin | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/sys/windows/advapi32.odin b/core/sys/windows/advapi32.odin index ab2c6737f..82031d4f7 100644 --- a/core/sys/windows/advapi32.odin +++ b/core/sys/windows/advapi32.odin @@ -119,4 +119,13 @@ foreign advapi32 { lpData: ^BYTE, cbData: DWORD, ) -> LSTATUS --- + + RegSetKeyValueW :: proc( + hKey: HKEY, + lpSubKey: LPCWSTR, + lpValueName: LPCWSTR, + dwType: DWORD, + lpData: LPCVOID, + cbData: DWORD, + ) -> LSTATUS --- } From c6903fbcd5d56c08b73b3cb269758e791bedbd50 Mon Sep 17 00:00:00 2001 From: hikari Date: Fri, 17 Jun 2022 15:14:21 +0300 Subject: [PATCH 04/22] sys/windows: add constants and macro --- core/sys/windows/types.odin | 12 ++++++++++++ core/sys/windows/user32.odin | 6 +++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/core/sys/windows/types.odin b/core/sys/windows/types.odin index d79197532..1b5189b13 100644 --- a/core/sys/windows/types.odin +++ b/core/sys/windows/types.odin @@ -633,6 +633,18 @@ ES_READONLY :: 0x0800 ES_WANTRETURN :: 0x1000 ES_NUMBER :: 0x2000 +// Edit Control Notification Codes +EN_SETFOCUS :: 0x0100 +EN_KILLFOCUS :: 0x0200 +EN_CHANGE :: 0x0300 +EN_UPDATE :: 0x0400 +EN_ERRSPACE :: 0x0500 +EN_MAXTEXT :: 0x0501 +EN_HSCROLL :: 0x0601 +EN_VSCROLL :: 0x0602 +EN_ALIGN_LTR_EC :: 0x0700 +EN_ALIGN_RTL_EC :: 0x0701 + // Font Weights FW_DONTCARE :: 0 FW_THIN :: 100 diff --git a/core/sys/windows/user32.odin b/core/sys/windows/user32.odin index 9fe64a92c..6a4e75b7b 100644 --- a/core/sys/windows/user32.odin +++ b/core/sys/windows/user32.odin @@ -237,6 +237,10 @@ GET_NCHITTEST_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> c_s return cast(c_short)LOWORD(cast(DWORD)wParam) } -GET_XBUTTON_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> WORD { +GET_XBUTTON_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> WORD { return HIWORD(cast(DWORD)wParam) } + +MAKEINTRESOURCEW :: #force_inline proc "contextless" (#any_int i: int) -> LPWSTR { + return cast(LPWSTR)uintptr(WORD(i)) +} From d89c4606bd54f9c72405e22e4e8b0c510747b14f Mon Sep 17 00:00:00 2001 From: Luxko Date: Sun, 19 Jun 2022 19:06:31 +0800 Subject: [PATCH 05/22] Add missing field for `TEXTURE_COPY_LOCATION` Add missing anonymous union field for [D3D12_TEXTURE_COPY_LOCATION ](https://docs.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_texture_copy_location): ```C union { D3D12_PLACED_SUBRESOURCE_FOOTPRINT PlacedFootprint; UINT SubresourceIndex; }; ``` --- vendor/directx/d3d12/d3d12.odin | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vendor/directx/d3d12/d3d12.odin b/vendor/directx/d3d12/d3d12.odin index c61b6cfb5..6a7eed22b 100644 --- a/vendor/directx/d3d12/d3d12.odin +++ b/vendor/directx/d3d12/d3d12.odin @@ -1459,6 +1459,10 @@ TEXTURE_COPY_TYPE :: enum i32 { TEXTURE_COPY_LOCATION :: struct { pResource: ^IResource, Type: TEXTURE_COPY_TYPE, + using _: struct #raw_union { + PlacedFootprint: PLACED_SUBRESOURCE_FOOTPRINT, + SubresourceIndex: u32, + }, } RESOLVE_MODE :: enum i32 { From 33d96fd28a107d55aacba87a6ed91ce60c9c41b8 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 20 Jun 2022 16:00:17 +0100 Subject: [PATCH 06/22] Correct debug information of #simd vectors --- src/llvm_backend_debug.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/llvm_backend_debug.cpp b/src/llvm_backend_debug.cpp index b91f32bfc..45a868581 100644 --- a/src/llvm_backend_debug.cpp +++ b/src/llvm_backend_debug.cpp @@ -419,7 +419,18 @@ LLVMMetadataRef lb_debug_type_internal(lbModule *m, Type *type) { break; case Type_SimdVector: - return LLVMDIBuilderCreateVectorType(m->debug_builder, cast(unsigned)type->SimdVector.count, 8*cast(unsigned)type_align_of(type), lb_debug_type(m, type->SimdVector.elem), nullptr, 0); + { + LLVMMetadataRef elem = lb_debug_type(m, type->SimdVector.elem); + LLVMMetadataRef subscripts[1] = {}; + subscripts[0] = LLVMDIBuilderGetOrCreateSubrange(m->debug_builder, + 0ll, + type->SimdVector.count + ); + return LLVMDIBuilderCreateVectorType( + m->debug_builder, + 8*cast(unsigned)type_size_of(type), 8*cast(unsigned)type_align_of(type), + elem, subscripts, gb_count_of(subscripts)); + } case Type_RelativePointer: { LLVMMetadataRef base_integer = lb_debug_type(m, type->RelativePointer.base_integer); From 888913c739464a51fec621d8eaf65eedb0527143 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Tue, 21 Jun 2022 17:29:55 +0200 Subject: [PATCH 07/22] Add runtime.dll_forward_reason for Windows DLLs. --- core/runtime/core.odin | 13 +++++++++++++ core/runtime/entry_windows.odin | 14 +++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/core/runtime/core.odin b/core/runtime/core.odin index 73d1e6371..8fb3d7210 100644 --- a/core/runtime/core.odin +++ b/core/runtime/core.odin @@ -267,6 +267,19 @@ type_table: []Type_Info args__: []cstring +when ODIN_OS == .Windows { + // NOTE(Jeroen): If we're a Windows DLL, fwdReason will be populated. + // This tells a DLL if it's first loaded, about to be unloaded, or a thread is joining/exiting. + + DLL_Forward_Reason :: enum u32 { + Process_Detach = 0, // About to unload DLL + Process_Attach = 1, // Entry point + Thread_Attach = 2, + Thread_Detach = 3, + } + dll_forward_reason: DLL_Forward_Reason +} + // IMPORTANT NOTE(bill): Must be in this order (as the compiler relies upon it) diff --git a/core/runtime/entry_windows.odin b/core/runtime/entry_windows.odin index 2f323cb41..a315c1209 100644 --- a/core/runtime/entry_windows.odin +++ b/core/runtime/entry_windows.odin @@ -8,15 +8,19 @@ when ODIN_BUILD_MODE == .Dynamic { @(link_name="DllMain", linkage="strong", require) DllMain :: proc "stdcall" (hinstDLL: rawptr, fdwReason: u32, lpReserved: rawptr) -> b32 { context = default_context() - switch fdwReason { - case 1: // DLL_PROCESS_ATTACH + + // Populate Windows DLL-specific global + dll_forward_reason = DLL_Forward_Reason(fdwReason) + + switch dll_forward_reason { + case .Process_Attach: #force_no_inline _startup_runtime() intrinsics.__entry_point() - case 0: // DLL_PROCESS_DETACH + case .Process_Detach: #force_no_inline _cleanup_runtime() - case 2: // DLL_THREAD_ATTACH + case .Thread_Attach: break - case 3: // DLL_THREAD_DETACH + case .Thread_Detach: break } return true From 6ffe814ca710572d07ecc3b40870ec8ed6ff9375 Mon Sep 17 00:00:00 2001 From: Pablo Narvaja Date: Thu, 23 Jun 2022 18:13:34 -0300 Subject: [PATCH 08/22] assign package docs to file docs --- core/odin/parser/parser.odin | 1 + 1 file changed, 1 insertion(+) diff --git a/core/odin/parser/parser.odin b/core/odin/parser/parser.odin index 25eda6bed..52ecb4781 100644 --- a/core/odin/parser/parser.odin +++ b/core/odin/parser/parser.odin @@ -183,6 +183,7 @@ parse_file :: proc(p: ^Parser, file: ^ast.File) -> bool { pd.name = pkg_name.text pd.comment = p.line_comment p.file.pkg_decl = pd + p.file.docs = docs expect_semicolon(p, pd) From f8744d87b02f1db75010eb9856bdad9d31fa7b45 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Fri, 24 Jun 2022 15:12:15 +0100 Subject: [PATCH 09/22] Add shorthand flag to `determine_type_from_polymorphic` --- src/check_type.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/check_type.cpp b/src/check_type.cpp index fc5b7aed7..bc89a9be9 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -1240,7 +1240,7 @@ Type *determine_type_from_polymorphic(CheckerContext *ctx, Type *poly_type, Oper if (!is_operand_value(operand)) { if (show_error) { gbString pts = type_to_string(poly_type); - gbString ots = type_to_string(operand.type); + gbString ots = type_to_string(operand.type, true); defer (gb_string_free(pts)); defer (gb_string_free(ots)); error(operand.expr, "Cannot determine polymorphic type from parameter: '%s' to '%s'", ots, pts); @@ -1253,7 +1253,7 @@ Type *determine_type_from_polymorphic(CheckerContext *ctx, Type *poly_type, Oper } if (show_error) { gbString pts = type_to_string(poly_type); - gbString ots = type_to_string(operand.type); + gbString ots = type_to_string(operand.type, true); defer (gb_string_free(pts)); defer (gb_string_free(ots)); error(operand.expr, "Cannot determine polymorphic type from parameter: '%s' to '%s'", ots, pts); From abe122ecb7ef33cff52fd072514de5ad40538bc2 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 26 Jun 2022 13:13:07 +0100 Subject: [PATCH 10/22] Implement #1859 --- src/check_expr.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 58972d2cf..b42301cd6 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -3249,8 +3249,14 @@ void check_binary_expr(CheckerContext *c, Operand *x, Ast *node, Type *type_hint return; } - - if (!are_types_identical(x->type, y->type)) { + if ((op.kind == Token_CmpAnd || op.kind == Token_CmpOr) && + is_type_boolean(x->type) && is_type_boolean(y->type)) { + // NOTE(bill, 2022-06-26) + // Allow any boolean types within `&&` and `||` + // This is an exception to all other binary expressions since the result + // of a comparison will always be an untyped boolean, and allowing + // any boolean between these two simplifies a lot of expressions + } else if (!are_types_identical(x->type, y->type)) { if (x->type != t_invalid && y->type != t_invalid) { gbString xt = type_to_string(x->type); From e58f45bef789ab068656827b3b75f8cd817976e5 Mon Sep 17 00:00:00 2001 From: Peter DV Date: Mon, 27 Jun 2022 11:26:34 +1000 Subject: [PATCH 11/22] Correct error reporting --- core/os/file_windows.odin | 42 +++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/core/os/file_windows.odin b/core/os/file_windows.odin index ca9beff5d..8019b0440 100644 --- a/core/os/file_windows.odin +++ b/core/os/file_windows.odin @@ -384,21 +384,33 @@ set_current_directory :: proc(path: string) -> (err: Errno) { -change_directory :: proc(path: string) -> Errno { +change_directory :: proc(path: string) -> (err: Errno) { wpath := win32.utf8_to_wstring(path, context.temp_allocator) - return Errno(win32.SetCurrentDirectoryW(wpath)) + + if !win32.SetCurrentDirectoryW(wpath) { + err = Errno(win32.GetLastError()) + } + return } -make_directory :: proc(path: string, mode: u32 = 0) -> Errno { +make_directory :: proc(path: string, mode: u32 = 0) -> (err: Errno) { // Mode is unused on Windows, but is needed on *nix wpath := win32.utf8_to_wstring(path, context.temp_allocator) - return Errno(win32.CreateDirectoryW(wpath, nil)) + + if !win32.CreateDirectoryW(wpath, nil) { + err = Errno(win32.GetLastError()) + } + return } -remove_directory :: proc(path: string) -> Errno { +remove_directory :: proc(path: string) -> (err: Errno) { wpath := win32.utf8_to_wstring(path, context.temp_allocator) - return Errno(win32.RemoveDirectoryW(wpath)) + + if !win32.RemoveDirectoryW(wpath) { + err = Errno(win32.GetLastError()) + } + return } @@ -464,23 +476,31 @@ fix_long_path :: proc(path: string) -> string { } -link :: proc(old_name, new_name: string) -> Errno { +link :: proc(old_name, new_name: string) -> (err: Errno) { n := win32.utf8_to_wstring(fix_long_path(new_name)) o := win32.utf8_to_wstring(fix_long_path(old_name)) return Errno(win32.CreateHardLinkW(n, o, nil)) } -unlink :: proc(path: string) -> Errno { +unlink :: proc(path: string) -> (err: Errno) { wpath := win32.utf8_to_wstring(path, context.temp_allocator) - return Errno(win32.DeleteFileW(wpath)) + + if !win32.DeleteFileW(wpath) { + err = Errno(win32.GetLastError()) + } + return } -rename :: proc(old_path, new_path: string) -> Errno { +rename :: proc(old_path, new_path: string) -> (err: Errno) { from := win32.utf8_to_wstring(old_path, context.temp_allocator) to := win32.utf8_to_wstring(new_path, context.temp_allocator) - return Errno(win32.MoveFileExW(from, to, win32.MOVEFILE_REPLACE_EXISTING)) + + if !win32.MoveFileExW(from, to, win32.MOVEFILE_REPLACE_EXISTING) { + err = Errno(win32.GetLastError()) + } + return } From 199dae6cd52d5401d6f71b73eef235814d5ab223 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 27 Jun 2022 11:02:20 +0100 Subject: [PATCH 12/22] Make SDL.*Event procedures return booleans instead of an integer where appropriate --- vendor/sdl2/sdl_events.odin | 10 +++++----- vendor/sdl2/sdl_gamecontroller.odin | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/vendor/sdl2/sdl_events.odin b/vendor/sdl2/sdl_events.odin index 29f6e8a43..473bc5739 100644 --- a/vendor/sdl2/sdl_events.odin +++ b/vendor/sdl2/sdl_events.odin @@ -488,15 +488,15 @@ foreign lib { HasEvents :: proc(minType, maxType: EventType) -> bool --- FlushEvent :: proc(type: EventType) --- FlushEvents :: proc(minType, maxType: EventType) --- - PollEvent :: proc(event: ^Event) -> c.int --- - WaitEvent :: proc(event: ^Event) -> c.int --- - WaitEventTimeout :: proc(event: ^Event, timeout: c.int) -> c.int --- - PushEvent :: proc(event: ^Event) -> c.int --- + PollEvent :: proc(event: ^Event) -> bool --- // original return value is c.int + WaitEvent :: proc(event: ^Event) -> bool --- // original return value is c.int + WaitEventTimeout :: proc(event: ^Event, timeout: c.int) -> bool --- // original return value is c.int + PushEvent :: proc(event: ^Event) -> bool --- // original return value is c.int SetEventFilter :: proc(filter: EventFilter, userdata: rawptr) --- GetEventFilter :: proc(filter: ^EventFilter, userdata: ^rawptr) -> bool --- AddEventWatch :: proc(filter: EventFilter, userdata: rawptr) --- DelEventWatch :: proc(filter: EventFilter, userdata: rawptr) --- FilterEvents :: proc(filter: EventFilter, userdata: rawptr) --- - EventState :: proc(type: EventType, state: c.int) -> u8 --- + EventState :: proc(type: EventType, state: c.int) -> b8 --- // original return value is u8 RegisterEvents :: proc(numevents: c.int) -> u32 --- } diff --git a/vendor/sdl2/sdl_gamecontroller.odin b/vendor/sdl2/sdl_gamecontroller.odin index 76e0b8966..8772faa26 100644 --- a/vendor/sdl2/sdl_gamecontroller.odin +++ b/vendor/sdl2/sdl_gamecontroller.odin @@ -118,7 +118,7 @@ foreign lib { GameControllerGetStringForAxis :: proc(axis: GameControllerAxis) -> cstring --- GameControllerGetBindForAxis :: proc(gamecontroller: ^GameController, axis: GameControllerAxis) -> GameControllerButtonBind--- GameControllerHasAxis :: proc(gamecontroller: ^GameController, axis: GameControllerAxis) -> bool --- - GameControllerGetAxis :: proc(gamecontroller: ^GameController, axis: GameControllerAxis) -> i16 --- + GameControllerGetAxis :: proc(gamecontroller: ^GameController, axis: GameControllerAxis) -> i16 --- GameControllerGetButtonFromString :: proc(str: cstring) -> GameControllerButton --- GameControllerGetStringForButton :: proc(button: GameControllerButton) -> cstring --- From 776b48c10db280f555853edbd08f0fc634b97db9 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 27 Jun 2022 11:02:40 +0100 Subject: [PATCH 13/22] Fix GetEventState --- vendor/sdl2/sdl_events.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/sdl2/sdl_events.odin b/vendor/sdl2/sdl_events.odin index 473bc5739..60daaea56 100644 --- a/vendor/sdl2/sdl_events.odin +++ b/vendor/sdl2/sdl_events.odin @@ -477,7 +477,7 @@ DISABLE :: 0 ENABLE :: 1 -GetEventState :: #force_inline proc "c" (type: EventType) -> u8 { return EventState(type, QUERY) } +GetEventState :: #force_inline proc "c" (type: EventType) -> b8 { return EventState(type, QUERY) } @(default_calling_convention="c", link_prefix="SDL_") From 9e288b7ce80f377cfb37c3f2d3ba1d95130885b6 Mon Sep 17 00:00:00 2001 From: "Jimmy \"Keeba\" Lefevre" <43423342+JimmyLefevre@users.noreply.github.com> Date: Mon, 27 Jun 2022 21:48:02 +0200 Subject: [PATCH 14/22] Change LPCSTR to LPCWSTR in windows _W procedures --- core/sys/windows/kernel32.odin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/sys/windows/kernel32.odin b/core/sys/windows/kernel32.odin index 8f6c63e42..284936852 100644 --- a/core/sys/windows/kernel32.odin +++ b/core/sys/windows/kernel32.odin @@ -6,7 +6,7 @@ foreign import kernel32 "system:Kernel32.lib" @(default_calling_convention="stdcall") foreign kernel32 { OutputDebugStringA :: proc(lpOutputString: LPCSTR) --- // The only A thing that is allowed - OutputDebugStringW :: proc(lpOutputString: LPCSTR) --- + OutputDebugStringW :: proc(lpOutputString: LPCWSTR) --- ReadConsoleW :: proc(hConsoleInput: HANDLE, lpBuffer: LPVOID, @@ -101,7 +101,7 @@ foreign kernel32 { GetExitCodeThread :: proc(thread: HANDLE, exit_code: ^DWORD) -> BOOL --- TerminateThread :: proc(thread: HANDLE, exit_code: DWORD) -> BOOL --- - CreateSemaphoreW :: proc(attributes: LPSECURITY_ATTRIBUTES, initial_count, maximum_count: LONG, name: LPCSTR) -> HANDLE --- + CreateSemaphoreW :: proc(attributes: LPSECURITY_ATTRIBUTES, initial_count, maximum_count: LONG, name: LPCWSTR) -> HANDLE --- ReleaseSemaphore :: proc(semaphore: HANDLE, release_count: LONG, previous_count: ^LONG) -> BOOL --- CreateWaitableTimerW :: proc( From b89bb877599d1b966ed831343503bb74e7e43908 Mon Sep 17 00:00:00 2001 From: Phil Date: Thu, 23 Jun 2022 22:59:42 -0700 Subject: [PATCH 15/22] Add OpenGL bindless textures ARB api to vendor --- vendor/OpenGL/impl.odin | 44 +++++++++++++++++++++++++++++++++++++ vendor/OpenGL/wrappers.odin | 30 +++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/vendor/OpenGL/impl.odin b/vendor/OpenGL/impl.odin index 530865cb0..e9adda4bd 100644 --- a/vendor/OpenGL/impl.odin +++ b/vendor/OpenGL/impl.odin @@ -947,6 +947,13 @@ impl_DrawTransformFeedbackStream: proc "c" (mode: u32, id: u32, stream: u32) impl_BeginQueryIndexed: proc "c" (target: u32, index: u32, id: u32) impl_EndQueryIndexed: proc "c" (target: u32, index: u32) impl_GetQueryIndexediv: proc "c" (target: u32, index: u32, pname: u32, params: [^]i32) +impl_GetTextureHandleARB: proc "c" (texture: u32) -> u64 +impl_GetTextureSamplerHandleARB: proc "c" (texture, sampler: u32) -> u64 +impl_GetImageHandleARB: proc "c" (texture: u32, level: i32, layered: bool, layer: i32, format: u32) -> u64 +impl_MakeTextureHandleResidentARB: proc "c" (handle: u64) +impl_MakeImageHandleResidentARB: proc "c" (handle: u64, access: u32) +impl_MakeTextureHandleNonResidentARB:proc "c" (handle: u64) +impl_MakeImageHandleNonResidentARB: proc "c" (handle: u64) load_4_0 :: proc(set_proc_address: Set_Proc_Address_Type) { set_proc_address(&impl_MinSampleShading, "glMinSampleShading") @@ -995,6 +1002,42 @@ load_4_0 :: proc(set_proc_address: Set_Proc_Address_Type) { set_proc_address(&impl_BeginQueryIndexed, "glBeginQueryIndexed") set_proc_address(&impl_EndQueryIndexed, "glEndQueryIndexed") set_proc_address(&impl_GetQueryIndexediv, "glGetQueryIndexediv") + + // Load ARB (architecture review board, vendor specific) extensions that might be available + set_proc_address(&impl_GetTextureHandleARB, "glGetTextureHandleARB") + if impl_GetTextureHandleARB == nil { + set_proc_address(&impl_GetTextureHandleARB, "glGetTextureHandleNV") + } + + set_proc_address(&impl_GetTextureSamplerHandleARB, "glGetTextureSamplerHandleARB") + if impl_GetTextureSamplerHandleARB == nil { + set_proc_address(&impl_GetTextureSamplerHandleARB, "glGetTextureSamplerHandleNV") + } + + set_proc_address(&impl_GetImageHandleARB, "glGetImageHandleARB") + if impl_GetImageHandleARB == nil { + set_proc_address(&impl_GetImageHandleARB, "glGetImageHandleNV") + } + + set_proc_address(&impl_MakeTextureHandleResidentARB, "glMakeTextureHandleResidentARB") + if impl_MakeTextureHandleResidentARB == nil { + set_proc_address(&impl_MakeTextureHandleResidentARB, "glMakeTextureHandleResidentNV") + } + + set_proc_address(&impl_MakeImageHandleResidentARB, "glMakeImageHandleResidentARB") + if impl_MakeImageHandleResidentARB == nil { + set_proc_address(&impl_MakeImageHandleResidentARB, "glMakeImageHandleResidentNV") + } + + set_proc_address(&impl_MakeTextureHandleNonResidentARB, "glMakeTextureHandleNonResidentARB") + if impl_MakeTextureHandleNonResidentARB == nil { + set_proc_address(&impl_MakeTextureHandleNonResidentARB, "glMakeTextureHandleNonResidentNV") + } + + set_proc_address(&impl_MakeImageHandleNonResidentARB, "glMakeImageHandleNonResidentARB") + if impl_MakeImageHandleNonResidentARB == nil { + set_proc_address(&impl_MakeImageHandleNonResidentARB, "glMakeImageHandleNonResidentNV") + } } @@ -1594,3 +1637,4 @@ load_4_6 :: proc(set_proc_address: Set_Proc_Address_Type) { set_proc_address(&impl_MultiDrawElementsIndirectCount, "glMultiDrawElementsIndirectCount") set_proc_address(&impl_PolygonOffsetClamp, "glPolygonOffsetClamp") } + diff --git a/vendor/OpenGL/wrappers.odin b/vendor/OpenGL/wrappers.odin index c0b5304b0..bb71b0e82 100644 --- a/vendor/OpenGL/wrappers.odin +++ b/vendor/OpenGL/wrappers.odin @@ -449,6 +449,20 @@ when !ODIN_DEBUG { BeginQueryIndexed :: proc "c" (target: u32, index: u32, id: u32) { impl_BeginQueryIndexed(target, index, id) } EndQueryIndexed :: proc "c" (target: u32, index: u32) { impl_EndQueryIndexed(target, index) } GetQueryIndexediv :: proc "c" (target: u32, index: u32, pname: u32, params: [^]i32) { impl_GetQueryIndexediv(target, index, pname, params) } + GetTextureHandleARB :: proc "c" (texture: u32) -> u64 + { return impl_GetTextureHandleARB(texture) } + GetTextureSamplerHandleARB :: proc "c" (texture, sampler: u32) -> u64 + { return impl_GetTextureSamplerHandleARB(texture, sampler) } + GetImageHandleARB :: proc "c" (texture: u32, level: i32, layered: bool, layer: i32, format: u32) -> u64 + { return impl_GetImageHandleARB(texture, level, layered, layer, format) } + MakeTextureHandleResidentARB :: proc "c" (handle: u64) + { impl_MakeTextureHandleResidentARB(handle) } + MakeImageHandleResidentARB :: proc "c" (handle: u64, access: u32) + { impl_MakeImageHandleResidentARB(handle, access) } + MakeTextureHandleNonResidentARB:: proc "c" (handle: u64) + { impl_MakeTextureHandleNonResidentARB(handle) } + MakeImageHandleNonResidentARB :: proc "c" (handle: u64) + { impl_MakeImageHandleNonResidentARB(handle) } // VERSION_4_1 ReleaseShaderCompiler :: proc "c" () { impl_ReleaseShaderCompiler() } @@ -1249,6 +1263,22 @@ when !ODIN_DEBUG { BeginQueryIndexed :: proc "c" (target: u32, index: u32, id: u32, loc := #caller_location) { impl_BeginQueryIndexed(target, index, id); debug_helper(loc, 0, target, index, id) } EndQueryIndexed :: proc "c" (target: u32, index: u32, loc := #caller_location) { impl_EndQueryIndexed(target, index); debug_helper(loc, 0, target, index) } GetQueryIndexediv :: proc "c" (target: u32, index: u32, pname: u32, params: [^]i32, loc := #caller_location) { impl_GetQueryIndexediv(target, index, pname, params); debug_helper(loc, 0, target, index, pname, params) } + GetTextureHandleARB :: proc "c" (target: u32, loc := #caller_location) -> u64 + { ret := impl_GetTextureHandleARB(target); debug_helper(loc, 0, target); return ret } + GetTextureSamplerHandleARB :: proc "c" (texture, sampler: u32, loc := #caller_location) -> u64 + { ret := impl_GetTextureSamplerHandleARB(texture, sampler); debug_helper(loc, 0, texture, sampler); return ret; } + GetImageHandleARB :: proc "c" (texture: u32, level: i32, layered: bool, layer: i32, format: u32, loc := #caller_location) -> u64 + { ret := impl_GetImageHandleARB(texture, level, layered, layer, format); debug_helper(loc, 0, texture, level, layered, layer, format); return ret; } + MakeTextureHandleResidentARB :: proc "c" (handle: u64, loc := #caller_location) + { impl_MakeTextureHandleResidentARB(handle); debug_helper(loc, 0, handle) } + MakeImageHandleResidentARB :: proc "c" (handle: u64, access: u32, loc := #caller_location) + { impl_MakeImageHandleResidentARB(handle, access); debug_helper(loc, 0, handle, access) } + MakeTextureHandleNonResidentARB:: proc "c" (handle: u64, loc := #caller_location) + { impl_MakeTextureHandleNonResidentARB(handle); debug_helper(loc, 0, handle) } + MakeImageHandleNonResidentARB :: proc "c" (handle: u64, loc := #caller_location) + { impl_MakeImageHandleNonResidentARB(handle); debug_helper(loc, 0, handle) } + + // VERSION_4_1 ReleaseShaderCompiler :: proc "c" (loc := #caller_location) { impl_ReleaseShaderCompiler(); debug_helper(loc, 0) } From ea42613fec8aa5875e1557cbc913651ad979463c Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 28 Jun 2022 11:27:50 +0100 Subject: [PATCH 16/22] Improve error message with suggestion for #1866 --- src/check_stmt.cpp | 21 ++++++++++++++++++++- src/types.cpp | 11 ++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index f061b4961..a6f6f1a7d 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -2142,7 +2142,26 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) { } if (new_name_count == 0) { - error(node, "No new declarations on the lhs"); + begin_error_block(); + error(node, "No new declarations on the left hand side"); + bool all_underscore = true; + for_array(i, vd->names) { + Ast *name = vd->names[i]; + if (name->kind == Ast_Ident) { + if (!is_blank_ident(name)) { + all_underscore = false; + break; + } + } else { + all_underscore = false; + break; + } + } + if (all_underscore) { + error_line("\tSuggestion: Try changing the declaration (:=) to an assignment (=)\n"); + } + + end_error_block(); } Type *init_type = nullptr; diff --git a/src/types.cpp b/src/types.cpp index ad83e0568..5f112ce09 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -724,10 +724,11 @@ gb_global RecursiveMutex g_type_mutex; struct TypePath; -i64 type_size_of (Type *t); -i64 type_align_of (Type *t); -i64 type_offset_of (Type *t, i32 index); -gbString type_to_string (Type *type, bool shorthand=false); +i64 type_size_of (Type *t); +i64 type_align_of (Type *t); +i64 type_offset_of (Type *t, i32 index); +gbString type_to_string (Type *type, bool shorthand=true); +gbString type_to_string (Type *type, gbAllocator allocator, bool shorthand=true); i64 type_size_of_internal(Type *t, TypePath *path); void init_map_internal_types(Type *type); Type * bit_set_to_int(Type *t); @@ -4287,7 +4288,7 @@ gbString write_type_to_string(gbString str, Type *type, bool shorthand=false) { } -gbString type_to_string(Type *type, gbAllocator allocator, bool shorthand=false) { +gbString type_to_string(Type *type, gbAllocator allocator, bool shorthand) { return write_type_to_string(gb_string_make(allocator, ""), type, shorthand); } gbString type_to_string(Type *type, bool shorthand) { From b313d09c2cebbe5da02dd9bccca40a5a67f50c3c Mon Sep 17 00:00:00 2001 From: Michael Kutowski Date: Tue, 28 Jun 2022 18:27:52 +0200 Subject: [PATCH 17/22] flux fixed key deletion and generic in `flux_to` --- core/math/ease/ease.odin | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/core/math/ease/ease.odin b/core/math/ease/ease.odin index 5a767b5a9..0bd7c3641 100644 --- a/core/math/ease/ease.odin +++ b/core/math/ease/ease.odin @@ -325,9 +325,9 @@ ease :: proc "contextless" (type: Ease, p: $T) -> T // in case type was invalid return 0 } - Flux_Map :: struct($T: typeid) { values: map[^T]Flux_Tween(T), + keys_to_be_deleted: [dynamic]^T, } Flux_Tween :: struct($T: typeid) { @@ -353,15 +353,17 @@ Flux_Tween :: struct($T: typeid) { } // init flux map to a float type and a wanted cap -flux_init :: proc($T: typeid, cap := 8) -> Flux_Map(T) where intrinsics.type_is_float(T) { +flux_init :: proc($T: typeid, value_capacity := 8) -> Flux_Map(T) where intrinsics.type_is_float(T) { return { - make(map[^T]Flux_Tween(T), cap), + values = make(map[^T]Flux_Tween(T), value_capacity), + keys_to_be_deleted = make([dynamic]^T, 0, value_capacity) } } // delete map content flux_destroy :: proc(flux: Flux_Map($T)) where intrinsics.type_is_float(T) { delete(flux.values) + delete(flux.keys_to_be_deleted) } // clear map content, stops all animations @@ -374,8 +376,8 @@ flux_clear :: proc(flux: ^Flux_Map($T)) where intrinsics.type_is_float(T) { // return value can be used to set callbacks flux_to :: proc( flux: ^Flux_Map($T), - value: ^f32, - goal: f32, + value: ^T, + goal: T, type: Ease = .Quadratic_Out, duration: time.Duration = time.Second, delay: f64 = 0, @@ -413,6 +415,8 @@ flux_tween_init :: proc(tween: ^Flux_Tween($T), duration: time.Duration) where i // calls callbacks in all stages, when they're filled // deletes tween from the map after completion flux_update :: proc(flux: ^Flux_Map($T), dt: f64) where intrinsics.type_is_float(T) { + clear(&flux.keys_to_be_deleted) + for key, tween in &flux.values { delay_remainder := f64(0) @@ -451,7 +455,8 @@ flux_update :: proc(flux: ^Flux_Map($T), dt: f64) where intrinsics.type_is_float } if tween.progress >= 1 { - delete_key(&flux.values, key) + // append keys to array that will be deleted after the loop + append(&flux.keys_to_be_deleted, key) if tween.on_complete != nil { tween.on_complete(flux, tween.data) @@ -459,17 +464,24 @@ flux_update :: proc(flux: ^Flux_Map($T), dt: f64) where intrinsics.type_is_float } } } + + // loop through keys that should be deleted from the map + if len(flux.keys_to_be_deleted) != 0 { + for key in flux.keys_to_be_deleted { + delete_key(&flux.values, key) + } + } } // stop a specific key inside the map // returns true when it successfully removed the key flux_stop :: proc(flux: ^Flux_Map($T), key: ^T) -> bool where intrinsics.type_is_float(T) { - if key in flux.values { - delete_key(&flux.values, key) - return true - } + if key in flux.values { + delete_key(&flux.values, key) + return true + } - return false + return false } // returns the amount of time left for the tween animation, if the key exists in the map From 0a8e6169d741e96a6d8b2a2b98bbccd67ef7d4fc Mon Sep 17 00:00:00 2001 From: Phil Date: Tue, 28 Jun 2022 11:36:50 -0700 Subject: [PATCH 18/22] remove unneeded semicolons --- vendor/OpenGL/wrappers.odin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vendor/OpenGL/wrappers.odin b/vendor/OpenGL/wrappers.odin index bb71b0e82..b62ed216b 100644 --- a/vendor/OpenGL/wrappers.odin +++ b/vendor/OpenGL/wrappers.odin @@ -1266,9 +1266,9 @@ when !ODIN_DEBUG { GetTextureHandleARB :: proc "c" (target: u32, loc := #caller_location) -> u64 { ret := impl_GetTextureHandleARB(target); debug_helper(loc, 0, target); return ret } GetTextureSamplerHandleARB :: proc "c" (texture, sampler: u32, loc := #caller_location) -> u64 - { ret := impl_GetTextureSamplerHandleARB(texture, sampler); debug_helper(loc, 0, texture, sampler); return ret; } + { ret := impl_GetTextureSamplerHandleARB(texture, sampler); debug_helper(loc, 0, texture, sampler); return ret } GetImageHandleARB :: proc "c" (texture: u32, level: i32, layered: bool, layer: i32, format: u32, loc := #caller_location) -> u64 - { ret := impl_GetImageHandleARB(texture, level, layered, layer, format); debug_helper(loc, 0, texture, level, layered, layer, format); return ret; } + { ret := impl_GetImageHandleARB(texture, level, layered, layer, format); debug_helper(loc, 0, texture, level, layered, layer, format); return ret } MakeTextureHandleResidentARB :: proc "c" (handle: u64, loc := #caller_location) { impl_MakeTextureHandleResidentARB(handle); debug_helper(loc, 0, handle) } MakeImageHandleResidentARB :: proc "c" (handle: u64, access: u32, loc := #caller_location) From 4d06a54c0ce7266d8f30c0f6b10dd527c3f9d8c6 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 30 Jun 2022 15:42:02 +0100 Subject: [PATCH 19/22] Use `memmove` if possible when emitting store over a certain size --- src/llvm_backend_general.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/llvm_backend_general.cpp b/src/llvm_backend_general.cpp index e3d30ccff..8122f1d86 100644 --- a/src/llvm_backend_general.cpp +++ b/src/llvm_backend_general.cpp @@ -852,6 +852,12 @@ bool lb_is_type_proc_recursive(Type *t) { void lb_emit_store(lbProcedure *p, lbValue ptr, lbValue value) { GB_ASSERT(value.value != nullptr); Type *a = type_deref(ptr.type); + + if (LLVMIsNull(value.value)) { + LLVMTypeRef src_t = LLVMGetElementType(LLVMTypeOf(ptr.value)); + LLVMBuildStore(p->builder, LLVMConstNull(src_t), ptr.value); + return; + } if (is_type_boolean(a)) { // NOTE(bill): There are multiple sized booleans, thus force a conversion (if necessarily) value = lb_emit_conv(p, value, a); @@ -861,6 +867,20 @@ void lb_emit_store(lbProcedure *p, lbValue ptr, lbValue value) { GB_ASSERT_MSG(are_types_identical(ca, core_type(value.type)), "%s != %s", type_to_string(a), type_to_string(value.type)); } + enum {MAX_STORE_SIZE = 32}; + + if (LLVMIsALoadInst(value.value) && lb_sizeof(LLVMTypeOf(value.value)) > 32) { + LLVMValueRef dst_ptr = ptr.value; + LLVMValueRef src_ptr = LLVMGetOperand(value.value, 0); + src_ptr = LLVMBuildPointerCast(p->builder, src_ptr, LLVMTypeOf(dst_ptr), ""); + + LLVMBuildMemMove(p->builder, + dst_ptr, 1, + src_ptr, 1, + LLVMConstInt(LLVMInt64TypeInContext(p->module->ctx), lb_sizeof(LLVMTypeOf(value.value)), false)); + return; + } + if (lb_is_type_proc_recursive(a)) { // NOTE(bill, 2020-11-11): Because of certain LLVM rules, a procedure value may be // stored as regular pointer with no procedure information From 1676c643dfd9ef45f2aaa4dfddb69cea4bcf80fc Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 30 Jun 2022 15:47:19 +0100 Subject: [PATCH 20/22] Change MAX_STORE_SIZE --- src/llvm_backend_general.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/llvm_backend_general.cpp b/src/llvm_backend_general.cpp index 8122f1d86..5b43a11ab 100644 --- a/src/llvm_backend_general.cpp +++ b/src/llvm_backend_general.cpp @@ -867,9 +867,9 @@ void lb_emit_store(lbProcedure *p, lbValue ptr, lbValue value) { GB_ASSERT_MSG(are_types_identical(ca, core_type(value.type)), "%s != %s", type_to_string(a), type_to_string(value.type)); } - enum {MAX_STORE_SIZE = 32}; + enum {MAX_STORE_SIZE = 64}; - if (LLVMIsALoadInst(value.value) && lb_sizeof(LLVMTypeOf(value.value)) > 32) { + if (LLVMIsALoadInst(value.value) && lb_sizeof(LLVMTypeOf(value.value)) > MAX_STORE_SIZE) { LLVMValueRef dst_ptr = ptr.value; LLVMValueRef src_ptr = LLVMGetOperand(value.value, 0); src_ptr = LLVMBuildPointerCast(p->builder, src_ptr, LLVMTypeOf(dst_ptr), ""); From babbc304b8985bf86c94ea635eb273e8526764ad Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 9 Jul 2022 23:53:18 +0100 Subject: [PATCH 21/22] Fix wasm compilation in windows --- src/build_settings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/build_settings.cpp b/src/build_settings.cpp index a82cc80c9..53f28b01a 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -1321,7 +1321,7 @@ bool init_build_paths(String init_filename) { return true; } - #if defined(GB_SYSTEM_WINDOWS) + if (bc->metrics.os == TargetOs_windows) { if (bc->resource_filepath.len > 0) { bc->build_paths[BuildPath_RC] = path_from_string(ha, bc->resource_filepath); bc->build_paths[BuildPath_RES] = path_from_string(ha, bc->resource_filepath); @@ -1377,7 +1377,7 @@ bool init_build_paths(String init_filename) { } } } - #endif + } // All the build targets and OSes. String output_extension; From e8148055ad78489832c55aab9b81edd694440d63 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 9 Jul 2022 23:55:02 +0100 Subject: [PATCH 22/22] Fix compilation on non-windows platforms --- src/build_settings.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/build_settings.cpp b/src/build_settings.cpp index 53f28b01a..65da09df0 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -1321,6 +1321,7 @@ bool init_build_paths(String init_filename) { return true; } + #if defined(GB_SYSTEM_WINDOWS) if (bc->metrics.os == TargetOs_windows) { if (bc->resource_filepath.len > 0) { bc->build_paths[BuildPath_RC] = path_from_string(ha, bc->resource_filepath); @@ -1378,6 +1379,7 @@ bool init_build_paths(String init_filename) { } } } + #endif // All the build targets and OSes. String output_extension;