From 2ff61bdfc7315ad5cda0d049970cf3a5baf1d72f Mon Sep 17 00:00:00 2001 From: Colin Davidson Date: Wed, 21 Sep 2022 18:35:56 -0700 Subject: [PATCH 001/110] fix target features to make wasm intrinsics happy --- src/build_settings.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/build_settings.cpp b/src/build_settings.cpp index f640bcced..02de22ec4 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -1311,13 +1311,16 @@ void enable_target_feature(TokenPos pos, String const &target_feature_list) { defer (mutex_unlock(&bc->target_features_mutex)); auto items = split_by_comma(target_feature_list); - array_free(&items); for_array(i, items) { String const &item = items.data[i]; if (!check_target_feature_is_valid(pos, item)) { error(pos, "Target feature '%.*s' is not valid", LIT(item)); + continue; } + + string_set_add(&bc->target_features_set, item); } + array_free(&items); } @@ -1340,7 +1343,7 @@ char const *target_features_set_to_cstring(gbAllocator allocator, bool with_quot if (with_quotes) features[len++] = '"'; String feature = build_context.target_features_set.entries[i].value; - gb_memmove(features, feature.text, feature.len); + gb_memmove(features + len, feature.text, feature.len); len += feature.len; if (with_quotes) features[len++] = '"'; } From 6c8aad0afbfab55ed959712e1db4b6c368b4bead Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 22 Sep 2022 15:17:36 +0100 Subject: [PATCH 002/110] Make `intrinsics.{count_ones, count_zeros, count_trailing_zeros, count_leading_zeros}` work at compile time --- src/check_builtin.cpp | 86 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index c835801ac..09294c93a 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -3685,8 +3685,92 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 gb_string_free(xts); } + Type *type = default_type(x.type); operand->mode = Addressing_Value; - operand->type = default_type(x.type); + operand->type = type; + + if (id == BuiltinProc_reverse_bits) { + // make runtime only for the time being + } else if (x.mode == Addressing_Constant && x.value.kind == ExactValue_Integer) { + convert_to_typed(c, &x, type); + if (x.mode == Addressing_Invalid) { + return false; + } + + ExactValue res = {}; + + i64 sz = type_size_of(x.type); + u64 bit_size = sz*8; + u64 rop64[4] = {}; // 2 u64 is the maximum we will ever need, so doubling it will ne fine + u8 *rop = cast(u8 *)rop64; + + size_t max_count = 0; + size_t written = 0; + size_t size = 1; + size_t nails = 0; + mp_endian endian = MP_LITTLE_ENDIAN; + + max_count = mp_pack_count(&x.value.value_integer, nails, size); + GB_ASSERT(sz >= cast(i64)max_count); + + mp_err err = mp_pack(rop, max_count, &written, MP_LSB_FIRST, size, endian, nails, &x.value.value_integer); + GB_ASSERT(err == MP_OKAY); + + if (id == BuiltinProc_reverse_bits) { + // TODO(bill): Should this even be allowed at compile time? + } else { + u64 v = 0; + switch (id) { + case BuiltinProc_count_ones: + case BuiltinProc_count_zeros: + switch (sz) { + case 1: v = bit_set_count(cast(u32)rop[0]); break; + case 2: v = bit_set_count(cast(u32)*(u16 *)rop); break; + case 4: v = bit_set_count(*(u32 *)rop); break; + case 8: v = bit_set_count(rop64[0]); break; + case 16: + v += bit_set_count(rop64[0]); + v += bit_set_count(rop64[1]); + break; + default: GB_PANIC("Unhandled sized"); + } + if (id == BuiltinProc_count_zeros) { + // flip the result + v = bit_size - v; + } + break; + case BuiltinProc_count_trailing_zeros: + for (u64 i = 0; i < bit_size; i++) { + u8 b = cast(u8)(i & 7); + u8 j = cast(u8)(i >> 3); + if (rop[j] & (1 << b)) { + break; + } + v += 1; + } + break; + case BuiltinProc_count_leading_zeros: + for (u64 i = bit_size-1; i < bit_size; i--) { + u8 b = cast(u8)(i & 7); + u8 j = cast(u8)(i >> 3); + if (rop[j] & (1 << b)) { + break; + } + v += 1; + } + break; + } + + + res = exact_value_u64(v); + } + + if (res.kind != ExactValue_Invalid) { + operand->mode = Addressing_Constant; + operand->value = res; + } + } + } break; From 37a2356485d66bc777105e0520a1206713cbb86f Mon Sep 17 00:00:00 2001 From: Tetralux Date: Wed, 21 Sep 2022 19:01:33 +0000 Subject: [PATCH 003/110] [sys/windows] Add DCB structure, SetCommState, GetCommState These are the procedures for configuring a serial port. You simply open the port with CreateFile (os.open), followed by a call to GetCommState, setting the DCB as desired, followed by a SetCommState call. The DCB structure uses C bitfields, so a configuration struct is provided along with a helper procedure to make it easier to initialize in Odin code. This makes it possible to initialize a DCB structure with one call to the helper: ``` dcb: DCB windows.init_dcb_with_config(&dcb, { BaudRate = 115200, ByteSize = 8, Parity = .None, StopBits = .One, }) ``` (The parity and the stopbits are actually optional in this example, as their zero-values are None and One, respectively.) --- core/sys/windows/kernel32.odin | 144 +++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) diff --git a/core/sys/windows/kernel32.odin b/core/sys/windows/kernel32.odin index 15ffa2dd3..a9ed44d8a 100644 --- a/core/sys/windows/kernel32.odin +++ b/core/sys/windows/kernel32.odin @@ -820,3 +820,147 @@ foreign kernel32 { HandlerRoutine :: proc "stdcall" (dwCtrlType: DWORD) -> BOOL PHANDLER_ROUTINE :: HandlerRoutine + + + + +DCB_Config :: struct { + fParity: bool, + fOutxCtsFlow: bool, + fOutxDsrFlow: bool, + fDtrControl: DTR_Control, + fDsrSensitivity: bool, + fTXContinueOnXoff: bool, + fOutX: bool, + fInX: bool, + fErrorChar: bool, + fNull: bool, + fRtsControl: RTS_Control, + fAbortOnError: bool, + BaudRate: DWORD, + ByteSize: BYTE, + Parity: Parity, + StopBits: Stop_Bits, + XonChar: byte, + XoffChar: byte, + ErrorChar: byte, + EvtChar: byte, +} +DTR_Control :: enum byte { + Disable = 0, + Enable = 1, + Handshake = 2, +} +RTS_Control :: enum byte { + Disable = 0, + Enable = 1, + Handshake = 2, + Toggle = 3, +} +Parity :: enum byte { + None = 0, + Odd = 1, + Even = 2, + Mark = 3, + Space = 4, +} +Stop_Bits :: enum byte { + One = 0, + One_And_A_Half = 1, + Two = 2, +} + +// A helper procedure to set the values of a DCB structure. +init_dcb_with_config :: proc "contextless" (dcb: ^DCB, config: DCB_Config) { + out: u32 + + // NOTE(tetra, 2022-09-21): On both Clang 14 on Windows, and MSVC, the bits in the bitfield + // appear to be defined from LSB to MSB order. + // i.e: `fBinary` (the first bitfield in the C source) is the LSB in the `settings` u32. + + out |= u32(1) << 0 // fBinary must always be true on Windows. + + out |= u32(config.fParity) << 1 + out |= u32(config.fOutxCtsFlow) << 2 + out |= u32(config.fOutxDsrFlow) << 3 + + out |= u32(config.fDtrControl) << 4 + + out |= u32(config.fDsrSensitivity) << 6 + out |= u32(config.fTXContinueOnXoff) << 7 + out |= u32(config.fOutX) << 8 + out |= u32(config.fInX) << 9 + out |= u32(config.fErrorChar) << 10 + out |= u32(config.fNull) << 11 + + out |= u32(config.fRtsControl) << 12 + + out |= u32(config.fAbortOnError) << 14 + + dcb.settings = out + + dcb.BaudRate = config.BaudRate + dcb.ByteSize = config.ByteSize + dcb.Parity = config.Parity + dcb.StopBits = config.StopBits + dcb.XonChar = config.XonChar + dcb.XoffChar = config.XoffChar + dcb.ErrorChar = config.ErrorChar + dcb.EvtChar = config.EvtChar + + dcb.DCBlength = size_of(DCB) +} +get_dcb_config :: proc "contextless" (dcb: DCB) -> (config: DCB_Config) { + config.fParity = bool((dcb.settings >> 1) & 0x01) + config.fOutxCtsFlow = bool((dcb.settings >> 2) & 0x01) + config.fOutxDsrFlow = bool((dcb.settings >> 3) & 0x01) + + config.fDtrControl = DTR_Control((dcb.settings >> 4) & 0x02) + + config.fDsrSensitivity = bool((dcb.settings >> 6) & 0x01) + config.fTXContinueOnXoff = bool((dcb.settings >> 7) & 0x01) + config.fOutX = bool((dcb.settings >> 8) & 0x01) + config.fInX = bool((dcb.settings >> 9) & 0x01) + config.fErrorChar = bool((dcb.settings >> 10) & 0x01) + config.fNull = bool((dcb.settings >> 11) & 0x01) + + config.fRtsControl = RTS_Control((dcb.settings >> 12) & 0x02) + + config.fAbortOnError = bool((dcb.settings >> 14) & 0x01) + + config.BaudRate = dcb.BaudRate + config.ByteSize = dcb.ByteSize + config.Parity = dcb.Parity + config.StopBits = dcb.StopBits + config.XonChar = dcb.XonChar + config.XoffChar = dcb.XoffChar + config.ErrorChar = dcb.ErrorChar + config.EvtChar = dcb.EvtChar + + return +} + +// NOTE(tetra): See get_dcb_config() and init_dcb_with_config() for help with initializing this. +DCB :: struct { + DCBlength: DWORD, // NOTE(tetra): Must be set to size_of(DCB). + BaudRate: DWORD, + settings: u32, // NOTE(tetra): These are bitfields in the C struct. + wReserved: WORD, + XOnLim: WORD, + XOffLim: WORD, + ByteSize: BYTE, + Parity: Parity, + StopBits: Stop_Bits, + XonChar: byte, + XoffChar: byte, + ErrorChar: byte, + EofChar: byte, + EvtChar: byte, + wReserved1: WORD, +} + +@(default_calling_convention="stdcall") +foreign kernel32 { + GetCommState :: proc(handle: HANDLE, dcb: ^DCB) -> BOOL --- + SetCommState :: proc(handle: HANDLE, dcb: ^DCB) -> BOOL --- +} \ No newline at end of file From 83ffb68bb7025752639b746597cdcfa463cc7074 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Fri, 23 Sep 2022 12:09:46 +0100 Subject: [PATCH 004/110] Fix typo in `map_insert` --- core/runtime/core_builtin.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/runtime/core_builtin.odin b/core/runtime/core_builtin.odin index 574023a1e..b5b003122 100644 --- a/core/runtime/core_builtin.odin +++ b/core/runtime/core_builtin.odin @@ -672,7 +672,7 @@ shrink_dynamic_array :: proc(array: ^$T/[dynamic]$E, new_cap := -1, loc := #call @builtin map_insert :: proc(m: ^$T/map[$K]$V, key: K, value: V, loc := #caller_location) -> (ptr: ^V) { key, value := key, value - h := __get_map_header(T) + h := __get_map_header_table(T) e := __dynamic_map_set(m, h, __get_map_key_hash(&key), &key, &value, loc) return (^V)(uintptr(e) + h.value_offset) From 162e86663fef8bd17f9c4d3104491069bcc043e3 Mon Sep 17 00:00:00 2001 From: matias Date: Mon, 26 Sep 2022 01:54:27 -0400 Subject: [PATCH 005/110] Add WSATRY_AGAIN to windows/types.odin Not sure if the intent is to only add the defines that are commonly used in this file in order to keep things lean, rather than the complete list of WSA error codes from winerror.h into winerror.odin. I can close this and redo by adding all the WSA codes into winerror.odin and deleting these instead if preferred. --- core/sys/windows/types.odin | 1 + 1 file changed, 1 insertion(+) diff --git a/core/sys/windows/types.odin b/core/sys/windows/types.odin index c366a0102..85c94284c 100644 --- a/core/sys/windows/types.odin +++ b/core/sys/windows/types.odin @@ -1662,6 +1662,7 @@ WSAENOTCONN: c_int : 10057 WSAESHUTDOWN: c_int : 10058 WSAETIMEDOUT: c_int : 10060 WSAECONNREFUSED: c_int : 10061 +WSATRY_AGAIN: c_int : 11002 MAX_PROTOCOL_CHAIN: DWORD : 7 From 4d208dc0922b713bc7351bfe2e846e3ac957aff7 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 27 Sep 2022 00:10:05 +0100 Subject: [PATCH 006/110] Override lbArgKind to be indirect for `#by_ptr` parameters --- src/llvm_backend_general.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/llvm_backend_general.cpp b/src/llvm_backend_general.cpp index f05ae81ca..ed77eb975 100644 --- a/src/llvm_backend_general.cpp +++ b/src/llvm_backend_general.cpp @@ -1507,6 +1507,7 @@ LLVMTypeRef lb_type_internal_for_procedures_raw(lbModule *m, Type *type) { LLVMTypeRef ret = nullptr; LLVMTypeRef *params = gb_alloc_array(permanent_allocator(), LLVMTypeRef, param_count); + bool *params_by_ptr = gb_alloc_array(permanent_allocator(), bool, param_count); if (type->Proc.result_count != 0) { Type *single_ret = reduce_tuple_to_single_type(type->Proc.results); ret = lb_type(m, single_ret); @@ -1532,9 +1533,11 @@ LLVMTypeRef lb_type_internal_for_procedures_raw(lbModule *m, Type *type) { } Type *e_type = reduce_tuple_to_single_type(e->type); + bool param_is_by_ptr = false; LLVMTypeRef param_type = nullptr; if (e->flags & EntityFlag_ByPtr) { param_type = lb_type(m, alloc_type_pointer(e_type)); + param_is_by_ptr = true; } else if (is_type_boolean(e_type) && type_size_of(e_type) <= 1) { param_type = LLVMInt1TypeInContext(m->ctx); @@ -1546,6 +1549,7 @@ LLVMTypeRef lb_type_internal_for_procedures_raw(lbModule *m, Type *type) { } } + params_by_ptr[param_index] = param_is_by_ptr; params[param_index++] = param_type; } } @@ -1571,6 +1575,13 @@ LLVMTypeRef lb_type_internal_for_procedures_raw(lbModule *m, Type *type) { LLVMPrintTypeToString(ft->ret.type), LLVMGetTypeContext(ft->ret.type), ft->ctx, LLVMGetGlobalContext()); } + for_array(j, ft->args) { + if (params_by_ptr[j]) { + // NOTE(bill): The parameter needs to be passed "indirectly", override it + GB_ASSERT(ft->args[j].kind == lbArg_Direct); + ft->args[j].kind = lbArg_Indirect; + } + } map_set(&m->function_type_map, type, ft); LLVMTypeRef new_abi_fn_type = lb_function_type_to_llvm_raw(ft, type->Proc.c_vararg); From 0fe006157e6e6f07722bcf4eb7c51a8db07d008c Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 27 Sep 2022 00:18:19 +0100 Subject: [PATCH 007/110] Remove extra pointer indirection --- 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 ed77eb975..0dabee076 100644 --- a/src/llvm_backend_general.cpp +++ b/src/llvm_backend_general.cpp @@ -1536,7 +1536,8 @@ LLVMTypeRef lb_type_internal_for_procedures_raw(lbModule *m, Type *type) { bool param_is_by_ptr = false; LLVMTypeRef param_type = nullptr; if (e->flags & EntityFlag_ByPtr) { - param_type = lb_type(m, alloc_type_pointer(e_type)); + // it will become a pointer afterwards by making it indirect + param_type = lb_type(m, e_type); param_is_by_ptr = true; } else if (is_type_boolean(e_type) && type_size_of(e_type) <= 1) { @@ -1578,7 +1579,6 @@ LLVMTypeRef lb_type_internal_for_procedures_raw(lbModule *m, Type *type) { for_array(j, ft->args) { if (params_by_ptr[j]) { // NOTE(bill): The parameter needs to be passed "indirectly", override it - GB_ASSERT(ft->args[j].kind == lbArg_Direct); ft->args[j].kind = lbArg_Indirect; } } From d1c778680b8489b3dfcbd20187a1b975e2c71d6d Mon Sep 17 00:00:00 2001 From: hikari Date: Tue, 27 Sep 2022 11:05:01 +0300 Subject: [PATCH 008/110] sys/windows: add a couple of functions and constants, fix formatting --- core/sys/windows/user32.odin | 3 + core/sys/windows/window_messages.odin | 2176 +++++++++++++------------ 2 files changed, 1095 insertions(+), 1084 deletions(-) diff --git a/core/sys/windows/user32.odin b/core/sys/windows/user32.odin index d5ad9c378..ffb82ad0e 100644 --- a/core/sys/windows/user32.odin +++ b/core/sys/windows/user32.odin @@ -104,6 +104,9 @@ foreign user32 { GetDC :: proc(hWnd: HWND) -> HDC --- ReleaseDC :: proc(hWnd: HWND, hDC: HDC) -> c_int --- + GetDlgCtrlID :: proc(hWnd: HWND) -> c_int --- + GetDlgItem :: proc(hDlg: HWND, nIDDlgItem: c_int) -> HWND --- + GetUpdateRect :: proc(hWnd: HWND, lpRect: LPRECT, bErase: BOOL) -> BOOL --- ValidateRect :: proc(hWnd: HWND, lpRect: ^RECT) -> BOOL --- InvalidateRect :: proc(hWnd: HWND, lpRect: ^RECT, bErase: BOOL) -> BOOL --- diff --git a/core/sys/windows/window_messages.odin b/core/sys/windows/window_messages.odin index 7ce9e545c..616247f59 100644 --- a/core/sys/windows/window_messages.odin +++ b/core/sys/windows/window_messages.odin @@ -1,1088 +1,1096 @@ // +build windows package sys_windows -WM_NULL :: 0x0000 -WM_CREATE :: 0x0001 -WM_DESTROY :: 0x0002 -WM_MOVE :: 0x0003 -WM_SIZE :: 0x0005 -WM_ACTIVATE :: 0x0006 -WM_SETFOCUS :: 0x0007 -WM_KILLFOCUS :: 0x0008 -WM_ENABLE :: 0x000a -WM_SETREDRAW :: 0x000b -WM_SETTEXT :: 0x000c -WM_GETTEXT :: 0x000d -WM_GETTEXTLENGTH :: 0x000e -WM_PAINT :: 0x000f -WM_CLOSE :: 0x0010 -WM_QUERYENDSESSION :: 0x0011 -WM_QUIT :: 0x0012 -WM_QUERYOPEN :: 0x0013 -WM_ERASEBKGND :: 0x0014 -WM_SYSCOLORCHANGE :: 0x0015 -WM_ENDSESSION :: 0x0016 -WM_SHOWWINDOW :: 0x0018 -WM_CTLCOLOR :: 0x0019 -WM_WININICHANGE :: 0x001a -WM_SETTINGCHANGE :: WM_WININICHANGE -WM_DEVMODECHANGE :: 0x001b -WM_ACTIVATEAPP :: 0x001c -WM_FONTCHANGE :: 0x001d -WM_TIMECHANGE :: 0x001e -WM_CANCELMODE :: 0x001f -WM_SETCURSOR :: 0x0020 -WM_MOUSEACTIVATE :: 0x0021 -WM_CHILDACTIVATE :: 0x0022 -WM_QUEUESYNC :: 0x0023 -WM_GETMINMAXINFO :: 0x0024 -WM_PAINTICON :: 0x0026 -WM_ICONERASEBKGND :: 0x0027 -WM_NEXTDLGCTL :: 0x0028 -WM_SPOOLERSTATUS :: 0x002a -WM_DRAWITEM :: 0x002b -WM_MEASUREITEM :: 0x002c -WM_DELETEITEM :: 0x002d -WM_VKEYTOITEM :: 0x002e -WM_CHARTOITEM :: 0x002f -WM_SETFONT :: 0x0030 -WM_GETFONT :: 0x0031 -WM_SETHOTKEY :: 0x0032 -WM_GETHOTKEY :: 0x0033 -WM_QUERYDRAGICON :: 0x0037 -WM_COMPAREITEM :: 0x0039 -WM_GETOBJECT :: 0x003d -WM_COMPACTING :: 0x0041 -WM_COMMNOTIFY :: 0x0044 -WM_WINDOWPOSCHANGING :: 0x0046 -WM_WINDOWPOSCHANGED :: 0x0047 -WM_POWER :: 0x0048 -WM_COPYGLOBALDATA :: 0x0049 -WM_COPYDATA :: 0x004a -WM_CANCELJOURNAL :: 0x004b -WM_NOTIFY :: 0x004e -WM_INPUTLANGCHANGEREQUEST :: 0x0050 -WM_INPUTLANGCHANGE :: 0x0051 -WM_TCARD :: 0x0052 -WM_HELP :: 0x0053 -WM_USERCHANGED :: 0x0054 -WM_NOTIFYFORMAT :: 0x0055 -WM_CONTEXTMENU :: 0x007b -WM_STYLECHANGING :: 0x007c -WM_STYLECHANGED :: 0x007d -WM_DISPLAYCHANGE :: 0x007e -WM_GETICON :: 0x007f -WM_SETICON :: 0x0080 -WM_NCCREATE :: 0x0081 -WM_NCDESTROY :: 0x0082 -WM_NCCALCSIZE :: 0x0083 -WM_NCHITTEST :: 0x0084 -WM_NCPAINT :: 0x0085 -WM_NCACTIVATE :: 0x0086 -WM_GETDLGCODE :: 0x0087 -WM_SYNCPAINT :: 0x0088 -WM_NCMOUSEMOVE :: 0x00a0 -WM_NCLBUTTONDOWN :: 0x00a1 -WM_NCLBUTTONUP :: 0x00a2 -WM_NCLBUTTONDBLCLK :: 0x00a3 -WM_NCRBUTTONDOWN :: 0x00a4 -WM_NCRBUTTONUP :: 0x00a5 -WM_NCRBUTTONDBLCLK :: 0x00a6 -WM_NCMBUTTONDOWN :: 0x00a7 -WM_NCMBUTTONUP :: 0x00a8 -WM_NCMBUTTONDBLCLK :: 0x00a9 -WM_NCXBUTTONDOWN :: 0x00ab -WM_NCXBUTTONUP :: 0x00ac -WM_NCXBUTTONDBLCLK :: 0x00ad -EM_GETSEL :: 0x00b0 -EM_SETSEL :: 0x00b1 -EM_GETRECT :: 0x00b2 -EM_SETRECT :: 0x00b3 -EM_SETRECTNP :: 0x00b4 -EM_SCROLL :: 0x00b5 -EM_LINESCROLL :: 0x00b6 -EM_SCROLLCARET :: 0x00b7 -EM_GETMODIFY :: 0x00b8 -EM_SETMODIFY :: 0x00b9 -EM_GETLINECOUNT :: 0x00ba -EM_LINEINDEX :: 0x00bb -EM_SETHANDLE :: 0x00bc -EM_GETHANDLE :: 0x00bd -EM_GETTHUMB :: 0x00be -EM_LINELENGTH :: 0x00c1 -EM_REPLACESEL :: 0x00c2 -EM_SETFONT :: 0x00c3 -EM_GETLINE :: 0x00c4 -EM_LIMITTEXT :: 0x00c5 -EM_SETLIMITTEXT :: 0x00c5 -EM_CANUNDO :: 0x00c6 -EM_UNDO :: 0x00c7 -EM_FMTLINES :: 0x00c8 -EM_LINEFROMCHAR :: 0x00c9 -EM_SETWORDBREAK :: 0x00ca -EM_SETTABSTOPS :: 0x00cb -EM_SETPASSWORDCHAR :: 0x00cc -EM_EMPTYUNDOBUFFER :: 0x00cd -EM_GETFIRSTVISIBLELINE :: 0x00ce -EM_SETREADONLY :: 0x00cf -EM_SETWORDBREAKPROC :: 0x00d0 -EM_GETWORDBREAKPROC :: 0x00d1 -EM_GETPASSWORDCHAR :: 0x00d2 -EM_SETMARGINS :: 0x00d3 -EM_GETMARGINS :: 0x00d4 -EM_GETLIMITTEXT :: 0x00d5 -EM_POSFROMCHAR :: 0x00d6 -EM_CHARFROMPOS :: 0x00d7 -EM_SETIMESTATUS :: 0x00d8 -EM_GETIMESTATUS :: 0x00d9 -SBM_SETPOS :: 0x00e0 -SBM_GETPOS :: 0x00e1 -SBM_SETRANGE :: 0x00e2 -SBM_GETRANGE :: 0x00e3 -SBM_ENABLE_ARROWS :: 0x00e4 -SBM_SETRANGEREDRAW :: 0x00e6 -SBM_SETSCROLLINFO :: 0x00e9 -SBM_GETSCROLLINFO :: 0x00ea -SBM_GETSCROLLBARINFO :: 0x00eb -BM_GETCHECK :: 0x00f0 -BM_SETCHECK :: 0x00f1 -BM_GETSTATE :: 0x00f2 -BM_SETSTATE :: 0x00f3 -BM_SETSTYLE :: 0x00f4 -BM_CLICK :: 0x00f5 -BM_GETIMAGE :: 0x00f6 -BM_SETIMAGE :: 0x00f7 -BM_SETDONTCLICK :: 0x00f8 -WM_INPUT_DEVICE_CHANGE :: 0x00fe -WM_INPUT :: 0x00ff -WM_KEYDOWN :: 0x0100 -WM_KEYFIRST :: 0x0100 -WM_KEYUP :: 0x0101 -WM_CHAR :: 0x0102 -WM_DEADCHAR :: 0x0103 -WM_SYSKEYDOWN :: 0x0104 -WM_SYSKEYUP :: 0x0105 -WM_SYSCHAR :: 0x0106 -WM_SYSDEADCHAR :: 0x0107 -WM_UNICHAR :: 0x0109 -WM_KEYLAST :: 0x0109 -UNICODE_NOCHAR :: 0xFFFF -WM_WNT_CONVERTREQUESTEX :: 0x0109 -WM_CONVERTREQUEST :: 0x010a -WM_CONVERTRESULT :: 0x010b -WM_INTERIM :: 0x010c -WM_IME_STARTCOMPOSITION :: 0x010d -WM_IME_ENDCOMPOSITION :: 0x010e -WM_IME_COMPOSITION :: 0x010f -WM_IME_KEYLAST :: 0x010f -WM_INITDIALOG :: 0x0110 -WM_COMMAND :: 0x0111 -WM_SYSCOMMAND :: 0x0112 -WM_TIMER :: 0x0113 -WM_HSCROLL :: 0x0114 -WM_VSCROLL :: 0x0115 -WM_INITMENU :: 0x0116 -WM_INITMENUPOPUP :: 0x0117 -WM_SYSTIMER :: 0x0118 -WM_MENUSELECT :: 0x011f -WM_MENUCHAR :: 0x0120 -WM_ENTERIDLE :: 0x0121 -WM_MENURBUTTONUP :: 0x0122 -WM_MENUDRAG :: 0x0123 -WM_MENUGETOBJECT :: 0x0124 -WM_UNINITMENUPOPUP :: 0x0125 -WM_MENUCOMMAND :: 0x0126 -WM_CHANGEUISTATE :: 0x0127 -WM_UPDATEUISTATE :: 0x0128 -WM_QUERYUISTATE :: 0x0129 -WM_LBTRACKPOINT :: 0x0131 -WM_CTLCOLORMSGBOX :: 0x0132 -WM_CTLCOLOREDIT :: 0x0133 -WM_CTLCOLORLISTBOX :: 0x0134 -WM_CTLCOLORBTN :: 0x0135 -WM_CTLCOLORDLG :: 0x0136 -WM_CTLCOLORSCROLLBAR :: 0x0137 -WM_CTLCOLORSTATIC :: 0x0138 -CB_GETEDITSEL :: 0x0140 -CB_LIMITTEXT :: 0x0141 -CB_SETEDITSEL :: 0x0142 -CB_ADDSTRING :: 0x0143 -CB_DELETESTRING :: 0x0144 -CB_DIR :: 0x0145 -CB_GETCOUNT :: 0x0146 -CB_GETCURSEL :: 0x0147 -CB_GETLBTEXT :: 0x0148 -CB_GETLBTEXTLEN :: 0x0149 -CB_INSERTSTRING :: 0x014a -CB_RESETCONTENT :: 0x014b -CB_FINDSTRING :: 0x014c -CB_SELECTSTRING :: 0x014d -CB_SETCURSEL :: 0x014e -CB_SHOWDROPDOWN :: 0x014f -CB_GETITEMDATA :: 0x0150 -CB_SETITEMDATA :: 0x0151 -CB_GETDROPPEDCONTROLRECT :: 0x0152 -CB_SETITEMHEIGHT :: 0x0153 -CB_GETITEMHEIGHT :: 0x0154 -CB_SETEXTENDEDUI :: 0x0155 -CB_GETEXTENDEDUI :: 0x0156 -CB_GETDROPPEDSTATE :: 0x0157 -CB_FINDSTRINGEXACT :: 0x0158 -CB_SETLOCALE :: 0x0159 -CB_GETLOCALE :: 0x015a -CB_GETTOPINDEX :: 0x015b -CB_SETTOPINDEX :: 0x015c -CB_GETHORIZONTALEXTENT :: 0x015d -CB_SETHORIZONTALEXTENT :: 0x015e -CB_GETDROPPEDWIDTH :: 0x015f -CB_SETDROPPEDWIDTH :: 0x0160 -CB_INITSTORAGE :: 0x0161 -CB_MULTIPLEADDSTRING :: 0x0163 -CB_GETCOMBOBOXINFO :: 0x0164 -CB_MSGMAX :: 0x0165 -WM_MOUSEFIRST :: 0x0200 -WM_MOUSEMOVE :: 0x0200 -WM_LBUTTONDOWN :: 0x0201 -WM_LBUTTONUP :: 0x0202 -WM_LBUTTONDBLCLK :: 0x0203 -WM_RBUTTONDOWN :: 0x0204 -WM_RBUTTONUP :: 0x0205 -WM_RBUTTONDBLCLK :: 0x0206 -WM_MBUTTONDOWN :: 0x0207 -WM_MBUTTONUP :: 0x0208 -WM_MBUTTONDBLCLK :: 0x0209 -WM_MOUSELAST :: 0x0209 -WM_MOUSEWHEEL :: 0x020a -WM_XBUTTONDOWN :: 0x020b -WM_XBUTTONUP :: 0x020c -WM_XBUTTONDBLCLK :: 0x020d -WM_MOUSEHWHEEL :: 0x020e -WM_PARENTNOTIFY :: 0x0210 -WM_ENTERMENULOOP :: 0x0211 -WM_EXITMENULOOP :: 0x0212 -WM_NEXTMENU :: 0x0213 -WM_SIZING :: 0x0214 -WM_CAPTURECHANGED :: 0x0215 -WM_MOVING :: 0x0216 -WM_POWERBROADCAST :: 0x0218 -WM_DEVICECHANGE :: 0x0219 -WM_MDICREATE :: 0x0220 -WM_MDIDESTROY :: 0x0221 -WM_MDIACTIVATE :: 0x0222 -WM_MDIRESTORE :: 0x0223 -WM_MDINEXT :: 0x0224 -WM_MDIMAXIMIZE :: 0x0225 -WM_MDITILE :: 0x0226 -WM_MDICASCADE :: 0x0227 -WM_MDIICONARRANGE :: 0x0228 -WM_MDIGETACTIVE :: 0x0229 -WM_MDISETMENU :: 0x0230 -WM_ENTERSIZEMOVE :: 0x0231 -WM_EXITSIZEMOVE :: 0x0232 -WM_DROPFILES :: 0x0233 -WM_MDIREFRESHMENU :: 0x0234 -WM_POINTERDEVICECHANGE :: 0x0238 -WM_POINTERDEVICEINRANGE :: 0x0239 -WM_POINTERDEVICEOUTOFRANGE :: 0x023a -WM_TOUCH :: 0x0240 -WM_NCPOINTERUPDATE :: 0x0241 -WM_NCPOINTERDOWN :: 0x0242 -WM_NCPOINTERUP :: 0x0243 -WM_POINTERUPDATE :: 0x0245 -WM_POINTERDOWN :: 0x0246 -WM_POINTERUP :: 0x0247 -WM_POINTERENTER :: 0x0249 -WM_POINTERLEAVE :: 0x024a -WM_POINTERACTIVATE :: 0x024b -WM_POINTERCAPTURECHANGED :: 0x024c -WM_TOUCHHITTESTING :: 0x024d -WM_POINTERWHEEL :: 0x024e -WM_POINTERHWHEEL :: 0x024f -DM_POINTERHITTEST :: 0x0250 -WM_POINTERROUTEDTO :: 0x0251 -WM_POINTERROUTEDAWAY :: 0x0252 -WM_POINTERROUTEDRELEASED :: 0x0253 -WM_IME_REPORT :: 0x0280 -WM_IME_SETCONTEXT :: 0x0281 -WM_IME_NOTIFY :: 0x0282 -WM_IME_CONTROL :: 0x0283 -WM_IME_COMPOSITIONFULL :: 0x0284 -WM_IME_SELECT :: 0x0285 -WM_IME_CHAR :: 0x0286 -WM_IME_REQUEST :: 0x0288 -WM_IMEKEYDOWN :: 0x0290 -WM_IME_KEYDOWN :: 0x0290 -WM_IMEKEYUP :: 0x0291 -WM_IME_KEYUP :: 0x0291 -WM_NCMOUSEHOVER :: 0x02a0 -WM_MOUSEHOVER :: 0x02a1 -WM_NCMOUSELEAVE :: 0x02a2 -WM_MOUSELEAVE :: 0x02a3 -WM_WTSSESSION_CHANGE :: 0x02b1 -WM_TABLET_FIRST :: 0x02c0 -WM_TABLET_LAST :: 0x02df -WM_DPICHANGED :: 0x02e0 -WM_DPICHANGED_BEFOREPARENT :: 0x02e2 -WM_DPICHANGED_AFTERPARENT :: 0x02e3 -WM_GETDPISCALEDSIZE :: 0x02e4 -WM_CUT :: 0x0300 -WM_COPY :: 0x0301 -WM_PASTE :: 0x0302 -WM_CLEAR :: 0x0303 -WM_UNDO :: 0x0304 -WM_RENDERFORMAT :: 0x0305 -WM_RENDERALLFORMATS :: 0x0306 -WM_DESTROYCLIPBOARD :: 0x0307 -WM_DRAWCLIPBOARD :: 0x0308 -WM_PAINTCLIPBOARD :: 0x0309 -WM_VSCROLLCLIPBOARD :: 0x030a -WM_SIZECLIPBOARD :: 0x030b -WM_ASKCBFORMATNAME :: 0x030c -WM_CHANGECBCHAIN :: 0x030d -WM_HSCROLLCLIPBOARD :: 0x030e -WM_QUERYNEWPALETTE :: 0x030f -WM_PALETTEISCHANGING :: 0x0310 -WM_PALETTECHANGED :: 0x0311 -WM_HOTKEY :: 0x0312 -WM_PRINT :: 0x0317 -WM_PRINTCLIENT :: 0x0318 -WM_APPCOMMAND :: 0x0319 -WM_THEMECHANGED :: 0x031A -WM_CLIPBOARDUPDATE :: 0x031D -WM_DWMCOMPOSITIONCHANGED :: 0x031E -WM_DWMNCRENDERINGCHANGED :: 0x031F -WM_DWMCOLORIZATIONCOLORCHANGED:: 0x0320 -WM_DWMWINDOWMAXIMIZEDCHANGE :: 0x0321 -WM_DWMSENDICONICTHUMBNAIL :: 0x0323 +WM_NULL :: 0x0000 +WM_CREATE :: 0x0001 +WM_DESTROY :: 0x0002 +WM_MOVE :: 0x0003 +WM_SIZE :: 0x0005 +WM_ACTIVATE :: 0x0006 +WM_SETFOCUS :: 0x0007 +WM_KILLFOCUS :: 0x0008 +WM_ENABLE :: 0x000a +WM_SETREDRAW :: 0x000b +WM_SETTEXT :: 0x000c +WM_GETTEXT :: 0x000d +WM_GETTEXTLENGTH :: 0x000e +WM_PAINT :: 0x000f +WM_CLOSE :: 0x0010 +WM_QUERYENDSESSION :: 0x0011 +WM_QUIT :: 0x0012 +WM_QUERYOPEN :: 0x0013 +WM_ERASEBKGND :: 0x0014 +WM_SYSCOLORCHANGE :: 0x0015 +WM_ENDSESSION :: 0x0016 +WM_SHOWWINDOW :: 0x0018 +WM_CTLCOLOR :: 0x0019 +WM_WININICHANGE :: 0x001a +WM_SETTINGCHANGE :: WM_WININICHANGE +WM_DEVMODECHANGE :: 0x001b +WM_ACTIVATEAPP :: 0x001c +WM_FONTCHANGE :: 0x001d +WM_TIMECHANGE :: 0x001e +WM_CANCELMODE :: 0x001f +WM_SETCURSOR :: 0x0020 +WM_MOUSEACTIVATE :: 0x0021 +WM_CHILDACTIVATE :: 0x0022 +WM_QUEUESYNC :: 0x0023 +WM_GETMINMAXINFO :: 0x0024 +WM_PAINTICON :: 0x0026 +WM_ICONERASEBKGND :: 0x0027 +WM_NEXTDLGCTL :: 0x0028 +WM_SPOOLERSTATUS :: 0x002a +WM_DRAWITEM :: 0x002b +WM_MEASUREITEM :: 0x002c +WM_DELETEITEM :: 0x002d +WM_VKEYTOITEM :: 0x002e +WM_CHARTOITEM :: 0x002f +WM_SETFONT :: 0x0030 +WM_GETFONT :: 0x0031 +WM_SETHOTKEY :: 0x0032 +WM_GETHOTKEY :: 0x0033 +WM_QUERYDRAGICON :: 0x0037 +WM_COMPAREITEM :: 0x0039 +WM_GETOBJECT :: 0x003d +WM_COMPACTING :: 0x0041 +WM_COMMNOTIFY :: 0x0044 +WM_WINDOWPOSCHANGING :: 0x0046 +WM_WINDOWPOSCHANGED :: 0x0047 +WM_POWER :: 0x0048 +WM_COPYGLOBALDATA :: 0x0049 +WM_COPYDATA :: 0x004a +WM_CANCELJOURNAL :: 0x004b +WM_NOTIFY :: 0x004e +WM_INPUTLANGCHANGEREQUEST :: 0x0050 +WM_INPUTLANGCHANGE :: 0x0051 +WM_TCARD :: 0x0052 +WM_HELP :: 0x0053 +WM_USERCHANGED :: 0x0054 +WM_NOTIFYFORMAT :: 0x0055 +WM_CONTEXTMENU :: 0x007b +WM_STYLECHANGING :: 0x007c +WM_STYLECHANGED :: 0x007d +WM_DISPLAYCHANGE :: 0x007e +WM_GETICON :: 0x007f +WM_SETICON :: 0x0080 +WM_NCCREATE :: 0x0081 +WM_NCDESTROY :: 0x0082 +WM_NCCALCSIZE :: 0x0083 +WM_NCHITTEST :: 0x0084 +WM_NCPAINT :: 0x0085 +WM_NCACTIVATE :: 0x0086 +WM_GETDLGCODE :: 0x0087 +WM_SYNCPAINT :: 0x0088 +WM_NCMOUSEMOVE :: 0x00a0 +WM_NCLBUTTONDOWN :: 0x00a1 +WM_NCLBUTTONUP :: 0x00a2 +WM_NCLBUTTONDBLCLK :: 0x00a3 +WM_NCRBUTTONDOWN :: 0x00a4 +WM_NCRBUTTONUP :: 0x00a5 +WM_NCRBUTTONDBLCLK :: 0x00a6 +WM_NCMBUTTONDOWN :: 0x00a7 +WM_NCMBUTTONUP :: 0x00a8 +WM_NCMBUTTONDBLCLK :: 0x00a9 +WM_NCXBUTTONDOWN :: 0x00ab +WM_NCXBUTTONUP :: 0x00ac +WM_NCXBUTTONDBLCLK :: 0x00ad +EM_GETSEL :: 0x00b0 +EM_SETSEL :: 0x00b1 +EM_GETRECT :: 0x00b2 +EM_SETRECT :: 0x00b3 +EM_SETRECTNP :: 0x00b4 +EM_SCROLL :: 0x00b5 +EM_LINESCROLL :: 0x00b6 +EM_SCROLLCARET :: 0x00b7 +EM_GETMODIFY :: 0x00b8 +EM_SETMODIFY :: 0x00b9 +EM_GETLINECOUNT :: 0x00ba +EM_LINEINDEX :: 0x00bb +EM_SETHANDLE :: 0x00bc +EM_GETHANDLE :: 0x00bd +EM_GETTHUMB :: 0x00be +EM_LINELENGTH :: 0x00c1 +EM_REPLACESEL :: 0x00c2 +EM_SETFONT :: 0x00c3 +EM_GETLINE :: 0x00c4 +EM_LIMITTEXT :: 0x00c5 +EM_SETLIMITTEXT :: 0x00c5 +EM_CANUNDO :: 0x00c6 +EM_UNDO :: 0x00c7 +EM_FMTLINES :: 0x00c8 +EM_LINEFROMCHAR :: 0x00c9 +EM_SETWORDBREAK :: 0x00ca +EM_SETTABSTOPS :: 0x00cb +EM_SETPASSWORDCHAR :: 0x00cc +EM_EMPTYUNDOBUFFER :: 0x00cd +EM_GETFIRSTVISIBLELINE :: 0x00ce +EM_SETREADONLY :: 0x00cf +EM_SETWORDBREAKPROC :: 0x00d0 +EM_GETWORDBREAKPROC :: 0x00d1 +EM_GETPASSWORDCHAR :: 0x00d2 +EM_SETMARGINS :: 0x00d3 +EM_GETMARGINS :: 0x00d4 +EM_GETLIMITTEXT :: 0x00d5 +EM_POSFROMCHAR :: 0x00d6 +EM_CHARFROMPOS :: 0x00d7 +EM_SETIMESTATUS :: 0x00d8 +EM_GETIMESTATUS :: 0x00d9 +SBM_SETPOS :: 0x00e0 +SBM_GETPOS :: 0x00e1 +SBM_SETRANGE :: 0x00e2 +SBM_GETRANGE :: 0x00e3 +SBM_ENABLE_ARROWS :: 0x00e4 +SBM_SETRANGEREDRAW :: 0x00e6 +SBM_SETSCROLLINFO :: 0x00e9 +SBM_GETSCROLLINFO :: 0x00ea +SBM_GETSCROLLBARINFO :: 0x00eb +BM_GETCHECK :: 0x00f0 +BM_SETCHECK :: 0x00f1 +BM_GETSTATE :: 0x00f2 +BM_SETSTATE :: 0x00f3 +BM_SETSTYLE :: 0x00f4 +BM_CLICK :: 0x00f5 +BM_GETIMAGE :: 0x00f6 +BM_SETIMAGE :: 0x00f7 +BM_SETDONTCLICK :: 0x00f8 +WM_INPUT_DEVICE_CHANGE :: 0x00fe +WM_INPUT :: 0x00ff +WM_KEYDOWN :: 0x0100 +WM_KEYFIRST :: 0x0100 +WM_KEYUP :: 0x0101 +WM_CHAR :: 0x0102 +WM_DEADCHAR :: 0x0103 +WM_SYSKEYDOWN :: 0x0104 +WM_SYSKEYUP :: 0x0105 +WM_SYSCHAR :: 0x0106 +WM_SYSDEADCHAR :: 0x0107 +WM_UNICHAR :: 0x0109 +WM_KEYLAST :: 0x0109 +UNICODE_NOCHAR :: 0xFFFF +WM_WNT_CONVERTREQUESTEX :: 0x0109 +WM_CONVERTREQUEST :: 0x010a +WM_CONVERTRESULT :: 0x010b +WM_INTERIM :: 0x010c +WM_IME_STARTCOMPOSITION :: 0x010d +WM_IME_ENDCOMPOSITION :: 0x010e +WM_IME_COMPOSITION :: 0x010f +WM_IME_KEYLAST :: 0x010f +WM_INITDIALOG :: 0x0110 +WM_COMMAND :: 0x0111 +WM_SYSCOMMAND :: 0x0112 +WM_TIMER :: 0x0113 +WM_HSCROLL :: 0x0114 +WM_VSCROLL :: 0x0115 +WM_INITMENU :: 0x0116 +WM_INITMENUPOPUP :: 0x0117 +WM_SYSTIMER :: 0x0118 +WM_MENUSELECT :: 0x011f +WM_MENUCHAR :: 0x0120 +WM_ENTERIDLE :: 0x0121 +WM_MENURBUTTONUP :: 0x0122 +WM_MENUDRAG :: 0x0123 +WM_MENUGETOBJECT :: 0x0124 +WM_UNINITMENUPOPUP :: 0x0125 +WM_MENUCOMMAND :: 0x0126 +WM_CHANGEUISTATE :: 0x0127 +WM_UPDATEUISTATE :: 0x0128 +WM_QUERYUISTATE :: 0x0129 +WM_LBTRACKPOINT :: 0x0131 +WM_CTLCOLORMSGBOX :: 0x0132 +WM_CTLCOLOREDIT :: 0x0133 +WM_CTLCOLORLISTBOX :: 0x0134 +WM_CTLCOLORBTN :: 0x0135 +WM_CTLCOLORDLG :: 0x0136 +WM_CTLCOLORSCROLLBAR :: 0x0137 +WM_CTLCOLORSTATIC :: 0x0138 +CB_GETEDITSEL :: 0x0140 +CB_LIMITTEXT :: 0x0141 +CB_SETEDITSEL :: 0x0142 +CB_ADDSTRING :: 0x0143 +CB_DELETESTRING :: 0x0144 +CB_DIR :: 0x0145 +CB_GETCOUNT :: 0x0146 +CB_GETCURSEL :: 0x0147 +CB_GETLBTEXT :: 0x0148 +CB_GETLBTEXTLEN :: 0x0149 +CB_INSERTSTRING :: 0x014a +CB_RESETCONTENT :: 0x014b +CB_FINDSTRING :: 0x014c +CB_SELECTSTRING :: 0x014d +CB_SETCURSEL :: 0x014e +CB_SHOWDROPDOWN :: 0x014f +CB_GETITEMDATA :: 0x0150 +CB_SETITEMDATA :: 0x0151 +CB_GETDROPPEDCONTROLRECT :: 0x0152 +CB_SETITEMHEIGHT :: 0x0153 +CB_GETITEMHEIGHT :: 0x0154 +CB_SETEXTENDEDUI :: 0x0155 +CB_GETEXTENDEDUI :: 0x0156 +CB_GETDROPPEDSTATE :: 0x0157 +CB_FINDSTRINGEXACT :: 0x0158 +CB_SETLOCALE :: 0x0159 +CB_GETLOCALE :: 0x015a +CB_GETTOPINDEX :: 0x015b +CB_SETTOPINDEX :: 0x015c +CB_GETHORIZONTALEXTENT :: 0x015d +CB_SETHORIZONTALEXTENT :: 0x015e +CB_GETDROPPEDWIDTH :: 0x015f +CB_SETDROPPEDWIDTH :: 0x0160 +CB_INITSTORAGE :: 0x0161 +CB_MULTIPLEADDSTRING :: 0x0163 +CB_GETCOMBOBOXINFO :: 0x0164 +CB_MSGMAX :: 0x0165 +WM_MOUSEFIRST :: 0x0200 +WM_MOUSEMOVE :: 0x0200 +WM_LBUTTONDOWN :: 0x0201 +WM_LBUTTONUP :: 0x0202 +WM_LBUTTONDBLCLK :: 0x0203 +WM_RBUTTONDOWN :: 0x0204 +WM_RBUTTONUP :: 0x0205 +WM_RBUTTONDBLCLK :: 0x0206 +WM_MBUTTONDOWN :: 0x0207 +WM_MBUTTONUP :: 0x0208 +WM_MBUTTONDBLCLK :: 0x0209 +WM_MOUSELAST :: 0x0209 +WM_MOUSEWHEEL :: 0x020a +WM_XBUTTONDOWN :: 0x020b +WM_XBUTTONUP :: 0x020c +WM_XBUTTONDBLCLK :: 0x020d +WM_MOUSEHWHEEL :: 0x020e +WM_PARENTNOTIFY :: 0x0210 +WM_ENTERMENULOOP :: 0x0211 +WM_EXITMENULOOP :: 0x0212 +WM_NEXTMENU :: 0x0213 +WM_SIZING :: 0x0214 +WM_CAPTURECHANGED :: 0x0215 +WM_MOVING :: 0x0216 +WM_POWERBROADCAST :: 0x0218 +WM_DEVICECHANGE :: 0x0219 +WM_MDICREATE :: 0x0220 +WM_MDIDESTROY :: 0x0221 +WM_MDIACTIVATE :: 0x0222 +WM_MDIRESTORE :: 0x0223 +WM_MDINEXT :: 0x0224 +WM_MDIMAXIMIZE :: 0x0225 +WM_MDITILE :: 0x0226 +WM_MDICASCADE :: 0x0227 +WM_MDIICONARRANGE :: 0x0228 +WM_MDIGETACTIVE :: 0x0229 +WM_MDISETMENU :: 0x0230 +WM_ENTERSIZEMOVE :: 0x0231 +WM_EXITSIZEMOVE :: 0x0232 +WM_DROPFILES :: 0x0233 +WM_MDIREFRESHMENU :: 0x0234 +WM_POINTERDEVICECHANGE :: 0x0238 +WM_POINTERDEVICEINRANGE :: 0x0239 +WM_POINTERDEVICEOUTOFRANGE :: 0x023a +WM_TOUCH :: 0x0240 +WM_NCPOINTERUPDATE :: 0x0241 +WM_NCPOINTERDOWN :: 0x0242 +WM_NCPOINTERUP :: 0x0243 +WM_POINTERUPDATE :: 0x0245 +WM_POINTERDOWN :: 0x0246 +WM_POINTERUP :: 0x0247 +WM_POINTERENTER :: 0x0249 +WM_POINTERLEAVE :: 0x024a +WM_POINTERACTIVATE :: 0x024b +WM_POINTERCAPTURECHANGED :: 0x024c +WM_TOUCHHITTESTING :: 0x024d +WM_POINTERWHEEL :: 0x024e +WM_POINTERHWHEEL :: 0x024f +DM_POINTERHITTEST :: 0x0250 +WM_POINTERROUTEDTO :: 0x0251 +WM_POINTERROUTEDAWAY :: 0x0252 +WM_POINTERROUTEDRELEASED :: 0x0253 +WM_IME_REPORT :: 0x0280 +WM_IME_SETCONTEXT :: 0x0281 +WM_IME_NOTIFY :: 0x0282 +WM_IME_CONTROL :: 0x0283 +WM_IME_COMPOSITIONFULL :: 0x0284 +WM_IME_SELECT :: 0x0285 +WM_IME_CHAR :: 0x0286 +WM_IME_REQUEST :: 0x0288 +WM_IMEKEYDOWN :: 0x0290 +WM_IME_KEYDOWN :: 0x0290 +WM_IMEKEYUP :: 0x0291 +WM_IME_KEYUP :: 0x0291 +WM_NCMOUSEHOVER :: 0x02a0 +WM_MOUSEHOVER :: 0x02a1 +WM_NCMOUSELEAVE :: 0x02a2 +WM_MOUSELEAVE :: 0x02a3 +WM_WTSSESSION_CHANGE :: 0x02b1 +WM_TABLET_FIRST :: 0x02c0 +WM_TABLET_LAST :: 0x02df +WM_DPICHANGED :: 0x02e0 +WM_DPICHANGED_BEFOREPARENT :: 0x02e2 +WM_DPICHANGED_AFTERPARENT :: 0x02e3 +WM_GETDPISCALEDSIZE :: 0x02e4 +WM_CUT :: 0x0300 +WM_COPY :: 0x0301 +WM_PASTE :: 0x0302 +WM_CLEAR :: 0x0303 +WM_UNDO :: 0x0304 +WM_RENDERFORMAT :: 0x0305 +WM_RENDERALLFORMATS :: 0x0306 +WM_DESTROYCLIPBOARD :: 0x0307 +WM_DRAWCLIPBOARD :: 0x0308 +WM_PAINTCLIPBOARD :: 0x0309 +WM_VSCROLLCLIPBOARD :: 0x030a +WM_SIZECLIPBOARD :: 0x030b +WM_ASKCBFORMATNAME :: 0x030c +WM_CHANGECBCHAIN :: 0x030d +WM_HSCROLLCLIPBOARD :: 0x030e +WM_QUERYNEWPALETTE :: 0x030f +WM_PALETTEISCHANGING :: 0x0310 +WM_PALETTECHANGED :: 0x0311 +WM_HOTKEY :: 0x0312 +WM_PRINT :: 0x0317 +WM_PRINTCLIENT :: 0x0318 +WM_APPCOMMAND :: 0x0319 +WM_THEMECHANGED :: 0x031A +WM_CLIPBOARDUPDATE :: 0x031D +WM_DWMCOMPOSITIONCHANGED :: 0x031E +WM_DWMNCRENDERINGCHANGED :: 0x031F +WM_DWMCOLORIZATIONCOLORCHANGED :: 0x0320 +WM_DWMWINDOWMAXIMIZEDCHANGE :: 0x0321 +WM_DWMSENDICONICTHUMBNAIL :: 0x0323 WM_DWMSENDICONICLIVEPREVIEWBITMAP :: 0x0326 -WM_GETTITLEBARINFOEX :: 0x033F -WM_HANDHELDFIRST :: 0x0358 -WM_HANDHELDLAST :: 0x035f -WM_AFXFIRST :: 0x0360 -WM_AFXLAST :: 0x037f -WM_PENWINFIRST :: 0x0380 -WM_RCRESULT :: 0x0381 -WM_HOOKRCRESULT :: 0x0382 -WM_GLOBALRCCHANGE :: 0x0383 -WM_PENMISCINFO :: 0x0383 -WM_SKB :: 0x0384 -WM_HEDITCTL :: 0x0385 -WM_PENCTL :: 0x0385 -WM_PENMISC :: 0x0386 -WM_CTLINIT :: 0x0387 -WM_PENEVENT :: 0x0388 -WM_PENWINLAST :: 0x038f -DDM_SETFMT :: 0x0400 -DM_GETDEFID :: 0x0400 -NIN_SELECT :: 0x0400 -TBM_GETPOS :: 0x0400 -WM_PSD_PAGESETUPDLG :: 0x0400 -WM_USER :: 0x0400 -CBEM_INSERTITEMA :: 0x0401 -DDM_DRAW :: 0x0401 -DM_SETDEFID :: 0x0401 -HKM_SETHOTKEY :: 0x0401 -PBM_SETRANGE :: 0x0401 -RB_INSERTBANDA :: 0x0401 -SB_SETTEXTA :: 0x0401 -TB_ENABLEBUTTON :: 0x0401 -TBM_GETRANGEMIN :: 0x0401 -TTM_ACTIVATE :: 0x0401 -WM_CHOOSEFONT_GETLOGFONT :: 0x0401 -WM_PSD_FULLPAGERECT :: 0x0401 -CBEM_SETIMAGELIST :: 0x0402 -DDM_CLOSE :: 0x0402 -DM_REPOSITION :: 0x0402 -HKM_GETHOTKEY :: 0x0402 -PBM_SETPOS :: 0x0402 -RB_DELETEBAND :: 0x0402 -SB_GETTEXTA :: 0x0402 -TB_CHECKBUTTON :: 0x0402 -TBM_GETRANGEMAX :: 0x0402 -WM_PSD_MINMARGINRECT :: 0x0402 -CBEM_GETIMAGELIST :: 0x0403 -DDM_BEGIN :: 0x0403 -HKM_SETRULES :: 0x0403 -PBM_DELTAPOS :: 0x0403 -RB_GETBARINFO :: 0x0403 -SB_GETTEXTLENGTHA :: 0x0403 -TBM_GETTIC :: 0x0403 -TB_PRESSBUTTON :: 0x0403 -TTM_SETDELAYTIME :: 0x0403 -WM_PSD_MARGINRECT :: 0x0403 -CBEM_GETITEMA :: 0x0404 -DDM_END :: 0x0404 -PBM_SETSTEP :: 0x0404 -RB_SETBARINFO :: 0x0404 -SB_SETPARTS :: 0x0404 -TB_HIDEBUTTON :: 0x0404 -TBM_SETTIC :: 0x0404 -TTM_ADDTOOLA :: 0x0404 -WM_PSD_GREEKTEXTRECT :: 0x0404 -CBEM_SETITEMA :: 0x0405 -PBM_STEPIT :: 0x0405 -TB_INDETERMINATE :: 0x0405 -TBM_SETPOS :: 0x0405 -TTM_DELTOOLA :: 0x0405 -WM_PSD_ENVSTAMPRECT :: 0x0405 -CBEM_GETCOMBOCONTROL :: 0x0406 -PBM_SETRANGE32 :: 0x0406 -RB_SETBANDINFOA :: 0x0406 -SB_GETPARTS :: 0x0406 -TB_MARKBUTTON :: 0x0406 -TBM_SETRANGE :: 0x0406 -TTM_NEWTOOLRECTA :: 0x0406 -WM_PSD_YAFULLPAGERECT :: 0x0406 -CBEM_GETEDITCONTROL :: 0x0407 -PBM_GETRANGE :: 0x0407 -RB_SETPARENT :: 0x0407 -SB_GETBORDERS :: 0x0407 -TBM_SETRANGEMIN :: 0x0407 -TTM_RELAYEVENT :: 0x0407 -CBEM_SETEXSTYLE :: 0x0408 -PBM_GETPOS :: 0x0408 -RB_HITTEST :: 0x0408 -SB_SETMINHEIGHT :: 0x0408 -TBM_SETRANGEMAX :: 0x0408 -TTM_GETTOOLINFOA :: 0x0408 -CBEM_GETEXSTYLE :: 0x0409 -CBEM_GETEXTENDEDSTYLE :: 0x0409 -PBM_SETBARCOLOR :: 0x0409 -RB_GETRECT :: 0x0409 -SB_SIMPLE :: 0x0409 -TB_ISBUTTONENABLED :: 0x0409 -TBM_CLEARTICS :: 0x0409 -TTM_SETTOOLINFOA :: 0x0409 -CBEM_HASEDITCHANGED :: 0x040a -RB_INSERTBANDW :: 0x040a -SB_GETRECT :: 0x040a -TB_ISBUTTONCHECKED :: 0x040a -TBM_SETSEL :: 0x040a -TTM_HITTESTA :: 0x040a -WIZ_QUERYNUMPAGES :: 0x040a -CBEM_INSERTITEMW :: 0x040b -RB_SETBANDINFOW :: 0x040b -SB_SETTEXTW :: 0x040b -TB_ISBUTTONPRESSED :: 0x040b -TBM_SETSELSTART :: 0x040b -TTM_GETTEXTA :: 0x040b -WIZ_NEXT :: 0x040b -CBEM_SETITEMW :: 0x040c -RB_GETBANDCOUNT :: 0x040c -SB_GETTEXTLENGTHW :: 0x040c -TB_ISBUTTONHIDDEN :: 0x040c -TBM_SETSELEND :: 0x040c -TTM_UPDATETIPTEXTA :: 0x040c -WIZ_PREV :: 0x040c -CBEM_GETITEMW :: 0x040d -RB_GETROWCOUNT :: 0x040d -SB_GETTEXTW :: 0x040d -TB_ISBUTTONINDETERMINATE :: 0x040d -TTM_GETTOOLCOUNT :: 0x040d -CBEM_SETEXTENDEDSTYLE :: 0x040e -RB_GETROWHEIGHT :: 0x040e -SB_ISSIMPLE :: 0x040e -TB_ISBUTTONHIGHLIGHTED :: 0x040e -TBM_GETPTICS :: 0x040e -TTM_ENUMTOOLSA :: 0x040e -SB_SETICON :: 0x040f -TBM_GETTICPOS :: 0x040f -TTM_GETCURRENTTOOLA :: 0x040f -RB_IDTOINDEX :: 0x0410 -SB_SETTIPTEXTA :: 0x0410 -TBM_GETNUMTICS :: 0x0410 -TTM_WINDOWFROMPOINT :: 0x0410 -RB_GETTOOLTIPS :: 0x0411 -SB_SETTIPTEXTW :: 0x0411 -TBM_GETSELSTART :: 0x0411 -TB_SETSTATE :: 0x0411 -TTM_TRACKACTIVATE :: 0x0411 -RB_SETTOOLTIPS :: 0x0412 -SB_GETTIPTEXTA :: 0x0412 -TB_GETSTATE :: 0x0412 -TBM_GETSELEND :: 0x0412 -TTM_TRACKPOSITION :: 0x0412 -RB_SETBKCOLOR :: 0x0413 -SB_GETTIPTEXTW :: 0x0413 -TB_ADDBITMAP :: 0x0413 -TBM_CLEARSEL :: 0x0413 -TTM_SETTIPBKCOLOR :: 0x0413 -RB_GETBKCOLOR :: 0x0414 -SB_GETICON :: 0x0414 -TB_ADDBUTTONSA :: 0x0414 -TBM_SETTICFREQ :: 0x0414 -TTM_SETTIPTEXTCOLOR :: 0x0414 -RB_SETTEXTCOLOR :: 0x0415 -TB_INSERTBUTTONA :: 0x0415 -TBM_SETPAGESIZE :: 0x0415 -TTM_GETDELAYTIME :: 0x0415 -RB_GETTEXTCOLOR :: 0x0416 -TB_DELETEBUTTON :: 0x0416 -TBM_GETPAGESIZE :: 0x0416 -TTM_GETTIPBKCOLOR :: 0x0416 -RB_SIZETORECT :: 0x0417 -TB_GETBUTTON :: 0x0417 -TBM_SETLINESIZE :: 0x0417 -TTM_GETTIPTEXTCOLOR :: 0x0417 -RB_BEGINDRAG :: 0x0418 -TB_BUTTONCOUNT :: 0x0418 -TBM_GETLINESIZE :: 0x0418 -TTM_SETMAXTIPWIDTH :: 0x0418 -RB_ENDDRAG :: 0x0419 -TB_COMMANDTOINDEX :: 0x0419 -TBM_GETTHUMBRECT :: 0x0419 -TTM_GETMAXTIPWIDTH :: 0x0419 -RB_DRAGMOVE :: 0x041a -TBM_GETCHANNELRECT :: 0x041a -TB_SAVERESTOREA :: 0x041a -TTM_SETMARGIN :: 0x041a -RB_GETBARHEIGHT :: 0x041b -TB_CUSTOMIZE :: 0x041b -TBM_SETTHUMBLENGTH :: 0x041b -TTM_GETMARGIN :: 0x041b -RB_GETBANDINFOW :: 0x041c -TB_ADDSTRINGA :: 0x041c -TBM_GETTHUMBLENGTH :: 0x041c -TTM_POP :: 0x041c -RB_GETBANDINFOA :: 0x041d -TB_GETITEMRECT :: 0x041d -TBM_SETTOOLTIPS :: 0x041d -TTM_UPDATE :: 0x041d -RB_MINIMIZEBAND :: 0x041e -TB_BUTTONSTRUCTSIZE :: 0x041e -TBM_GETTOOLTIPS :: 0x041e -TTM_GETBUBBLESIZE :: 0x041e -RB_MAXIMIZEBAND :: 0x041f -TBM_SETTIPSIDE :: 0x041f -TB_SETBUTTONSIZE :: 0x041f -TTM_ADJUSTRECT :: 0x041f -TBM_SETBUDDY :: 0x0420 -TB_SETBITMAPSIZE :: 0x0420 -TTM_SETTITLEA :: 0x0420 -MSG_FTS_JUMP_VA :: 0x0421 -TB_AUTOSIZE :: 0x0421 -TBM_GETBUDDY :: 0x0421 -TTM_SETTITLEW :: 0x0421 -RB_GETBANDBORDERS :: 0x0422 -MSG_FTS_JUMP_QWORD :: 0x0423 -RB_SHOWBAND :: 0x0423 -TB_GETTOOLTIPS :: 0x0423 -MSG_REINDEX_REQUEST :: 0x0424 -TB_SETTOOLTIPS :: 0x0424 -MSG_FTS_WHERE_IS_IT :: 0x0425 -RB_SETPALETTE :: 0x0425 -TB_SETPARENT :: 0x0425 -RB_GETPALETTE :: 0x0426 -RB_MOVEBAND :: 0x0427 -TB_SETROWS :: 0x0427 -TB_GETROWS :: 0x0428 -TB_GETBITMAPFLAGS :: 0x0429 -TB_SETCMDID :: 0x042a -RB_PUSHCHEVRON :: 0x042b -TB_CHANGEBITMAP :: 0x042b -TB_GETBITMAP :: 0x042c -MSG_GET_DEFFONT :: 0x042d -TB_GETBUTTONTEXTA :: 0x042d -TB_REPLACEBITMAP :: 0x042e -TB_SETINDENT :: 0x042f -TB_SETIMAGELIST :: 0x0430 -TB_GETIMAGELIST :: 0x0431 -TB_LOADIMAGES :: 0x0432 -EM_CANPASTE :: 0x0432 -TTM_ADDTOOLW :: 0x0432 -EM_DISPLAYBAND :: 0x0433 -TB_GETRECT :: 0x0433 -TTM_DELTOOLW :: 0x0433 -EM_EXGETSEL :: 0x0434 -TB_SETHOTIMAGELIST :: 0x0434 -TTM_NEWTOOLRECTW :: 0x0434 -EM_EXLIMITTEXT :: 0x0435 -TB_GETHOTIMAGELIST :: 0x0435 -TTM_GETTOOLINFOW :: 0x0435 -EM_EXLINEFROMCHAR :: 0x0436 -TB_SETDISABLEDIMAGELIST :: 0x0436 -TTM_SETTOOLINFOW :: 0x0436 -EM_EXSETSEL :: 0x0437 -TB_GETDISABLEDIMAGELIST :: 0x0437 -TTM_HITTESTW :: 0x0437 -EM_FINDTEXT :: 0x0438 -TB_SETSTYLE :: 0x0438 -TTM_GETTEXTW :: 0x0438 -EM_FORMATRANGE :: 0x0439 -TB_GETSTYLE :: 0x0439 -TTM_UPDATETIPTEXTW :: 0x0439 -EM_GETCHARFORMAT :: 0x043a -TB_GETBUTTONSIZE :: 0x043a -TTM_ENUMTOOLSW :: 0x043a -EM_GETEVENTMASK :: 0x043b -TB_SETBUTTONWIDTH :: 0x043b -TTM_GETCURRENTTOOLW :: 0x043b -EM_GETOLEINTERFACE :: 0x043c -TB_SETMAXTEXTROWS :: 0x043c -EM_GETPARAFORMAT :: 0x043d -TB_GETTEXTROWS :: 0x043d -EM_GETSELTEXT :: 0x043e -TB_GETOBJECT :: 0x043e -EM_HIDESELECTION :: 0x043f -TB_GETBUTTONINFOW :: 0x043f -EM_PASTESPECIAL :: 0x0440 -TB_SETBUTTONINFOW :: 0x0440 -EM_REQUESTRESIZE :: 0x0441 -TB_GETBUTTONINFOA :: 0x0441 -EM_SELECTIONTYPE :: 0x0442 -TB_SETBUTTONINFOA :: 0x0442 -EM_SETBKGNDCOLOR :: 0x0443 -TB_INSERTBUTTONW :: 0x0443 -EM_SETCHARFORMAT :: 0x0444 -TB_ADDBUTTONSW :: 0x0444 -EM_SETEVENTMASK :: 0x0445 -TB_HITTEST :: 0x0445 -EM_SETOLECALLBACK :: 0x0446 -TB_SETDRAWTEXTFLAGS :: 0x0446 -EM_SETPARAFORMAT :: 0x0447 -TB_GETHOTITEM :: 0x0447 -EM_SETTARGETDEVICE :: 0x0448 -TB_SETHOTITEM :: 0x0448 -EM_STREAMIN :: 0x0449 -TB_SETANCHORHIGHLIGHT :: 0x0449 -EM_STREAMOUT :: 0x044a -TB_GETANCHORHIGHLIGHT :: 0x044a -EM_GETTEXTRANGE :: 0x044b -TB_GETBUTTONTEXTW :: 0x044b -EM_FINDWORDBREAK :: 0x044c -TB_SAVERESTOREW :: 0x044c -EM_SETOPTIONS :: 0x044d -TB_ADDSTRINGW :: 0x044d -EM_GETOPTIONS :: 0x044e -TB_MAPACCELERATORA :: 0x044e -EM_FINDTEXTEX :: 0x044f -TB_GETINSERTMARK :: 0x044f -EM_GETWORDBREAKPROCEX :: 0x0450 -TB_SETINSERTMARK :: 0x0450 -EM_SETWORDBREAKPROCEX :: 0x0451 -TB_INSERTMARKHITTEST :: 0x0451 -EM_SETUNDOLIMIT :: 0x0452 -TB_MOVEBUTTON :: 0x0452 -TB_GETMAXSIZE :: 0x0453 -EM_REDO :: 0x0454 -TB_SETEXTENDEDSTYLE :: 0x0454 -EM_CANREDO :: 0x0455 -TB_GETEXTENDEDSTYLE :: 0x0455 -EM_GETUNDONAME :: 0x0456 -TB_GETPADDING :: 0x0456 -EM_GETREDONAME :: 0x0457 -TB_SETPADDING :: 0x0457 -EM_STOPGROUPTYPING :: 0x0458 -TB_SETINSERTMARKCOLOR :: 0x0458 -EM_SETTEXTMODE :: 0x0459 -TB_GETINSERTMARKCOLOR :: 0x0459 -EM_GETTEXTMODE :: 0x045a -TB_MAPACCELERATORW :: 0x045a -EM_AUTOURLDETECT :: 0x045b -TB_GETSTRINGW :: 0x045b -EM_GETAUTOURLDETECT :: 0x045c -TB_GETSTRINGA :: 0x045c -EM_SETPALETTE :: 0x045d -EM_GETTEXTEX :: 0x045e -EM_GETTEXTLENGTHEX :: 0x045f -EM_SHOWSCROLLBAR :: 0x0460 -EM_SETTEXTEX :: 0x0461 -TAPI_REPLY :: 0x0463 -ACM_OPENA :: 0x0464 -BFFM_SETSTATUSTEXTA :: 0x0464 -CDM_FIRST :: 0x0464 -CDM_GETSPEC :: 0x0464 -EM_SETPUNCTUATION :: 0x0464 -IPM_CLEARADDRESS :: 0x0464 -WM_CAP_UNICODE_START :: 0x0464 -ACM_PLAY :: 0x0465 -BFFM_ENABLEOK :: 0x0465 -CDM_GETFILEPATH :: 0x0465 -EM_GETPUNCTUATION :: 0x0465 -IPM_SETADDRESS :: 0x0465 -PSM_SETCURSEL :: 0x0465 -UDM_SETRANGE :: 0x0465 -WM_CHOOSEFONT_SETLOGFONT :: 0x0465 -ACM_STOP :: 0x0466 -BFFM_SETSELECTIONA :: 0x0466 -CDM_GETFOLDERPATH :: 0x0466 -EM_SETWORDWRAPMODE :: 0x0466 -IPM_GETADDRESS :: 0x0466 -PSM_REMOVEPAGE :: 0x0466 -UDM_GETRANGE :: 0x0466 -WM_CAP_SET_CALLBACK_ERRORW :: 0x0466 -WM_CHOOSEFONT_SETFLAGS :: 0x0466 -ACM_OPENW :: 0x0467 -BFFM_SETSELECTIONW :: 0x0467 -CDM_GETFOLDERIDLIST :: 0x0467 -EM_GETWORDWRAPMODE :: 0x0467 -IPM_SETRANGE :: 0x0467 -PSM_ADDPAGE :: 0x0467 -UDM_SETPOS :: 0x0467 -WM_CAP_SET_CALLBACK_STATUSW :: 0x0467 -BFFM_SETSTATUSTEXTW :: 0x0468 -CDM_SETCONTROLTEXT :: 0x0468 -EM_SETIMECOLOR :: 0x0468 -IPM_SETFOCUS :: 0x0468 -PSM_CHANGED :: 0x0468 -UDM_GETPOS :: 0x0468 -CDM_HIDECONTROL :: 0x0469 -EM_GETIMECOLOR :: 0x0469 -IPM_ISBLANK :: 0x0469 -PSM_RESTARTWINDOWS :: 0x0469 -UDM_SETBUDDY :: 0x0469 -CDM_SETDEFEXT :: 0x046a -EM_SETIMEOPTIONS :: 0x046a -PSM_REBOOTSYSTEM :: 0x046a -UDM_GETBUDDY :: 0x046a -EM_GETIMEOPTIONS :: 0x046b -PSM_CANCELTOCLOSE :: 0x046b -UDM_SETACCEL :: 0x046b -EM_CONVPOSITION :: 0x046c -PSM_QUERYSIBLINGS :: 0x046c -UDM_GETACCEL :: 0x046c -MCIWNDM_GETZOOM :: 0x046d -PSM_UNCHANGED :: 0x046d -UDM_SETBASE :: 0x046d -PSM_APPLY :: 0x046e -UDM_GETBASE :: 0x046e -PSM_SETTITLEA :: 0x046f -UDM_SETRANGE32 :: 0x046f -PSM_SETWIZBUTTONS :: 0x0470 -UDM_GETRANGE32 :: 0x0470 -WM_CAP_DRIVER_GET_NAMEW :: 0x0470 -PSM_PRESSBUTTON :: 0x0471 -UDM_SETPOS32 :: 0x0471 -WM_CAP_DRIVER_GET_VERSIONW :: 0x0471 -PSM_SETCURSELID :: 0x0472 -UDM_GETPOS32 :: 0x0472 -PSM_SETFINISHTEXTA :: 0x0473 -PSM_GETTABCONTROL :: 0x0474 -PSM_ISDIALOGMESSAGE :: 0x0475 -MCIWNDM_REALIZE :: 0x0476 -PSM_GETCURRENTPAGEHWND :: 0x0476 -MCIWNDM_SETTIMEFORMATA :: 0x0477 -PSM_INSERTPAGE :: 0x0477 -EM_SETLANGOPTIONS :: 0x0478 -MCIWNDM_GETTIMEFORMATA :: 0x0478 -PSM_SETTITLEW :: 0x0478 -WM_CAP_FILE_SET_CAPTURE_FILEW :: 0x0478 -EM_GETLANGOPTIONS :: 0x0479 -MCIWNDM_VALIDATEMEDIA :: 0x0479 -PSM_SETFINISHTEXTW :: 0x0479 -WM_CAP_FILE_GET_CAPTURE_FILEW :: 0x0479 -EM_GETIMECOMPMODE :: 0x047a -EM_FINDTEXTW :: 0x047b -MCIWNDM_PLAYTO :: 0x047b -WM_CAP_FILE_SAVEASW :: 0x047b -EM_FINDTEXTEXW :: 0x047c -MCIWNDM_GETFILENAMEA :: 0x047c -EM_RECONVERSION :: 0x047d -MCIWNDM_GETDEVICEA :: 0x047d -PSM_SETHEADERTITLEA :: 0x047d -WM_CAP_FILE_SAVEDIBW :: 0x047d -EM_SETIMEMODEBIAS :: 0x047e -MCIWNDM_GETPALETTE :: 0x047e -PSM_SETHEADERTITLEW :: 0x047e -EM_GETIMEMODEBIAS :: 0x047f -MCIWNDM_SETPALETTE :: 0x047f -PSM_SETHEADERSUBTITLEA :: 0x047f -MCIWNDM_GETERRORA :: 0x0480 -PSM_SETHEADERSUBTITLEW :: 0x0480 -PSM_HWNDTOINDEX :: 0x0481 -PSM_INDEXTOHWND :: 0x0482 -MCIWNDM_SETINACTIVETIMER :: 0x0483 -PSM_PAGETOINDEX :: 0x0483 -PSM_INDEXTOPAGE :: 0x0484 -DL_BEGINDRAG :: 0x0485 -MCIWNDM_GETINACTIVETIMER :: 0x0485 -PSM_IDTOINDEX :: 0x0485 -DL_DRAGGING :: 0x0486 -PSM_INDEXTOID :: 0x0486 -DL_DROPPED :: 0x0487 -PSM_GETRESULT :: 0x0487 -DL_CANCELDRAG :: 0x0488 -PSM_RECALCPAGESIZES :: 0x0488 -MCIWNDM_GET_SOURCE :: 0x048c -MCIWNDM_PUT_SOURCE :: 0x048d -MCIWNDM_GET_DEST :: 0x048e -MCIWNDM_PUT_DEST :: 0x048f -MCIWNDM_CAN_PLAY :: 0x0490 -MCIWNDM_CAN_WINDOW :: 0x0491 -MCIWNDM_CAN_RECORD :: 0x0492 -MCIWNDM_CAN_SAVE :: 0x0493 -MCIWNDM_CAN_EJECT :: 0x0494 -MCIWNDM_CAN_CONFIG :: 0x0495 -IE_GETINK :: 0x0496 -IE_MSGFIRST :: 0x0496 -MCIWNDM_PALETTEKICK :: 0x0496 -IE_SETINK :: 0x0497 -IE_GETPENTIP :: 0x0498 -IE_SETPENTIP :: 0x0499 -IE_GETERASERTIP :: 0x049a -IE_SETERASERTIP :: 0x049b -IE_GETBKGND :: 0x049c -IE_SETBKGND :: 0x049d -IE_GETGRIDORIGIN :: 0x049e -IE_SETGRIDORIGIN :: 0x049f -IE_GETGRIDPEN :: 0x04a0 -IE_SETGRIDPEN :: 0x04a1 -IE_GETGRIDSIZE :: 0x04a2 -IE_SETGRIDSIZE :: 0x04a3 -IE_GETMODE :: 0x04a4 -IE_SETMODE :: 0x04a5 -IE_GETINKRECT :: 0x04a6 -WM_CAP_SET_MCI_DEVICEW :: 0x04a6 -WM_CAP_GET_MCI_DEVICEW :: 0x04a7 -WM_CAP_PAL_OPENW :: 0x04b4 -WM_CAP_PAL_SAVEW :: 0x04b5 -IE_GETAPPDATA :: 0x04b8 -IE_SETAPPDATA :: 0x04b9 -IE_GETDRAWOPTS :: 0x04ba -IE_SETDRAWOPTS :: 0x04bb -IE_GETFORMAT :: 0x04bc -IE_SETFORMAT :: 0x04bd -IE_GETINKINPUT :: 0x04be -IE_SETINKINPUT :: 0x04bf -IE_GETNOTIFY :: 0x04c0 -IE_SETNOTIFY :: 0x04c1 -IE_GETRECOG :: 0x04c2 -IE_SETRECOG :: 0x04c3 -IE_GETSECURITY :: 0x04c4 -IE_SETSECURITY :: 0x04c5 -IE_GETSEL :: 0x04c6 -IE_SETSEL :: 0x04c7 -CDM_LAST :: 0x04c8 -EM_SETBIDIOPTIONS :: 0x04c8 -IE_DOCOMMAND :: 0x04c8 -MCIWNDM_NOTIFYMODE :: 0x04c8 -EM_GETBIDIOPTIONS :: 0x04c9 -IE_GETCOMMAND :: 0x04c9 -EM_SETTYPOGRAPHYOPTIONS :: 0x04ca -IE_GETCOUNT :: 0x04ca -EM_GETTYPOGRAPHYOPTIONS :: 0x04cb -IE_GETGESTURE :: 0x04cb -MCIWNDM_NOTIFYMEDIA :: 0x04cb -EM_SETEDITSTYLE :: 0x04cc -IE_GETMENU :: 0x04cc -EM_GETEDITSTYLE :: 0x04cd -IE_GETPAINTDC :: 0x04cd -MCIWNDM_NOTIFYERROR :: 0x04cd -IE_GETPDEVENT :: 0x04ce -IE_GETSELCOUNT :: 0x04cf -IE_GETSELITEMS :: 0x04d0 -IE_GETSTYLE :: 0x04d1 -MCIWNDM_SETTIMEFORMATW :: 0x04db -EM_OUTLINE :: 0x04dc -MCIWNDM_GETTIMEFORMATW :: 0x04dc -EM_GETSCROLLPOS :: 0x04dd -EM_SETSCROLLPOS :: 0x04de -EM_SETFONTSIZE :: 0x04df -EM_GETZOOM :: 0x04e0 -MCIWNDM_GETFILENAMEW :: 0x04e0 -EM_SETZOOM :: 0x04e1 -MCIWNDM_GETDEVICEW :: 0x04e1 -EM_GETVIEWKIND :: 0x04e2 -EM_SETVIEWKIND :: 0x04e3 -EM_GETPAGE :: 0x04e4 -MCIWNDM_GETERRORW :: 0x04e4 -EM_SETPAGE :: 0x04e5 -EM_GETHYPHENATEINFO :: 0x04e6 -EM_SETHYPHENATEINFO :: 0x04e7 -EM_GETPAGEROTATE :: 0x04eb -EM_SETPAGEROTATE :: 0x04ec -EM_GETCTFMODEBIAS :: 0x04ed -EM_SETCTFMODEBIAS :: 0x04ee -EM_GETCTFOPENSTATUS :: 0x04f0 -EM_SETCTFOPENSTATUS :: 0x04f1 -EM_GETIMECOMPTEXT :: 0x04f2 -EM_ISIME :: 0x04f3 -EM_GETIMEPROPERTY :: 0x04f4 -EM_GETQUERYRTFOBJ :: 0x050d -EM_SETQUERYRTFOBJ :: 0x050e -FM_GETFOCUS :: 0x0600 -FM_GETDRIVEINFOA :: 0x0601 -FM_GETSELCOUNT :: 0x0602 -FM_GETSELCOUNTLFN :: 0x0603 -FM_GETFILESELA :: 0x0604 -FM_GETFILESELLFNA :: 0x0605 -FM_REFRESH_WINDOWS :: 0x0606 -FM_RELOAD_EXTENSIONS :: 0x0607 -FM_GETDRIVEINFOW :: 0x0611 -FM_GETFILESELW :: 0x0614 -FM_GETFILESELLFNW :: 0x0615 -WLX_WM_SAS :: 0x0659 -SM_GETSELCOUNT :: 0x07e8 -UM_GETSELCOUNT :: 0x07e8 -WM_CPL_LAUNCH :: 0x07e8 -SM_GETSERVERSELA :: 0x07e9 -UM_GETUSERSELA :: 0x07e9 -WM_CPL_LAUNCHED :: 0x07e9 -SM_GETSERVERSELW :: 0x07ea -UM_GETUSERSELW :: 0x07ea -SM_GETCURFOCUSA :: 0x07eb -UM_GETGROUPSELA :: 0x07eb -SM_GETCURFOCUSW :: 0x07ec -UM_GETGROUPSELW :: 0x07ec -SM_GETOPTIONS :: 0x07ed -UM_GETCURFOCUSA :: 0x07ed -UM_GETCURFOCUSW :: 0x07ee -UM_GETOPTIONS :: 0x07ef -UM_GETOPTIONS2 :: 0x07f0 -LVM_FIRST :: 0x1000 -LVM_GETBKCOLOR :: 0x1000 -LVM_SETBKCOLOR :: 0x1001 -LVM_GETIMAGELIST :: 0x1002 -LVM_SETIMAGELIST :: 0x1003 -LVM_GETITEMCOUNT :: 0x1004 -LVM_GETITEMA :: 0x1005 -LVM_SETITEMA :: 0x1006 -LVM_INSERTITEMA :: 0x1007 -LVM_DELETEITEM :: 0x1008 -LVM_DELETEALLITEMS :: 0x1009 -LVM_GETCALLBACKMASK :: 0x100a -LVM_SETCALLBACKMASK :: 0x100b -LVM_GETNEXTITEM :: 0x100c -LVM_FINDITEMA :: 0x100d -LVM_GETITEMRECT :: 0x100e -LVM_SETITEMPOSITION :: 0x100f -LVM_GETITEMPOSITION :: 0x1010 -LVM_GETSTRINGWIDTHA :: 0x1011 -LVM_HITTEST :: 0x1012 -LVM_ENSUREVISIBLE :: 0x1013 -LVM_SCROLL :: 0x1014 -LVM_REDRAWITEMS :: 0x1015 -LVM_ARRANGE :: 0x1016 -LVM_EDITLABELA :: 0x1017 -LVM_GETEDITCONTROL :: 0x1018 -LVM_GETCOLUMNA :: 0x1019 -LVM_SETCOLUMNA :: 0x101a -LVM_INSERTCOLUMNA :: 0x101b -LVM_DELETECOLUMN :: 0x101c -LVM_GETCOLUMNWIDTH :: 0x101d -LVM_SETCOLUMNWIDTH :: 0x101e -LVM_GETHEADER :: 0x101f -LVM_CREATEDRAGIMAGE :: 0x1021 -LVM_GETVIEWRECT :: 0x1022 -LVM_GETTEXTCOLOR :: 0x1023 -LVM_SETTEXTCOLOR :: 0x1024 -LVM_GETTEXTBKCOLOR :: 0x1025 -LVM_SETTEXTBKCOLOR :: 0x1026 -LVM_GETTOPINDEX :: 0x1027 -LVM_GETCOUNTPERPAGE :: 0x1028 -LVM_GETORIGIN :: 0x1029 -LVM_UPDATE :: 0x102a -LVM_SETITEMSTATE :: 0x102b -LVM_GETITEMSTATE :: 0x102c -LVM_GETITEMTEXTA :: 0x102d -LVM_SETITEMTEXTA :: 0x102e -LVM_SETITEMCOUNT :: 0x102f -LVM_SORTITEMS :: 0x1030 -LVM_SETITEMPOSITION32 :: 0x1031 -LVM_GETSELECTEDCOUNT :: 0x1032 -LVM_GETITEMSPACING :: 0x1033 -LVM_GETISEARCHSTRINGA :: 0x1034 -LVM_SETICONSPACING :: 0x1035 -LVM_SETEXTENDEDLISTVIEWSTYLE :: 0x1036 -LVM_GETEXTENDEDLISTVIEWSTYLE :: 0x1037 -LVM_GETSUBITEMRECT :: 0x1038 -LVM_SUBITEMHITTEST :: 0x1039 -LVM_SETCOLUMNORDERARRAY :: 0x103a -LVM_GETCOLUMNORDERARRAY :: 0x103b -LVM_SETHOTITEM :: 0x103c -LVM_GETHOTITEM :: 0x103d -LVM_SETHOTCURSOR :: 0x103e -LVM_GETHOTCURSOR :: 0x103f -LVM_APPROXIMATEVIEWRECT :: 0x1040 -LVM_SETWORKAREAS :: 0x1041 -LVM_GETSELECTIONMARK :: 0x1042 -LVM_SETSELECTIONMARK :: 0x1043 -LVM_SETBKIMAGEA :: 0x1044 -LVM_GETBKIMAGEA :: 0x1045 -LVM_GETWORKAREAS :: 0x1046 -LVM_SETHOVERTIME :: 0x1047 -LVM_GETHOVERTIME :: 0x1048 -LVM_GETNUMBEROFWORKAREAS :: 0x1049 -LVM_SETTOOLTIPS :: 0x104a -LVM_GETITEMW :: 0x104b -LVM_SETITEMW :: 0x104c -LVM_INSERTITEMW :: 0x104d -LVM_GETTOOLTIPS :: 0x104e -LVM_FINDITEMW :: 0x1053 -LVM_GETSTRINGWIDTHW :: 0x1057 -LVM_GETCOLUMNW :: 0x105f -LVM_SETCOLUMNW :: 0x1060 -LVM_INSERTCOLUMNW :: 0x1061 -LVM_GETITEMTEXTW :: 0x1073 -LVM_SETITEMTEXTW :: 0x1074 -LVM_GETISEARCHSTRINGW :: 0x1075 -LVM_EDITLABELW :: 0x1076 -LVM_GETBKIMAGEW :: 0x108b -LVM_SETSELECTEDCOLUMN :: 0x108c -LVM_SETTILEWIDTH :: 0x108d -LVM_SETVIEW :: 0x108e -LVM_GETVIEW :: 0x108f -LVM_INSERTGROUP :: 0x1091 -LVM_SETGROUPINFO :: 0x1093 -LVM_GETGROUPINFO :: 0x1095 -LVM_REMOVEGROUP :: 0x1096 -LVM_MOVEGROUP :: 0x1097 -LVM_MOVEITEMTOGROUP :: 0x109a -LVM_SETGROUPMETRICS :: 0x109b -LVM_GETGROUPMETRICS :: 0x109c -LVM_ENABLEGROUPVIEW :: 0x109d -LVM_SORTGROUPS :: 0x109e -LVM_INSERTGROUPSORTED :: 0x109f -LVM_REMOVEALLGROUPS :: 0x10a0 -LVM_HASGROUP :: 0x10a1 -LVM_SETTILEVIEWINFO :: 0x10a2 -LVM_GETTILEVIEWINFO :: 0x10a3 -LVM_SETTILEINFO :: 0x10a4 -LVM_GETTILEINFO :: 0x10a5 -LVM_SETINSERTMARK :: 0x10a6 -LVM_GETINSERTMARK :: 0x10a7 -LVM_INSERTMARKHITTEST :: 0x10a8 -LVM_GETINSERTMARKRECT :: 0x10a9 -LVM_SETINSERTMARKCOLOR :: 0x10aa -LVM_GETINSERTMARKCOLOR :: 0x10ab -LVM_SETINFOTIP :: 0x10ad -LVM_GETSELECTEDCOLUMN :: 0x10ae -LVM_ISGROUPVIEWENABLED :: 0x10af -LVM_GETOUTLINECOLOR :: 0x10b0 -LVM_SETOUTLINECOLOR :: 0x10b1 -LVM_CANCELEDITLABEL :: 0x10b3 -LVM_MAPINDEXTOID :: 0x10b4 -LVM_MAPIDTOINDEX :: 0x10b5 -LVM_ISITEMVISIBLE :: 0x10b6 -LVM_GETEMPTYTEXT :: 0x10cc -LVM_GETFOOTERRECT :: 0x10cd -LVM_GETFOOTERINFO :: 0x10ce -LVM_GETFOOTERITEMRECT :: 0x10cf -LVM_GETFOOTERITEM :: 0x10d0 -LVM_GETITEMINDEXRECT :: 0x10d1 -LVM_SETITEMINDEXSTATE :: 0x10d2 -LVM_GETNEXTITEMINDEX :: 0x10d3 -OCM__BASE :: 0x2000 -LVM_SETUNICODEFORMAT :: 0x2005 -LVM_GETUNICODEFORMAT :: 0x2006 -OCM_CTLCOLOR :: 0x2019 -OCM_DRAWITEM :: 0x202b -OCM_MEASUREITEM :: 0x202c -OCM_DELETEITEM :: 0x202d -OCM_VKEYTOITEM :: 0x202e -OCM_CHARTOITEM :: 0x202f -OCM_COMPAREITEM :: 0x2039 -OCM_NOTIFY :: 0x204e -OCM_COMMAND :: 0x2111 -OCM_HSCROLL :: 0x2114 -OCM_VSCROLL :: 0x2115 -OCM_CTLCOLORMSGBOX :: 0x2132 -OCM_CTLCOLOREDIT :: 0x2133 -OCM_CTLCOLORLISTBOX :: 0x2134 -OCM_CTLCOLORBTN :: 0x2135 -OCM_CTLCOLORDLG :: 0x2136 -OCM_CTLCOLORSCROLLBAR :: 0x2137 -OCM_CTLCOLORSTATIC :: 0x2138 -OCM_PARENTNOTIFY :: 0x2210 -WM_APP :: 0x8000 -WM_RASDIALEVENT :: 0xcccd +WM_GETTITLEBARINFOEX :: 0x033F +WM_HANDHELDFIRST :: 0x0358 +WM_HANDHELDLAST :: 0x035f +WM_AFXFIRST :: 0x0360 +WM_AFXLAST :: 0x037f +WM_PENWINFIRST :: 0x0380 +WM_RCRESULT :: 0x0381 +WM_HOOKRCRESULT :: 0x0382 +WM_GLOBALRCCHANGE :: 0x0383 +WM_PENMISCINFO :: 0x0383 +WM_SKB :: 0x0384 +WM_HEDITCTL :: 0x0385 +WM_PENCTL :: 0x0385 +WM_PENMISC :: 0x0386 +WM_CTLINIT :: 0x0387 +WM_PENEVENT :: 0x0388 +WM_PENWINLAST :: 0x038f +DDM_SETFMT :: 0x0400 +DM_GETDEFID :: 0x0400 +NIN_SELECT :: 0x0400 +TBM_GETPOS :: 0x0400 +WM_PSD_PAGESETUPDLG :: 0x0400 +WM_USER :: 0x0400 +CBEM_INSERTITEMA :: 0x0401 +DDM_DRAW :: 0x0401 +DM_SETDEFID :: 0x0401 +HKM_SETHOTKEY :: 0x0401 +PBM_SETRANGE :: 0x0401 +RB_INSERTBANDA :: 0x0401 +SB_SETTEXTA :: 0x0401 +TB_ENABLEBUTTON :: 0x0401 +TBM_GETRANGEMIN :: 0x0401 +TTM_ACTIVATE :: 0x0401 +WM_CHOOSEFONT_GETLOGFONT :: 0x0401 +WM_PSD_FULLPAGERECT :: 0x0401 +CBEM_SETIMAGELIST :: 0x0402 +DDM_CLOSE :: 0x0402 +DM_REPOSITION :: 0x0402 +HKM_GETHOTKEY :: 0x0402 +PBM_SETPOS :: 0x0402 +RB_DELETEBAND :: 0x0402 +SB_GETTEXTA :: 0x0402 +TB_CHECKBUTTON :: 0x0402 +TBM_GETRANGEMAX :: 0x0402 +WM_PSD_MINMARGINRECT :: 0x0402 +CBEM_GETIMAGELIST :: 0x0403 +DDM_BEGIN :: 0x0403 +HKM_SETRULES :: 0x0403 +PBM_DELTAPOS :: 0x0403 +RB_GETBARINFO :: 0x0403 +SB_GETTEXTLENGTHA :: 0x0403 +TBM_GETTIC :: 0x0403 +TB_PRESSBUTTON :: 0x0403 +TTM_SETDELAYTIME :: 0x0403 +WM_PSD_MARGINRECT :: 0x0403 +CBEM_GETITEMA :: 0x0404 +DDM_END :: 0x0404 +PBM_SETSTEP :: 0x0404 +RB_SETBARINFO :: 0x0404 +SB_SETPARTS :: 0x0404 +TB_HIDEBUTTON :: 0x0404 +TBM_SETTIC :: 0x0404 +TTM_ADDTOOLA :: 0x0404 +WM_PSD_GREEKTEXTRECT :: 0x0404 +CBEM_SETITEMA :: 0x0405 +PBM_STEPIT :: 0x0405 +TB_INDETERMINATE :: 0x0405 +TBM_SETPOS :: 0x0405 +TTM_DELTOOLA :: 0x0405 +WM_PSD_ENVSTAMPRECT :: 0x0405 +CBEM_GETCOMBOCONTROL :: 0x0406 +PBM_SETRANGE32 :: 0x0406 +RB_SETBANDINFOA :: 0x0406 +SB_GETPARTS :: 0x0406 +TB_MARKBUTTON :: 0x0406 +TBM_SETRANGE :: 0x0406 +TTM_NEWTOOLRECTA :: 0x0406 +WM_PSD_YAFULLPAGERECT :: 0x0406 +CBEM_GETEDITCONTROL :: 0x0407 +PBM_GETRANGE :: 0x0407 +RB_SETPARENT :: 0x0407 +SB_GETBORDERS :: 0x0407 +TBM_SETRANGEMIN :: 0x0407 +TTM_RELAYEVENT :: 0x0407 +CBEM_SETEXSTYLE :: 0x0408 +PBM_GETPOS :: 0x0408 +RB_HITTEST :: 0x0408 +SB_SETMINHEIGHT :: 0x0408 +TBM_SETRANGEMAX :: 0x0408 +TTM_GETTOOLINFOA :: 0x0408 +CBEM_GETEXSTYLE :: 0x0409 +CBEM_GETEXTENDEDSTYLE :: 0x0409 +PBM_SETBARCOLOR :: 0x0409 +RB_GETRECT :: 0x0409 +SB_SIMPLE :: 0x0409 +TB_ISBUTTONENABLED :: 0x0409 +TBM_CLEARTICS :: 0x0409 +TTM_SETTOOLINFOA :: 0x0409 +CBEM_HASEDITCHANGED :: 0x040a +RB_INSERTBANDW :: 0x040a +SB_GETRECT :: 0x040a +TB_ISBUTTONCHECKED :: 0x040a +TBM_SETSEL :: 0x040a +TTM_HITTESTA :: 0x040a +WIZ_QUERYNUMPAGES :: 0x040a +CBEM_INSERTITEMW :: 0x040b +RB_SETBANDINFOW :: 0x040b +SB_SETTEXTW :: 0x040b +TB_ISBUTTONPRESSED :: 0x040b +TBM_SETSELSTART :: 0x040b +TTM_GETTEXTA :: 0x040b +WIZ_NEXT :: 0x040b +CBEM_SETITEMW :: 0x040c +RB_GETBANDCOUNT :: 0x040c +SB_GETTEXTLENGTHW :: 0x040c +TB_ISBUTTONHIDDEN :: 0x040c +TBM_SETSELEND :: 0x040c +TTM_UPDATETIPTEXTA :: 0x040c +WIZ_PREV :: 0x040c +CBEM_GETITEMW :: 0x040d +RB_GETROWCOUNT :: 0x040d +SB_GETTEXTW :: 0x040d +TB_ISBUTTONINDETERMINATE :: 0x040d +TTM_GETTOOLCOUNT :: 0x040d +CBEM_SETEXTENDEDSTYLE :: 0x040e +RB_GETROWHEIGHT :: 0x040e +SB_ISSIMPLE :: 0x040e +TB_ISBUTTONHIGHLIGHTED :: 0x040e +TBM_GETPTICS :: 0x040e +TTM_ENUMTOOLSA :: 0x040e +SB_SETICON :: 0x040f +TBM_GETTICPOS :: 0x040f +TTM_GETCURRENTTOOLA :: 0x040f +RB_IDTOINDEX :: 0x0410 +SB_SETTIPTEXTA :: 0x0410 +TBM_GETNUMTICS :: 0x0410 +TTM_WINDOWFROMPOINT :: 0x0410 +RB_GETTOOLTIPS :: 0x0411 +SB_SETTIPTEXTW :: 0x0411 +TBM_GETSELSTART :: 0x0411 +TB_SETSTATE :: 0x0411 +TTM_TRACKACTIVATE :: 0x0411 +RB_SETTOOLTIPS :: 0x0412 +SB_GETTIPTEXTA :: 0x0412 +TB_GETSTATE :: 0x0412 +TBM_GETSELEND :: 0x0412 +TTM_TRACKPOSITION :: 0x0412 +RB_SETBKCOLOR :: 0x0413 +SB_GETTIPTEXTW :: 0x0413 +TB_ADDBITMAP :: 0x0413 +TBM_CLEARSEL :: 0x0413 +TTM_SETTIPBKCOLOR :: 0x0413 +RB_GETBKCOLOR :: 0x0414 +SB_GETICON :: 0x0414 +TB_ADDBUTTONSA :: 0x0414 +TBM_SETTICFREQ :: 0x0414 +TTM_SETTIPTEXTCOLOR :: 0x0414 +RB_SETTEXTCOLOR :: 0x0415 +TB_INSERTBUTTONA :: 0x0415 +TBM_SETPAGESIZE :: 0x0415 +TTM_GETDELAYTIME :: 0x0415 +RB_GETTEXTCOLOR :: 0x0416 +TB_DELETEBUTTON :: 0x0416 +TBM_GETPAGESIZE :: 0x0416 +TTM_GETTIPBKCOLOR :: 0x0416 +RB_SIZETORECT :: 0x0417 +TB_GETBUTTON :: 0x0417 +TBM_SETLINESIZE :: 0x0417 +TTM_GETTIPTEXTCOLOR :: 0x0417 +RB_BEGINDRAG :: 0x0418 +TB_BUTTONCOUNT :: 0x0418 +TBM_GETLINESIZE :: 0x0418 +TTM_SETMAXTIPWIDTH :: 0x0418 +RB_ENDDRAG :: 0x0419 +TB_COMMANDTOINDEX :: 0x0419 +TBM_GETTHUMBRECT :: 0x0419 +TTM_GETMAXTIPWIDTH :: 0x0419 +RB_DRAGMOVE :: 0x041a +TBM_GETCHANNELRECT :: 0x041a +TB_SAVERESTOREA :: 0x041a +TTM_SETMARGIN :: 0x041a +RB_GETBARHEIGHT :: 0x041b +TB_CUSTOMIZE :: 0x041b +TBM_SETTHUMBLENGTH :: 0x041b +TTM_GETMARGIN :: 0x041b +RB_GETBANDINFOW :: 0x041c +TB_ADDSTRINGA :: 0x041c +TBM_GETTHUMBLENGTH :: 0x041c +TTM_POP :: 0x041c +RB_GETBANDINFOA :: 0x041d +TB_GETITEMRECT :: 0x041d +TBM_SETTOOLTIPS :: 0x041d +TTM_UPDATE :: 0x041d +RB_MINIMIZEBAND :: 0x041e +TB_BUTTONSTRUCTSIZE :: 0x041e +TBM_GETTOOLTIPS :: 0x041e +TTM_GETBUBBLESIZE :: 0x041e +RB_MAXIMIZEBAND :: 0x041f +TBM_SETTIPSIDE :: 0x041f +TB_SETBUTTONSIZE :: 0x041f +TTM_ADJUSTRECT :: 0x041f +TBM_SETBUDDY :: 0x0420 +TB_SETBITMAPSIZE :: 0x0420 +TTM_SETTITLEA :: 0x0420 +MSG_FTS_JUMP_VA :: 0x0421 +TB_AUTOSIZE :: 0x0421 +TBM_GETBUDDY :: 0x0421 +TTM_SETTITLEW :: 0x0421 +RB_GETBANDBORDERS :: 0x0422 +MSG_FTS_JUMP_QWORD :: 0x0423 +RB_SHOWBAND :: 0x0423 +TB_GETTOOLTIPS :: 0x0423 +MSG_REINDEX_REQUEST :: 0x0424 +TB_SETTOOLTIPS :: 0x0424 +MSG_FTS_WHERE_IS_IT :: 0x0425 +RB_SETPALETTE :: 0x0425 +TB_SETPARENT :: 0x0425 +RB_GETPALETTE :: 0x0426 +RB_MOVEBAND :: 0x0427 +TB_SETROWS :: 0x0427 +TB_GETROWS :: 0x0428 +TB_GETBITMAPFLAGS :: 0x0429 +TB_SETCMDID :: 0x042a +RB_PUSHCHEVRON :: 0x042b +TB_CHANGEBITMAP :: 0x042b +TB_GETBITMAP :: 0x042c +MSG_GET_DEFFONT :: 0x042d +TB_GETBUTTONTEXTA :: 0x042d +TB_REPLACEBITMAP :: 0x042e +TB_SETINDENT :: 0x042f +TB_SETIMAGELIST :: 0x0430 +TB_GETIMAGELIST :: 0x0431 +TB_LOADIMAGES :: 0x0432 +EM_CANPASTE :: 0x0432 +TTM_ADDTOOLW :: 0x0432 +EM_DISPLAYBAND :: 0x0433 +TB_GETRECT :: 0x0433 +TTM_DELTOOLW :: 0x0433 +EM_EXGETSEL :: 0x0434 +TB_SETHOTIMAGELIST :: 0x0434 +TTM_NEWTOOLRECTW :: 0x0434 +EM_EXLIMITTEXT :: 0x0435 +TB_GETHOTIMAGELIST :: 0x0435 +TTM_GETTOOLINFOW :: 0x0435 +EM_EXLINEFROMCHAR :: 0x0436 +TB_SETDISABLEDIMAGELIST :: 0x0436 +TTM_SETTOOLINFOW :: 0x0436 +EM_EXSETSEL :: 0x0437 +TB_GETDISABLEDIMAGELIST :: 0x0437 +TTM_HITTESTW :: 0x0437 +EM_FINDTEXT :: 0x0438 +TB_SETSTYLE :: 0x0438 +TTM_GETTEXTW :: 0x0438 +EM_FORMATRANGE :: 0x0439 +TB_GETSTYLE :: 0x0439 +TTM_UPDATETIPTEXTW :: 0x0439 +EM_GETCHARFORMAT :: 0x043a +TB_GETBUTTONSIZE :: 0x043a +TTM_ENUMTOOLSW :: 0x043a +EM_GETEVENTMASK :: 0x043b +TB_SETBUTTONWIDTH :: 0x043b +TTM_GETCURRENTTOOLW :: 0x043b +EM_GETOLEINTERFACE :: 0x043c +TB_SETMAXTEXTROWS :: 0x043c +EM_GETPARAFORMAT :: 0x043d +TB_GETTEXTROWS :: 0x043d +EM_GETSELTEXT :: 0x043e +TB_GETOBJECT :: 0x043e +EM_HIDESELECTION :: 0x043f +TB_GETBUTTONINFOW :: 0x043f +EM_PASTESPECIAL :: 0x0440 +TB_SETBUTTONINFOW :: 0x0440 +EM_REQUESTRESIZE :: 0x0441 +TB_GETBUTTONINFOA :: 0x0441 +EM_SELECTIONTYPE :: 0x0442 +TB_SETBUTTONINFOA :: 0x0442 +EM_SETBKGNDCOLOR :: 0x0443 +TB_INSERTBUTTONW :: 0x0443 +EM_SETCHARFORMAT :: 0x0444 +TB_ADDBUTTONSW :: 0x0444 +EM_SETEVENTMASK :: 0x0445 +TB_HITTEST :: 0x0445 +EM_SETOLECALLBACK :: 0x0446 +TB_SETDRAWTEXTFLAGS :: 0x0446 +EM_SETPARAFORMAT :: 0x0447 +TB_GETHOTITEM :: 0x0447 +EM_SETTARGETDEVICE :: 0x0448 +TB_SETHOTITEM :: 0x0448 +EM_STREAMIN :: 0x0449 +TB_SETANCHORHIGHLIGHT :: 0x0449 +EM_STREAMOUT :: 0x044a +TB_GETANCHORHIGHLIGHT :: 0x044a +EM_GETTEXTRANGE :: 0x044b +TB_GETBUTTONTEXTW :: 0x044b +EM_FINDWORDBREAK :: 0x044c +TB_SAVERESTOREW :: 0x044c +EM_SETOPTIONS :: 0x044d +TB_ADDSTRINGW :: 0x044d +EM_GETOPTIONS :: 0x044e +TB_MAPACCELERATORA :: 0x044e +EM_FINDTEXTEX :: 0x044f +TB_GETINSERTMARK :: 0x044f +EM_GETWORDBREAKPROCEX :: 0x0450 +TB_SETINSERTMARK :: 0x0450 +EM_SETWORDBREAKPROCEX :: 0x0451 +TB_INSERTMARKHITTEST :: 0x0451 +EM_SETUNDOLIMIT :: 0x0452 +TB_MOVEBUTTON :: 0x0452 +TB_GETMAXSIZE :: 0x0453 +EM_REDO :: 0x0454 +TB_SETEXTENDEDSTYLE :: 0x0454 +EM_CANREDO :: 0x0455 +TB_GETEXTENDEDSTYLE :: 0x0455 +EM_GETUNDONAME :: 0x0456 +TB_GETPADDING :: 0x0456 +EM_GETREDONAME :: 0x0457 +TB_SETPADDING :: 0x0457 +EM_STOPGROUPTYPING :: 0x0458 +TB_SETINSERTMARKCOLOR :: 0x0458 +EM_SETTEXTMODE :: 0x0459 +TB_GETINSERTMARKCOLOR :: 0x0459 +EM_GETTEXTMODE :: 0x045a +TB_MAPACCELERATORW :: 0x045a +EM_AUTOURLDETECT :: 0x045b +TB_GETSTRINGW :: 0x045b +EM_GETAUTOURLDETECT :: 0x045c +TB_GETSTRINGA :: 0x045c +EM_SETPALETTE :: 0x045d +EM_GETTEXTEX :: 0x045e +EM_GETTEXTLENGTHEX :: 0x045f +EM_SHOWSCROLLBAR :: 0x0460 +EM_SETTEXTEX :: 0x0461 +TAPI_REPLY :: 0x0463 +ACM_OPENA :: 0x0464 +BFFM_SETSTATUSTEXTA :: 0x0464 +CDM_FIRST :: 0x0464 +CDM_GETSPEC :: 0x0464 +EM_SETPUNCTUATION :: 0x0464 +IPM_CLEARADDRESS :: 0x0464 +WM_CAP_UNICODE_START :: 0x0464 +ACM_PLAY :: 0x0465 +BFFM_ENABLEOK :: 0x0465 +CDM_GETFILEPATH :: 0x0465 +EM_GETPUNCTUATION :: 0x0465 +IPM_SETADDRESS :: 0x0465 +PSM_SETCURSEL :: 0x0465 +UDM_SETRANGE :: 0x0465 +WM_CHOOSEFONT_SETLOGFONT :: 0x0465 +ACM_STOP :: 0x0466 +BFFM_SETSELECTIONA :: 0x0466 +CDM_GETFOLDERPATH :: 0x0466 +EM_SETWORDWRAPMODE :: 0x0466 +IPM_GETADDRESS :: 0x0466 +PSM_REMOVEPAGE :: 0x0466 +UDM_GETRANGE :: 0x0466 +WM_CAP_SET_CALLBACK_ERRORW :: 0x0466 +WM_CHOOSEFONT_SETFLAGS :: 0x0466 +ACM_OPENW :: 0x0467 +BFFM_SETSELECTIONW :: 0x0467 +CDM_GETFOLDERIDLIST :: 0x0467 +EM_GETWORDWRAPMODE :: 0x0467 +IPM_SETRANGE :: 0x0467 +PSM_ADDPAGE :: 0x0467 +UDM_SETPOS :: 0x0467 +WM_CAP_SET_CALLBACK_STATUSW :: 0x0467 +BFFM_SETSTATUSTEXTW :: 0x0468 +CDM_SETCONTROLTEXT :: 0x0468 +EM_SETIMECOLOR :: 0x0468 +IPM_SETFOCUS :: 0x0468 +PSM_CHANGED :: 0x0468 +UDM_GETPOS :: 0x0468 +CDM_HIDECONTROL :: 0x0469 +EM_GETIMECOLOR :: 0x0469 +IPM_ISBLANK :: 0x0469 +PSM_RESTARTWINDOWS :: 0x0469 +UDM_SETBUDDY :: 0x0469 +CDM_SETDEFEXT :: 0x046a +EM_SETIMEOPTIONS :: 0x046a +PSM_REBOOTSYSTEM :: 0x046a +UDM_GETBUDDY :: 0x046a +EM_GETIMEOPTIONS :: 0x046b +PSM_CANCELTOCLOSE :: 0x046b +UDM_SETACCEL :: 0x046b +EM_CONVPOSITION :: 0x046c +PSM_QUERYSIBLINGS :: 0x046c +UDM_GETACCEL :: 0x046c +MCIWNDM_GETZOOM :: 0x046d +PSM_UNCHANGED :: 0x046d +UDM_SETBASE :: 0x046d +PSM_APPLY :: 0x046e +UDM_GETBASE :: 0x046e +PSM_SETTITLEA :: 0x046f +UDM_SETRANGE32 :: 0x046f +PSM_SETWIZBUTTONS :: 0x0470 +UDM_GETRANGE32 :: 0x0470 +WM_CAP_DRIVER_GET_NAMEW :: 0x0470 +PSM_PRESSBUTTON :: 0x0471 +UDM_SETPOS32 :: 0x0471 +WM_CAP_DRIVER_GET_VERSIONW :: 0x0471 +PSM_SETCURSELID :: 0x0472 +UDM_GETPOS32 :: 0x0472 +PSM_SETFINISHTEXTA :: 0x0473 +PSM_GETTABCONTROL :: 0x0474 +PSM_ISDIALOGMESSAGE :: 0x0475 +MCIWNDM_REALIZE :: 0x0476 +PSM_GETCURRENTPAGEHWND :: 0x0476 +MCIWNDM_SETTIMEFORMATA :: 0x0477 +PSM_INSERTPAGE :: 0x0477 +EM_SETLANGOPTIONS :: 0x0478 +MCIWNDM_GETTIMEFORMATA :: 0x0478 +PSM_SETTITLEW :: 0x0478 +WM_CAP_FILE_SET_CAPTURE_FILEW :: 0x0478 +EM_GETLANGOPTIONS :: 0x0479 +MCIWNDM_VALIDATEMEDIA :: 0x0479 +PSM_SETFINISHTEXTW :: 0x0479 +WM_CAP_FILE_GET_CAPTURE_FILEW :: 0x0479 +EM_GETIMECOMPMODE :: 0x047a +EM_FINDTEXTW :: 0x047b +MCIWNDM_PLAYTO :: 0x047b +WM_CAP_FILE_SAVEASW :: 0x047b +EM_FINDTEXTEXW :: 0x047c +MCIWNDM_GETFILENAMEA :: 0x047c +EM_RECONVERSION :: 0x047d +MCIWNDM_GETDEVICEA :: 0x047d +PSM_SETHEADERTITLEA :: 0x047d +WM_CAP_FILE_SAVEDIBW :: 0x047d +EM_SETIMEMODEBIAS :: 0x047e +MCIWNDM_GETPALETTE :: 0x047e +PSM_SETHEADERTITLEW :: 0x047e +EM_GETIMEMODEBIAS :: 0x047f +MCIWNDM_SETPALETTE :: 0x047f +PSM_SETHEADERSUBTITLEA :: 0x047f +MCIWNDM_GETERRORA :: 0x0480 +PSM_SETHEADERSUBTITLEW :: 0x0480 +PSM_HWNDTOINDEX :: 0x0481 +PSM_INDEXTOHWND :: 0x0482 +MCIWNDM_SETINACTIVETIMER :: 0x0483 +PSM_PAGETOINDEX :: 0x0483 +PSM_INDEXTOPAGE :: 0x0484 +DL_BEGINDRAG :: 0x0485 +MCIWNDM_GETINACTIVETIMER :: 0x0485 +PSM_IDTOINDEX :: 0x0485 +DL_DRAGGING :: 0x0486 +PSM_INDEXTOID :: 0x0486 +DL_DROPPED :: 0x0487 +PSM_GETRESULT :: 0x0487 +DL_CANCELDRAG :: 0x0488 +PSM_RECALCPAGESIZES :: 0x0488 +MCIWNDM_GET_SOURCE :: 0x048c +MCIWNDM_PUT_SOURCE :: 0x048d +MCIWNDM_GET_DEST :: 0x048e +MCIWNDM_PUT_DEST :: 0x048f +MCIWNDM_CAN_PLAY :: 0x0490 +MCIWNDM_CAN_WINDOW :: 0x0491 +MCIWNDM_CAN_RECORD :: 0x0492 +MCIWNDM_CAN_SAVE :: 0x0493 +MCIWNDM_CAN_EJECT :: 0x0494 +MCIWNDM_CAN_CONFIG :: 0x0495 +IE_GETINK :: 0x0496 +IE_MSGFIRST :: 0x0496 +MCIWNDM_PALETTEKICK :: 0x0496 +IE_SETINK :: 0x0497 +IE_GETPENTIP :: 0x0498 +IE_SETPENTIP :: 0x0499 +IE_GETERASERTIP :: 0x049a +IE_SETERASERTIP :: 0x049b +IE_GETBKGND :: 0x049c +IE_SETBKGND :: 0x049d +IE_GETGRIDORIGIN :: 0x049e +IE_SETGRIDORIGIN :: 0x049f +IE_GETGRIDPEN :: 0x04a0 +IE_SETGRIDPEN :: 0x04a1 +IE_GETGRIDSIZE :: 0x04a2 +IE_SETGRIDSIZE :: 0x04a3 +IE_GETMODE :: 0x04a4 +IE_SETMODE :: 0x04a5 +IE_GETINKRECT :: 0x04a6 +WM_CAP_SET_MCI_DEVICEW :: 0x04a6 +WM_CAP_GET_MCI_DEVICEW :: 0x04a7 +WM_CAP_PAL_OPENW :: 0x04b4 +WM_CAP_PAL_SAVEW :: 0x04b5 +IE_GETAPPDATA :: 0x04b8 +IE_SETAPPDATA :: 0x04b9 +IE_GETDRAWOPTS :: 0x04ba +IE_SETDRAWOPTS :: 0x04bb +IE_GETFORMAT :: 0x04bc +IE_SETFORMAT :: 0x04bd +IE_GETINKINPUT :: 0x04be +IE_SETINKINPUT :: 0x04bf +IE_GETNOTIFY :: 0x04c0 +IE_SETNOTIFY :: 0x04c1 +IE_GETRECOG :: 0x04c2 +IE_SETRECOG :: 0x04c3 +IE_GETSECURITY :: 0x04c4 +IE_SETSECURITY :: 0x04c5 +IE_GETSEL :: 0x04c6 +IE_SETSEL :: 0x04c7 +CDM_LAST :: 0x04c8 +EM_SETBIDIOPTIONS :: 0x04c8 +IE_DOCOMMAND :: 0x04c8 +MCIWNDM_NOTIFYMODE :: 0x04c8 +EM_GETBIDIOPTIONS :: 0x04c9 +IE_GETCOMMAND :: 0x04c9 +EM_SETTYPOGRAPHYOPTIONS :: 0x04ca +IE_GETCOUNT :: 0x04ca +EM_GETTYPOGRAPHYOPTIONS :: 0x04cb +IE_GETGESTURE :: 0x04cb +MCIWNDM_NOTIFYMEDIA :: 0x04cb +EM_SETEDITSTYLE :: 0x04cc +IE_GETMENU :: 0x04cc +EM_GETEDITSTYLE :: 0x04cd +IE_GETPAINTDC :: 0x04cd +MCIWNDM_NOTIFYERROR :: 0x04cd +IE_GETPDEVENT :: 0x04ce +IE_GETSELCOUNT :: 0x04cf +IE_GETSELITEMS :: 0x04d0 +IE_GETSTYLE :: 0x04d1 +MCIWNDM_SETTIMEFORMATW :: 0x04db +EM_OUTLINE :: 0x04dc +MCIWNDM_GETTIMEFORMATW :: 0x04dc +EM_GETSCROLLPOS :: 0x04dd +EM_SETSCROLLPOS :: 0x04de +EM_SETFONTSIZE :: 0x04df +EM_GETZOOM :: 0x04e0 +MCIWNDM_GETFILENAMEW :: 0x04e0 +EM_SETZOOM :: 0x04e1 +MCIWNDM_GETDEVICEW :: 0x04e1 +EM_GETVIEWKIND :: 0x04e2 +EM_SETVIEWKIND :: 0x04e3 +EM_GETPAGE :: 0x04e4 +MCIWNDM_GETERRORW :: 0x04e4 +EM_SETPAGE :: 0x04e5 +EM_GETHYPHENATEINFO :: 0x04e6 +EM_SETHYPHENATEINFO :: 0x04e7 +EM_GETPAGEROTATE :: 0x04eb +EM_SETPAGEROTATE :: 0x04ec +EM_GETCTFMODEBIAS :: 0x04ed +EM_SETCTFMODEBIAS :: 0x04ee +EM_GETCTFOPENSTATUS :: 0x04f0 +EM_SETCTFOPENSTATUS :: 0x04f1 +EM_GETIMECOMPTEXT :: 0x04f2 +EM_ISIME :: 0x04f3 +EM_GETIMEPROPERTY :: 0x04f4 +EM_GETQUERYRTFOBJ :: 0x050d +EM_SETQUERYRTFOBJ :: 0x050e +FM_GETFOCUS :: 0x0600 +FM_GETDRIVEINFOA :: 0x0601 +FM_GETSELCOUNT :: 0x0602 +FM_GETSELCOUNTLFN :: 0x0603 +FM_GETFILESELA :: 0x0604 +FM_GETFILESELLFNA :: 0x0605 +FM_REFRESH_WINDOWS :: 0x0606 +FM_RELOAD_EXTENSIONS :: 0x0607 +FM_GETDRIVEINFOW :: 0x0611 +FM_GETFILESELW :: 0x0614 +FM_GETFILESELLFNW :: 0x0615 +WLX_WM_SAS :: 0x0659 +SM_GETSELCOUNT :: 0x07e8 +UM_GETSELCOUNT :: 0x07e8 +WM_CPL_LAUNCH :: 0x07e8 +SM_GETSERVERSELA :: 0x07e9 +UM_GETUSERSELA :: 0x07e9 +WM_CPL_LAUNCHED :: 0x07e9 +SM_GETSERVERSELW :: 0x07ea +UM_GETUSERSELW :: 0x07ea +SM_GETCURFOCUSA :: 0x07eb +UM_GETGROUPSELA :: 0x07eb +SM_GETCURFOCUSW :: 0x07ec +UM_GETGROUPSELW :: 0x07ec +SM_GETOPTIONS :: 0x07ed +UM_GETCURFOCUSA :: 0x07ed +UM_GETCURFOCUSW :: 0x07ee +UM_GETOPTIONS :: 0x07ef +UM_GETOPTIONS2 :: 0x07f0 +LVM_FIRST :: 0x1000 +LVM_GETBKCOLOR :: 0x1000 +LVM_SETBKCOLOR :: 0x1001 +LVM_GETIMAGELIST :: 0x1002 +LVM_SETIMAGELIST :: 0x1003 +LVM_GETITEMCOUNT :: 0x1004 +LVM_GETITEMA :: 0x1005 +LVM_SETITEMA :: 0x1006 +LVM_INSERTITEMA :: 0x1007 +LVM_DELETEITEM :: 0x1008 +LVM_DELETEALLITEMS :: 0x1009 +LVM_GETCALLBACKMASK :: 0x100a +LVM_SETCALLBACKMASK :: 0x100b +LVM_GETNEXTITEM :: 0x100c +LVM_FINDITEMA :: 0x100d +LVM_GETITEMRECT :: 0x100e +LVM_SETITEMPOSITION :: 0x100f +LVM_GETITEMPOSITION :: 0x1010 +LVM_GETSTRINGWIDTHA :: 0x1011 +LVM_HITTEST :: 0x1012 +LVM_ENSUREVISIBLE :: 0x1013 +LVM_SCROLL :: 0x1014 +LVM_REDRAWITEMS :: 0x1015 +LVM_ARRANGE :: 0x1016 +LVM_EDITLABELA :: 0x1017 +LVM_GETEDITCONTROL :: 0x1018 +LVM_GETCOLUMNA :: 0x1019 +LVM_SETCOLUMNA :: 0x101a +LVM_INSERTCOLUMNA :: 0x101b +LVM_DELETECOLUMN :: 0x101c +LVM_GETCOLUMNWIDTH :: 0x101d +LVM_SETCOLUMNWIDTH :: 0x101e +LVM_GETHEADER :: 0x101f +LVM_CREATEDRAGIMAGE :: 0x1021 +LVM_GETVIEWRECT :: 0x1022 +LVM_GETTEXTCOLOR :: 0x1023 +LVM_SETTEXTCOLOR :: 0x1024 +LVM_GETTEXTBKCOLOR :: 0x1025 +LVM_SETTEXTBKCOLOR :: 0x1026 +LVM_GETTOPINDEX :: 0x1027 +LVM_GETCOUNTPERPAGE :: 0x1028 +LVM_GETORIGIN :: 0x1029 +LVM_UPDATE :: 0x102a +LVM_SETITEMSTATE :: 0x102b +LVM_GETITEMSTATE :: 0x102c +LVM_GETITEMTEXTA :: 0x102d +LVM_SETITEMTEXTA :: 0x102e +LVM_SETITEMCOUNT :: 0x102f +LVM_SORTITEMS :: 0x1030 +LVM_SETITEMPOSITION32 :: 0x1031 +LVM_GETSELECTEDCOUNT :: 0x1032 +LVM_GETITEMSPACING :: 0x1033 +LVM_GETISEARCHSTRINGA :: 0x1034 +LVM_SETICONSPACING :: 0x1035 +LVM_SETEXTENDEDLISTVIEWSTYLE :: 0x1036 +LVM_GETEXTENDEDLISTVIEWSTYLE :: 0x1037 +LVM_GETSUBITEMRECT :: 0x1038 +LVM_SUBITEMHITTEST :: 0x1039 +LVM_SETCOLUMNORDERARRAY :: 0x103a +LVM_GETCOLUMNORDERARRAY :: 0x103b +LVM_SETHOTITEM :: 0x103c +LVM_GETHOTITEM :: 0x103d +LVM_SETHOTCURSOR :: 0x103e +LVM_GETHOTCURSOR :: 0x103f +LVM_APPROXIMATEVIEWRECT :: 0x1040 +LVM_SETWORKAREAS :: 0x1041 +LVM_GETSELECTIONMARK :: 0x1042 +LVM_SETSELECTIONMARK :: 0x1043 +LVM_SETBKIMAGEA :: 0x1044 +LVM_GETBKIMAGEA :: 0x1045 +LVM_GETWORKAREAS :: 0x1046 +LVM_SETHOVERTIME :: 0x1047 +LVM_GETHOVERTIME :: 0x1048 +LVM_GETNUMBEROFWORKAREAS :: 0x1049 +LVM_SETTOOLTIPS :: 0x104a +LVM_GETITEMW :: 0x104b +LVM_SETITEMW :: 0x104c +LVM_INSERTITEMW :: 0x104d +LVM_GETTOOLTIPS :: 0x104e +LVM_FINDITEMW :: 0x1053 +LVM_GETSTRINGWIDTHW :: 0x1057 +LVM_GETCOLUMNW :: 0x105f +LVM_SETCOLUMNW :: 0x1060 +LVM_INSERTCOLUMNW :: 0x1061 +LVM_GETITEMTEXTW :: 0x1073 +LVM_SETITEMTEXTW :: 0x1074 +LVM_GETISEARCHSTRINGW :: 0x1075 +LVM_EDITLABELW :: 0x1076 +LVM_GETBKIMAGEW :: 0x108b +LVM_SETSELECTEDCOLUMN :: 0x108c +LVM_SETTILEWIDTH :: 0x108d +LVM_SETVIEW :: 0x108e +LVM_GETVIEW :: 0x108f +LVM_INSERTGROUP :: 0x1091 +LVM_SETGROUPINFO :: 0x1093 +LVM_GETGROUPINFO :: 0x1095 +LVM_REMOVEGROUP :: 0x1096 +LVM_MOVEGROUP :: 0x1097 +LVM_MOVEITEMTOGROUP :: 0x109a +LVM_SETGROUPMETRICS :: 0x109b +LVM_GETGROUPMETRICS :: 0x109c +LVM_ENABLEGROUPVIEW :: 0x109d +LVM_SORTGROUPS :: 0x109e +LVM_INSERTGROUPSORTED :: 0x109f +LVM_REMOVEALLGROUPS :: 0x10a0 +LVM_HASGROUP :: 0x10a1 +LVM_SETTILEVIEWINFO :: 0x10a2 +LVM_GETTILEVIEWINFO :: 0x10a3 +LVM_SETTILEINFO :: 0x10a4 +LVM_GETTILEINFO :: 0x10a5 +LVM_SETINSERTMARK :: 0x10a6 +LVM_GETINSERTMARK :: 0x10a7 +LVM_INSERTMARKHITTEST :: 0x10a8 +LVM_GETINSERTMARKRECT :: 0x10a9 +LVM_SETINSERTMARKCOLOR :: 0x10aa +LVM_GETINSERTMARKCOLOR :: 0x10ab +LVM_SETINFOTIP :: 0x10ad +LVM_GETSELECTEDCOLUMN :: 0x10ae +LVM_ISGROUPVIEWENABLED :: 0x10af +LVM_GETOUTLINECOLOR :: 0x10b0 +LVM_SETOUTLINECOLOR :: 0x10b1 +LVM_CANCELEDITLABEL :: 0x10b3 +LVM_MAPINDEXTOID :: 0x10b4 +LVM_MAPIDTOINDEX :: 0x10b5 +LVM_ISITEMVISIBLE :: 0x10b6 +LVM_GETEMPTYTEXT :: 0x10cc +LVM_GETFOOTERRECT :: 0x10cd +LVM_GETFOOTERINFO :: 0x10ce +LVM_GETFOOTERITEMRECT :: 0x10cf +LVM_GETFOOTERITEM :: 0x10d0 +LVM_GETITEMINDEXRECT :: 0x10d1 +LVM_SETITEMINDEXSTATE :: 0x10d2 +LVM_GETNEXTITEMINDEX :: 0x10d3 +BCM_FIRST :: 0x1600 +BCM_SETDROPDOWNSTATE :: BCM_FIRST + 0x0006 +BCM_SETSPLITINFO :: BCM_FIRST + 0x0007 +BCM_GETSPLITINFO :: BCM_FIRST + 0x0008 +BCM_SETNOTE :: BCM_FIRST + 0x0009 +BCM_GETNOTE :: BCM_FIRST + 0x000A +BCM_GETNOTELENGTH :: BCM_FIRST + 0x000B +BCM_SETSHIELD :: BCM_FIRST + 0x000C +OCM__BASE :: 0x2000 +LVM_SETUNICODEFORMAT :: 0x2005 +LVM_GETUNICODEFORMAT :: 0x2006 +OCM_CTLCOLOR :: 0x2019 +OCM_DRAWITEM :: 0x202b +OCM_MEASUREITEM :: 0x202c +OCM_DELETEITEM :: 0x202d +OCM_VKEYTOITEM :: 0x202e +OCM_CHARTOITEM :: 0x202f +OCM_COMPAREITEM :: 0x2039 +OCM_NOTIFY :: 0x204e +OCM_COMMAND :: 0x2111 +OCM_HSCROLL :: 0x2114 +OCM_VSCROLL :: 0x2115 +OCM_CTLCOLORMSGBOX :: 0x2132 +OCM_CTLCOLOREDIT :: 0x2133 +OCM_CTLCOLORLISTBOX :: 0x2134 +OCM_CTLCOLORBTN :: 0x2135 +OCM_CTLCOLORDLG :: 0x2136 +OCM_CTLCOLORSCROLLBAR :: 0x2137 +OCM_CTLCOLORSTATIC :: 0x2138 +OCM_PARENTNOTIFY :: 0x2210 +WM_APP :: 0x8000 +WM_RASDIALEVENT :: 0xcccd From 35e70f4be17f4123ec25108d664864f13b38087e Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 27 Sep 2022 22:30:00 +0100 Subject: [PATCH 009/110] Add node data for union when using `intrinsics.type_convert_variants_to_pointers` --- src/check_builtin.cpp | 1 + src/docs_writer.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index 09294c93a..a00dd5def 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -4751,6 +4751,7 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 new_type->Union.variants = variants; // NOTE(bill): Is this even correct? + new_type->Union.node = operand->expr; new_type->Union.scope = bt->Union.scope; operand->type = new_type; diff --git a/src/docs_writer.cpp b/src/docs_writer.cpp index 1b8e1fc34..5246971ff 100644 --- a/src/docs_writer.cpp +++ b/src/docs_writer.cpp @@ -639,7 +639,7 @@ OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type) { doc_type.polmorphic_params = odin_doc_type(w, type->Union.polymorphic_params); } - if (type->Union.node) { + if (type->Union.node && type->Union.node->kind == Ast_UnionType) { ast_node(ut, UnionType, type->Union.node); if (ut->align) { doc_type.custom_align = odin_doc_expr_string(w, ut->align); From c4d19dfa925ffe44c04fcda90543a272b7165274 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 27 Sep 2022 22:31:46 +0100 Subject: [PATCH 010/110] Use `uint` instead of `int` to improve code generation for bounds checking --- core/bytes/buffer.odin | 7 ++----- core/bytes/bytes.odin | 2 +- core/runtime/error_checks.odin | 6 +++--- core/slice/slice.odin | 4 ++-- core/strings/strings.odin | 2 +- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/core/bytes/buffer.odin b/core/bytes/buffer.odin index d9f195871..bba834f7e 100644 --- a/core/bytes/buffer.odin +++ b/core/bytes/buffer.odin @@ -240,14 +240,11 @@ buffer_read_ptr :: proc(b: ^Buffer, ptr: rawptr, size: int) -> (n: int, err: io. buffer_read_at :: proc(b: ^Buffer, p: []byte, offset: int) -> (n: int, err: io.Error) { b.last_read = .Invalid - if offset < 0 || offset >= len(b.buf) { + if uint(offset) >= len(b.buf) { err = .Invalid_Offset return } - - if 0 <= offset && offset < len(b.buf) { - n = copy(p, b.buf[offset:]) - } + n = copy(p, b.buf[offset:]) if n > 0 { b.last_read = .Read } diff --git a/core/bytes/bytes.odin b/core/bytes/bytes.odin index f1737f3c5..d39f01b06 100644 --- a/core/bytes/bytes.odin +++ b/core/bytes/bytes.odin @@ -638,7 +638,7 @@ trim_left_proc :: proc(s: []byte, p: proc(rune) -> bool) -> []byte { index_rune :: proc(s: []byte, r: rune) -> int { switch { - case 0 <= r && r < utf8.RUNE_SELF: + case u32(r) < utf8.RUNE_SELF: return index_byte(s, byte(r)) case r == utf8.RUNE_ERROR: diff --git a/core/runtime/error_checks.odin b/core/runtime/error_checks.odin index 0d0b39072..8539c724d 100644 --- a/core/runtime/error_checks.odin +++ b/core/runtime/error_checks.odin @@ -18,7 +18,7 @@ type_assertion_trap :: proc "contextless" () -> ! { bounds_check_error :: proc "contextless" (file: string, line, column: i32, index, count: int) { - if 0 <= index && index < count { + if uint(index) < uint(count) { return } @(cold) @@ -99,8 +99,8 @@ dynamic_array_expr_error :: proc "contextless" (file: string, line, column: i32, matrix_bounds_check_error :: proc "contextless" (file: string, line, column: i32, row_index, column_index, row_count, column_count: int) { - if 0 <= row_index && row_index < row_count && - 0 <= column_index && column_index < column_count { + if uint(row_index) < uint(row_count) && + uint(column_index) < uint(column_count) { return } @(cold) diff --git a/core/slice/slice.odin b/core/slice/slice.odin index abc84787f..032a8ca6e 100644 --- a/core/slice/slice.odin +++ b/core/slice/slice.odin @@ -321,14 +321,14 @@ last_ptr :: proc(array: $T/[]$E) -> ^E { } get :: proc(array: $T/[]$E, index: int) -> (value: E, ok: bool) { - if 0 <= index && index < len(array) { + if uint(index) < len(array) { value = array[index] ok = true } return } get_ptr :: proc(array: $T/[]$E, index: int) -> (value: ^E, ok: bool) { - if 0 <= index && index < len(array) { + if uint(index) < len(array) { value = &array[index] ok = true } diff --git a/core/strings/strings.odin b/core/strings/strings.odin index a0f553a68..ba357e027 100644 --- a/core/strings/strings.odin +++ b/core/strings/strings.odin @@ -760,7 +760,7 @@ last_index_byte :: proc(s: string, c: byte) -> int { */ index_rune :: proc(s: string, r: rune) -> int { switch { - case 0 <= r && r < utf8.RUNE_SELF: + case u32(r) < utf8.RUNE_SELF: return index_byte(s, byte(r)) case r == utf8.RUNE_ERROR: From cd910b1512a3f3815417327af15c2eae0e763154 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Wed, 28 Sep 2022 16:41:26 +0200 Subject: [PATCH 011/110] [strconv] Add parsing of Inf & NaN --- core/strconv/strconv.odin | 34 +++- tests/issues/run.bat | 10 +- tests/issues/run.sh | 10 +- tests/issues/test_issue_1592.odin | 323 ++++++++++++++---------------- tests/issues/test_issue_2087.odin | 58 ++++++ tests/issues/test_issue_829.odin | 19 +- 6 files changed, 247 insertions(+), 207 deletions(-) create mode 100644 tests/issues/test_issue_2087.odin diff --git a/core/strconv/strconv.odin b/core/strconv/strconv.odin index c2d48be7a..ae89722bf 100644 --- a/core/strconv/strconv.odin +++ b/core/strconv/strconv.odin @@ -567,7 +567,7 @@ parse_f32 :: proc(s: string, n: ^int = nil) -> (value: f32, ok: bool) { // ``` parse_f64 :: proc(str: string, n: ^int = nil) -> (value: f64, ok: bool) { s := str - defer if n != nil { n^ = len(str)-len(s) } + defer if n != nil { n^ = len(str) - len(s) } if s == "" { return } @@ -588,6 +588,38 @@ parse_f64 :: proc(str: string, n: ^int = nil) -> (value: f64, ok: bool) { v := _digit_value(r) if v >= 10 { + if r == '.' || r == 'e' || r == 'E' { // Skip parsing NaN and Inf if it's probably a regular float + break + } + if len(s) >= 3 + i { + buf: [4]u8 + copy(buf[:], s[i:][:3]) + + v2 := transmute(u32)buf + v2 &= 0xDFDFDFDF // Knock out lower-case bits + + buf = transmute([4]u8)v2 + + when ODIN_ENDIAN == .Little { + if v2 == 0x464e49 { // "INF" + s = s[3+i:] + value = 0h7ff00000_00000000 if sign == 1 else 0hfff00000_00000000 + return value, len(s) == 0 + } else if v2 == 0x4e414e { // "NAN" + s = s[3+i:] + return 0h7ff80000_00000001, len(s) == 0 + } + } else { + if v2 == 0x494e4600 { // "\0FNI" + s = s[3+i:] + value = 0h7ff00000_00000000 if sign == 1 else 0hfff00000_00000000 + return value, len(s) == 0 + } else if v2 == 0x4e414e00 { // "\0NAN" + s = s[3+i:] + return 0h7ff80000_00000001, len(s) == 0 + } + } + } break } value *= 10 diff --git a/tests/issues/run.bat b/tests/issues/run.bat index a7078ae0f..2ecd14d95 100644 --- a/tests/issues/run.bat +++ b/tests/issues/run.bat @@ -2,15 +2,13 @@ if not exist "build\" mkdir build -set COMMON=-collection:tests=.. -out:build\test_issue.exe +set COMMON=-collection:tests=.. @echo on -..\..\odin build test_issue_829.odin %COMMON% -file -build\test_issue - -..\..\odin build test_issue_1592.odin %COMMON% -file -build\test_issue +..\..\odin test test_issue_829.odin %COMMON% -file +..\..\odin test test_issue_1592.odin %COMMON% -file +..\..\odin test test_issue_2087.odin %COMMON% -file @echo off diff --git a/tests/issues/run.sh b/tests/issues/run.sh index ec0804bac..f781c8278 100755 --- a/tests/issues/run.sh +++ b/tests/issues/run.sh @@ -3,15 +3,13 @@ set -eu mkdir -p build ODIN=../../odin -COMMON="-collection:tests=.. -out:build/test_issue" +COMMON="-collection:tests=.." set -x -$ODIN build test_issue_829.odin $COMMON -file -./build/test_issue - -$ODIN build test_issue_1592.odin $COMMON -file -./build/test_issue +$ODIN test test_issue_829.odin $COMMON -file +$ODIN test test_issue_1592.odin $COMMON -file +$ODIN test test_issue_2087.odin $COMMON -file set +x diff --git a/tests/issues/test_issue_1592.odin b/tests/issues/test_issue_1592.odin index bb350a30b..800314a93 100644 --- a/tests/issues/test_issue_1592.odin +++ b/tests/issues/test_issue_1592.odin @@ -3,36 +3,6 @@ package test_issues import "core:fmt" import "core:testing" -import tc "tests:common" - -main :: proc() { - t := testing.T{} - - /* This won't short-circuit */ - test_orig() - - /* These will short-circuit */ - test_simple_const_false(&t) - test_simple_const_true(&t) - - /* These won't short-circuit */ - test_simple_proc_false(&t) - test_simple_proc_true(&t) - - /* These won't short-circuit */ - test_const_false_const_false(&t) - test_const_false_const_true(&t) - test_const_true_const_false(&t) - test_const_true_const_true(&t) - - /* These won't short-circuit */ - test_proc_false_const_false(&t) - test_proc_false_const_true(&t) - test_proc_true_const_false(&t) - test_proc_true_const_true(&t) - - tc.report(&t) -} /* Original issue #1592 example */ @@ -43,7 +13,6 @@ bool_result :: proc() -> bool { return false } -@test test_orig :: proc() { if bool_result() || CONSTANT_BOOL { } @@ -62,428 +31,428 @@ true_result :: proc() -> bool { @test test_simple_const_false :: proc(t: ^testing.T) { if CONSTANT_FALSE { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if (CONSTANT_FALSE) { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if !CONSTANT_FALSE { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if (!CONSTANT_FALSE) { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if !(CONSTANT_FALSE) { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if !!CONSTANT_FALSE { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if CONSTANT_FALSE == true { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if CONSTANT_FALSE == false { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if !(CONSTANT_FALSE == true) { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if !(CONSTANT_FALSE == false) { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } } @test test_simple_const_true :: proc(t: ^testing.T) { if CONSTANT_TRUE { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if (CONSTANT_TRUE) { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if !CONSTANT_TRUE { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if (!CONSTANT_TRUE) { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if (!CONSTANT_TRUE) { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if !(CONSTANT_TRUE) { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if !!CONSTANT_TRUE { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if CONSTANT_TRUE == true { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if CONSTANT_TRUE == false { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if !(CONSTANT_TRUE == true) { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if !(CONSTANT_TRUE == false) { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } } @test test_simple_proc_false :: proc(t: ^testing.T) { if false_result() { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if !false_result() { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } } @test test_simple_proc_true :: proc(t: ^testing.T) { if true_result() { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if !true_result() { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } } @test test_const_false_const_false :: proc(t: ^testing.T) { if CONSTANT_FALSE || CONSTANT_FALSE { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if CONSTANT_FALSE && CONSTANT_FALSE { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if !CONSTANT_FALSE || CONSTANT_FALSE { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if !CONSTANT_FALSE && CONSTANT_FALSE { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if CONSTANT_FALSE || !CONSTANT_FALSE { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if CONSTANT_FALSE && !CONSTANT_FALSE { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if !(CONSTANT_FALSE || CONSTANT_FALSE) { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if !(CONSTANT_FALSE && CONSTANT_FALSE) { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } } @test test_const_false_const_true :: proc(t: ^testing.T) { if CONSTANT_FALSE || CONSTANT_TRUE { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if CONSTANT_FALSE && CONSTANT_TRUE { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if !CONSTANT_FALSE || CONSTANT_TRUE { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if !CONSTANT_FALSE && CONSTANT_TRUE { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if CONSTANT_FALSE || !CONSTANT_TRUE { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if CONSTANT_FALSE && !CONSTANT_TRUE { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if !(CONSTANT_FALSE || CONSTANT_TRUE) { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if !(CONSTANT_FALSE && CONSTANT_TRUE) { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } } @test test_const_true_const_false :: proc(t: ^testing.T) { if CONSTANT_TRUE || CONSTANT_FALSE { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if CONSTANT_TRUE && CONSTANT_FALSE { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if !CONSTANT_TRUE || CONSTANT_FALSE { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if !CONSTANT_TRUE && CONSTANT_FALSE { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if CONSTANT_TRUE || !CONSTANT_FALSE { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if CONSTANT_TRUE && !CONSTANT_FALSE { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if !(CONSTANT_TRUE || CONSTANT_FALSE) { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if !(CONSTANT_TRUE && CONSTANT_FALSE) { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } } @test test_const_true_const_true :: proc(t: ^testing.T) { if CONSTANT_TRUE || CONSTANT_TRUE { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if CONSTANT_TRUE && CONSTANT_TRUE { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if !CONSTANT_TRUE || CONSTANT_TRUE { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if !CONSTANT_TRUE && CONSTANT_TRUE { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if CONSTANT_TRUE || !CONSTANT_TRUE { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if CONSTANT_TRUE && !CONSTANT_TRUE { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if !(CONSTANT_TRUE || CONSTANT_TRUE) { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if !(CONSTANT_TRUE && CONSTANT_TRUE) { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } } @test test_proc_false_const_false :: proc(t: ^testing.T) { if false_result() || CONSTANT_FALSE { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if false_result() && CONSTANT_FALSE { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if !(false_result() || CONSTANT_FALSE) { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if !(false_result() && CONSTANT_FALSE) { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } } @test test_proc_false_const_true :: proc(t: ^testing.T) { if false_result() || CONSTANT_TRUE { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if false_result() && CONSTANT_TRUE { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if !(false_result() || CONSTANT_TRUE) { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if !(false_result() && CONSTANT_TRUE) { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } } @test test_proc_true_const_false :: proc(t: ^testing.T) { if true_result() || CONSTANT_FALSE { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if true_result() && CONSTANT_FALSE { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if !(true_result() || CONSTANT_FALSE) { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if !(true_result() && CONSTANT_FALSE) { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } } @test test_proc_true_const_true :: proc(t: ^testing.T) { if true_result() || CONSTANT_TRUE { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if true_result() && CONSTANT_TRUE { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } else { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } if !(true_result() || CONSTANT_TRUE) { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } if !(true_result() && CONSTANT_TRUE) { - tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) + testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) } else { - tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) + testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) } } diff --git a/tests/issues/test_issue_2087.odin b/tests/issues/test_issue_2087.odin new file mode 100644 index 000000000..19181bfca --- /dev/null +++ b/tests/issues/test_issue_2087.odin @@ -0,0 +1,58 @@ +// Tests issue #2087 https://github.com/odin-lang/Odin/issues/2087 +package test_issues + +import "core:math" +import "core:strconv" +import "core:testing" + +@(test) +test_parse_float :: proc(t: ^testing.T) { + { + f, ok := strconv.parse_f64("1.2") + testing.expect(t, ok && f == 1.2, "expected f64(1.2), fully consumed") + + f, ok = strconv.parse_f64("1.2a") + testing.expect(t, !ok && f == 1.2, "expected f64(1.2), partially consumed") + + f, ok = strconv.parse_f64("inf") + testing.expect(t, ok && math.classify(f) == math.Float_Class.Inf, "expected f64(+inf), fully consumed") + f, ok = strconv.parse_f64("+inf") + testing.expect(t, ok && math.classify(f) == math.Float_Class.Inf, "expected f64(+inf), fully consumed") + f, ok = strconv.parse_f64("-inf") + testing.expect(t, ok && math.classify(f) == math.Float_Class.Neg_Inf, "expected f64(-inf), fully consumed") + f, ok = strconv.parse_f64("inFinity") + testing.expect(t, !ok && math.classify(f) == math.Float_Class.Inf, "expected f64(+inf), partially consumed") + f, ok = strconv.parse_f64("+InFinity") + testing.expect(t, !ok && math.classify(f) == math.Float_Class.Inf, "expected f64(+inf), partially consumed") + f, ok = strconv.parse_f64("-InfiniTy") + testing.expect(t, !ok && math.classify(f) == math.Float_Class.Neg_Inf, "expected f64(-inf), partially consumed") + f, ok = strconv.parse_f64("nan") + testing.expect(t, ok && math.classify(f) == math.Float_Class.NaN, "expected f64(nan), fully consumed") + f, ok = strconv.parse_f64("nAN") + testing.expect(t, ok && math.classify(f) == math.Float_Class.NaN, "expected f64(nan), fully consumed") + } + { + f, ok := strconv.parse_f32("1.2") + testing.expect(t, ok && f == 1.2, "expected f32(1.2), fully consumed") + + f, ok = strconv.parse_f32("1.2a") + testing.expect(t, !ok && f == 1.2, "expected f32(1.2), partially consumed") + + f, ok = strconv.parse_f32("inf") + testing.expect(t, ok && math.classify(f) == math.Float_Class.Inf, "expected f32(+inf), fully consumed") + f, ok = strconv.parse_f32("+inf") + testing.expect(t, ok && math.classify(f) == math.Float_Class.Inf, "expected f32(+inf), fully consumed") + f, ok = strconv.parse_f32("-inf") + testing.expect(t, ok && math.classify(f) == math.Float_Class.Neg_Inf, "expected f32(-inf), fully consumed") + f, ok = strconv.parse_f32("inFinity") + testing.expect(t, !ok && math.classify(f) == math.Float_Class.Inf, "expected f32(+inf), partially consumed") + f, ok = strconv.parse_f32("+InFinity") + testing.expect(t, !ok && math.classify(f) == math.Float_Class.Inf, "expected f32(+inf), partially consumed") + f, ok = strconv.parse_f32("-InfiniTy") + testing.expect(t, !ok && math.classify(f) == math.Float_Class.Neg_Inf, "expected f32(-inf), partially consumed") + f, ok = strconv.parse_f32("nan") + testing.expect(t, ok && math.classify(f) == math.Float_Class.NaN, "expected f32(nan), fully consumed") + f, ok = strconv.parse_f32("nAN") + testing.expect(t, ok && math.classify(f) == math.Float_Class.NaN, "expected f32(nan), fully consumed") + } +} \ No newline at end of file diff --git a/tests/issues/test_issue_829.odin b/tests/issues/test_issue_829.odin index 4ff3d71f1..273b3b3b5 100644 --- a/tests/issues/test_issue_829.odin +++ b/tests/issues/test_issue_829.odin @@ -3,31 +3,16 @@ package test_issues import "core:fmt" import "core:testing" -import tc "tests:common" /* Original issue #829 example */ - env : map[string]proc(a, b : int) -> int = { "+" = proc(a, b : int) -> int { return a + b }, } -test_orig :: proc() { - fmt.println(env["+"](1, 2)) -} - -main :: proc() { - t := testing.T{} - - test_orig() - - test_orig_ret(&t) - - tc.report(&t) -} - +@(test) test_orig_ret :: proc(t: ^testing.T) { r := fmt.tprint(env["+"](1, 2)) - tc.expect(t, r == "3", fmt.tprintf("%s: \"%s\" != \"3\"\n", #procedure, r)) + testing.expect(t, r == "3", fmt.tprintf("%s: \"%s\" != \"3\"\n", #procedure, r)) } From 99894686cfa59b35959dea9d3302bd218afc7890 Mon Sep 17 00:00:00 2001 From: Felipe Lavratti Date: Wed, 28 Sep 2022 15:58:35 +0100 Subject: [PATCH 012/110] Change llvm-copy-to-zip path to use real one, instead of link --- .gitignore | 2 +- build_odin.sh | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index deccccbbd..67314e23a 100644 --- a/.gitignore +++ b/.gitignore @@ -271,7 +271,7 @@ odin odin.dSYM *.bin demo.bin -libLLVM*.so +libLLVM*.so* # shared collection shared/ diff --git a/build_odin.sh b/build_odin.sh index b7462106b..4d2e461dd 100755 --- a/build_odin.sh +++ b/build_odin.sh @@ -100,7 +100,11 @@ config_linux() { LDFLAGS="$LDFLAGS -ldl" CXXFLAGS="$CXXFLAGS $($LLVM_CONFIG --cxxflags --ldflags)" LDFLAGS="$LDFLAGS $($LLVM_CONFIG --libs core native --system-libs --libfiles) -Wl,-rpath=\$ORIGIN" - cp $($LLVM_CONFIG --libfiles) ./ + + # Creates a copy of the llvm library in the build dir, this is meant to support compiler explorer. + # The annoyance is that this copy can be cluttering the development folder. TODO: split staging folders + # for development and compiler explorer builds + cp $(readlink -f $($LLVM_CONFIG --libfiles)) ./ } build_odin() { From fae025aac82a731feee726151048fd99fd97c846 Mon Sep 17 00:00:00 2001 From: Felipe Lavratti Date: Thu, 29 Sep 2022 01:42:12 +0100 Subject: [PATCH 013/110] Fix llvm copy on nightly ci --- .github/workflows/nightly.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index f84f14f76..7fe7513e0 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -50,7 +50,7 @@ jobs: run: | mkdir dist cp odin dist - cp libLLVM*.so dist + cp libLLVM* dist cp -r shared dist cp -r core dist cp -r vendor dist From f65bdf5733e43ab5a5c849af4664a58b707272b0 Mon Sep 17 00:00:00 2001 From: Michael Kutowski Date: Fri, 30 Sep 2022 19:40:41 +0200 Subject: [PATCH 014/110] else statement to allow skipping unused struct fields --- core/encoding/json/unmarshal.odin | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/core/encoding/json/unmarshal.odin b/core/encoding/json/unmarshal.odin index 062649b58..19288a294 100644 --- a/core/encoding/json/unmarshal.odin +++ b/core/encoding/json/unmarshal.odin @@ -380,20 +380,18 @@ unmarshal_object :: proc(p: ^Parser, v: any, end_token: Token_Kind) -> (err: Unm field := any{field_ptr, type.id} unmarshal_value(p, field) or_return + if parse_comma(p) { + break struct_loop + } + continue struct_loop + } else { + // allows skipping unused struct fields + parse_value(p) or_return if parse_comma(p) { break struct_loop } continue struct_loop } - - // NOTE(bill, 2022-09-14): Previously this would not be allowed - // {"foo": 123, "bar": 456} - // T :: struct{foo: int} - // `T` is missing the `bar` field - // The line below is commented out to ignore fields in an object which - // do not have a corresponding target field - // - // return Unsupported_Type_Error{v.id, p.curr_token} } case reflect.Type_Info_Map: From a7280472812d4a0d82d402e22181c781e0039ebf Mon Sep 17 00:00:00 2001 From: hikari Date: Sat, 1 Oct 2022 17:12:23 +0300 Subject: [PATCH 015/110] sys/windows: add a bunch of stuff --- core/sys/windows/advapi32.odin | 30 ++++++++ core/sys/windows/gdi32.odin | 1 + core/sys/windows/shell32.odin | 5 ++ core/sys/windows/shlwapi.odin | 1 + core/sys/windows/types.odin | 132 ++++++++++++++++++++++++++++++++- core/sys/windows/user32.odin | 1 + 6 files changed, 169 insertions(+), 1 deletion(-) diff --git a/core/sys/windows/advapi32.odin b/core/sys/windows/advapi32.odin index 82031d4f7..c2fbb560a 100644 --- a/core/sys/windows/advapi32.odin +++ b/core/sys/windows/advapi32.odin @@ -128,4 +128,34 @@ foreign advapi32 { lpData: LPCVOID, cbData: DWORD, ) -> LSTATUS --- + + GetFileSecurityA :: proc( + lpFileName: LPCSTR, + RequestedInformation: SECURITY_INFORMATION, + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + nLength: DWORD, + lpnLengthNeeded: LPDWORD, + ) -> BOOL --- + + DuplicateToken :: proc( + ExistingTokenHandle: HANDLE, + ImpersonationLevel: SECURITY_IMPERSONATION_LEVEL, + DuplicateTokenHandle: PHANDLE, + ) -> BOOL --- + + MapGenericMask :: proc( + AccessMask: PDWORD, + GenericMapping: PGENERIC_MAPPING, + ) --- + + AccessCheck :: proc( + pSecurityDescriptor: PSECURITY_DESCRIPTOR, + ClientToken: HANDLE, + DesiredAccess: DWORD, + GenericMapping: PGENERIC_MAPPING, + PrivilegeSet: PPRIVILEGE_SET, + PrivilegeSetLength: LPDWORD, + GrantedAccess: LPDWORD, + AccessStatus: LPBOOL, + ) -> BOOL --- } diff --git a/core/sys/windows/gdi32.odin b/core/sys/windows/gdi32.odin index 4403a5dc3..274cae35b 100644 --- a/core/sys/windows/gdi32.odin +++ b/core/sys/windows/gdi32.odin @@ -77,6 +77,7 @@ foreign gdi32 { ) -> HFONT --- TextOutW :: proc(hdc: HDC, x, y: c_int, lpString: LPCWSTR, c: c_int) -> BOOL --- GetTextExtentPoint32W :: proc(hdc: HDC, lpString: LPCWSTR, c: c_int, psizl: LPSIZE) -> BOOL --- + GetTextMetricsW :: proc(hdc: HDC, lptm: LPTEXTMETRICW) -> BOOL --- } RGB :: #force_inline proc "contextless" (r, g, b: u8) -> COLORREF { diff --git a/core/sys/windows/shell32.odin b/core/sys/windows/shell32.odin index fa7a24906..a3d6c6fb8 100644 --- a/core/sys/windows/shell32.odin +++ b/core/sys/windows/shell32.odin @@ -14,4 +14,9 @@ foreign shell32 { lpDirectory: LPCWSTR, nShowCmd: INT, ) -> HINSTANCE --- + SHCreateDirectoryExW :: proc( + hwnd: HWND, + pszPath: LPCWSTR, + psa: ^SECURITY_ATTRIBUTES, + ) -> c_int --- } diff --git a/core/sys/windows/shlwapi.odin b/core/sys/windows/shlwapi.odin index 1852d536f..241ade8f6 100644 --- a/core/sys/windows/shlwapi.odin +++ b/core/sys/windows/shlwapi.odin @@ -8,4 +8,5 @@ foreign shlwapi { PathFileExistsW :: proc(pszPath: wstring) -> BOOL --- PathFindExtensionW :: proc(pszPath: wstring) -> wstring --- PathFindFileNameW :: proc(pszPath: wstring) -> wstring --- + SHAutoComplete :: proc(hwndEdit: HWND, dwFlags: DWORD) -> LWSTDAPI --- } diff --git a/core/sys/windows/types.odin b/core/sys/windows/types.odin index 85c94284c..0b7729767 100644 --- a/core/sys/windows/types.odin +++ b/core/sys/windows/types.odin @@ -20,6 +20,7 @@ DWORD :: c_ulong DWORDLONG :: c.ulonglong QWORD :: c.ulonglong HANDLE :: distinct LPVOID +PHANDLE :: ^HANDLE HINSTANCE :: HANDLE HMODULE :: distinct HINSTANCE HRESULT :: distinct LONG @@ -133,6 +134,11 @@ LPWSAOVERLAPPED :: distinct rawptr LPWSAOVERLAPPED_COMPLETION_ROUTINE :: distinct rawptr LPCVOID :: rawptr +PACCESS_TOKEN :: PVOID +PSECURITY_DESCRIPTOR :: PVOID +PSID :: PVOID +PCLAIMS_BLOB :: PVOID + PCONDITION_VARIABLE :: ^CONDITION_VARIABLE PLARGE_INTEGER :: ^LARGE_INTEGER PSRWLOCK :: ^SRWLOCK @@ -175,6 +181,7 @@ FILE_SHARE_DELETE: DWORD : 0x00000004 FILE_GENERIC_ALL: DWORD : 0x10000000 FILE_GENERIC_EXECUTE: DWORD : 0x20000000 FILE_GENERIC_READ: DWORD : 0x80000000 +FILE_ALL_ACCESS :: STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF FILE_ACTION_ADDED :: 0x00000001 FILE_ACTION_REMOVED :: 0x00000002 @@ -230,6 +237,20 @@ SECURITY_SQOS_PRESENT: DWORD : 0x00100000 FIONBIO: c_ulong : 0x8004667e +OWNER_SECURITY_INFORMATION :: 0x00000001 +GROUP_SECURITY_INFORMATION :: 0x00000002 +DACL_SECURITY_INFORMATION :: 0x00000004 +SACL_SECURITY_INFORMATION :: 0x00000008 +LABEL_SECURITY_INFORMATION :: 0x00000010 +ATTRIBUTE_SECURITY_INFORMATION :: 0x00000020 +SCOPE_SECURITY_INFORMATION :: 0x00000040 +PROCESS_TRUST_LABEL_SECURITY_INFORMATION :: 0x00000080 +ACCESS_FILTER_SECURITY_INFORMATION :: 0x00000100 +BACKUP_SECURITY_INFORMATION :: 0x00010000 +PROTECTED_DACL_SECURITY_INFORMATION :: 0x80000000 +PROTECTED_SACL_SECURITY_INFORMATION :: 0x40000000 +UNPROTECTED_DACL_SECURITY_INFORMATION :: 0x20000000 +UNPROTECTED_SACL_SECURITY_INFORMATION :: 0x10000000 GET_FILEEX_INFO_LEVELS :: distinct i32 GetFileExInfoStandard: GET_FILEEX_INFO_LEVELS : 0 @@ -773,6 +794,30 @@ MSG :: struct { LPMSG :: ^MSG +TEXTMETRICW :: struct { + tmHeight: LONG, + tmAscent: LONG, + tmDescent: LONG, + tmInternalLeading: LONG, + tmExternalLeading: LONG, + tmAveCharWidth: LONG, + tmMaxCharWidth: LONG, + tmWeight: LONG, + tmOverhang: LONG, + tmDigitizedAspectX: LONG, + tmDigitizedAspectY: LONG, + tmFirstChar: WCHAR, + tmLastChar: WCHAR, + tmDefaultChar: WCHAR, + tmBreakChar: WCHAR, + tmItalic: BYTE, + tmUnderlined: BYTE, + tmStruckOut: BYTE, + tmPitchAndFamily: BYTE, + tmCharSet: BYTE, +} +LPTEXTMETRICW :: ^TEXTMETRICW + PAINTSTRUCT :: struct { hdc: HDC, fErase: BOOL, @@ -1462,6 +1507,24 @@ IDI_WARNING := IDI_EXCLAMATION IDI_ERROR := IDI_HAND IDI_INFORMATION := IDI_ASTERISK +IMAGE_BITMAP :: 0 +IMAGE_ICON :: 1 +IMAGE_CURSOR :: 2 +IMAGE_ENHMETAFILE :: 3 + +LR_DEFAULTCOLOR :: 0x00000000 +LR_MONOCHROME :: 0x00000001 +LR_COLOR :: 0x00000002 +LR_COPYRETURNORG :: 0x00000004 +LR_COPYDELETEORG :: 0x00000008 +LR_LOADFROMFILE :: 0x00000010 +LR_LOADTRANSPARENT :: 0x00000020 +LR_DEFAULTSIZE :: 0x00000040 +LR_VGACOLOR :: 0x00000080 +LR_LOADMAP3DCOLORS :: 0x00001000 +LR_CREATEDIBSECTION :: 0x00002000 +LR_COPYFROMRESOURCE :: 0x00004000 +LR_SHARED :: 0x00008000 // DIB color table identifiers DIB_RGB_COLORS :: 0 @@ -1793,7 +1856,58 @@ HEAP_ZERO_MEMORY: DWORD : 0x00000008 HANDLE_FLAG_INHERIT: DWORD : 0x00000001 HANDLE_FLAG_PROTECT_FROM_CLOSE :: 0x00000002 -TOKEN_READ: DWORD : 0x20008 +GENERIC_MAPPING :: struct { + GenericRead: ACCESS_MASK, + GenericWrite: ACCESS_MASK, + GenericExecute: ACCESS_MASK, + GenericAll: ACCESS_MASK, +} +PGENERIC_MAPPING :: ^GENERIC_MAPPING + +SECURITY_IMPERSONATION_LEVEL :: enum { + SecurityAnonymous, + SecurityIdentification, + SecurityImpersonation, + SecurityDelegation, +} + +SECURITY_INFORMATION :: DWORD +ANYSIZE_ARRAY :: 1 + +LUID_AND_ATTRIBUTES :: struct { + Luid: LUID, + Attributes: DWORD, +} + +PRIVILEGE_SET :: struct { + PrivilegeCount: DWORD, + Control: DWORD, + Privilege: [ANYSIZE_ARRAY]LUID_AND_ATTRIBUTES, +} +PPRIVILEGE_SET :: ^PRIVILEGE_SET + +// Token Specific Access Rights. +TOKEN_ASSIGN_PRIMARY :: 0x0001 +TOKEN_DUPLICATE :: 0x0002 +TOKEN_IMPERSONATE :: 0x0004 +TOKEN_QUERY :: 0x0008 +TOKEN_QUERY_SOURCE :: 0x0010 +TOKEN_ADJUST_PRIVILEGES :: 0x0020 +TOKEN_ADJUST_GROUPS :: 0x0040 +TOKEN_ADJUST_DEFAULT :: 0x0080 +TOKEN_ADJUST_SESSIONID :: 0x0100 + +TOKEN_ALL_ACCESS_P :: STANDARD_RIGHTS_REQUIRED | TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE | TOKEN_IMPERSONATE | TOKEN_QUERY |\ + TOKEN_QUERY_SOURCE | TOKEN_ADJUST_PRIVILEGES | TOKEN_ADJUST_GROUPS | TOKEN_ADJUST_DEFAULT + +TOKEN_ALL_ACCESS :: TOKEN_ALL_ACCESS_P | TOKEN_ADJUST_SESSIONID +TOKEN_READ :: STANDARD_RIGHTS_READ | TOKEN_QUERY +TOKEN_WRITE :: STANDARD_RIGHTS_WRITE | TOKEN_ADJUST_PRIVILEGES | TOKEN_ADJUST_GROUPS | TOKEN_ADJUST_DEFAULT +TOKEN_EXECUTE :: STANDARD_RIGHTS_EXECUTE +TOKEN_TRUST_CONSTRAINT_MASK :: STANDARD_RIGHTS_READ | TOKEN_QUERY | TOKEN_QUERY_SOURCE +TOKEN_ACCESS_PSEUDO_HANDLE_WIN8 :: TOKEN_QUERY | TOKEN_QUERY_SOURCE +TOKEN_ACCESS_PSEUDO_HANDLE :: TOKEN_ACCESS_PSEUDO_HANDLE_WIN8 + CP_ACP :: 0 // default to ANSI code page CP_OEMCP :: 1 // default to OEM code page @@ -3048,6 +3162,22 @@ SHCONTF_FLATLIST :: 0x4000 SHCONTF_ENABLE_ASYNC :: 0x8000 SHCONTF_INCLUDESUPERHIDDEN :: 0x10000 +SHACF_DEFAULT :: 0x00000000 // Currently (SHACF_FILESYSTEM | SHACF_URLALL) +SHACF_FILESYSTEM :: 0x00000001 // This includes the File System as well as the rest of the shell (Desktop\My Computer\Control Panel\) +SHACF_URLALL :: (SHACF_URLHISTORY | SHACF_URLMRU) +SHACF_URLHISTORY :: 0x00000002 // URLs in the User's History +SHACF_URLMRU :: 0x00000004 // URLs in the User's Recently Used list. +SHACF_USETAB :: 0x00000008 // Use the tab to move thru the autocomplete possibilities instead of to the next dialog/window control. +SHACF_FILESYS_ONLY :: 0x00000010 // This includes the File System +SHACF_FILESYS_DIRS :: 0x00000020 // Same as SHACF_FILESYS_ONLY except it only includes directories, UNC servers, and UNC server shares. +SHACF_VIRTUAL_NAMESPACE :: 0x00000040 // Also include the virtual namespace +SHACF_AUTOSUGGEST_FORCE_ON :: 0x10000000 // Ignore the registry default and force the feature on. +SHACF_AUTOSUGGEST_FORCE_OFF :: 0x20000000 // Ignore the registry default and force the feature off. +SHACF_AUTOAPPEND_FORCE_ON :: 0x40000000 // Ignore the registry default and force the feature on. (Also know as AutoComplete) +SHACF_AUTOAPPEND_FORCE_OFF :: 0x80000000 // Ignore the registry default and force the feature off. (Also know as AutoComplete) + +LWSTDAPI :: HRESULT + CLSID_FileOpenDialog := &GUID{0xDC1C5A9C, 0xE88A, 0x4DDE, {0xA5, 0xA1, 0x60, 0xF8, 0x2A, 0x20, 0xAE, 0xF7}} CLSID_FileSaveDialog := &GUID{0xC0B4E2F3, 0xBA21, 0x4773, {0x8D, 0xBA, 0x33, 0x5E, 0xC9, 0x46, 0xEB, 0x8B}} diff --git a/core/sys/windows/user32.odin b/core/sys/windows/user32.odin index ffb82ad0e..9a30e6454 100644 --- a/core/sys/windows/user32.odin +++ b/core/sys/windows/user32.odin @@ -78,6 +78,7 @@ foreign user32 { LoadIconW :: proc(hInstance: HINSTANCE, lpIconName: LPCWSTR) -> HICON --- LoadCursorA :: proc(hInstance: HINSTANCE, lpCursorName: LPCSTR) -> HCURSOR --- LoadCursorW :: proc(hInstance: HINSTANCE, lpCursorName: LPCWSTR) -> HCURSOR --- + LoadImageW :: proc(hInst: HINSTANCE, name: LPCWSTR, type: UINT, cx: c_int, cy: c_int, fuLoad: UINT) -> HANDLE --- GetWindowRect :: proc(hWnd: HWND, lpRect: LPRECT) -> BOOL --- GetClientRect :: proc(hWnd: HWND, lpRect: LPRECT) -> BOOL --- From ce09cb0bdb123cca72021117e700b9b404361aeb Mon Sep 17 00:00:00 2001 From: hikari Date: Sat, 1 Oct 2022 17:13:17 +0300 Subject: [PATCH 016/110] sys/windows: add comctl32 --- core/sys/windows/comctl32.odin | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 core/sys/windows/comctl32.odin diff --git a/core/sys/windows/comctl32.odin b/core/sys/windows/comctl32.odin new file mode 100644 index 000000000..983c45d36 --- /dev/null +++ b/core/sys/windows/comctl32.odin @@ -0,0 +1,9 @@ +// +build windows +package sys_windows + +foreign import "system:Comctl32.lib" + +@(default_calling_convention="stdcall") +foreign Comctl32 { + LoadIconWithScaleDown :: proc(hinst: HINSTANCE, pszName: PCWSTR, cx: c_int, cy: c_int, phico: ^HICON) -> HRESULT --- +} From 8a5b39f734d63c65d4dc07cbf20e2e3b7a41a0b1 Mon Sep 17 00:00:00 2001 From: Vitalii Kravchenko Date: Sun, 2 Oct 2022 07:40:28 +0100 Subject: [PATCH 017/110] Darwin: allow reading/writing files larger than max(i32) --- core/os/os_darwin.odin | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/core/os/os_darwin.odin b/core/os/os_darwin.odin index 5c2cf8ec2..9dbb73a25 100644 --- a/core/os/os_darwin.odin +++ b/core/os/os_darwin.odin @@ -369,27 +369,45 @@ close :: proc(fd: Handle) -> bool { return _unix_close(fd) == 0 } +@(private) +MAX_RW :: 0x7fffffff // The limit on Darwin is max(i32), trying to read/write more than that fails. + write :: proc(fd: Handle, data: []u8) -> (int, Errno) { assert(fd != -1) - if len(data) == 0 { - return 0, 0 - } - bytes_written := _unix_write(fd, raw_data(data), len(data)) - if bytes_written == -1 { - return 0, 1 - } - return bytes_written, 0 + bytes_total := len(data) + bytes_written_total := 0 + + for bytes_written_total < bytes_total { + bytes_to_write := min(bytes_total - bytes_written_total, MAX_RW) + slice := data[bytes_written_total:bytes_written_total + bytes_to_write] + bytes_written := _unix_write(fd, raw_data(slice), bytes_to_write) + if bytes_written == -1 { + return bytes_written_total, 1 + } + bytes_written_total += bytes_written + } + + return bytes_written_total, 0 } read :: proc(fd: Handle, data: []u8) -> (int, Errno) { assert(fd != -1) - bytes_read := _unix_read(fd, raw_data(data), len(data)) - if bytes_read == -1 { - return 0, 1 + bytes_total := len(data) + bytes_read_total := 0 + + for bytes_read_total < bytes_total { + bytes_to_read := min(bytes_total - bytes_read_total, MAX_RW) + slice := data[bytes_read_total:bytes_read_total + bytes_to_read] + bytes_read := _unix_read(fd, raw_data(slice), bytes_to_read) + if bytes_read == -1 { + return bytes_read_total, 1 + } + bytes_read_total += bytes_read } - return bytes_read, 0 + + return bytes_read_total, 0 } seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Errno) { From d52a9b61af066deaa29398bb4195418f2817e42c Mon Sep 17 00:00:00 2001 From: Vitalii Kravchenko Date: Sun, 2 Oct 2022 07:47:22 +0100 Subject: [PATCH 018/110] Fix indentation --- core/os/os_darwin.odin | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/core/os/os_darwin.odin b/core/os/os_darwin.odin index 9dbb73a25..ac7376752 100644 --- a/core/os/os_darwin.odin +++ b/core/os/os_darwin.odin @@ -375,18 +375,18 @@ MAX_RW :: 0x7fffffff // The limit on Darwin is max(i32), trying to read/write mo write :: proc(fd: Handle, data: []u8) -> (int, Errno) { assert(fd != -1) - bytes_total := len(data) - bytes_written_total := 0 + bytes_total := len(data) + bytes_written_total := 0 - for bytes_written_total < bytes_total { + for bytes_written_total < bytes_total { bytes_to_write := min(bytes_total - bytes_written_total, MAX_RW) - slice := data[bytes_written_total:bytes_written_total + bytes_to_write] - bytes_written := _unix_write(fd, raw_data(slice), bytes_to_write) - if bytes_written == -1 { - return bytes_written_total, 1 - } - bytes_written_total += bytes_written - } + slice := data[bytes_written_total:bytes_written_total + bytes_to_write] + bytes_written := _unix_write(fd, raw_data(slice), bytes_to_write) + if bytes_written == -1 { + return bytes_written_total, 1 + } + bytes_written_total += bytes_written + } return bytes_written_total, 0 } From 35ee7f3cba3d08e76241b5baf8a1c41848749855 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 2 Oct 2022 11:58:17 +0100 Subject: [PATCH 019/110] Add `system:legacy_stdio_definitions.lib` to `.odin` for Windows --- core/c/libc/stdio.odin | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/c/libc/stdio.odin b/core/c/libc/stdio.odin index 9b1089d85..1b41c5560 100644 --- a/core/c/libc/stdio.odin +++ b/core/c/libc/stdio.odin @@ -1,7 +1,10 @@ package libc when ODIN_OS == .Windows { - foreign import libc "system:libucrt.lib" + foreign import libc { + "system:libucrt.lib", + "system:legacy_stdio_definitions.lib", + } } else when ODIN_OS == .Darwin { foreign import libc "system:System.framework" } else { From 79fe30321ab571038f8d3822ce989becd2336306 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Sun, 2 Oct 2022 20:56:30 +0200 Subject: [PATCH 020/110] [tests] Skip issues test on Windows for now. --- .github/workflows/ci.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e6341671a..558781a0a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,11 +38,6 @@ jobs: cd tests/vendor make timeout-minutes: 10 - - name: Odin issues tests - run: | - cd tests/issues - ./run.sh - timeout-minutes: 10 - name: Odin check examples/all for Linux i386 run: ./odin check examples/all -vet -strict-style -target:linux_i386 timeout-minutes: 10 From 1c9aad4d7be05ee7da14e9aa3b56733dc6df7a36 Mon Sep 17 00:00:00 2001 From: Ricardo Silva Date: Mon, 3 Oct 2022 14:49:35 +0100 Subject: [PATCH 021/110] Update Darwin release map --- core/sys/info/platform_darwin.odin | 1 + 1 file changed, 1 insertion(+) diff --git a/core/sys/info/platform_darwin.odin b/core/sys/info/platform_darwin.odin index fe58d5b06..d226f668c 100644 --- a/core/sys/info/platform_darwin.odin +++ b/core/sys/info/platform_darwin.odin @@ -464,6 +464,7 @@ macos_release_map: map[string]Darwin_To_Release = { "21F2092" = {{21, 5, 0}, "macOS", {"Monterey", {12, 4, 0}}}, "21G72" = {{21, 6, 0}, "macOS", {"Monterey", {12, 5, 0}}}, "21G83" = {{21, 6, 0}, "macOS", {"Monterey", {12, 5, 1}}}, + "21G115" = {{21, 6, 0}, "macOS", {"Monterey", {12, 6, 0}}}, } @(private) From d13dc7eca718508eb40dc17edff9d298c5f4052c Mon Sep 17 00:00:00 2001 From: matias Date: Mon, 3 Oct 2022 11:35:27 -0400 Subject: [PATCH 022/110] Add a few Fiber functions to kernel32.odin This is not the complete set, but a start. --- core/sys/windows/kernel32.odin | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/core/sys/windows/kernel32.odin b/core/sys/windows/kernel32.odin index a9ed44d8a..9e5e5448b 100644 --- a/core/sys/windows/kernel32.odin +++ b/core/sys/windows/kernel32.odin @@ -963,4 +963,15 @@ DCB :: struct { foreign kernel32 { GetCommState :: proc(handle: HANDLE, dcb: ^DCB) -> BOOL --- SetCommState :: proc(handle: HANDLE, dcb: ^DCB) -> BOOL --- -} \ No newline at end of file +} + + +LPFIBER_START_ROUTINE :: #type proc "stdcall" (lpFiberParameter: LPVOID) + +@(default_calling_convention = "stdcall") +foreign kernel32 { + CreateFiber :: proc(dwStackSize: SIZE_T, lpStartAddress: LPFIBER_START_ROUTINE, lpParameter: LPVOID) -> LPVOID --- + DeleteFiber :: proc(lpFiber: LPVOID) --- + ConvertThreadToFiber :: proc(lpParameter: LPVOID) -> LPVOID --- + SwitchToFiber :: proc(lpFiber: LPVOID) --- +} From de8f6709f7a6d90d89a18b4ba2f177070397b684 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Tue, 4 Oct 2022 02:07:54 +0200 Subject: [PATCH 023/110] Disable issues tests for the moment. --- .github/workflows/ci.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 558781a0a..0d8e10d59 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -158,13 +158,6 @@ jobs: cd tests\core\math\big call build.bat timeout-minutes: 10 - - name: Odin issues tests - shell: cmd - run: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat - cd tests\issues - call run.bat - timeout-minutes: 10 - name: Odin check examples/all for Windows 32bits shell: cmd run: | From aebafdcd086aafba8c40f54850dc2e11ff1113af Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 4 Oct 2022 10:18:32 +0100 Subject: [PATCH 024/110] update `virtual.growing_arena_bootstrap_new` --- core/mem/virtual/growing_arena.odin | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/mem/virtual/growing_arena.odin b/core/mem/virtual/growing_arena.odin index 0fb826c07..44d56866e 100644 --- a/core/mem/virtual/growing_arena.odin +++ b/core/mem/virtual/growing_arena.odin @@ -76,8 +76,7 @@ growing_arena_destroy :: proc(arena: ^Growing_Arena) { growing_arena_free_all(arena) } -growing_arena_bootstrap_new_by_offset :: proc($T: typeid, offset_to_arena: uintptr, minimum_block_size := DEFAULT_MINIMUM_BLOCK_SIZE) -> (ptr: ^T, err: Allocator_Error) { - bootstrap: Growing_Arena +growing_arena_bootstrap_new_by_offset :: proc($T: typeid, offset_to_arena: uintptr, minimum_block_size: uint = DEFAULT_MINIMUM_BLOCK_SIZE) -> (ptr: ^T, err: Allocator_Error) { bootstrap: Growing_Arena bootstrap.minimum_block_size = minimum_block_size data := growing_arena_alloc(&bootstrap, size_of(T), align_of(T)) or_return @@ -89,7 +88,7 @@ growing_arena_bootstrap_new_by_offset :: proc($T: typeid, offset_to_arena: uintp return } -growing_arena_bootstrap_new_by_name :: proc($T: typeid, $field_name: string, minimum_block_size := DEFAULT_MINIMUM_BLOCK_SIZE) -> (ptr: ^T, err: Allocator_Error) { +growing_arena_bootstrap_new_by_name :: proc($T: typeid, $field_name: string, minimum_block_size: uint = DEFAULT_MINIMUM_BLOCK_SIZE) -> (ptr: ^T, err: Allocator_Error) { return growing_arena_bootstrap_new_by_offset(T, offset_of_by_string(T, field_name), minimum_block_size) } growing_arena_bootstrap_new :: proc{ From bb9b58b8c42eec3d810688939a7dd454b6fa0c32 Mon Sep 17 00:00:00 2001 From: hikari Date: Fri, 7 Oct 2022 03:53:14 +0300 Subject: [PATCH 025/110] sys/windows: add some constants --- core/sys/windows/types.odin | 13 +++++++++++-- core/sys/windows/window_messages.odin | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/core/sys/windows/types.odin b/core/sys/windows/types.odin index 0b7729767..d4983fd06 100644 --- a/core/sys/windows/types.odin +++ b/core/sys/windows/types.odin @@ -1111,8 +1111,14 @@ WS_EX_TOPMOST : UINT : 0x0000_0008 WS_EX_TRANSPARENT : UINT : 0x0000_0020 WS_EX_WINDOWEDGE : UINT : 0x0000_0100 -PBS_SMOOTH :: 0x01 -PBS_VERTICAL :: 0x04 +PBS_SMOOTH :: 0x01 +PBS_VERTICAL :: 0x04 +PBS_MARQUEE :: 0x08 +PBS_SMOOTHREVERSE :: 0x10 + +PBST_NORMAL :: 0x0001 +PBST_ERROR :: 0x0002 +PBST_PAUSED :: 0x0003 QS_ALLEVENTS : UINT : QS_INPUT | QS_POSTMESSAGE | QS_TIMER | QS_PAINT | QS_HOTKEY QS_ALLINPUT : UINT : QS_INPUT | QS_POSTMESSAGE | QS_TIMER | QS_PAINT | QS_HOTKEY | QS_SENDMESSAGE @@ -1837,12 +1843,15 @@ WAIT_FAILED: DWORD : 0xFFFFFFFF PIPE_ACCESS_INBOUND: DWORD : 0x00000001 PIPE_ACCESS_OUTBOUND: DWORD : 0x00000002 +PIPE_ACCESS_DUPLEX: DWORD : 0x00000003 FILE_FLAG_FIRST_PIPE_INSTANCE: DWORD : 0x00080000 FILE_FLAG_OVERLAPPED: DWORD : 0x40000000 PIPE_WAIT: DWORD : 0x00000000 PIPE_TYPE_BYTE: DWORD : 0x00000000 +PIPE_TYPE_MESSAGE: DWORD : 0x00000004 PIPE_REJECT_REMOTE_CLIENTS: DWORD : 0x00000008 PIPE_READMODE_BYTE: DWORD : 0x00000000 +PIPE_READMODE_MESSAGE: DWORD : 0x00000002 PIPE_ACCEPT_REMOTE_CLIENTS: DWORD : 0x00000000 FD_SETSIZE :: 64 diff --git a/core/sys/windows/window_messages.odin b/core/sys/windows/window_messages.odin index 616247f59..888c5ccf9 100644 --- a/core/sys/windows/window_messages.odin +++ b/core/sys/windows/window_messages.odin @@ -454,6 +454,7 @@ TB_ISBUTTONENABLED :: 0x0409 TBM_CLEARTICS :: 0x0409 TTM_SETTOOLINFOA :: 0x0409 CBEM_HASEDITCHANGED :: 0x040a +PBM_SETMARQUEE :: 0x040a RB_INSERTBANDW :: 0x040a SB_GETRECT :: 0x040a TB_ISBUTTONCHECKED :: 0x040a @@ -488,10 +489,12 @@ TTM_ENUMTOOLSA :: 0x040e SB_SETICON :: 0x040f TBM_GETTICPOS :: 0x040f TTM_GETCURRENTTOOLA :: 0x040f +PBM_SETSTATE :: 0x0410 RB_IDTOINDEX :: 0x0410 SB_SETTIPTEXTA :: 0x0410 TBM_GETNUMTICS :: 0x0410 TTM_WINDOWFROMPOINT :: 0x0410 +PBM_GETSTATE :: 0x0411 RB_GETTOOLTIPS :: 0x0411 SB_SETTIPTEXTW :: 0x0411 TBM_GETSELSTART :: 0x0411 From 8b06fd093518c01c896e4eb2bcb271a5bc593b7e Mon Sep 17 00:00:00 2001 From: Phuk Ng Yu Date: Fri, 7 Oct 2022 00:06:46 -0700 Subject: [PATCH 026/110] os2/file_windows fix --- core/os/os2/file_windows.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/os/os2/file_windows.odin b/core/os/os2/file_windows.odin index 7589ed799..e4ae4856a 100644 --- a/core/os/os2/file_windows.odin +++ b/core/os/os2/file_windows.odin @@ -130,7 +130,7 @@ _new_file :: proc(handle: uintptr, name: string) -> ^File { f := new(File, _file_allocator()) f.impl.allocator = _file_allocator() - f.impl.fd = rawptr(fd) + f.impl.fd = rawptr(handle) f.impl.name = strings.clone(name, f.impl.allocator) f.impl.wname = win32.utf8_to_wstring(name, f.impl.allocator) From 5362e883f43c12ce1340e18752ced120f287f812 Mon Sep 17 00:00:00 2001 From: Jan Ivanecky Date: Sat, 8 Oct 2022 00:47:42 +0200 Subject: [PATCH 027/110] Add additional NSWindow methods --- vendor/darwin/Foundation/NSWindow.odin | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/vendor/darwin/Foundation/NSWindow.odin b/vendor/darwin/Foundation/NSWindow.odin index 330af6012..15a73e63b 100644 --- a/vendor/darwin/Foundation/NSWindow.odin +++ b/vendor/darwin/Foundation/NSWindow.odin @@ -156,6 +156,22 @@ Window_makeKeyAndOrderFront :: proc(self: ^Window, key: ^NS.Object) { Window_setTitle :: proc(self: ^Window, title: ^NS.String) { msgSend(nil, self, "setTitle:", title) } +@(objc_type=Window, objc_name="setTitlebarAppearsTransparent") +Window_setTitlebarAppearsTransparent :: proc(self: ^Window, ok: NS.BOOL) { + msgSend(nil, self, "setTitlebarAppearsTransparent:", ok) +} +@(objc_type=Window, objc_name="setMovable") +Window_setMovable :: proc(self: ^Window, ok: NS.BOOL) { + msgSend(nil, self, "setMovable:", ok) +} +@(objc_type=Window, objc_name="setMovableByWindowBackground") +Window_setMovableByWindowBackground :: proc(self: ^Window, ok: NS.BOOL) { + msgSend(nil, self, "setMovableByWindowBackground:", ok) +} +@(objc_type=Window, objc_name="setStyleMask") +Window_setStyleMask :: proc(self: ^Window, style_mask: WindowStyleMask) { + msgSend(nil, self, "setStyleMask:", style_mask) +} @(objc_type=Window, objc_name="close") Window_close :: proc(self: ^Window) { msgSend(nil, self, "close") From 64f1e8b7a262ebee08900bc2f7e88fe6ad7132e8 Mon Sep 17 00:00:00 2001 From: Lucas Perlind Date: Sat, 8 Oct 2022 14:55:20 +1100 Subject: [PATCH 028/110] Github CI: Add test case for issue 2113 --- .github/workflows/ci.yml | 8 ++++++++ tests/issues/run.bat | 16 ++++++++++++---- tests/issues/run.sh | 13 ++++++++----- tests/issues/test_issue_2113.odin | 13 +++++++++++++ 4 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 tests/issues/test_issue_2113.odin diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0d8e10d59..5da70931f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,6 +38,10 @@ jobs: cd tests/vendor make timeout-minutes: 10 + - name: Odin issues tests + run: | + cd tests/issues + ./run.sh - name: Odin check examples/all for Linux i386 run: ./odin check examples/all -vet -strict-style -target:linux_i386 timeout-minutes: 10 @@ -151,6 +155,10 @@ jobs: cd tests\vendor call build.bat timeout-minutes: 10 + - name: Odin issues tests + run: | + cd tests/issues + ./run.bat - name: core:math/big tests shell: cmd run: | diff --git a/tests/issues/run.bat b/tests/issues/run.bat index 2ecd14d95..c526fd472 100644 --- a/tests/issues/run.bat +++ b/tests/issues/run.bat @@ -1,15 +1,23 @@ @echo off if not exist "build\" mkdir build +pushd build -set COMMON=-collection:tests=.. +set COMMON=-collection:tests=..\.. + +set ERROR_DID_OCCUR=0 @echo on -..\..\odin test test_issue_829.odin %COMMON% -file -..\..\odin test test_issue_1592.odin %COMMON% -file -..\..\odin test test_issue_2087.odin %COMMON% -file +..\..\..\odin test ..\test_issue_829.odin %COMMON% -file +..\..\..\odin test ..\test_issue_1592.odin %COMMON% -file +..\..\..\odin test ..\test_issue_2087.odin %COMMON% -file +..\..\..\odin build ..\test_issue_2113.odin %COMMON% -file -debug @echo off +if %ERRORLEVEL% NEQ 0 set ERROR_DID_OCCUR=1 + +popd rmdir /S /Q build +if %ERROR_DID_OCCUR% NEQ 0 EXIT /B 1 diff --git a/tests/issues/run.sh b/tests/issues/run.sh index f781c8278..440c953d9 100755 --- a/tests/issues/run.sh +++ b/tests/issues/run.sh @@ -2,15 +2,18 @@ set -eu mkdir -p build -ODIN=../../odin -COMMON="-collection:tests=.." +pushd build +ODIN=../../../odin +COMMON="-collection:tests=../.." set -x -$ODIN test test_issue_829.odin $COMMON -file -$ODIN test test_issue_1592.odin $COMMON -file -$ODIN test test_issue_2087.odin $COMMON -file +$ODIN test ../test_issue_829.odin $COMMON -file +$ODIN test ../test_issue_1592.odin $COMMON -file +$ODIN test ../test_issue_2087.odin $COMMON -file +$ODIN build ../test_issue_2113.odin $COMMON -file -debug set +x +popd rm -rf build diff --git a/tests/issues/test_issue_2113.odin b/tests/issues/test_issue_2113.odin new file mode 100644 index 000000000..dab9c7d07 --- /dev/null +++ b/tests/issues/test_issue_2113.odin @@ -0,0 +1,13 @@ +// Tests issue #2113 https://github.com/odin-lang/Odin/issues/2113 +// Causes a panic on compilation +package test_issues + +T :: struct { + a: int, +} + +main :: proc() { + array: #soa[1]T + a := &array[0] + _ = a +} From e188a542dae2268e62f7920f611f466759706347 Mon Sep 17 00:00:00 2001 From: Lucas Perlind Date: Sat, 8 Oct 2022 16:51:03 +1100 Subject: [PATCH 029/110] llvm_backend_debug: Add debug info for soa pointer This fixes issue #2113 --- src/llvm_backend_debug.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/llvm_backend_debug.cpp b/src/llvm_backend_debug.cpp index ee2e03739..29b0ab488 100644 --- a/src/llvm_backend_debug.cpp +++ b/src/llvm_backend_debug.cpp @@ -293,6 +293,7 @@ LLVMMetadataRef lb_debug_type_internal(lbModule *m, Type *type) { case Type_Named: GB_PANIC("Type_Named should be handled in lb_debug_type separately"); + case Type_SoaPointer: case Type_Pointer: return LLVMDIBuilderCreatePointerType(m->debug_builder, lb_debug_type(m, type->Pointer.elem), word_bits, word_bits, 0, nullptr, 0); case Type_MultiPointer: From 141133e3263b8a8a6004d48c6d8a74ecae9cc3ad Mon Sep 17 00:00:00 2001 From: Jan Ivanecky Date: Sat, 8 Oct 2022 16:29:49 +0200 Subject: [PATCH 030/110] Add class_getInstanceMethod, method_setImplementation bindings --- vendor/darwin/Foundation/objc.odin | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vendor/darwin/Foundation/objc.odin b/vendor/darwin/Foundation/objc.odin index 7db82df73..78f1f7780 100644 --- a/vendor/darwin/Foundation/objc.odin +++ b/vendor/darwin/Foundation/objc.odin @@ -13,6 +13,9 @@ foreign Foundation { objc_allocateClassPair :: proc "c" (superclass: Class, name: cstring, extraBytes: uint) --- class_addMethod :: proc "c" (cls: Class, name: SEL, imp: IMP, types: cstring) -> BOOL --- + class_getInstanceMethod :: proc "c" (cls: Class, name: SEL) -> Method --- + + method_setImplementation :: proc "c" (method: Method, imp: IMP) --- } From 7e5c063d9888cd74a90da73944252e99f6b0adea Mon Sep 17 00:00:00 2001 From: Jan Ivanecky Date: Sat, 8 Oct 2022 16:38:21 +0200 Subject: [PATCH 031/110] Add glfw.GetCocoaWindow --- vendor/glfw/native.odin | 33 --------------------------------- vendor/glfw/native_darwin.odin | 16 ++++++++++++++++ vendor/glfw/native_linux.odin | 15 +++++++++++++++ vendor/glfw/native_windows.odin | 15 +++++++++++++++ 4 files changed, 46 insertions(+), 33 deletions(-) delete mode 100644 vendor/glfw/native.odin create mode 100644 vendor/glfw/native_darwin.odin create mode 100644 vendor/glfw/native_linux.odin create mode 100644 vendor/glfw/native_windows.odin diff --git a/vendor/glfw/native.odin b/vendor/glfw/native.odin deleted file mode 100644 index 8ed439a94..000000000 --- a/vendor/glfw/native.odin +++ /dev/null @@ -1,33 +0,0 @@ -package glfw - -when ODIN_OS == .Windows { - import win32 "core:sys/windows" - - foreign import glfw { "lib/glfw3_mt.lib", "system:user32.lib", "system:gdi32.lib", "system:shell32.lib" } - - @(default_calling_convention="c", link_prefix="glfw") - foreign glfw { - GetWin32Adapter :: proc(monitor: MonitorHandle) -> cstring --- - GetWin32Monitor :: proc(monitor: MonitorHandle) -> cstring --- - GetWin32Window :: proc(window: WindowHandle) -> win32.HWND --- - GetWGLContext :: proc(window: WindowHandle) -> rawptr --- - } -} else when ODIN_OS == .Linux { - // TODO: Native Linux - // Display* glfwGetX11Display(void); - // RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor); - // RROutput glfwGetX11Monitor(GLFWmonitor* monitor); - // Window glfwGetX11Window(GLFWwindow* window); - // void glfwSetX11SelectionString(const char* string); - // const char* glfwGetX11SelectionString(void); - - // struct wl_display* glfwGetWaylandDisplay(void); - // struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor); - // struct wl_surface* glfwGetWaylandWindow(GLFWwindow* window); -} else when ODIN_OS == .Darwin { - // TODO: Native Darwin - // CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor); - // id glfwGetCocoaWindow(GLFWwindow* window); - // id glfwGetNSGLContext(GLFWwindow* window); -} - diff --git a/vendor/glfw/native_darwin.odin b/vendor/glfw/native_darwin.odin new file mode 100644 index 000000000..696645249 --- /dev/null +++ b/vendor/glfw/native_darwin.odin @@ -0,0 +1,16 @@ +//+build darwin + +package glfw + +import NS "vendor:darwin/foundation" + +foreign import glfw { "lib/darwin/libglfw3.a" } + +@(default_calling_convention="c", link_prefix="glfw") +foreign glfw { + GetCocoaWindow :: proc(window: WindowHandle) -> ^NS.Window --- +} + +// TODO: +// CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor); +// id glfwGetNSGLContext(GLFWwindow* window); diff --git a/vendor/glfw/native_linux.odin b/vendor/glfw/native_linux.odin new file mode 100644 index 000000000..9b9e14790 --- /dev/null +++ b/vendor/glfw/native_linux.odin @@ -0,0 +1,15 @@ +//+build linux + +package glfw + +// TODO: Native Linux +// Display* glfwGetX11Display(void); +// RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor); +// RROutput glfwGetX11Monitor(GLFWmonitor* monitor); +// Window glfwGetX11Window(GLFWwindow* window); +// void glfwSetX11SelectionString(const char* string); +// const char* glfwGetX11SelectionString(void); + +// struct wl_display* glfwGetWaylandDisplay(void); +// struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor); +// struct wl_surface* glfwGetWaylandWindow(GLFWwindow* window); diff --git a/vendor/glfw/native_windows.odin b/vendor/glfw/native_windows.odin new file mode 100644 index 000000000..1d9c3af86 --- /dev/null +++ b/vendor/glfw/native_windows.odin @@ -0,0 +1,15 @@ +//+build windows + +package glfw + +import win32 "core:sys/windows" + +foreign import glfw { "lib/glfw3_mt.lib", "system:user32.lib", "system:gdi32.lib", "system:shell32.lib" } + +@(default_calling_convention="c", link_prefix="glfw") +foreign glfw { + GetWin32Adapter :: proc(monitor: MonitorHandle) -> cstring --- + GetWin32Monitor :: proc(monitor: MonitorHandle) -> cstring --- + GetWin32Window :: proc(window: WindowHandle) -> win32.HWND --- + GetWGLContext :: proc(window: WindowHandle) -> rawptr --- +} From ab7367ae47ba387c2a7e8ef1401f7cf1e5aca0c8 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Sat, 8 Oct 2022 19:00:05 +0200 Subject: [PATCH 032/110] Fix #2112 --- src/build_settings.cpp | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/src/build_settings.cpp b/src/build_settings.cpp index 02de22ec4..237858efa 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -1502,44 +1502,24 @@ bool init_build_paths(String init_filename) { } else { Path output_path; - if (str_eq(init_filename, str_lit("."))) { - // We must name the output file after the current directory. - debugf("Output name will be created from current base name %.*s.\n", LIT(bc->build_paths[BuildPath_Main_Package].basename)); - String last_element = last_path_element(bc->build_paths[BuildPath_Main_Package].basename); + // We must name the output file after the current directory. + debugf("Output name will be created from current base name %.*s.\n", LIT(bc->build_paths[BuildPath_Main_Package].basename)); + String last_element = last_path_element(bc->build_paths[BuildPath_Main_Package].basename); - if (last_element.len == 0) { - gb_printf_err("The output name is created from the last path element. `%.*s` has none. Use `-out:output_name.ext` to set it.\n", LIT(bc->build_paths[BuildPath_Main_Package].basename)); - return false; - } - output_path.basename = copy_string(ha, bc->build_paths[BuildPath_Main_Package].basename); - output_path.name = copy_string(ha, last_element); - - } else { - // Init filename was not 'current path'. - // Contruct the output name from the path elements as usual. - String output_name = init_filename; - // If it ends with a trailing (back)slash, strip it before continuing. - while (output_name.len > 0 && (output_name[output_name.len-1] == '/' || output_name[output_name.len-1] == '\\')) { - output_name.len -= 1; - } - output_name = remove_directory_from_path(output_name); - output_name = remove_extension_from_path(output_name); - output_name = copy_string(ha, string_trim_whitespace(output_name)); - output_path = path_from_string(ha, output_name); - - // Replace extension. - if (output_path.ext.len > 0) { - gb_free(ha, output_path.ext.text); - } + if (last_element.len == 0) { + gb_printf_err("The output name is created from the last path element. `%.*s` has none. Use `-out:output_name.ext` to set it.\n", LIT(bc->build_paths[BuildPath_Main_Package].basename)); + return false; } - output_path.ext = copy_string(ha, output_extension); + output_path.basename = copy_string(ha, bc->build_paths[BuildPath_Main_Package].basename); + output_path.name = copy_string(ha, last_element); + output_path.ext = copy_string(ha, output_extension); bc->build_paths[BuildPath_Output] = output_path; } // Do we have an extension? We might not if the output filename was supplied. if (bc->build_paths[BuildPath_Output].ext.len == 0) { - if (build_context.metrics.os == TargetOs_windows || build_context.build_mode != BuildMode_Executable) { + if (bc->metrics.os == TargetOs_windows || bc->build_mode != BuildMode_Executable) { bc->build_paths[BuildPath_Output].ext = copy_string(ha, output_extension); } } From 159c5311c38e815202d300d5852964dbc664ef8d Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Sat, 8 Oct 2022 23:01:06 +0200 Subject: [PATCH 033/110] Revert "Fix #2112" --- src/build_settings.cpp | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/src/build_settings.cpp b/src/build_settings.cpp index 237858efa..02de22ec4 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -1502,24 +1502,44 @@ bool init_build_paths(String init_filename) { } else { Path output_path; - // We must name the output file after the current directory. - debugf("Output name will be created from current base name %.*s.\n", LIT(bc->build_paths[BuildPath_Main_Package].basename)); - String last_element = last_path_element(bc->build_paths[BuildPath_Main_Package].basename); + if (str_eq(init_filename, str_lit("."))) { + // We must name the output file after the current directory. + debugf("Output name will be created from current base name %.*s.\n", LIT(bc->build_paths[BuildPath_Main_Package].basename)); + String last_element = last_path_element(bc->build_paths[BuildPath_Main_Package].basename); - if (last_element.len == 0) { - gb_printf_err("The output name is created from the last path element. `%.*s` has none. Use `-out:output_name.ext` to set it.\n", LIT(bc->build_paths[BuildPath_Main_Package].basename)); - return false; + if (last_element.len == 0) { + gb_printf_err("The output name is created from the last path element. `%.*s` has none. Use `-out:output_name.ext` to set it.\n", LIT(bc->build_paths[BuildPath_Main_Package].basename)); + return false; + } + output_path.basename = copy_string(ha, bc->build_paths[BuildPath_Main_Package].basename); + output_path.name = copy_string(ha, last_element); + + } else { + // Init filename was not 'current path'. + // Contruct the output name from the path elements as usual. + String output_name = init_filename; + // If it ends with a trailing (back)slash, strip it before continuing. + while (output_name.len > 0 && (output_name[output_name.len-1] == '/' || output_name[output_name.len-1] == '\\')) { + output_name.len -= 1; + } + output_name = remove_directory_from_path(output_name); + output_name = remove_extension_from_path(output_name); + output_name = copy_string(ha, string_trim_whitespace(output_name)); + output_path = path_from_string(ha, output_name); + + // Replace extension. + if (output_path.ext.len > 0) { + gb_free(ha, output_path.ext.text); + } } - output_path.basename = copy_string(ha, bc->build_paths[BuildPath_Main_Package].basename); - output_path.name = copy_string(ha, last_element); - output_path.ext = copy_string(ha, output_extension); + output_path.ext = copy_string(ha, output_extension); bc->build_paths[BuildPath_Output] = output_path; } // Do we have an extension? We might not if the output filename was supplied. if (bc->build_paths[BuildPath_Output].ext.len == 0) { - if (bc->metrics.os == TargetOs_windows || bc->build_mode != BuildMode_Executable) { + if (build_context.metrics.os == TargetOs_windows || build_context.build_mode != BuildMode_Executable) { bc->build_paths[BuildPath_Output].ext = copy_string(ha, output_extension); } } From ef0c6fc4b30a35678cc7190e56745770fbe553cc Mon Sep 17 00:00:00 2001 From: Julian Ceipek Date: Sat, 8 Oct 2022 23:51:50 -0400 Subject: [PATCH 034/110] Fix signature for `shouldTerminateAfterLastWindowClosed` delegate proc --- vendor/darwin/Foundation/NSApplication.odin | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vendor/darwin/Foundation/NSApplication.odin b/vendor/darwin/Foundation/NSApplication.odin index 2fc4e6356..d55a185f2 100644 --- a/vendor/darwin/Foundation/NSApplication.odin +++ b/vendor/darwin/Foundation/NSApplication.odin @@ -11,7 +11,7 @@ ActivationPolicy :: enum UInteger { ApplicationDelegate :: struct { willFinishLaunching: proc "c" (self: ^ApplicationDelegate, notification: ^Notification), didFinishLaunching: proc "c" (self: ^ApplicationDelegate, notification: ^Notification), - shouldTerminateAfterLastWindowClosed: proc "c" (self: ^ApplicationDelegate, sender: ^Application), + shouldTerminateAfterLastWindowClosed: proc "c" (self: ^ApplicationDelegate, sender: ^Application) -> bool, user_data: rawptr, } @@ -34,9 +34,9 @@ Application_setDelegate :: proc(self: ^Application, delegate: ^ApplicationDelega del := (^ApplicationDelegate)(self->pointerValue()) del->didFinishLaunching(notification) } - shouldTerminateAfterLastWindowClosed :: proc "c" (self: ^Value, _: SEL, application: ^Application) { + shouldTerminateAfterLastWindowClosed :: proc "c" (self: ^Value, _: SEL, application: ^Application) -> bool { del := (^ApplicationDelegate)(self->pointerValue()) - del->shouldTerminateAfterLastWindowClosed(application) + return del->shouldTerminateAfterLastWindowClosed(application) } wrapper := Value.valueWithPointer(delegate) From 63086c7eaf3c0e97b1e8991fc94e146fb4efac38 Mon Sep 17 00:00:00 2001 From: Julian Ceipek Date: Sun, 9 Oct 2022 14:31:26 -0400 Subject: [PATCH 035/110] Use `NS.BOOL` instead of `bool` --- vendor/darwin/Foundation/NSApplication.odin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vendor/darwin/Foundation/NSApplication.odin b/vendor/darwin/Foundation/NSApplication.odin index d55a185f2..0b62687b7 100644 --- a/vendor/darwin/Foundation/NSApplication.odin +++ b/vendor/darwin/Foundation/NSApplication.odin @@ -11,7 +11,7 @@ ActivationPolicy :: enum UInteger { ApplicationDelegate :: struct { willFinishLaunching: proc "c" (self: ^ApplicationDelegate, notification: ^Notification), didFinishLaunching: proc "c" (self: ^ApplicationDelegate, notification: ^Notification), - shouldTerminateAfterLastWindowClosed: proc "c" (self: ^ApplicationDelegate, sender: ^Application) -> bool, + shouldTerminateAfterLastWindowClosed: proc "c" (self: ^ApplicationDelegate, sender: ^Application) -> BOOL, user_data: rawptr, } @@ -34,7 +34,7 @@ Application_setDelegate :: proc(self: ^Application, delegate: ^ApplicationDelega del := (^ApplicationDelegate)(self->pointerValue()) del->didFinishLaunching(notification) } - shouldTerminateAfterLastWindowClosed :: proc "c" (self: ^Value, _: SEL, application: ^Application) -> bool { + shouldTerminateAfterLastWindowClosed :: proc "c" (self: ^Value, _: SEL, application: ^Application) -> BOOL { del := (^ApplicationDelegate)(self->pointerValue()) return del->shouldTerminateAfterLastWindowClosed(application) } From 4c78ba2152608563ef3e6eade8c6ebaabcec27b5 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Sun, 9 Oct 2022 21:34:43 +0200 Subject: [PATCH 036/110] Fix #2122 --- core/strconv/strconv.odin | 9 ++++++++- tests/issues/test_issue_2087.odin | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/strconv/strconv.odin b/core/strconv/strconv.odin index ae89722bf..c621ac8e0 100644 --- a/core/strconv/strconv.odin +++ b/core/strconv/strconv.odin @@ -575,9 +575,11 @@ parse_f64 :: proc(str: string, n: ^int = nil) -> (value: f64, ok: bool) { i := 0 sign: f64 = 1 + seen_sign := true switch s[i] { case '-': i += 1; sign = -1 case '+': i += 1 + case: seen_sign = false } for ; i < len(s); i += 1 { @@ -677,8 +679,13 @@ parse_f64 :: proc(str: string, n: ^int = nil) -> (value: f64, ok: bool) { for exp > 0 { scale *= 10; exp -= 1 } } } - s = s[i:] + // If we only consumed a sign, return false + if i == 1 && seen_sign { + return 0, false + } + + s = s[i:] if frac { value = sign * (value/scale) } else { diff --git a/tests/issues/test_issue_2087.odin b/tests/issues/test_issue_2087.odin index 19181bfca..26b6d487d 100644 --- a/tests/issues/test_issue_2087.odin +++ b/tests/issues/test_issue_2087.odin @@ -10,9 +10,13 @@ test_parse_float :: proc(t: ^testing.T) { { f, ok := strconv.parse_f64("1.2") testing.expect(t, ok && f == 1.2, "expected f64(1.2), fully consumed") - f, ok = strconv.parse_f64("1.2a") testing.expect(t, !ok && f == 1.2, "expected f64(1.2), partially consumed") + f, ok = strconv.parse_f64("+") + testing.expect(t, !ok && f == 0.0, "expected f64(0.0), with ok=false") + f, ok = strconv.parse_f64("-") + testing.expect(t, !ok && f == 0.0, "expected f64(0.0), with ok=false") + f, ok = strconv.parse_f64("inf") testing.expect(t, ok && math.classify(f) == math.Float_Class.Inf, "expected f64(+inf), fully consumed") From fa6cfde4b0e97e6fffb1a373de37fb9251ac7cfd Mon Sep 17 00:00:00 2001 From: hikari Date: Mon, 10 Oct 2022 07:26:32 +0300 Subject: [PATCH 037/110] sys/windows: add free disk space function binding --- core/sys/windows/kernel32.odin | 7 +++++++ core/sys/windows/types.odin | 1 + 2 files changed, 8 insertions(+) diff --git a/core/sys/windows/kernel32.odin b/core/sys/windows/kernel32.odin index 9e5e5448b..05686b7d2 100644 --- a/core/sys/windows/kernel32.odin +++ b/core/sys/windows/kernel32.odin @@ -346,6 +346,13 @@ foreign kernel32 { GenerateConsoleCtrlEvent :: proc(dwCtrlEvent: DWORD, dwProcessGroupId: DWORD) -> BOOL --- FreeConsole :: proc() -> BOOL --- GetConsoleWindow :: proc() -> HWND --- + + GetDiskFreeSpaceExW :: proc( + lpDirectoryName: LPCWSTR, + lpFreeBytesAvailableToCaller: PULARGE_INTEGER, + lpTotalNumberOfBytes: PULARGE_INTEGER, + lpTotalNumberOfFreeBytes: PULARGE_INTEGER, + ) -> BOOL --- } diff --git a/core/sys/windows/types.odin b/core/sys/windows/types.odin index d4983fd06..30cc62451 100644 --- a/core/sys/windows/types.odin +++ b/core/sys/windows/types.odin @@ -44,6 +44,7 @@ BOOLEAN :: distinct b8 GROUP :: distinct c_uint LARGE_INTEGER :: distinct c_longlong ULARGE_INTEGER :: distinct c_ulonglong +PULARGE_INTEGER :: ^ULARGE_INTEGER LONG :: c_long UINT :: c_uint INT :: c_int From a1935bc1f4b4f966e132cb42f4d0f6419a60222b Mon Sep 17 00:00:00 2001 From: hikari Date: Mon, 10 Oct 2022 20:40:41 +0300 Subject: [PATCH 038/110] sys/windows: replace A with W --- core/sys/windows/advapi32.odin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/sys/windows/advapi32.odin b/core/sys/windows/advapi32.odin index c2fbb560a..e98aa6c43 100644 --- a/core/sys/windows/advapi32.odin +++ b/core/sys/windows/advapi32.odin @@ -129,8 +129,8 @@ foreign advapi32 { cbData: DWORD, ) -> LSTATUS --- - GetFileSecurityA :: proc( - lpFileName: LPCSTR, + GetFileSecurityW :: proc( + lpFileName: LPCWSTR, RequestedInformation: SECURITY_INFORMATION, pSecurityDescriptor: PSECURITY_DESCRIPTOR, nLength: DWORD, From 419eab50590ded8777f55f5b29306201a85162c5 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 10 Oct 2022 21:48:56 +0100 Subject: [PATCH 039/110] Force call site attributes for procedures (relating to #2121 causing ABI issues for `intrinsics.objc_send`) --- src/llvm_abi.cpp | 36 ++++++++++++++++++------------------ src/llvm_backend_proc.cpp | 14 ++++++++++++++ 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/llvm_abi.cpp b/src/llvm_abi.cpp index 4bdc31077..0654ed82a 100644 --- a/src/llvm_abi.cpp +++ b/src/llvm_abi.cpp @@ -550,10 +550,10 @@ namespace lbAbiAmd64SysV { if (is_mem_cls(cls, attribute_kind)) { LLVMAttributeRef attribute = nullptr; if (attribute_kind == Amd64TypeAttribute_ByVal) { - if (!is_calling_convention_odin(calling_convention)) { + // if (!is_calling_convention_odin(calling_convention)) { return lb_arg_type_indirect_byval(c, type); - } - attribute = nullptr; + // } + // attribute = nullptr; } else if (attribute_kind == Amd64TypeAttribute_StructRect) { attribute = lb_create_enum_attribute_with_type(c, "sret", type); } @@ -982,13 +982,13 @@ namespace lbAbiArm64 { } return false; } - - unsigned is_homogenous_aggregate_small_enough(LLVMTypeRef *base_type_, unsigned member_count_) { - return (member_count_ <= 4); - } + + unsigned is_homogenous_aggregate_small_enough(LLVMTypeRef base_type, unsigned member_count) { + return (member_count <= 4); + } lbArgType compute_return_type(LLVMContextRef c, LLVMTypeRef type, bool return_is_defined) { - LLVMTypeRef homo_base_type = {}; + LLVMTypeRef homo_base_type = nullptr; unsigned homo_member_count = 0; if (!return_is_defined) { @@ -996,16 +996,16 @@ namespace lbAbiArm64 { } else if (is_register(type)) { return non_struct(c, type); } else if (is_homogenous_aggregate(c, type, &homo_base_type, &homo_member_count)) { - if(is_homogenous_aggregate_small_enough(&homo_base_type, homo_member_count)) { - return lb_arg_type_direct(type, LLVMArrayType(homo_base_type, homo_member_count), nullptr, nullptr); - } else { - //TODO(Platin): do i need to create stuff that can handle the diffrent return type? - // else this needs a fix in llvm_backend_proc as we would need to cast it to the correct array type - - //LLVMTypeRef array_type = LLVMArrayType(homo_base_type, homo_member_count); - LLVMAttributeRef attr = lb_create_enum_attribute_with_type(c, "sret", type); - return lb_arg_type_indirect(type, attr); - } + if (is_homogenous_aggregate_small_enough(homo_base_type, homo_member_count)) { + return lb_arg_type_direct(type, LLVMArrayType(homo_base_type, homo_member_count), nullptr, nullptr); + } else { + //TODO(Platin): do i need to create stuff that can handle the diffrent return type? + // else this needs a fix in llvm_backend_proc as we would need to cast it to the correct array type + + //LLVMTypeRef array_type = LLVMArrayType(homo_base_type, homo_member_count); + LLVMAttributeRef attr = lb_create_enum_attribute_with_type(c, "sret", type); + return lb_arg_type_indirect(type, attr); + } } else { i64 size = lb_sizeof(type); if (size <= 16) { diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp index 56ffe3fe9..4d7896c8a 100644 --- a/src/llvm_backend_proc.cpp +++ b/src/llvm_backend_proc.cpp @@ -753,12 +753,16 @@ lbValue lb_emit_call_internal(lbProcedure *p, lbValue value, lbValue return_ptr, } GB_ASSERT_MSG(lb_is_type_kind(fnp, LLVMFunctionTypeKind), "%s", LLVMPrintTypeToString(fnp)); + lbFunctionType *ft = map_must_get(&p->module->function_type_map, base_type(value.type)); + { unsigned param_count = LLVMCountParamTypes(fnp); GB_ASSERT(arg_count >= param_count); LLVMTypeRef *param_types = gb_alloc_array(temporary_allocator(), LLVMTypeRef, param_count); LLVMGetParamTypes(fnp, param_types); + + for (unsigned i = 0; i < param_count; i++) { LLVMTypeRef param_type = param_types[i]; LLVMTypeRef arg_type = LLVMTypeOf(args[i]); @@ -776,10 +780,20 @@ lbValue lb_emit_call_internal(lbProcedure *p, lbValue value, lbValue return_ptr, LLVMValueRef ret = LLVMBuildCall2(p->builder, fnp, fn, args, arg_count, ""); + LLVMAttributeIndex param_offset = LLVMAttributeIndex_FirstArgIndex; if (return_ptr.value != nullptr) { + param_offset += 1; + LLVMAddCallSiteAttribute(ret, 1, lb_create_enum_attribute_with_type(p->module->ctx, "sret", LLVMTypeOf(args[0]))); } + for_array(i, ft->args) { + LLVMAttributeRef attribute = ft->args[i].attribute; + if (attribute != nullptr) { + LLVMAddCallSiteAttribute(ret, param_offset + cast(LLVMAttributeIndex)i, attribute); + } + } + switch (inlining) { case ProcInlining_none: break; From 047d45584ec76cf952d040066d00bdd312219a83 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 11 Oct 2022 21:21:56 +0100 Subject: [PATCH 040/110] Fix #2016 when passing an untyped integer to a generic `typeid` parameter --- src/check_expr.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 0686d9cb2..6edd4a93c 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -6413,7 +6413,9 @@ CallArgumentError check_polymorphic_record_type(CheckerContext *c, Operand *oper if (e->kind == Entity_TypeName) { if (o->mode != Addressing_Type) { if (show_error) { - error(o->expr, "Expected a type for the argument '%.*s'", LIT(e->token.string)); + gbString expr = expr_to_string(o->expr); + error(o->expr, "Expected a type for the argument '%.*s', got %s", LIT(e->token.string), expr); + gb_string_free(expr); } err = CallArgumentError_WrongTypes; } @@ -6456,6 +6458,10 @@ CallArgumentError check_polymorphic_record_type(CheckerContext *c, Operand *oper // add_type_info_type(c, o->type); } + if (show_error && err) { + return err; + } + { bool failure = false; Entity *found_entity = find_polymorphic_record_entity(c, original_type, param_count, ordered_operands, &failure); From c909e8e4b8bf986dd7c57bd527e0c5152da3c3d6 Mon Sep 17 00:00:00 2001 From: hikari Date: Wed, 12 Oct 2022 04:35:41 +0300 Subject: [PATCH 041/110] sys/windows: add SHFileOperationW --- core/sys/windows/shell32.odin | 1 + core/sys/windows/types.odin | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/core/sys/windows/shell32.odin b/core/sys/windows/shell32.odin index a3d6c6fb8..10a7d37d3 100644 --- a/core/sys/windows/shell32.odin +++ b/core/sys/windows/shell32.odin @@ -19,4 +19,5 @@ foreign shell32 { pszPath: LPCWSTR, psa: ^SECURITY_ATTRIBUTES, ) -> c_int --- + SHFileOperationW :: proc(lpFileOp: LPSHFILEOPSTRUCTW) -> c_int --- } diff --git a/core/sys/windows/types.odin b/core/sys/windows/types.odin index 30cc62451..b9ff6998a 100644 --- a/core/sys/windows/types.odin +++ b/core/sys/windows/types.odin @@ -925,6 +925,48 @@ NM_FONTCHANGED :: NM_OUTOFMEMORY-22 NM_CUSTOMTEXT :: NM_OUTOFMEMORY-23 // uses NMCUSTOMTEXT struct NM_TVSTATEIMAGECHANGING :: NM_OUTOFMEMORY-23 // uses NMTVSTATEIMAGECHANGING struct, defined after HTREEITEM +PCZZWSTR :: ^WCHAR + +SHFILEOPSTRUCTW :: struct { + hwnd: HWND, + wFunc: UINT, + pFrom: PCZZWSTR, + pTo: PCZZWSTR, + fFlags: FILEOP_FLAGS, + fAnyOperationsAborted: BOOL, + hNameMappings: LPVOID, + lpszProgressTitle: PCWSTR, // only used if FOF_SIMPLEPROGRESS +} +LPSHFILEOPSTRUCTW :: ^SHFILEOPSTRUCTW + +// Shell File Operations +FO_MOVE :: 0x0001 +FO_COPY :: 0x0002 +FO_DELETE :: 0x0003 +FO_RENAME :: 0x0004 + +// SHFILEOPSTRUCT.fFlags and IFileOperation::SetOperationFlags() flag values +FOF_MULTIDESTFILES :: 0x0001 +FOF_CONFIRMMOUSE :: 0x0002 +FOF_SILENT :: 0x0004 // don't display progress UI (confirm prompts may be displayed still) +FOF_RENAMEONCOLLISION :: 0x0008 // automatically rename the source files to avoid the collisions +FOF_NOCONFIRMATION :: 0x0010 // don't display confirmation UI, assume "yes" for cases that can be bypassed, "no" for those that can not +FOF_WANTMAPPINGHANDLE :: 0x0020 // Fill in SHFILEOPSTRUCT.hNameMappings + // Must be freed using SHFreeNameMappings +FOF_ALLOWUNDO :: 0x0040 // enable undo including Recycle behavior for IFileOperation::Delete() +FOF_FILESONLY :: 0x0080 // only operate on the files (non folders), both files and folders are assumed without this +FOF_SIMPLEPROGRESS :: 0x0100 // means don't show names of files +FOF_NOCONFIRMMKDIR :: 0x0200 // don't dispplay confirmatino UI before making any needed directories, assume "Yes" in these cases +FOF_NOERRORUI :: 0x0400 // don't put up error UI, other UI may be displayed, progress, confirmations +FOF_NOCOPYSECURITYATTRIBS :: 0x0800 // dont copy file security attributes (ACLs) +FOF_NORECURSION :: 0x1000 // don't recurse into directories for operations that would recurse +FOF_NO_CONNECTED_ELEMENTS :: 0x2000 // don't operate on connected elements ("xxx_files" folders that go with .htm files) +FOF_WANTNUKEWARNING :: 0x4000 // during delete operation, warn if object is being permanently destroyed instead of recycling (partially overrides FOF_NOCONFIRMATION) +FOF_NORECURSEREPARSE :: 0x8000 // deprecated; the operations engine always does the right thing on FolderLink objects (symlinks, reparse points, folder shortcuts) +FOF_NO_UI :: (FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR) // don't display any UI at all + +FILEOP_FLAGS :: WORD + DEVMODEW :: struct { dmDeviceName: [32]wchar_t, dmSpecVersion: WORD, From 6642e1fc9df0e7419d067a44fb161994bff8f73c Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 12 Oct 2022 19:10:04 +0100 Subject: [PATCH 042/110] Unify `Static_Arena` and `Growing_Arena` into `Arena` --- core/mem/virtual/arena.odin | 270 ++++++++++++++++++++++++++++ core/mem/virtual/arena_util.odin | 64 +++---- core/mem/virtual/growing_arena.odin | 170 ------------------ core/mem/virtual/static_arena.odin | 153 ---------------- 4 files changed, 302 insertions(+), 355 deletions(-) create mode 100644 core/mem/virtual/arena.odin delete mode 100644 core/mem/virtual/growing_arena.odin delete mode 100644 core/mem/virtual/static_arena.odin diff --git a/core/mem/virtual/arena.odin b/core/mem/virtual/arena.odin new file mode 100644 index 000000000..21c3db2ee --- /dev/null +++ b/core/mem/virtual/arena.odin @@ -0,0 +1,270 @@ +package mem_virtual + +import "core:mem" + +Arena_Kind :: enum u8 { + Growing = 0, // chained memory block + Static = 1, // fixed reservation +} + +Arena :: struct { + curr_block: ^Memory_Block, + total_used: uint, + total_reserved: uint, + + kind: Arena_Kind, + minimum_block_size: uint, + temp_count: int, +} + + +STATIC_ARENA_DEFAULT_COMMIT_SIZE :: 1<<20 // 1 MiB should be enough to start with +GROWING_ARENA_DEFAULT_MINIMUM_BLOCK_SIZE :: STATIC_ARENA_DEFAULT_COMMIT_SIZE + +// 1 GiB on 64-bit systems, 128 MiB on 32-bit systems by default +STATIC_ARENA_DEFAULT_RESERVE_SIZE :: 1<<30 when size_of(uintptr) == 8 else 1<<27 + + + +arena_init_growing :: proc(arena: ^Arena, reserved: uint = GROWING_ARENA_DEFAULT_MINIMUM_BLOCK_SIZE) -> (err: Allocator_Error) { + arena.kind = .Growing + arena.curr_block = memory_block_alloc(0, reserved, {}) or_return + arena.total_used = 0 + arena.total_reserved = arena.curr_block.reserved + return +} + + +arena_init_static :: proc(arena: ^Arena, reserved: uint, commit_size: uint = STATIC_ARENA_DEFAULT_COMMIT_SIZE) -> (err: Allocator_Error) { + arena.kind = .Static + arena.curr_block = memory_block_alloc(commit_size, reserved, {}) or_return + arena.total_used = 0 + arena.total_reserved = arena.curr_block.reserved + return +} + +arena_alloc :: proc(arena: ^Arena, min_size: int, alignment: int, loc := #caller_location) -> (data: []byte, err: Allocator_Error) { + align_forward_offset :: proc "contextless" (arena: ^Arena, alignment: int) -> uint #no_bounds_check { + alignment_offset := uint(0) + ptr := uintptr(arena.curr_block.base[arena.curr_block.used:]) + mask := uintptr(alignment-1) + if ptr & mask != 0 { + alignment_offset = uint(alignment) - uint(ptr & mask) + } + return alignment_offset + } + + assert(mem.is_power_of_two(uintptr(alignment)), "non-power of two alignment", loc) + + switch arena.kind { + case .Growing: + size := uint(0) + if arena.curr_block != nil { + size = uint(min_size) + align_forward_offset(arena, alignment) + } + + if arena.curr_block == nil || arena.curr_block.used + size > arena.curr_block.reserved { + size = uint(mem.align_forward_int(min_size, alignment)) + arena.minimum_block_size = max(GROWING_ARENA_DEFAULT_MINIMUM_BLOCK_SIZE, arena.minimum_block_size) + + block_size := max(size, arena.minimum_block_size) + + new_block := memory_block_alloc(size, block_size, {}) or_return + new_block.prev = arena.curr_block + arena.curr_block = new_block + arena.total_reserved += new_block.reserved + } + + + data, err = alloc_from_memory_block(arena.curr_block, int(size), alignment) + if err == nil { + arena.total_used += size + } + case .Static: + if arena.curr_block == nil { + reserve_size := max(arena.minimum_block_size, STATIC_ARENA_DEFAULT_RESERVE_SIZE) + arena_init_static(arena, reserve_size, STATIC_ARENA_DEFAULT_COMMIT_SIZE) or_return + } + data, err = alloc_from_memory_block(arena.curr_block, min_size, alignment) + arena.total_used = arena.curr_block.used + } + return +} + +arena_static_reset_to :: proc(arena: ^Arena, pos: uint, loc := #caller_location) -> bool { + if arena.curr_block != nil { + assert(arena.kind == .Static, "expected a .Static arena", loc) + + prev_pos := arena.curr_block.used + arena.curr_block.used = clamp(pos, 0, arena.curr_block.reserved) + + if prev_pos < pos { + mem.zero_slice(arena.curr_block.base[arena.curr_block.used:][:pos-prev_pos]) + } + return true + } else if pos == 0 { + return true + } + return false +} + +arena_growing_free_last_memory_block :: proc(arena: ^Arena, loc := #caller_location) { + if free_block := arena.curr_block; free_block != nil { + assert(arena.kind == .Growing, "expected a .Growing arena", loc) + arena.curr_block = free_block.prev + memory_block_dealloc(free_block) + } +} + +arena_free_all :: proc(arena: ^Arena) { + switch arena.kind { + case .Growing: + for arena.curr_block != nil { + arena_growing_free_last_memory_block(arena) + } + case .Static: + arena_static_reset_to(arena, 0) + } + arena.total_used = 0 + arena.total_reserved = 0 +} + +arena_destroy :: proc(arena: ^Arena) { + arena_free_all(arena) + memory_block_dealloc(arena.curr_block) + arena.curr_block = nil + arena.total_used = 0 + arena.total_reserved = 0 + arena.temp_count = 0 +} + +arena_growing_bootstrap_new_by_offset :: proc($T: typeid, offset_to_arena: uintptr, minimum_block_size: uint = GROWING_ARENA_DEFAULT_MINIMUM_BLOCK_SIZE) -> (ptr: ^T, err: Allocator_Error) { + bootstrap: Arena + bootstrap.kind = .Growing + bootstrap.minimum_block_size = minimum_block_size + + data := arena_alloc(&bootstrap, size_of(T), align_of(T)) or_return + + ptr = (^T)(raw_data(data)) + + (^Arena)(uintptr(ptr) + offset_to_arena)^ = bootstrap + + return +} + +arena_growing_bootstrap_new_by_name :: proc($T: typeid, $field_name: string, minimum_block_size: uint = GROWING_ARENA_DEFAULT_MINIMUM_BLOCK_SIZE) -> (ptr: ^T, err: Allocator_Error) { + return arena_growing_bootstrap_new_by_offset(T, offset_of_by_string(T, field_name), minimum_block_size) +} + +arena_growing_bootstrap_new :: proc{ + arena_growing_bootstrap_new_by_offset, + arena_growing_bootstrap_new_by_name, +} + +arena_static_bootstrap_new_by_offset :: proc($T: typeid, offset_to_arena: uintptr, reserved: uint) -> (ptr: ^T, err: Allocator_Error) { + bootstrap: Arena + bootstrap.kind = .Static + bootstrap.minimum_block_size = reserved + + data := arena_alloc(&bootstrap, size_of(T), align_of(T)) or_return + + ptr = (^T)(raw_data(data)) + + (^Arena)(uintptr(ptr) + offset_to_arena)^ = bootstrap + + return +} + +arena_static_bootstrap_new_by_name :: proc($T: typeid, $field_name: string, reserved: uint) -> (ptr: ^T, err: Allocator_Error) { + return arena_static_bootstrap_new_by_offset(T, offset_of_by_string(T, field_name), reserved) +} +arena_static_bootstrap_new :: proc{ + arena_static_bootstrap_new_by_offset, + arena_static_bootstrap_new_by_name, +} + + +arena_allocator :: proc(arena: ^Arena) -> mem.Allocator { + return mem.Allocator{arena_allocator_proc, arena} +} + +arena_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode, + size, alignment: int, + old_memory: rawptr, old_size: int, + location := #caller_location) -> (data: []byte, err: Allocator_Error) { + arena := (^Arena)(allocator_data) + + switch mode { + case .Alloc: + return arena_alloc(arena, size, alignment) + case .Free: + err = .Mode_Not_Implemented + return + case .Free_All: + arena_free_all(arena) + return + case .Resize: + return mem.default_resize_bytes_align(mem.byte_slice(old_memory, old_size), size, alignment, arena_allocator(arena), location) + + case .Query_Features, .Query_Info: + err = .Mode_Not_Implemented + return + } + + err = .Mode_Not_Implemented + return +} + +Arena_Temp :: struct { + arena: ^Arena, + block: ^Memory_Block, + used: uint, +} + +arena_temp_begin :: proc(arena: ^Arena, loc := #caller_location) -> (temp: Arena_Temp) { + assert(arena != nil, "nil arena", loc) + temp.arena = arena + temp.block = arena.curr_block + if arena.curr_block != nil { + temp.used = arena.curr_block.used + } + arena.temp_count += 1 + return +} + +arena_temp_end :: proc(temp: Arena_Temp, loc := #caller_location) { + assert(temp.arena != nil, "nil arena", loc) + arena := temp.arena + + memory_block_found := false + for block := arena.curr_block; block != nil; block = block.prev { + if block == temp.block { + memory_block_found = true + break + } + } + if !memory_block_found { + assert(arena.curr_block == temp.block, "memory block stored within Arena_Temp not owned by Arena", loc) + } + + for arena.curr_block != temp.block { + arena_growing_free_last_memory_block(arena) + } + + if block := arena.curr_block; block != nil { + assert(block.used >= temp.used, "out of order use of arena_temp_end", loc) + amount_to_zero := min(block.used-temp.used, block.reserved-block.used) + mem.zero_slice(block.base[temp.used:][:amount_to_zero]) + block.used = temp.used + } + + assert(arena.temp_count > 0, "double-use of arena_temp_end", loc) + arena.temp_count -= 1 +} + +arena_check_temp :: proc(arena: ^Arena, loc := #caller_location) { + assert(arena.temp_count == 0, "Arena_Temp not been ended", loc) +} + + + diff --git a/core/mem/virtual/arena_util.odin b/core/mem/virtual/arena_util.odin index 0e152db7a..f721c4ffa 100644 --- a/core/mem/virtual/arena_util.odin +++ b/core/mem/virtual/arena_util.odin @@ -1,41 +1,41 @@ package mem_virtual -arena_init :: proc{ - static_arena_init, - growing_arena_init, -} +// arena_init :: proc{ +// static_arena_init, +// growing_arena_init, +// } -arena_temp_begin :: proc{ - static_arena_temp_begin, - growing_arena_temp_begin, -} +// arena_temp_begin :: proc{ +// static_arena_temp_begin, +// growing_arena_temp_begin, +// } -arena_temp_end :: proc{ - static_arena_temp_end, - growing_arena_temp_end, -} +// arena_temp_end :: proc{ +// static_arena_temp_end, +// growing_arena_temp_end, +// } -arena_check_temp :: proc{ - static_arena_check_temp, - growing_arena_check_temp, -} +// arena_check_temp :: proc{ +// static_arena_check_temp, +// growing_arena_check_temp, +// } -arena_allocator :: proc{ - static_arena_allocator, - growing_arena_allocator, -} +// arena_allocator :: proc{ +// static_arena_allocator, +// growing_arena_allocator, +// } -arena_alloc :: proc{ - static_arena_alloc, - growing_arena_alloc, -} +// arena_alloc :: proc{ +// static_arena_alloc, +// growing_arena_alloc, +// } -arena_free_all :: proc{ - static_arena_free_all, - growing_arena_free_all, -} +// arena_free_all :: proc{ +// static_arena_free_all, +// growing_arena_free_all, +// } -arena_destroy :: proc{ - static_arena_destroy, - growing_arena_destroy, -} \ No newline at end of file +// arena_destroy :: proc{ +// static_arena_destroy, +// growing_arena_destroy, +// } \ No newline at end of file diff --git a/core/mem/virtual/growing_arena.odin b/core/mem/virtual/growing_arena.odin deleted file mode 100644 index 44d56866e..000000000 --- a/core/mem/virtual/growing_arena.odin +++ /dev/null @@ -1,170 +0,0 @@ -package mem_virtual - -import "core:mem" - -Growing_Arena :: struct { - curr_block: ^Memory_Block, - total_used: uint, - total_reserved: uint, - - minimum_block_size: uint, - temp_count: int, -} - -DEFAULT_MINIMUM_BLOCK_SIZE :: 1<<20 // 1 MiB should be enough - -growing_arena_init :: proc(arena: ^Growing_Arena, reserved: uint = DEFAULT_MINIMUM_BLOCK_SIZE) -> (err: Allocator_Error) { - arena.curr_block = memory_block_alloc(0, reserved, {}) or_return - arena.total_used = 0 - arena.total_reserved = arena.curr_block.reserved - return -} - -growing_arena_alloc :: proc(arena: ^Growing_Arena, min_size: int, alignment: int) -> (data: []byte, err: Allocator_Error) { - align_forward_offset :: proc "contextless" (arena: ^Growing_Arena, alignment: int) -> uint #no_bounds_check { - alignment_offset := uint(0) - ptr := uintptr(arena.curr_block.base[arena.curr_block.used:]) - mask := uintptr(alignment-1) - if ptr & mask != 0 { - alignment_offset = uint(alignment) - uint(ptr & mask) - } - return alignment_offset - } - - assert(mem.is_power_of_two(uintptr(alignment))) - - size := uint(0) - if arena.curr_block != nil { - size = uint(min_size) + align_forward_offset(arena, alignment) - } - - if arena.curr_block == nil || arena.curr_block.used + size > arena.curr_block.reserved { - size = uint(mem.align_forward_int(min_size, alignment)) - arena.minimum_block_size = max(DEFAULT_MINIMUM_BLOCK_SIZE, arena.minimum_block_size) - - block_size := max(size, arena.minimum_block_size) - - new_block := memory_block_alloc(size, block_size, {}) or_return - new_block.prev = arena.curr_block - arena.curr_block = new_block - arena.total_reserved += new_block.reserved - } - - - data, err = alloc_from_memory_block(arena.curr_block, int(size), alignment) - if err == nil { - arena.total_used += size - } - return -} - -growing_arena_free_last_memory_block :: proc(arena: ^Growing_Arena) { - free_block := arena.curr_block - arena.curr_block = free_block.prev - memory_block_dealloc(free_block) -} - -growing_arena_free_all :: proc(arena: ^Growing_Arena) { - for arena.curr_block != nil { - growing_arena_free_last_memory_block(arena) - } - arena.total_used = 0 - arena.total_reserved = 0 -} - -growing_arena_destroy :: proc(arena: ^Growing_Arena) { - growing_arena_free_all(arena) -} - -growing_arena_bootstrap_new_by_offset :: proc($T: typeid, offset_to_arena: uintptr, minimum_block_size: uint = DEFAULT_MINIMUM_BLOCK_SIZE) -> (ptr: ^T, err: Allocator_Error) { bootstrap: Growing_Arena - bootstrap.minimum_block_size = minimum_block_size - - data := growing_arena_alloc(&bootstrap, size_of(T), align_of(T)) or_return - - ptr = (^T)(raw_data(data)) - - (^Growing_Arena)(uintptr(ptr) + offset_to_arena)^ = bootstrap - - return -} - -growing_arena_bootstrap_new_by_name :: proc($T: typeid, $field_name: string, minimum_block_size: uint = DEFAULT_MINIMUM_BLOCK_SIZE) -> (ptr: ^T, err: Allocator_Error) { - return growing_arena_bootstrap_new_by_offset(T, offset_of_by_string(T, field_name), minimum_block_size) -} -growing_arena_bootstrap_new :: proc{ - growing_arena_bootstrap_new_by_offset, - growing_arena_bootstrap_new_by_name, -} - -growing_arena_allocator :: proc(arena: ^Growing_Arena) -> mem.Allocator { - return mem.Allocator{growing_arena_allocator_proc, arena} -} - -growing_arena_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode, - size, alignment: int, - old_memory: rawptr, old_size: int, - location := #caller_location) -> (data: []byte, err: Allocator_Error) { - arena := (^Growing_Arena)(allocator_data) - - switch mode { - case .Alloc: - return growing_arena_alloc(arena, size, alignment) - case .Free: - err = .Mode_Not_Implemented - return - case .Free_All: - growing_arena_free_all(arena) - return - case .Resize: - return mem.default_resize_bytes_align(mem.byte_slice(old_memory, old_size), size, alignment, growing_arena_allocator(arena), location) - - case .Query_Features, .Query_Info: - err = .Mode_Not_Implemented - return - } - - err = .Mode_Not_Implemented - return -} - -Growing_Arena_Temp :: struct { - arena: ^Growing_Arena, - block: ^Memory_Block, - used: uint, -} - -growing_arena_temp_begin :: proc(arena: ^Growing_Arena) -> (temp: Growing_Arena_Temp) { - temp.arena = arena - temp.block = arena.curr_block - if arena.curr_block != nil { - temp.used = arena.curr_block.used - } - arena.temp_count += 1 - return -} - -growing_arena_temp_end :: proc(temp: Growing_Arena_Temp, loc := #caller_location) { - assert(temp.arena != nil, "nil arena", loc) - arena := temp.arena - - for arena.curr_block != temp.block { - growing_arena_free_last_memory_block(arena) - } - - if block := arena.curr_block; block != nil { - assert(block.used >= temp.used, "out of order use of growing_arena_temp_end", loc) - amount_to_zero := min(block.used-temp.used, block.reserved-block.used) - mem.zero_slice(block.base[temp.used:][:amount_to_zero]) - block.used = temp.used - } - - assert(arena.temp_count > 0, "double-use of growing_arena_temp_end", loc) - arena.temp_count -= 1 -} - -growing_arena_check_temp :: proc(arena: ^Growing_Arena, loc := #caller_location) { - assert(arena.temp_count == 0, "Growing_Arena_Temp not been ended", loc) -} - - - diff --git a/core/mem/virtual/static_arena.odin b/core/mem/virtual/static_arena.odin deleted file mode 100644 index 7e8a62f4a..000000000 --- a/core/mem/virtual/static_arena.odin +++ /dev/null @@ -1,153 +0,0 @@ -package mem_virtual - -import "core:mem" - -Static_Arena :: struct { - block: ^Memory_Block, - total_used: uint, - total_reserved: uint, - - minimum_block_size: uint, - temp_count: int, -} - -STATIC_ARENA_DEFAULT_COMMIT_SIZE :: 1<<20 // 1 MiB should be enough to start with - -// 1 GiB on 64-bit systems, 128 MiB on 32-bit systems by default -STATIC_ARENA_DEFAULT_RESERVE_SIZE :: 1<<30 when size_of(uintptr) == 8 else 1<<27 - -static_arena_init :: proc(arena: ^Static_Arena, reserved: uint, commit_size: uint = STATIC_ARENA_DEFAULT_COMMIT_SIZE) -> (err: Allocator_Error) { - arena.block = memory_block_alloc(commit_size, reserved, {}) or_return - arena.total_used = 0 - arena.total_reserved = arena.block.reserved - return -} - -static_arena_destroy :: proc(arena: ^Static_Arena) { - memory_block_dealloc(arena.block) - arena^ = {} -} - - -static_arena_alloc :: proc(arena: ^Static_Arena, size: int, alignment: int) -> (data: []byte, err: Allocator_Error) { - align_forward :: #force_inline proc "contextless" (ptr: uint, align: uint) -> uint { - mask := align-1 - return (ptr + mask) &~ mask - } - - if arena.block == nil { - reserve_size := max(arena.minimum_block_size, STATIC_ARENA_DEFAULT_RESERVE_SIZE) - static_arena_init(arena, reserve_size, STATIC_ARENA_DEFAULT_COMMIT_SIZE) or_return - } - - MINIMUM_ALIGN :: 2*align_of(uintptr) - - defer arena.total_used = arena.block.used - return alloc_from_memory_block(arena.block, size, max(MINIMUM_ALIGN, alignment)) -} - -static_arena_reset_to :: proc(arena: ^Static_Arena, pos: uint) -> bool { - if arena.block != nil { - prev_pos := arena.block.used - arena.block.used = clamp(pos, 0, arena.block.reserved) - - if prev_pos < pos { - mem.zero_slice(arena.block.base[arena.block.used:][:pos-prev_pos]) - } - return true - } else if pos == 0 { - return true - } - return false -} - -static_arena_free_all :: proc(arena: ^Static_Arena) { - static_arena_reset_to(arena, 0) -} - - -static_arena_bootstrap_new_by_offset :: proc($T: typeid, offset_to_arena: uintptr, reserved: uint) -> (ptr: ^T, err: Allocator_Error) { - bootstrap: Static_Arena - bootstrap.minimum_block_size = reserved - - data := static_arena_alloc(&bootstrap, size_of(T), align_of(T)) or_return - - ptr = (^T)(raw_data(data)) - - (^Static_Arena)(uintptr(ptr) + offset_to_arena)^ = bootstrap - - return -} - -static_arena_bootstrap_new_by_name :: proc($T: typeid, $field_name: string, reserved: uint) -> (ptr: ^T, err: Allocator_Error) { - return static_arena_bootstrap_new_by_offset(T, offset_of_by_string(T, field_name), reserved) -} -static_arena_bootstrap_new :: proc{ - static_arena_bootstrap_new_by_offset, - static_arena_bootstrap_new_by_name, -} - - -static_arena_allocator :: proc(arena: ^Static_Arena) -> mem.Allocator { - return mem.Allocator{static_arena_allocator_proc, arena} -} - -static_arena_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode, - size, alignment: int, - old_memory: rawptr, old_size: int, - location := #caller_location) -> (data: []byte, err: Allocator_Error) { - arena := (^Static_Arena)(allocator_data) - - switch mode { - case .Alloc: - return static_arena_alloc(arena, size, alignment) - case .Free: - err = .Mode_Not_Implemented - return - case .Free_All: - static_arena_free_all(arena) - return - case .Resize: - return mem.default_resize_bytes_align(mem.byte_slice(old_memory, old_size), size, alignment, static_arena_allocator(arena), location) - - case .Query_Features, .Query_Info: - err = .Mode_Not_Implemented - return - } - - err = .Mode_Not_Implemented - return -} - - -Static_Arena_Temp :: struct { - arena: ^Static_Arena, - used: uint, -} - - -static_arena_temp_begin :: proc(arena: ^Static_Arena) -> (temp: Static_Arena_Temp) { - temp.arena = arena - temp.used = arena.block.used if arena.block != nil else 0 - arena.temp_count += 1 - return -} - -static_arena_temp_end :: proc(temp: Static_Arena_Temp, loc := #caller_location) { - assert(temp.arena != nil, "nil arena", loc) - arena := temp.arena - - used := arena.block.used if arena.block != nil else 0 - - assert(temp.used >= used, "invalid Static_Arena_Temp", loc) - - static_arena_reset_to(arena, temp.used) - - assert(arena.temp_count > 0, "double-use of static_arena_temp_end", loc) - arena.temp_count -= 1 -} - - -static_arena_check_temp :: proc(arena: ^Static_Arena, loc := #caller_location) { - assert(arena.temp_count == 0, "Static_Arena_Temp not been ended", loc) -} \ No newline at end of file From b84108c4b55e94c495dc7d9d57404455d023ca7f Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 12 Oct 2022 20:28:51 +0100 Subject: [PATCH 043/110] Inline align forward offset code --- core/mem/virtual/arena.odin | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/core/mem/virtual/arena.odin b/core/mem/virtual/arena.odin index 21c3db2ee..ba2708fc3 100644 --- a/core/mem/virtual/arena.odin +++ b/core/mem/virtual/arena.odin @@ -44,23 +44,18 @@ arena_init_static :: proc(arena: ^Arena, reserved: uint, commit_size: uint = STA } arena_alloc :: proc(arena: ^Arena, min_size: int, alignment: int, loc := #caller_location) -> (data: []byte, err: Allocator_Error) { - align_forward_offset :: proc "contextless" (arena: ^Arena, alignment: int) -> uint #no_bounds_check { - alignment_offset := uint(0) - ptr := uintptr(arena.curr_block.base[arena.curr_block.used:]) - mask := uintptr(alignment-1) - if ptr & mask != 0 { - alignment_offset = uint(alignment) - uint(ptr & mask) - } - return alignment_offset - } - assert(mem.is_power_of_two(uintptr(alignment)), "non-power of two alignment", loc) switch arena.kind { case .Growing: - size := uint(0) + size := uint(min_size) if arena.curr_block != nil { - size = uint(min_size) + align_forward_offset(arena, alignment) + // align forward offset + ptr := uintptr(arena.curr_block.base[arena.curr_block.used:]) + mask := uintptr(alignment-1) + if ptr & mask != 0 { + size += uint(alignment) - uint(ptr & mask) + } } if arena.curr_block == nil || arena.curr_block.used + size > arena.curr_block.reserved { From 835b8ffa22d7dce1a4b3cd1677a50095200a3883 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 12 Oct 2022 20:30:48 +0100 Subject: [PATCH 044/110] Update `total_used` for `arena_static_reset_to` --- core/mem/virtual/arena.odin | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/mem/virtual/arena.odin b/core/mem/virtual/arena.odin index ba2708fc3..d2ffa73f2 100644 --- a/core/mem/virtual/arena.odin +++ b/core/mem/virtual/arena.odin @@ -96,8 +96,10 @@ arena_static_reset_to :: proc(arena: ^Arena, pos: uint, loc := #caller_location) if prev_pos < pos { mem.zero_slice(arena.curr_block.base[arena.curr_block.used:][:pos-prev_pos]) } + arena.total_used = arena.curr_block.used return true } else if pos == 0 { + arena.total_used = 0 return true } return false From 5c62211f00ca1f11a92e7a97b3727b9e29fb0ebd Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 12 Oct 2022 20:44:36 +0100 Subject: [PATCH 045/110] Inline resize logic for `virtual.Arena` --- core/mem/alloc.odin | 15 +++++++------ core/mem/virtual/arena.odin | 45 +++++++++++++++++++++++++++++-------- 2 files changed, 44 insertions(+), 16 deletions(-) diff --git a/core/mem/alloc.odin b/core/mem/alloc.odin index 54004d333..b5788c8a8 100644 --- a/core/mem/alloc.odin +++ b/core/mem/alloc.odin @@ -243,13 +243,11 @@ default_resize_bytes_align :: proc(old_data: []byte, new_size, alignment: int, a return alloc_bytes(new_size, alignment, allocator, loc) } - if new_size == 0 { - err := free_bytes(old_data, allocator, loc) - return nil, err - } - if new_size == old_size { - return old_data, .None + return old_data, nil + } + if new_size == 0 { + return nil, free_bytes(old_data, allocator, loc) } new_memory, err := alloc_bytes(new_size, alignment, allocator, loc) @@ -258,6 +256,9 @@ default_resize_bytes_align :: proc(old_data: []byte, new_size, alignment: int, a } runtime.copy(new_memory, old_data) - free_bytes(old_data, allocator, loc) + err1 := free_bytes(old_data, allocator, loc) + if err == nil { + err = err1 + } return new_memory, err } diff --git a/core/mem/virtual/arena.odin b/core/mem/virtual/arena.odin index d2ffa73f2..1dd8d249c 100644 --- a/core/mem/virtual/arena.odin +++ b/core/mem/virtual/arena.odin @@ -46,6 +46,10 @@ arena_init_static :: proc(arena: ^Arena, reserved: uint, commit_size: uint = STA arena_alloc :: proc(arena: ^Arena, min_size: int, alignment: int, loc := #caller_location) -> (data: []byte, err: Allocator_Error) { assert(mem.is_power_of_two(uintptr(alignment)), "non-power of two alignment", loc) + if min_size == 0 { + return nil, nil + } + switch arena.kind { case .Growing: size := uint(min_size) @@ -186,9 +190,9 @@ arena_allocator :: proc(arena: ^Arena) -> mem.Allocator { } arena_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode, - size, alignment: int, - old_memory: rawptr, old_size: int, - location := #caller_location) -> (data: []byte, err: Allocator_Error) { + size, alignment: int, + old_memory: rawptr, old_size: int, + location := #caller_location) -> (data: []byte, err: Allocator_Error) { arena := (^Arena)(allocator_data) switch mode { @@ -196,19 +200,42 @@ arena_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode, return arena_alloc(arena, size, alignment) case .Free: err = .Mode_Not_Implemented - return case .Free_All: arena_free_all(arena) - return case .Resize: - return mem.default_resize_bytes_align(mem.byte_slice(old_memory, old_size), size, alignment, arena_allocator(arena), location) + old_data := ([^]byte)(old_memory) - case .Query_Features, .Query_Info: + switch { + case old_data == nil: + return arena_alloc(arena, size, alignment) + case size == old_size: + // return old memory + data = old_data[:size] + return + case size == 0: + err = .Mode_Not_Implemented + return + case (uintptr(old_data) & uintptr(alignment-1) == 0) && size < old_size: + // shrink data in-place + data = old_data[:size] + return + } + + new_memory := arena_alloc(arena, size, alignment) or_return + if new_memory == nil { + return + } + copy(new_memory, old_data[:old_size]) + return new_memory, nil + case .Query_Features: + set := (^mem.Allocator_Mode_Set)(old_memory) + if set != nil { + set^ = {.Alloc, .Free_All, .Resize, .Query_Features} + } + case .Query_Info: err = .Mode_Not_Implemented - return } - err = .Mode_Not_Implemented return } From 5a8fbc230da9d16a1f8f4345bc7c803fe8f77bab Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 12 Oct 2022 21:16:34 +0100 Subject: [PATCH 046/110] Sanity corrections to virtual calls --- core/mem/virtual/arena.odin | 57 ++++++++++++-------------- core/mem/virtual/virtual.odin | 2 +- core/mem/virtual/virtual_platform.odin | 1 - 3 files changed, 28 insertions(+), 32 deletions(-) diff --git a/core/mem/virtual/arena.odin b/core/mem/virtual/arena.odin index 1dd8d249c..e95dc227c 100644 --- a/core/mem/virtual/arena.odin +++ b/core/mem/virtual/arena.odin @@ -18,7 +18,8 @@ Arena :: struct { } -STATIC_ARENA_DEFAULT_COMMIT_SIZE :: 1<<20 // 1 MiB should be enough to start with +// 1 MiB should be enough to start with +STATIC_ARENA_DEFAULT_COMMIT_SIZE :: 1<<20 GROWING_ARENA_DEFAULT_MINIMUM_BLOCK_SIZE :: STATIC_ARENA_DEFAULT_COMMIT_SIZE // 1 GiB on 64-bit systems, 128 MiB on 32-bit systems by default @@ -43,27 +44,18 @@ arena_init_static :: proc(arena: ^Arena, reserved: uint, commit_size: uint = STA return } -arena_alloc :: proc(arena: ^Arena, min_size: int, alignment: int, loc := #caller_location) -> (data: []byte, err: Allocator_Error) { +arena_alloc :: proc(arena: ^Arena, size: uint, alignment: uint, loc := #caller_location) -> (data: []byte, err: Allocator_Error) { assert(mem.is_power_of_two(uintptr(alignment)), "non-power of two alignment", loc) - if min_size == 0 { + size := size + if size == 0 { return nil, nil } switch arena.kind { case .Growing: - size := uint(min_size) - if arena.curr_block != nil { - // align forward offset - ptr := uintptr(arena.curr_block.base[arena.curr_block.used:]) - mask := uintptr(alignment-1) - if ptr & mask != 0 { - size += uint(alignment) - uint(ptr & mask) - } - } - if arena.curr_block == nil || arena.curr_block.used + size > arena.curr_block.reserved { - size = uint(mem.align_forward_int(min_size, alignment)) + size = mem.align_forward_uint(size, alignment) arena.minimum_block_size = max(GROWING_ARENA_DEFAULT_MINIMUM_BLOCK_SIZE, arena.minimum_block_size) block_size := max(size, arena.minimum_block_size) @@ -74,17 +66,15 @@ arena_alloc :: proc(arena: ^Arena, min_size: int, alignment: int, loc := #caller arena.total_reserved += new_block.reserved } - - data, err = alloc_from_memory_block(arena.curr_block, int(size), alignment) - if err == nil { - arena.total_used += size - } + prev_used := arena.curr_block.used + data, err = alloc_from_memory_block(arena.curr_block, size, alignment) + arena.total_used += arena.curr_block.used - prev_used case .Static: if arena.curr_block == nil { reserve_size := max(arena.minimum_block_size, STATIC_ARENA_DEFAULT_RESERVE_SIZE) arena_init_static(arena, reserve_size, STATIC_ARENA_DEFAULT_COMMIT_SIZE) or_return } - data, err = alloc_from_memory_block(arena.curr_block, min_size, alignment) + data, err = alloc_from_memory_block(arena.curr_block, size, alignment) arena.total_used = arena.curr_block.used } return @@ -123,11 +113,11 @@ arena_free_all :: proc(arena: ^Arena) { for arena.curr_block != nil { arena_growing_free_last_memory_block(arena) } + arena.total_reserved = 0 case .Static: arena_static_reset_to(arena, 0) } arena.total_used = 0 - arena.total_reserved = 0 } arena_destroy :: proc(arena: ^Arena) { @@ -139,6 +129,16 @@ arena_destroy :: proc(arena: ^Arena) { arena.temp_count = 0 } +arena_growing_bootstrap_new :: proc{ + arena_growing_bootstrap_new_by_offset, + arena_growing_bootstrap_new_by_name, +} + +arena_static_bootstrap_new :: proc{ + arena_static_bootstrap_new_by_offset, + arena_static_bootstrap_new_by_name, +} + arena_growing_bootstrap_new_by_offset :: proc($T: typeid, offset_to_arena: uintptr, minimum_block_size: uint = GROWING_ARENA_DEFAULT_MINIMUM_BLOCK_SIZE) -> (ptr: ^T, err: Allocator_Error) { bootstrap: Arena bootstrap.kind = .Growing @@ -157,11 +157,6 @@ arena_growing_bootstrap_new_by_name :: proc($T: typeid, $field_name: string, min return arena_growing_bootstrap_new_by_offset(T, offset_of_by_string(T, field_name), minimum_block_size) } -arena_growing_bootstrap_new :: proc{ - arena_growing_bootstrap_new_by_offset, - arena_growing_bootstrap_new_by_name, -} - arena_static_bootstrap_new_by_offset :: proc($T: typeid, offset_to_arena: uintptr, reserved: uint) -> (ptr: ^T, err: Allocator_Error) { bootstrap: Arena bootstrap.kind = .Static @@ -179,10 +174,6 @@ arena_static_bootstrap_new_by_offset :: proc($T: typeid, offset_to_arena: uintpt arena_static_bootstrap_new_by_name :: proc($T: typeid, $field_name: string, reserved: uint) -> (ptr: ^T, err: Allocator_Error) { return arena_static_bootstrap_new_by_offset(T, offset_of_by_string(T, field_name), reserved) } -arena_static_bootstrap_new :: proc{ - arena_static_bootstrap_new_by_offset, - arena_static_bootstrap_new_by_name, -} arena_allocator :: proc(arena: ^Arena) -> mem.Allocator { @@ -195,6 +186,9 @@ arena_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode, location := #caller_location) -> (data: []byte, err: Allocator_Error) { arena := (^Arena)(allocator_data) + size, alignment := uint(size), uint(alignment) + old_size := uint(old_size) + switch mode { case .Alloc: return arena_alloc(arena, size, alignment) @@ -239,6 +233,9 @@ arena_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode, return } + + + Arena_Temp :: struct { arena: ^Arena, block: ^Memory_Block, diff --git a/core/mem/virtual/virtual.odin b/core/mem/virtual/virtual.odin index 22e96f6bd..e023b2324 100644 --- a/core/mem/virtual/virtual.odin +++ b/core/mem/virtual/virtual.odin @@ -106,7 +106,7 @@ memory_block_alloc :: proc(committed, reserved: uint, flags: Memory_Block_Flags) return &pmblock.block, nil } -alloc_from_memory_block :: proc(block: ^Memory_Block, min_size, alignment: int) -> (data: []byte, err: Allocator_Error) { +alloc_from_memory_block :: proc(block: ^Memory_Block, min_size, alignment: uint) -> (data: []byte, err: Allocator_Error) { calc_alignment_offset :: proc "contextless" (block: ^Memory_Block, alignment: uintptr) -> uint { alignment_offset := uint(0) ptr := uintptr(block.base[block.used:]) diff --git a/core/mem/virtual/virtual_platform.odin b/core/mem/virtual/virtual_platform.odin index 367346f63..2f167cbeb 100644 --- a/core/mem/virtual/virtual_platform.odin +++ b/core/mem/virtual/virtual_platform.odin @@ -63,7 +63,6 @@ platform_memory_commit :: proc "contextless" (block: ^Platform_Memory_Block, to_ return .Out_Of_Memory } - commit(block, to_commit) or_return block.committed = to_commit return nil From 765cd66b30f2da13ffc911b56e258a92f0d8ebdb Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 12 Oct 2022 21:20:31 +0100 Subject: [PATCH 047/110] Clean up `minimum_block_size` default implicit initialization --- core/mem/virtual/arena.odin | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/mem/virtual/arena.odin b/core/mem/virtual/arena.odin index e95dc227c..33d25e3a5 100644 --- a/core/mem/virtual/arena.odin +++ b/core/mem/virtual/arena.odin @@ -56,7 +56,9 @@ arena_alloc :: proc(arena: ^Arena, size: uint, alignment: uint, loc := #caller_l case .Growing: if arena.curr_block == nil || arena.curr_block.used + size > arena.curr_block.reserved { size = mem.align_forward_uint(size, alignment) - arena.minimum_block_size = max(GROWING_ARENA_DEFAULT_MINIMUM_BLOCK_SIZE, arena.minimum_block_size) + if arena.minimum_block_size == 0 { + arena.minimum_block_size = GROWING_ARENA_DEFAULT_MINIMUM_BLOCK_SIZE + } block_size := max(size, arena.minimum_block_size) @@ -71,8 +73,10 @@ arena_alloc :: proc(arena: ^Arena, size: uint, alignment: uint, loc := #caller_l arena.total_used += arena.curr_block.used - prev_used case .Static: if arena.curr_block == nil { - reserve_size := max(arena.minimum_block_size, STATIC_ARENA_DEFAULT_RESERVE_SIZE) - arena_init_static(arena, reserve_size, STATIC_ARENA_DEFAULT_COMMIT_SIZE) or_return + if arena.minimum_block_size == 0 { + arena.minimum_block_size = STATIC_ARENA_DEFAULT_RESERVE_SIZE + } + arena_init_static(arena=arena, reserved=arena.minimum_block_size, commit_size=STATIC_ARENA_DEFAULT_COMMIT_SIZE) or_return } data, err = alloc_from_memory_block(arena.curr_block, size, alignment) arena.total_used = arena.curr_block.used From 5ed06f7eb8b2e84844d7384e5e91ce59ab94340e Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 12 Oct 2022 21:23:45 +0100 Subject: [PATCH 048/110] Rename constants; minor rearrange of `Arena` layout --- core/mem/virtual/arena.odin | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/core/mem/virtual/arena.odin b/core/mem/virtual/arena.odin index 33d25e3a5..af26b950e 100644 --- a/core/mem/virtual/arena.odin +++ b/core/mem/virtual/arena.odin @@ -2,32 +2,31 @@ package mem_virtual import "core:mem" -Arena_Kind :: enum u8 { - Growing = 0, // chained memory block - Static = 1, // fixed reservation +Arena_Kind :: enum uint { + Growing = 0, // chained memory blocks (singly linked list) + Static = 1, // fixed reservation sized } Arena :: struct { - curr_block: ^Memory_Block, - total_used: uint, - total_reserved: uint, - kind: Arena_Kind, + curr_block: ^Memory_Block, + total_used: uint, + total_reserved: uint, minimum_block_size: uint, - temp_count: int, + temp_count: uint, } // 1 MiB should be enough to start with -STATIC_ARENA_DEFAULT_COMMIT_SIZE :: 1<<20 -GROWING_ARENA_DEFAULT_MINIMUM_BLOCK_SIZE :: STATIC_ARENA_DEFAULT_COMMIT_SIZE +DEFAULT_ARENA_STATIC_COMMIT_SIZE :: 1<<20 +DEFAULT_ARENA_GROWING_MINIMUM_BLOCK_SIZE :: DEFAULT_ARENA_STATIC_COMMIT_SIZE // 1 GiB on 64-bit systems, 128 MiB on 32-bit systems by default -STATIC_ARENA_DEFAULT_RESERVE_SIZE :: 1<<30 when size_of(uintptr) == 8 else 1<<27 +DEFAULT_ARENA_STATIC_RESERVE_SIZE :: 1<<30 when size_of(uintptr) == 8 else 1<<27 -arena_init_growing :: proc(arena: ^Arena, reserved: uint = GROWING_ARENA_DEFAULT_MINIMUM_BLOCK_SIZE) -> (err: Allocator_Error) { +arena_init_growing :: proc(arena: ^Arena, reserved: uint = DEFAULT_ARENA_GROWING_MINIMUM_BLOCK_SIZE) -> (err: Allocator_Error) { arena.kind = .Growing arena.curr_block = memory_block_alloc(0, reserved, {}) or_return arena.total_used = 0 @@ -36,7 +35,7 @@ arena_init_growing :: proc(arena: ^Arena, reserved: uint = GROWING_ARENA_DEFAULT } -arena_init_static :: proc(arena: ^Arena, reserved: uint, commit_size: uint = STATIC_ARENA_DEFAULT_COMMIT_SIZE) -> (err: Allocator_Error) { +arena_init_static :: proc(arena: ^Arena, reserved: uint, commit_size: uint = DEFAULT_ARENA_STATIC_COMMIT_SIZE) -> (err: Allocator_Error) { arena.kind = .Static arena.curr_block = memory_block_alloc(commit_size, reserved, {}) or_return arena.total_used = 0 @@ -57,7 +56,7 @@ arena_alloc :: proc(arena: ^Arena, size: uint, alignment: uint, loc := #caller_l if arena.curr_block == nil || arena.curr_block.used + size > arena.curr_block.reserved { size = mem.align_forward_uint(size, alignment) if arena.minimum_block_size == 0 { - arena.minimum_block_size = GROWING_ARENA_DEFAULT_MINIMUM_BLOCK_SIZE + arena.minimum_block_size = DEFAULT_ARENA_GROWING_MINIMUM_BLOCK_SIZE } block_size := max(size, arena.minimum_block_size) @@ -74,9 +73,9 @@ arena_alloc :: proc(arena: ^Arena, size: uint, alignment: uint, loc := #caller_l case .Static: if arena.curr_block == nil { if arena.minimum_block_size == 0 { - arena.minimum_block_size = STATIC_ARENA_DEFAULT_RESERVE_SIZE + arena.minimum_block_size = DEFAULT_ARENA_STATIC_RESERVE_SIZE } - arena_init_static(arena=arena, reserved=arena.minimum_block_size, commit_size=STATIC_ARENA_DEFAULT_COMMIT_SIZE) or_return + arena_init_static(arena=arena, reserved=arena.minimum_block_size, commit_size=DEFAULT_ARENA_STATIC_COMMIT_SIZE) or_return } data, err = alloc_from_memory_block(arena.curr_block, size, alignment) arena.total_used = arena.curr_block.used @@ -143,7 +142,7 @@ arena_static_bootstrap_new :: proc{ arena_static_bootstrap_new_by_name, } -arena_growing_bootstrap_new_by_offset :: proc($T: typeid, offset_to_arena: uintptr, minimum_block_size: uint = GROWING_ARENA_DEFAULT_MINIMUM_BLOCK_SIZE) -> (ptr: ^T, err: Allocator_Error) { +arena_growing_bootstrap_new_by_offset :: proc($T: typeid, offset_to_arena: uintptr, minimum_block_size: uint = DEFAULT_ARENA_GROWING_MINIMUM_BLOCK_SIZE) -> (ptr: ^T, err: Allocator_Error) { bootstrap: Arena bootstrap.kind = .Growing bootstrap.minimum_block_size = minimum_block_size @@ -157,7 +156,7 @@ arena_growing_bootstrap_new_by_offset :: proc($T: typeid, offset_to_arena: uintp return } -arena_growing_bootstrap_new_by_name :: proc($T: typeid, $field_name: string, minimum_block_size: uint = GROWING_ARENA_DEFAULT_MINIMUM_BLOCK_SIZE) -> (ptr: ^T, err: Allocator_Error) { +arena_growing_bootstrap_new_by_name :: proc($T: typeid, $field_name: string, minimum_block_size: uint = DEFAULT_ARENA_GROWING_MINIMUM_BLOCK_SIZE) -> (ptr: ^T, err: Allocator_Error) { return arena_growing_bootstrap_new_by_offset(T, offset_of_by_string(T, field_name), minimum_block_size) } From cf4afc2e7b2e6a5219cbc25ca9d2039261d1e939 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 12 Oct 2022 21:26:50 +0100 Subject: [PATCH 049/110] Inline `assert` condition --- core/mem/virtual/arena.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/mem/virtual/arena.odin b/core/mem/virtual/arena.odin index af26b950e..ab66f3685 100644 --- a/core/mem/virtual/arena.odin +++ b/core/mem/virtual/arena.odin @@ -44,7 +44,7 @@ arena_init_static :: proc(arena: ^Arena, reserved: uint, commit_size: uint = DEF } arena_alloc :: proc(arena: ^Arena, size: uint, alignment: uint, loc := #caller_location) -> (data: []byte, err: Allocator_Error) { - assert(mem.is_power_of_two(uintptr(alignment)), "non-power of two alignment", loc) + assert(alignment & (alignment-1) == 0, "non-power of two alignment", loc) size := size if size == 0 { From 2c14f0a109a25730fbe568a6710a1b943ff08132 Mon Sep 17 00:00:00 2001 From: hikari Date: Thu, 13 Oct 2022 11:19:05 +0300 Subject: [PATCH 050/110] sys/windows: add ITaskbarList interfaces --- core/sys/windows/types.odin | 82 +++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/core/sys/windows/types.odin b/core/sys/windows/types.odin index b9ff6998a..af28a9060 100644 --- a/core/sys/windows/types.odin +++ b/core/sys/windows/types.odin @@ -3232,10 +3232,14 @@ LWSTDAPI :: HRESULT CLSID_FileOpenDialog := &GUID{0xDC1C5A9C, 0xE88A, 0x4DDE, {0xA5, 0xA1, 0x60, 0xF8, 0x2A, 0x20, 0xAE, 0xF7}} CLSID_FileSaveDialog := &GUID{0xC0B4E2F3, 0xBA21, 0x4773, {0x8D, 0xBA, 0x33, 0x5E, 0xC9, 0x46, 0xEB, 0x8B}} +CLSID_TaskbarList := &GUID{0x56FDF344, 0xFD6D, 0x11d0, {0x95, 0x8A, 0x00, 0x60, 0x97, 0xC9, 0xA0, 0x90}} IID_IFileDialog := &GUID{0x42F85136, 0xDB7E, 0x439C, {0x85, 0xF1, 0xE4, 0x07, 0x5D, 0x13, 0x5F, 0xC8}} IID_IFileSaveDialog := &GUID{0x84BCCD23, 0x5FDE, 0x4CDB, {0xAE, 0xA4, 0xAF, 0x64, 0xB8, 0x3D, 0x78, 0xAB}} IID_IFileOpenDialog := &GUID{0xD57C7288, 0xD4AD, 0x4768, {0xBE, 0x02, 0x9D, 0x96, 0x95, 0x32, 0xD9, 0x60}} +IID_ITaskbarList := &GUID{0x56FDF342, 0xFD6D, 0x11d0, {0x95, 0x8A, 0x00, 0x60, 0x97, 0xC9, 0xA0, 0x90}} +IID_ITaskbarList2 := &GUID{0x602D4995, 0xB13A, 0x429b, {0xA6, 0x6E, 0x19, 0x35, 0xE4, 0x4F, 0x43, 0x17}} +IID_ITaskbarList3 := &GUID{0xea1afb91, 0x9e28, 0x4b86, {0x90, 0xe9, 0x9e, 0x9f, 0x8a, 0x5e, 0xef, 0xaf}} IModalWindow :: struct #raw_union { #subtype IUnknown: IUnknown, @@ -3540,6 +3544,84 @@ IFileSaveDialogVtbl :: struct { ApplyProperties: proc "stdcall" (this: ^IFileSaveDialog, psi: ^IShellItem, pStore: ^IPropertyStore, hwnd: HWND, pSink: ^IFileOperationProgressSink) -> HRESULT, } +ITaskbarList :: struct #raw_union { + #subtype IUnknown: IUnknown, + using Vtbl: ^ITaskbarListVtbl, +} +ITaskbarListVtbl :: struct { + using IUnknownVtbl: IUnknownVtbl, + HrInit: proc "stdcall" (this: ^ITaskbarList) -> HRESULT, + AddTab: proc "stdcall" (this: ^ITaskbarList, hwnd: HWND) -> HRESULT, + DeleteTab: proc "stdcall" (this: ^ITaskbarList, hwnd: HWND) -> HRESULT, + ActivateTab: proc "stdcall" (this: ^ITaskbarList, hwnd: HWND) -> HRESULT, + SetActiveAlt: proc "stdcall" (this: ^ITaskbarList, hwnd: HWND) -> HRESULT, +} + +ITaskbarList2 :: struct #raw_union { + #subtype ITaskbarList: ITaskbarList, + using Vtbl: ^ITaskbarList2Vtbl, +} +ITaskbarList2Vtbl :: struct { + using ITaskbarListVtbl: ITaskbarListVtbl, + MarkFullscreenWindow: proc "stdcall" (this: ^ITaskbarList2, hwnd: HWND, fFullscreen: BOOL) -> HRESULT, +} + +TBPFLAG :: enum c_int { + NOPROGRESS = 0, + INDETERMINATE = 0x1, + NORMAL = 0x2, + ERROR = 0x4, + PAUSED = 0x8, +} + +THUMBBUTTONFLAGS :: enum c_int { + ENABLED = 0, + DISABLED = 0x1, + DISMISSONCLICK = 0x2, + NOBACKGROUND = 0x4, + HIDDEN = 0x8, + NONINTERACTIVE = 0x10, +} + +THUMBBUTTONMASK :: enum c_int { + BITMAP = 0x1, + ICON = 0x2, + TOOLTIP = 0x4, + FLAGS = 0x8, +} + +THUMBBUTTON :: struct { + dwMask: THUMBBUTTONMASK, + iId: UINT, + iBitmap: UINT, + hIcon: HICON, + szTip: [260]WCHAR, + dwFlags: THUMBBUTTONFLAGS, +} +LPTHUMBBUTTON :: ^THUMBBUTTON + +HIMAGELIST :: ^IUnknown + +ITaskbarList3 :: struct #raw_union { + #subtype ITaskbarList2: ITaskbarList2, + using Vtbl: ^ITaskbarList3Vtbl, +} +ITaskbarList3Vtbl :: struct { + using ITaskbarList2Vtbl: ITaskbarList2Vtbl, + SetProgressValue: proc "stdcall" (this: ^ITaskbarList3, hwnd: HWND, ullCompleted: ULONGLONG, ullTotal: ULONGLONG) -> HRESULT, + SetProgressState: proc "stdcall" (this: ^ITaskbarList3, hwnd: HWND, tbpFlags: TBPFLAG) -> HRESULT, + RegisterTab: proc "stdcall" (this: ^ITaskbarList3, hwndTab: HWND, hwndMDI: HWND) -> HRESULT, + UnregisterTab: proc "stdcall" (this: ^ITaskbarList3, hwndTab: HWND) -> HRESULT, + SetTabOrder: proc "stdcall" (this: ^ITaskbarList3, hwndTab: HWND, hwndInsertBefore: HWND) -> HRESULT, + SetTabActive: proc "stdcall" (this: ^ITaskbarList3, hwndTab: HWND, hwndMDI: HWND, dwReserved: DWORD) -> HRESULT, + ThumbBarAddButtons: proc "stdcall" (this: ^ITaskbarList3, hwnd: HWND, cButtons: UINT, pButton: LPTHUMBBUTTON) -> HRESULT, + ThumbBarUpdateButtons: proc "stdcall" (this: ^ITaskbarList3, hwnd: HWND, cButtons: UINT, pButton: LPTHUMBBUTTON) -> HRESULT, + ThumbBarSetImageList: proc "stdcall" (this: ^ITaskbarList3, hwnd: HWND, himl: HIMAGELIST) -> HRESULT, + SetOverlayIcon: proc "stdcall" (this: ^ITaskbarList3, hwnd: HWND, hIcon: HICON, pszDescription: LPCWSTR) -> HRESULT, + SetThumbnailTooltip: proc "stdcall" (this: ^ITaskbarList3, hwnd: HWND, pszTip: LPCWSTR) -> HRESULT, + SetThumbnailClip: proc "stdcall" (this: ^ITaskbarList3, hwnd: HWND, prcClip: ^RECT) -> HRESULT, +} + MEMORYSTATUSEX :: struct { dwLength: DWORD, dwMemoryLoad: DWORD, From b725e01cddc32045b35fc44ed0b1e1df1bb7fbfe Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 13 Oct 2022 11:10:16 +0100 Subject: [PATCH 051/110] Add @(require_results) to many procedures --- core/mem/virtual/arena.odin | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/mem/virtual/arena.odin b/core/mem/virtual/arena.odin index ab66f3685..3cc4cdbd6 100644 --- a/core/mem/virtual/arena.odin +++ b/core/mem/virtual/arena.odin @@ -26,6 +26,7 @@ DEFAULT_ARENA_STATIC_RESERVE_SIZE :: 1<<30 when size_of(uintptr) == 8 else 1<<27 +@(require_results) arena_init_growing :: proc(arena: ^Arena, reserved: uint = DEFAULT_ARENA_GROWING_MINIMUM_BLOCK_SIZE) -> (err: Allocator_Error) { arena.kind = .Growing arena.curr_block = memory_block_alloc(0, reserved, {}) or_return @@ -35,6 +36,7 @@ arena_init_growing :: proc(arena: ^Arena, reserved: uint = DEFAULT_ARENA_GROWING } +@(require_results) arena_init_static :: proc(arena: ^Arena, reserved: uint, commit_size: uint = DEFAULT_ARENA_STATIC_COMMIT_SIZE) -> (err: Allocator_Error) { arena.kind = .Static arena.curr_block = memory_block_alloc(commit_size, reserved, {}) or_return @@ -43,6 +45,7 @@ arena_init_static :: proc(arena: ^Arena, reserved: uint, commit_size: uint = DEF return } +@(require_results) arena_alloc :: proc(arena: ^Arena, size: uint, alignment: uint, loc := #caller_location) -> (data: []byte, err: Allocator_Error) { assert(alignment & (alignment-1) == 0, "non-power of two alignment", loc) @@ -142,6 +145,7 @@ arena_static_bootstrap_new :: proc{ arena_static_bootstrap_new_by_name, } +@(require_results) arena_growing_bootstrap_new_by_offset :: proc($T: typeid, offset_to_arena: uintptr, minimum_block_size: uint = DEFAULT_ARENA_GROWING_MINIMUM_BLOCK_SIZE) -> (ptr: ^T, err: Allocator_Error) { bootstrap: Arena bootstrap.kind = .Growing @@ -156,10 +160,12 @@ arena_growing_bootstrap_new_by_offset :: proc($T: typeid, offset_to_arena: uintp return } +@(require_results) arena_growing_bootstrap_new_by_name :: proc($T: typeid, $field_name: string, minimum_block_size: uint = DEFAULT_ARENA_GROWING_MINIMUM_BLOCK_SIZE) -> (ptr: ^T, err: Allocator_Error) { return arena_growing_bootstrap_new_by_offset(T, offset_of_by_string(T, field_name), minimum_block_size) } +@(require_results) arena_static_bootstrap_new_by_offset :: proc($T: typeid, offset_to_arena: uintptr, reserved: uint) -> (ptr: ^T, err: Allocator_Error) { bootstrap: Arena bootstrap.kind = .Static @@ -174,11 +180,13 @@ arena_static_bootstrap_new_by_offset :: proc($T: typeid, offset_to_arena: uintpt return } +@(require_results) arena_static_bootstrap_new_by_name :: proc($T: typeid, $field_name: string, reserved: uint) -> (ptr: ^T, err: Allocator_Error) { return arena_static_bootstrap_new_by_offset(T, offset_of_by_string(T, field_name), reserved) } +@(require_results) arena_allocator :: proc(arena: ^Arena) -> mem.Allocator { return mem.Allocator{arena_allocator_proc, arena} } @@ -245,6 +253,7 @@ Arena_Temp :: struct { used: uint, } +@(require_results) arena_temp_begin :: proc(arena: ^Arena, loc := #caller_location) -> (temp: Arena_Temp) { assert(arena != nil, "nil arena", loc) temp.arena = arena From d48828dd80ef8419e8b1dab4178340e654322719 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 13 Oct 2022 12:45:17 +0100 Subject: [PATCH 052/110] Add overflow check when using a growing arena --- core/mem/virtual/arena.odin | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/mem/virtual/arena.odin b/core/mem/virtual/arena.odin index 3cc4cdbd6..57dbc2168 100644 --- a/core/mem/virtual/arena.odin +++ b/core/mem/virtual/arena.odin @@ -1,6 +1,7 @@ package mem_virtual import "core:mem" +import "core:intrinsics" Arena_Kind :: enum uint { Growing = 0, // chained memory blocks (singly linked list) @@ -56,7 +57,7 @@ arena_alloc :: proc(arena: ^Arena, size: uint, alignment: uint, loc := #caller_l switch arena.kind { case .Growing: - if arena.curr_block == nil || arena.curr_block.used + size > arena.curr_block.reserved { + if arena.curr_block == nil || (intrinsics.overflow_add(arena.curr_block.used, size) or_else 0) > arena.curr_block.reserved { size = mem.align_forward_uint(size, alignment) if arena.minimum_block_size == 0 { arena.minimum_block_size = DEFAULT_ARENA_GROWING_MINIMUM_BLOCK_SIZE From 7662808bc92271bbd5c9d6fad27301055f7e00ce Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 13 Oct 2022 12:53:33 +0100 Subject: [PATCH 053/110] Add `overflow_add` checks to `alloc_from_memory_block` --- core/mem/virtual/virtual.odin | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/mem/virtual/virtual.odin b/core/mem/virtual/virtual.odin index e023b2324..b209d06e4 100644 --- a/core/mem/virtual/virtual.odin +++ b/core/mem/virtual/virtual.odin @@ -1,6 +1,7 @@ package mem_virtual import "core:mem" +import "core:intrinsics" DEFAULT_PAGE_SIZE := uint(4096) @@ -134,11 +135,14 @@ alloc_from_memory_block :: proc(block: ^Memory_Block, min_size, alignment: uint) return nil } - alignment_offset := calc_alignment_offset(block, uintptr(alignment)) - size := uint(min_size) + alignment_offset + size, size_ok := intrinsics.overflow_add(min_size, alignment_offset) + if !size_ok { + err = .Out_Of_Memory + return + } - if block.used + size > block.reserved { + if to_be_used, ok := intrinsics.overflow_add(block.used, size); !ok || to_be_used > block.reserved { err = .Out_Of_Memory return } From 06d1df4cae548e5baee226c570920e96eaca3ca1 Mon Sep 17 00:00:00 2001 From: terids Date: Fri, 14 Oct 2022 02:03:57 +0100 Subject: [PATCH 054/110] Fix GetInstanceProcAddr crash It was trying to initialise itself with itself when calling load_proc_addresses(Instance) Discord bug channel reference https://discord.com/channels/568138951836172421/585072813954564100/1030265964572450867 --- vendor/vulkan/_gen/create_vulkan_odin_wrapper.py | 14 +++++++------- vendor/vulkan/procedures.odin | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/vendor/vulkan/_gen/create_vulkan_odin_wrapper.py b/vendor/vulkan/_gen/create_vulkan_odin_wrapper.py index 9a32f5796..1dbac58d8 100644 --- a/vendor/vulkan/_gen/create_vulkan_odin_wrapper.py +++ b/vendor/vulkan/_gen/create_vulkan_odin_wrapper.py @@ -84,7 +84,7 @@ def convert_type(t, prev_name, curr_name): else: ttype = t[:len(t)-1] elem = convert_type(ttype, prev_name, curr_name) - + if curr_name.endswith("s") or curr_name.endswith("Table"): if prev_name.endswith("Count") or prev_name.endswith("Counts"): pointer = "[^]" @@ -95,10 +95,10 @@ def convert_type(t, prev_name, curr_name): pointer = "[^]" elif curr_name.startswith("p"): pointer = "[^]" - + if curr_name and elem.endswith("Flags"): pointer = "[^]" - + return "{}{}".format(pointer, elem) elif t[0].isupper(): return t @@ -276,7 +276,7 @@ def parse_enums(f): f.write("// Enums\n") data = re.findall(r"typedef enum Vk(\w+) {(.+?)} \w+;", src, re.S) - + data.sort(key=lambda x: x[0]) generated_flags = set() @@ -458,14 +458,14 @@ def parse_procedures(f): for rt, name, fields in data: proc_name = no_vk(name) - + pf = [] prev_name = "" for type_, fname in re.findall(r"(?:\s*|)(.+?)\s*(\w+)(?:,|$)", fields): curr_name = fix_arg(fname) pf.append((do_type(type_, prev_name, curr_name), curr_name)) prev_name = curr_name - + data_fields = ', '.join(["{}: {}".format(n, t) for t, n in pf if t != ""]) ts = "proc \"c\" ({})".format(data_fields) @@ -510,7 +510,7 @@ def group_functions(f): if table_name in ('Device', 'Queue', 'CommandBuffer') and name != 'GetDeviceProcAddr': group_map["Device"].append(nn) - elif table_name in ('Instance', 'PhysicalDevice') or name == 'GetDeviceProcAddr': + elif table_name in ('Instance', 'PhysicalDevice') and name != 'ProcGetInstanceProcAddr' or name == 'GetDeviceProcAddr': group_map["Instance"].append(nn) elif table_name in ('rawptr', '', 'DebugReportFlagsEXT') or name == 'GetInstanceProcAddr': # Skip the allocation function and the dll entry point diff --git a/vendor/vulkan/procedures.odin b/vendor/vulkan/procedures.odin index 227f02a87..02cfa9dbf 100644 --- a/vendor/vulkan/procedures.odin +++ b/vendor/vulkan/procedures.odin @@ -533,6 +533,7 @@ DeviceMemoryReportCallbackEXT: ProcDeviceMemoryReportCallbackEXT EnumerateInstanceExtensionProperties: ProcEnumerateInstanceExtensionProperties EnumerateInstanceLayerProperties: ProcEnumerateInstanceLayerProperties EnumerateInstanceVersion: ProcEnumerateInstanceVersion +GetInstanceProcAddr: ProcGetInstanceProcAddr // Instance Procedures AcquireDrmDisplayEXT: ProcAcquireDrmDisplayEXT @@ -564,7 +565,6 @@ GetDisplayPlaneCapabilities2KHR: ProcGetDisplayP GetDisplayPlaneCapabilitiesKHR: ProcGetDisplayPlaneCapabilitiesKHR GetDisplayPlaneSupportedDisplaysKHR: ProcGetDisplayPlaneSupportedDisplaysKHR GetDrmDisplayEXT: ProcGetDrmDisplayEXT -GetInstanceProcAddr: ProcGetInstanceProcAddr GetPhysicalDeviceCalibrateableTimeDomainsEXT: ProcGetPhysicalDeviceCalibrateableTimeDomainsEXT GetPhysicalDeviceCooperativeMatrixPropertiesNV: ProcGetPhysicalDeviceCooperativeMatrixPropertiesNV GetPhysicalDeviceDisplayPlaneProperties2KHR: ProcGetPhysicalDeviceDisplayPlaneProperties2KHR @@ -1045,6 +1045,7 @@ load_proc_addresses_custom :: proc(set_proc_address: SetProcAddressType) { set_proc_address(&EnumerateInstanceExtensionProperties, "vkEnumerateInstanceExtensionProperties") set_proc_address(&EnumerateInstanceLayerProperties, "vkEnumerateInstanceLayerProperties") set_proc_address(&EnumerateInstanceVersion, "vkEnumerateInstanceVersion") + set_proc_address(&GetInstanceProcAddr, "vkGetInstanceProcAddr") // Instance Procedures set_proc_address(&AcquireDrmDisplayEXT, "vkAcquireDrmDisplayEXT") @@ -1076,7 +1077,6 @@ load_proc_addresses_custom :: proc(set_proc_address: SetProcAddressType) { set_proc_address(&GetDisplayPlaneCapabilitiesKHR, "vkGetDisplayPlaneCapabilitiesKHR") set_proc_address(&GetDisplayPlaneSupportedDisplaysKHR, "vkGetDisplayPlaneSupportedDisplaysKHR") set_proc_address(&GetDrmDisplayEXT, "vkGetDrmDisplayEXT") - set_proc_address(&GetInstanceProcAddr, "vkGetInstanceProcAddr") set_proc_address(&GetPhysicalDeviceCalibrateableTimeDomainsEXT, "vkGetPhysicalDeviceCalibrateableTimeDomainsEXT") set_proc_address(&GetPhysicalDeviceCooperativeMatrixPropertiesNV, "vkGetPhysicalDeviceCooperativeMatrixPropertiesNV") set_proc_address(&GetPhysicalDeviceDisplayPlaneProperties2KHR, "vkGetPhysicalDeviceDisplayPlaneProperties2KHR") @@ -2839,7 +2839,6 @@ load_proc_addresses_instance :: proc(instance: Instance) { GetDisplayPlaneCapabilitiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDisplayPlaneCapabilitiesKHR") GetDisplayPlaneSupportedDisplaysKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDisplayPlaneSupportedDisplaysKHR") GetDrmDisplayEXT = auto_cast GetInstanceProcAddr(instance, "vkGetDrmDisplayEXT") - GetInstanceProcAddr = auto_cast GetInstanceProcAddr(instance, "vkGetInstanceProcAddr") GetPhysicalDeviceCalibrateableTimeDomainsEXT = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceCalibrateableTimeDomainsEXT") GetPhysicalDeviceCooperativeMatrixPropertiesNV = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceCooperativeMatrixPropertiesNV") GetPhysicalDeviceDisplayPlaneProperties2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceDisplayPlaneProperties2KHR") @@ -3322,6 +3321,7 @@ load_proc_addresses_global :: proc(vk_get_instance_proc_addr: rawptr) { EnumerateInstanceExtensionProperties = auto_cast GetInstanceProcAddr(nil, "vkEnumerateInstanceExtensionProperties") EnumerateInstanceLayerProperties = auto_cast GetInstanceProcAddr(nil, "vkEnumerateInstanceLayerProperties") EnumerateInstanceVersion = auto_cast GetInstanceProcAddr(nil, "vkEnumerateInstanceVersion") + GetInstanceProcAddr = auto_cast GetInstanceProcAddr(nil, "vkGetInstanceProcAddr") } load_proc_addresses :: proc{ From 73c1f08776688f18940abcbff5d5b9f0f594049d Mon Sep 17 00:00:00 2001 From: Lucas Perlind Date: Fri, 14 Oct 2022 18:22:59 +1100 Subject: [PATCH 055/110] Improve error messages with 'using _' --- src/check_decl.cpp | 5 +++++ src/check_stmt.cpp | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/check_decl.cpp b/src/check_decl.cpp index 9d043e60a..bb56749af 100644 --- a/src/check_decl.cpp +++ b/src/check_decl.cpp @@ -1488,6 +1488,11 @@ void check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *decl, Type *ty if (!(e->flags & EntityFlag_Using)) { continue; } + if (is_blank_ident(e->token)) { + error(e->token, "'using' a procedure parameter requires a non blank identifier"); + break; + } + bool is_value = (e->flags & EntityFlag_Value) != 0 && !is_type_pointer(e->type); String name = e->token.string; Type *t = base_type(type_deref(e->type)); diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index 630182273..9cacb4a35 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -584,7 +584,11 @@ void check_label(CheckerContext *ctx, Ast *label, Ast *parent) { // Returns 'true' for 'continue', 'false' for 'return' bool check_using_stmt_entity(CheckerContext *ctx, AstUsingStmt *us, Ast *expr, bool is_selector, Entity *e) { if (e == nullptr) { - error(us->token, "'using' applied to an unknown entity"); + if (is_blank_ident(expr)) { + error(us->token, "'using' in a statement is not allowed with the blank identifier '_'"); + } else { + error(us->token, "'using' applied to an unknown entity"); + } return true; } From ff51c5ee5628774574f63e72f5efe6c49aaae54e Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 15 Oct 2022 12:52:07 +0100 Subject: [PATCH 056/110] Wrap `intrinsics.overflow_add` to `safe_add` --- core/mem/virtual/arena.odin | 6 +---- core/mem/virtual/arena_util.odin | 41 -------------------------------- core/mem/virtual/virtual.odin | 11 +++++++-- 3 files changed, 10 insertions(+), 48 deletions(-) delete mode 100644 core/mem/virtual/arena_util.odin diff --git a/core/mem/virtual/arena.odin b/core/mem/virtual/arena.odin index 57dbc2168..45426eddc 100644 --- a/core/mem/virtual/arena.odin +++ b/core/mem/virtual/arena.odin @@ -1,7 +1,6 @@ package mem_virtual import "core:mem" -import "core:intrinsics" Arena_Kind :: enum uint { Growing = 0, // chained memory blocks (singly linked list) @@ -57,7 +56,7 @@ arena_alloc :: proc(arena: ^Arena, size: uint, alignment: uint, loc := #caller_l switch arena.kind { case .Growing: - if arena.curr_block == nil || (intrinsics.overflow_add(arena.curr_block.used, size) or_else 0) > arena.curr_block.reserved { + if arena.curr_block == nil || (safe_add(arena.curr_block.used, size) or_else 0) > arena.curr_block.reserved { size = mem.align_forward_uint(size, alignment) if arena.minimum_block_size == 0 { arena.minimum_block_size = DEFAULT_ARENA_GROWING_MINIMUM_BLOCK_SIZE @@ -299,6 +298,3 @@ arena_temp_end :: proc(temp: Arena_Temp, loc := #caller_location) { arena_check_temp :: proc(arena: ^Arena, loc := #caller_location) { assert(arena.temp_count == 0, "Arena_Temp not been ended", loc) } - - - diff --git a/core/mem/virtual/arena_util.odin b/core/mem/virtual/arena_util.odin deleted file mode 100644 index f721c4ffa..000000000 --- a/core/mem/virtual/arena_util.odin +++ /dev/null @@ -1,41 +0,0 @@ -package mem_virtual - -// arena_init :: proc{ -// static_arena_init, -// growing_arena_init, -// } - -// arena_temp_begin :: proc{ -// static_arena_temp_begin, -// growing_arena_temp_begin, -// } - -// arena_temp_end :: proc{ -// static_arena_temp_end, -// growing_arena_temp_end, -// } - -// arena_check_temp :: proc{ -// static_arena_check_temp, -// growing_arena_check_temp, -// } - -// arena_allocator :: proc{ -// static_arena_allocator, -// growing_arena_allocator, -// } - -// arena_alloc :: proc{ -// static_arena_alloc, -// growing_arena_alloc, -// } - -// arena_free_all :: proc{ -// static_arena_free_all, -// growing_arena_free_all, -// } - -// arena_destroy :: proc{ -// static_arena_destroy, -// growing_arena_destroy, -// } \ No newline at end of file diff --git a/core/mem/virtual/virtual.odin b/core/mem/virtual/virtual.odin index b209d06e4..426482fff 100644 --- a/core/mem/virtual/virtual.odin +++ b/core/mem/virtual/virtual.odin @@ -136,13 +136,13 @@ alloc_from_memory_block :: proc(block: ^Memory_Block, min_size, alignment: uint) } alignment_offset := calc_alignment_offset(block, uintptr(alignment)) - size, size_ok := intrinsics.overflow_add(min_size, alignment_offset) + size, size_ok := safe_add(min_size, alignment_offset) if !size_ok { err = .Out_Of_Memory return } - if to_be_used, ok := intrinsics.overflow_add(block.used, size); !ok || to_be_used > block.reserved { + if to_be_used, ok := safe_add(block.used, size); !ok || to_be_used > block.reserved { err = .Out_Of_Memory return } @@ -166,3 +166,10 @@ memory_block_dealloc :: proc(block_to_free: ^Memory_Block) { } } + + +@(private) +safe_add :: #force_inline proc "contextless" (x, y: uint) -> (uint, bool) { + z, did_overflow := intrinsics.overflow_add(x, y) + return z, !did_overflow +} \ No newline at end of file From 075040ae057e48bb9df4cb03bc0ea39e98a804ad Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 18 Oct 2022 00:06:21 +0100 Subject: [PATCH 057/110] Update sort_private.odin --- core/slice/sort_private.odin | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/slice/sort_private.odin b/core/slice/sort_private.odin index 86a6f5928..32eb7d417 100644 --- a/core/slice/sort_private.odin +++ b/core/slice/sort_private.odin @@ -177,7 +177,6 @@ _quick_sort_general :: proc(data: $T/[]$E, a, b, max_depth: int, call: $P, $KIND } -// merge sort _stable_sort_general :: proc(data: $T/[]$E, call: $P, $KIND: Sort_Kind) where (ORD(E) && KIND == .Ordered) || (KIND != .Ordered) #no_bounds_check { less :: #force_inline proc(a, b: E, call: P) -> bool { when KIND == .Ordered { @@ -190,7 +189,9 @@ _stable_sort_general :: proc(data: $T/[]$E, call: $P, $KIND: Sort_Kind) where (O #panic("unhandled Sort_Kind") } } - + + // insertion sort + // TODO(bill): use a different algorithm as insertion sort is O(n^2) n := len(data) for i in 1.. 0 && less(data[j], data[j-1], call); j -= 1 { From 9f55404845adb10a933cc725c019faa140efb202 Mon Sep 17 00:00:00 2001 From: Julian Fondren Date: Mon, 17 Oct 2022 22:32:10 -0500 Subject: [PATCH 058/110] fix core:c/libc.errno link_name for Linux and FreeBSD Although the FreeBSD link matches Darwin, its EILSEQ still matches Linux. Confirmed with the following program: ```odin package main import "core:c/libc" main :: proc() { libc.printf("%d\n", libc.errno()^) // 0 _ = libc.fopen("nonexistent file", "r") libc.printf("%d\n", libc.errno()^) // 2 } ``` on Linux: Odin: dev-2022-10:075040ae OS: Manjaro Linux, Linux 5.10.147-1-MANJARO CPU: Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz RAM: 15953 MiB and FreeBSD: Odin: dev-2022-10:075040ae OS: FreeBSD: Unknown CPU: Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz RAM: 990 MiB FreeBSD uname -r: 13.0-RELEASE --- core/c/libc/errno.odin | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/core/c/libc/errno.odin b/core/c/libc/errno.odin index 53437f42f..fe6fbb073 100644 --- a/core/c/libc/errno.odin +++ b/core/c/libc/errno.odin @@ -14,11 +14,24 @@ when ODIN_OS == .Windows { // EDOM, // EILSEQ // ERANGE -when ODIN_OS == .Linux || ODIN_OS == .FreeBSD { +when ODIN_OS == .Linux { @(private="file") @(default_calling_convention="c") foreign libc { - @(link_name="__libc_errno_location") + @(link_name="__errno_location") + _get_errno :: proc() -> ^int --- + } + + EDOM :: 33 + EILSEQ :: 84 + ERANGE :: 34 +} + +when ODIN_OS == .FreeBSD { + @(private="file") + @(default_calling_convention="c") + foreign libc { + @(link_name="__error") _get_errno :: proc() -> ^int --- } From 80ce1b7d850d264f5d8538724aa2b43e8e4a5c09 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 18 Oct 2022 10:28:17 +0100 Subject: [PATCH 059/110] Allow for `N = -1` in `wstring_to_utf8` --- core/sys/windows/util.odin | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/sys/windows/util.odin b/core/sys/windows/util.odin index 36383a2c7..298588cb6 100644 --- a/core/sys/windows/util.odin +++ b/core/sys/windows/util.odin @@ -62,19 +62,19 @@ utf8_to_wstring :: proc(s: string, allocator := context.temp_allocator) -> wstri wstring_to_utf8 :: proc(s: wstring, N: int, allocator := context.temp_allocator) -> (res: string, err: runtime.Allocator_Error) { context.allocator = allocator - if N <= 0 { + if N == 0 { return } - n := WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s, i32(N), nil, 0, nil, nil) + n := WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s, i32(N) if N > 0 else -1, nil, 0, nil, nil) if n == 0 { return } - // If N == -1 the call to WideCharToMultiByte assume the wide string is null terminated + // If N < 0 the call to WideCharToMultiByte assume the wide string is null terminated // and will scan it to find the first null terminated character. The resulting string will // also be null terminated. - // If N != -1 it assumes the wide string is not null terminated and the resulting string + // If N > 0 it assumes the wide string is not null terminated and the resulting string // will not be null terminated. text := make([]byte, n) or_return From 765969e6a3c449b4fab8da0b5b672a5a436010c9 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 19 Oct 2022 16:06:36 +0100 Subject: [PATCH 060/110] Revert `default_resize_bytes_align` logic to previous behaviour --- core/mem/alloc.odin | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/core/mem/alloc.odin b/core/mem/alloc.odin index b5788c8a8..54004d333 100644 --- a/core/mem/alloc.odin +++ b/core/mem/alloc.odin @@ -243,11 +243,13 @@ default_resize_bytes_align :: proc(old_data: []byte, new_size, alignment: int, a return alloc_bytes(new_size, alignment, allocator, loc) } - if new_size == old_size { - return old_data, nil - } if new_size == 0 { - return nil, free_bytes(old_data, allocator, loc) + err := free_bytes(old_data, allocator, loc) + return nil, err + } + + if new_size == old_size { + return old_data, .None } new_memory, err := alloc_bytes(new_size, alignment, allocator, loc) @@ -256,9 +258,6 @@ default_resize_bytes_align :: proc(old_data: []byte, new_size, alignment: int, a } runtime.copy(new_memory, old_data) - err1 := free_bytes(old_data, allocator, loc) - if err == nil { - err = err1 - } + free_bytes(old_data, allocator, loc) return new_memory, err } From 098f51aa800a8d2efd06ea54911b8ec067c586ed Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 19 Oct 2022 16:59:38 +0100 Subject: [PATCH 061/110] Allow `transmute` to be constant for integers of the same internal endianness --- src/big_int.cpp | 2 +- src/check_expr.cpp | 61 ++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/src/big_int.cpp b/src/big_int.cpp index 5509545ca..d8b3e63a7 100644 --- a/src/big_int.cpp +++ b/src/big_int.cpp @@ -71,7 +71,7 @@ void big_int_and (BigInt *dst, BigInt const *x, BigInt const *y); void big_int_and_not(BigInt *dst, BigInt const *x, BigInt const *y); void big_int_xor (BigInt *dst, BigInt const *x, BigInt const *y); void big_int_or (BigInt *dst, BigInt const *x, BigInt const *y); -void big_int_not (BigInt *dst, BigInt const *x, u64 bit_count, bool is_signed); +void big_int_not (BigInt *dst, BigInt const *x, i32 bit_count, bool is_signed); void big_int_add_eq(BigInt *dst, BigInt const *x); diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 6edd4a93c..ab5838bf5 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -2916,7 +2916,12 @@ bool check_transmute(CheckerContext *c, Ast *node, Operand *o, Type *t) { // return false; // } - if (is_type_untyped(o->type)) { + Type *src_t = o->type; + Type *dst_t = t; + Type *src_bt = base_type(src_t); + Type *dst_bt = base_type(dst_t); + + if (is_type_untyped(src_t)) { gbString expr_str = expr_to_string(o->expr); error(o->expr, "Cannot transmute untyped expression: '%s'", expr_str); gb_string_free(expr_str); @@ -2925,7 +2930,6 @@ bool check_transmute(CheckerContext *c, Ast *node, Operand *o, Type *t) { return false; } - Type *dst_bt = base_type(t); if (dst_bt == nullptr || dst_bt == t_invalid) { GB_ASSERT(global_error_collector.count != 0); @@ -2934,21 +2938,21 @@ bool check_transmute(CheckerContext *c, Ast *node, Operand *o, Type *t) { return false; } - Type *src_bt = base_type(o->type); if (src_bt == nullptr || src_bt == t_invalid) { // NOTE(bill): this should be an error GB_ASSERT(global_error_collector.count != 0); o->mode = Addressing_Value; o->expr = node; - o->type = t; + o->type = dst_t; return true; } - i64 srcz = type_size_of(o->type); - i64 dstz = type_size_of(t); + + i64 srcz = type_size_of(src_t); + i64 dstz = type_size_of(dst_t); if (srcz != dstz) { gbString expr_str = expr_to_string(o->expr); - gbString type_str = type_to_string(t); + gbString type_str = type_to_string(dst_t); error(o->expr, "Cannot transmute '%s' to '%s', %lld vs %lld bytes", expr_str, type_str, srcz, dstz); gb_string_free(type_str); gb_string_free(expr_str); @@ -2958,16 +2962,53 @@ bool check_transmute(CheckerContext *c, Ast *node, Operand *o, Type *t) { } if (build_context.vet_extra) { - if (are_types_identical(o->type, t)) { - gbString str = type_to_string(t); + if (are_types_identical(o->type, dst_t)) { + gbString str = type_to_string(dst_t); warning(o->expr, "Unneeded transmute to the same type '%s'", str); gb_string_free(str); } } o->expr = node; + o->type = dst_t; + if (o->mode == Addressing_Constant) { + if (are_types_identical(src_bt, dst_bt)) { + return true; + } + if (is_type_integer(src_t) && is_type_integer(dst_t)) { + if (types_have_same_internal_endian(src_t, dst_t)) { + ExactValue src_v = exact_value_to_integer(o->value); + GB_ASSERT(src_v.kind == ExactValue_Integer); + BigInt v = src_v.value_integer; + + BigInt smax = {}; + BigInt umax = {}; + + big_int_from_u64(&smax, 0); + big_int_not(&smax, &smax, cast(i32)(srcz*8 - 1), false); + + big_int_from_u64(&umax, 1); + BigInt sz_in_bits = big_int_make_i64(srcz*8); + big_int_shl_eq(&umax, &sz_in_bits); + + if (is_type_unsigned(src_t) && !is_type_unsigned(dst_t)) { + if (big_int_cmp(&v, &smax) >= 0) { + big_int_sub_eq(&v, &umax); + } + } else if (!is_type_unsigned(src_t) && is_type_unsigned(dst_t)) { + if (big_int_is_neg(&v)) { + big_int_add_eq(&v, &umax); + } + } + + o->value.kind = ExactValue_Integer; + o->value.value_integer = v; + return true; + } + } + } + o->mode = Addressing_Value; - o->type = t; o->value = {}; return true; } From 53e84b7f31a218102034c60e157b60d22adcf303 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 19 Oct 2022 23:39:47 +0100 Subject: [PATCH 062/110] Remove doubly linked list of `Platform_Memory_Block` fields --- core/mem/virtual/virtual.odin | 12 ------------ core/mem/virtual/virtual_platform.odin | 25 ------------------------- 2 files changed, 37 deletions(-) diff --git a/core/mem/virtual/virtual.odin b/core/mem/virtual/virtual.odin index 426482fff..c4a475dba 100644 --- a/core/mem/virtual/virtual.odin +++ b/core/mem/virtual/virtual.odin @@ -96,13 +96,6 @@ memory_block_alloc :: proc(committed, reserved: uint, flags: Memory_Block_Flags) pmblock.block.committed = committed pmblock.block.reserved = reserved - sentinel := &global_platform_memory_block_sentinel - platform_mutex_lock() - pmblock.next = sentinel - pmblock.prev = sentinel.prev - pmblock.prev.next = pmblock - pmblock.next.prev = pmblock - platform_mutex_unlock() return &pmblock.block, nil } @@ -157,11 +150,6 @@ alloc_from_memory_block :: proc(block: ^Memory_Block, min_size, alignment: uint) memory_block_dealloc :: proc(block_to_free: ^Memory_Block) { if block := (^Platform_Memory_Block)(block_to_free); block != nil { - platform_mutex_lock() - block.prev.next = block.next - block.next.prev = block.prev - platform_mutex_unlock() - platform_memory_free(block) } } diff --git a/core/mem/virtual/virtual_platform.odin b/core/mem/virtual/virtual_platform.odin index 2f167cbeb..c2b505cd2 100644 --- a/core/mem/virtual/virtual_platform.odin +++ b/core/mem/virtual/virtual_platform.odin @@ -1,13 +1,10 @@ //+private package mem_virtual -import "core:sync" - Platform_Memory_Block :: struct { block: Memory_Block, committed: uint, reserved: uint, - prev, next: ^Platform_Memory_Block, } platform_memory_alloc :: proc "contextless" (to_commit, to_reserve: uint) -> (block: ^Platform_Memory_Block, err: Allocator_Error) { @@ -33,28 +30,6 @@ platform_memory_free :: proc "contextless" (block: ^Platform_Memory_Block) { } } -platform_mutex_lock :: proc() { - sync.mutex_lock(&global_memory_block_mutex) -} - -platform_mutex_unlock :: proc() { - sync.mutex_unlock(&global_memory_block_mutex) -} - -global_memory_block_mutex: sync.Mutex -global_platform_memory_block_sentinel: Platform_Memory_Block -global_platform_memory_block_sentinel_set: bool - -@(init) -platform_memory_init :: proc() { - if !global_platform_memory_block_sentinel_set { - _platform_memory_init() - global_platform_memory_block_sentinel.prev = &global_platform_memory_block_sentinel - global_platform_memory_block_sentinel.next = &global_platform_memory_block_sentinel - global_platform_memory_block_sentinel_set = true - } -} - platform_memory_commit :: proc "contextless" (block: ^Platform_Memory_Block, to_commit: uint) -> (err: Allocator_Error) { if to_commit < block.committed { return nil From 2242178d967d01cdcf70c2b64b7fa52b91e338fe Mon Sep 17 00:00:00 2001 From: Julian Ceipek Date: Thu, 20 Oct 2022 21:07:14 -0400 Subject: [PATCH 063/110] Fix signature for `objc_allocateClassPair` --- core/runtime/procs_darwin.odin | 2 +- vendor/darwin/Foundation/objc.odin | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/runtime/procs_darwin.odin b/core/runtime/procs_darwin.odin index b54a28dcc..9c53b5b16 100644 --- a/core/runtime/procs_darwin.odin +++ b/core/runtime/procs_darwin.odin @@ -12,7 +12,7 @@ objc_SEL :: ^intrinsics.objc_selector foreign Foundation { objc_lookUpClass :: proc "c" (name: cstring) -> objc_Class --- sel_registerName :: proc "c" (name: cstring) -> objc_SEL --- - objc_allocateClassPair :: proc "c" (superclass: objc_Class, name: cstring, extraBytes: uint) --- + objc_allocateClassPair :: proc "c" (superclass: objc_Class, name: cstring, extraBytes: uint) -> objc_Class --- objc_msgSend :: proc "c" (self: objc_id, op: objc_SEL, #c_vararg args: ..any) --- objc_msgSend_fpret :: proc "c" (self: objc_id, op: objc_SEL, #c_vararg args: ..any) -> f64 --- diff --git a/vendor/darwin/Foundation/objc.odin b/vendor/darwin/Foundation/objc.odin index 78f1f7780..2ece561f3 100644 --- a/vendor/darwin/Foundation/objc.odin +++ b/vendor/darwin/Foundation/objc.odin @@ -10,7 +10,7 @@ IMP :: proc "c" (object: id, sel: SEL, #c_vararg args: ..any) -> id foreign Foundation { objc_lookUpClass :: proc "c" (name: cstring) -> Class --- sel_registerName :: proc "c" (name: cstring) -> SEL --- - objc_allocateClassPair :: proc "c" (superclass: Class, name: cstring, extraBytes: uint) --- + objc_allocateClassPair :: proc "c" (superclass: Class, name: cstring, extraBytes: uint) -> Class --- class_addMethod :: proc "c" (cls: Class, name: SEL, imp: IMP, types: cstring) -> BOOL --- class_getInstanceMethod :: proc "c" (cls: Class, name: SEL) -> Method --- From fda8e8a30b36c71b08642668f18ee7f8d12f417b Mon Sep 17 00:00:00 2001 From: Julian Ceipek Date: Thu, 20 Oct 2022 21:16:53 -0400 Subject: [PATCH 064/110] Use `c.size_t` to match C declaration more directly --- vendor/darwin/Foundation/objc.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/darwin/Foundation/objc.odin b/vendor/darwin/Foundation/objc.odin index 2ece561f3..9468b971a 100644 --- a/vendor/darwin/Foundation/objc.odin +++ b/vendor/darwin/Foundation/objc.odin @@ -10,7 +10,7 @@ IMP :: proc "c" (object: id, sel: SEL, #c_vararg args: ..any) -> id foreign Foundation { objc_lookUpClass :: proc "c" (name: cstring) -> Class --- sel_registerName :: proc "c" (name: cstring) -> SEL --- - objc_allocateClassPair :: proc "c" (superclass: Class, name: cstring, extraBytes: uint) -> Class --- + objc_allocateClassPair :: proc "c" (superclass : Class, name : cstring, extraBytes : c.size_t) -> Class --- class_addMethod :: proc "c" (cls: Class, name: SEL, imp: IMP, types: cstring) -> BOOL --- class_getInstanceMethod :: proc "c" (cls: Class, name: SEL) -> Method --- From f26516f6faf337f39bab172ebba7ae2cb1337fcc Mon Sep 17 00:00:00 2001 From: Julian Ceipek Date: Thu, 20 Oct 2022 21:18:11 -0400 Subject: [PATCH 065/110] Add `objc_registerClassPair` to allow subclassing --- vendor/darwin/Foundation/objc.odin | 1 + 1 file changed, 1 insertion(+) diff --git a/vendor/darwin/Foundation/objc.odin b/vendor/darwin/Foundation/objc.odin index 9468b971a..03cc7648e 100644 --- a/vendor/darwin/Foundation/objc.odin +++ b/vendor/darwin/Foundation/objc.odin @@ -11,6 +11,7 @@ foreign Foundation { objc_lookUpClass :: proc "c" (name: cstring) -> Class --- sel_registerName :: proc "c" (name: cstring) -> SEL --- objc_allocateClassPair :: proc "c" (superclass : Class, name : cstring, extraBytes : c.size_t) -> Class --- + objc_registerClassPair :: proc "c" (cls : Class) --- class_addMethod :: proc "c" (cls: Class, name: SEL, imp: IMP, types: cstring) -> BOOL --- class_getInstanceMethod :: proc "c" (cls: Class, name: SEL) -> Method --- From 8ceb691cec2d950b0f9700a2eb31aa085823b3bb Mon Sep 17 00:00:00 2001 From: Julian Ceipek Date: Thu, 20 Oct 2022 21:38:43 -0400 Subject: [PATCH 066/110] Fix indentation --- vendor/darwin/Foundation/objc.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/darwin/Foundation/objc.odin b/vendor/darwin/Foundation/objc.odin index 03cc7648e..722065564 100644 --- a/vendor/darwin/Foundation/objc.odin +++ b/vendor/darwin/Foundation/objc.odin @@ -10,7 +10,7 @@ IMP :: proc "c" (object: id, sel: SEL, #c_vararg args: ..any) -> id foreign Foundation { objc_lookUpClass :: proc "c" (name: cstring) -> Class --- sel_registerName :: proc "c" (name: cstring) -> SEL --- - objc_allocateClassPair :: proc "c" (superclass : Class, name : cstring, extraBytes : c.size_t) -> Class --- + objc_allocateClassPair :: proc "c" (superclass : Class, name : cstring, extraBytes : c.size_t) -> Class --- objc_registerClassPair :: proc "c" (cls : Class) --- class_addMethod :: proc "c" (cls: Class, name: SEL, imp: IMP, types: cstring) -> BOOL --- From 648e3c65eadbfcc01da4b9a13216772c63cfb765 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Fri, 21 Oct 2022 19:20:15 +0200 Subject: [PATCH 067/110] Add RawMouseMotionSupported --- vendor/glfw/bindings/bindings.odin | 1 + vendor/glfw/constants.odin | 3 +++ 2 files changed, 4 insertions(+) diff --git a/vendor/glfw/bindings/bindings.odin b/vendor/glfw/bindings/bindings.odin index aea09e31d..e7287e316 100644 --- a/vendor/glfw/bindings/bindings.odin +++ b/vendor/glfw/bindings/bindings.odin @@ -110,6 +110,7 @@ foreign glfw { WaitEventsTimeout :: proc(timeout: f64) --- PostEmptyEvent :: proc() --- + RawMouseMotionSupported :: proc() -> b32 --- GetInputMode :: proc(window: WindowHandle, mode: c.int) -> c.int --- SetInputMode :: proc(window: WindowHandle, mode, value: c.int) --- diff --git a/vendor/glfw/constants.odin b/vendor/glfw/constants.odin index 245cfef52..ec1364e07 100644 --- a/vendor/glfw/constants.odin +++ b/vendor/glfw/constants.odin @@ -339,6 +339,9 @@ CURSOR_NORMAL :: 0x00034001 CURSOR_HIDDEN :: 0x00034002 CURSOR_DISABLED :: 0x00034003 +/* Mouse motion */ +RAW_MOUSE_MOTION :: 0x00033005 + /* Behavior? */ ANY_RELEASE_BEHAVIOR :: 0 RELEASE_BEHAVIOR_FLUSH :: 0x00035001 From 989107094c64b6f74dadb40df2374a9db625778a Mon Sep 17 00:00:00 2001 From: Jasper Geer Date: Fri, 21 Oct 2022 15:41:58 -0400 Subject: [PATCH 068/110] throw type checker error when scalar cast to non-square matrix --- src/check_expr.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/check_expr.cpp b/src/check_expr.cpp index ab5838bf5..b3c04caa4 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -821,11 +821,12 @@ i64 check_distance_between_types(CheckerContext *c, Operand *operand, Type *type if (are_types_identical(src, dst)) { return 5; } - - Type *dst_elem = base_array_type(dst); - i64 distance = check_distance_between_types(c, operand, dst_elem); - if (distance >= 0) { - return distance + 7; + if (dst->Matrix.row_count == dst->Matrix.column_count) { + Type *dst_elem = base_array_type(dst); + i64 distance = check_distance_between_types(c, operand, dst_elem); + if (distance >= 0) { + return distance + 7; + } } } From a51943e27f625552c4a56ec7389ff2d06e8c7a8d Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Sun, 23 Oct 2022 04:18:58 +0200 Subject: [PATCH 069/110] Add `core:math/rand.choice` --- core/math/rand/rand.odin | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/math/rand/rand.odin b/core/math/rand/rand.odin index f7dfcb3b8..2d92d29ff 100644 --- a/core/math/rand/rand.odin +++ b/core/math/rand/rand.odin @@ -182,3 +182,12 @@ shuffle :: proc(array: $T/[]$E, r: ^Rand = nil) { array[i], array[j] = array[j], array[i] } } + +// Returns a random element from the given slice +choice :: proc(array: $T/[]$E, r: ^Rand = nil) -> (res: E) { + n := i64(len(array)) + if n < 1 { + return E{} + } + return array[int63_max(n, r)] +} \ No newline at end of file From 92fb65cf2eed21e5f97d7818172290271eaee63e Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Sun, 23 Oct 2022 04:32:45 +0200 Subject: [PATCH 070/110] Fix `#defined(I)`. --- src/check_builtin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index a00dd5def..fc889fb28 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -1533,10 +1533,10 @@ bool check_builtin_procedure_directive(CheckerContext *c, Operand *operand, Ast } bool is_defined = check_identifier_exists(c->scope, arg); - gb_unused(is_defined); + // gb_unused(is_defined); operand->type = t_untyped_bool; operand->mode = Addressing_Constant; - operand->value = exact_value_bool(false); + operand->value = exact_value_bool(is_defined); } else if (name == "config") { if (ce->args.count != 2) { From a5f8c3f692ff802104b81416513396981409c2f3 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 23 Oct 2022 13:17:37 +0100 Subject: [PATCH 071/110] Update many `enum`s to `bit_set`s for D3D11 --- vendor/directx/d3d11/d3d11.odin | 312 ++++++++++++++++++-------------- 1 file changed, 177 insertions(+), 135 deletions(-) diff --git a/vendor/directx/d3d11/d3d11.odin b/vendor/directx/d3d11/d3d11.odin index a41ce1190..42a860c4b 100644 --- a/vendor/directx/d3d11/d3d11.odin +++ b/vendor/directx/d3d11/d3d11.odin @@ -30,7 +30,7 @@ foreign d3d11 { DriverType: DRIVER_TYPE, Software: HMODULE, Flags: CREATE_DEVICE_FLAGS, - pFeatureLevels: ^FEATURE_LEVEL, + pFeatureLevels: [^]FEATURE_LEVEL, FeatureLevels: u32, SDKVersion: u32, ppDevice: ^^IDevice, @@ -41,8 +41,8 @@ foreign d3d11 { pAdapter: ^dxgi.IAdapter, DriverType: DRIVER_TYPE, Software: HMODULE, - Flags: u32, - pFeatureLevels: ^FEATURE_LEVEL, + Flags: CREATE_DEVICE_FLAGS, + pFeatureLevels: [^]FEATURE_LEVEL, FeatureLevels: u32, SDKVersion: u32, pSwapChainDesc: ^dxgi.SWAP_CHAIN_DESC, @@ -539,25 +539,37 @@ ANISOTROPIC_FILTERING_BIT :: 0x40 SDK_VERSION :: 7 RETURN_PARAMETER_INDEX :: -1 -COMPONENT_MASK :: enum u32 { // TODO: make bit_set +COMPONENT_MASK :: distinct bit_set[COMPONENT_MASK_ELEMENT; u32] +COMPONENT_MASK_ELEMENT :: enum u32 { X = 1, Y = 2, Z = 4, W = 8, } -SHADER_REQUIRES :: enum u32 { // TODO: make bit_set - DOUBLES = 0x00000001, - EARLY_DEPTH_STENCIL = 0x00000002, - UAVS_AT_EVERY_STAGE = 0x00000004, - _64_UAVS = 0x00000008, - MINIMUM_PRECISION = 0x00000010, - _11_1_DOUBLE_EXTENSIONS = 0x00000020, - _11_1_SHADER_EXTENSIONS = 0x00000040, - LEVEL_9_COMPARISON_FILTERING = 0x00000080, - TILED_RESOURCES = 0x00000100, +SHADER_REQUIRES_FLAGS :: distinct bit_set[SHADER_REQUIRES_FLAG; u64] +SHADER_REQUIRES_FLAG :: enum u64 { + DOUBLES = 0, + EARLY_DEPTH_STENCIL = 1, + UAVS_AT_EVERY_STAGE = 2, + _64_UAVS = 3, + MINIMUM_PRECISION = 4, + _11_1_DOUBLE_EXTENSIONS = 5, + _11_1_SHADER_EXTENSIONS = 6, + LEVEL_9_COMPARISON_FILTERING = 7, + TILED_RESOURCES = 8, } +SHADER_REQUIRES_DOUBLES :: SHADER_REQUIRES_FLAGS{.DOUBLES} +SHADER_REQUIRES_EARLY_DEPTH_STENCIL :: SHADER_REQUIRES_FLAGS{.EARLY_DEPTH_STENCIL} +SHADER_REQUIRES_UAVS_AT_EVERY_STAGE :: SHADER_REQUIRES_FLAGS{.UAVS_AT_EVERY_STAGE} +SHADER_REQUIRES_64_UAVS :: SHADER_REQUIRES_FLAGS{._64_UAVS} +SHADER_REQUIRES_MINIMUM_PRECISION :: SHADER_REQUIRES_FLAGS{.MINIMUM_PRECISION} +SHADER_REQUIRES_11_1_DOUBLE_EXTENSIONS :: SHADER_REQUIRES_FLAGS{._11_1_DOUBLE_EXTENSIONS} +SHADER_REQUIRES_11_1_SHADER_EXTENSIONS :: SHADER_REQUIRES_FLAGS{._11_1_SHADER_EXTENSIONS} +SHADER_REQUIRES_LEVEL_9_COMPARISON_FILTERING :: SHADER_REQUIRES_FLAGS{.LEVEL_9_COMPARISON_FILTERING} +SHADER_REQUIRES_TILED_RESOURCES :: SHADER_REQUIRES_FLAGS{.TILED_RESOURCES} + DRIVER_TYPE :: enum i32 { UNKNOWN = 0, HARDWARE = 1, @@ -708,11 +720,12 @@ SHADER_VARIABLE_CLASS :: enum i32 { INTERFACE_POINTER = 7, } -SHADER_VARIABLE_FLAGS :: enum u32 { // TODO: make bit_set - USERPACKED = 0x1, - USED = 0x2, - INTERFACE_POINTER = 0x4, - INTERFACE_PARAMETER = 0x8, +SHADER_VARIABLE_FLAGS :: distinct bit_set[SHADER_VARIABLE_FLAG; u32] +SHADER_VARIABLE_FLAG :: enum u32 { + USERPACKED = 0, + USED = 1, + INTERFACE_POINTER = 2, + INTERFACE_PARAMETER = 3, } SHADER_VARIABLE_TYPE :: enum i32 { @@ -776,14 +789,21 @@ SHADER_VARIABLE_TYPE :: enum i32 { MIN16UINT = 57, } -SHADER_INPUT_FLAGS :: enum u32 { // TODO: make bit_set - USERPACKED = 0x1, - COMPARISON_SAMPLER = 0x2, - TEXTURE_COMPONENT_0 = 0x4, - TEXTURE_COMPONENT_1 = 0x8, +SHADER_INPUT_FLAGS :: distinct bit_set[SHADER_INPUT_FLAG; u32] +SHADER_INPUT_FLAG :: enum u32 { + USERPACKED = 0, + COMPARISON_SAMPLER = 1, + TEXTURE_COMPONENT_0 = 2, + TEXTURE_COMPONENT_1 = 3, TEXTURE_COMPONENTS = 0xc, - UNUSED = 0x10, + UNUSED = 4, } +SHADER_INPUT_FLAG_USERPACKED :: SHADER_INPUT_FLAGS{.USERPACKED} +SHADER_INPUT_FLAG_COMPARISON_SAMPLER :: SHADER_INPUT_FLAGS{.COMPARISON_SAMPLER} +SHADER_INPUT_FLAG_TEXTURE_COMPONENT_0 :: SHADER_INPUT_FLAGS{.TEXTURE_COMPONENT_0} +SHADER_INPUT_FLAG_TEXTURE_COMPONENT_1 :: SHADER_INPUT_FLAGS{.TEXTURE_COMPONENT_1} +SHADER_INPUT_FLAG_TEXTURE_COMPONENTS :: SHADER_INPUT_FLAGS{.TEXTURE_COMPONENT_0, .TEXTURE_COMPONENT_1} +SHADER_INPUT_FLAG_UNUSED :: SHADER_INPUT_FLAGS{.UNUSED} SHADER_INPUT_TYPE :: enum i32 { CBUFFER = 0, @@ -802,8 +822,9 @@ SHADER_INPUT_TYPE :: enum i32 { UAV_FEEDBACKTEXTURE = 13, } -SHADER_CBUFFER_FLAGS :: enum u32 { // TODO: make bit_set - USERPACKED = 0x1, +SHADER_CBUFFER_FLAGS :: distinct bit_set[SHADER_CBUFFER_FLAG; u32] +SHADER_CBUFFER_FLAG :: enum u32 { + USERPACKED = 0, } CBUFFER_TYPE :: enum i32 { @@ -906,10 +927,10 @@ INTERPOLATION_MODE :: enum i32 { LINEAR_NOPERSPECTIVE_SAMPLE = 7, } -PARAMETER_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - IN = 0x1, - OUT = 0x2, +PARAMETER_FLAGS :: distinct bit_set[PARAMETER_FLAG; u32] +PARAMETER_FLAG :: enum u32 { + IN = 0, + OUT = 1, } CDEFAULT :: struct { @@ -1022,43 +1043,46 @@ USAGE :: enum i32 { STAGING = 3, } -BIND_FLAG :: enum u32 { // TODO: make bit_set - VERTEX_BUFFER = 0x1, - INDEX_BUFFER = 0x2, - CONSTANT_BUFFER = 0x4, - SHADER_RESOURCE = 0x8, - STREAM_OUTPUT = 0x10, - RENDER_TARGET = 0x20, - DEPTH_STENCIL = 0x40, - UNORDERED_ACCESS = 0x80, - DECODER = 0x200, - VIDEO_ENCODER = 0x400, +BIND_FLAGS :: distinct bit_set[BIND_FLAG; u32] +BIND_FLAG :: enum u32 { + VERTEX_BUFFER = 0, + INDEX_BUFFER = 1, + CONSTANT_BUFFER = 2, + SHADER_RESOURCE = 3, + STREAM_OUTPUT = 4, + RENDER_TARGET = 5, + DEPTH_STENCIL = 6, + UNORDERED_ACCESS = 7, + DECODER = 9, + VIDEO_ENCODER = 10, } -CPU_ACCESS_FLAG :: enum u32 { // TODO: make bit_set - WRITE = 0x10000, - READ = 0x20000, +CPU_ACCESS_FLAGS :: distinct bit_set[CPU_ACCESS_FLAG; u32] +CPU_ACCESS_FLAG :: enum u32 { + WRITE = 16, + READ = 17, } -RESOURCE_MISC_FLAG :: enum u32 { // TODO: make bit_set - GENERATE_MIPS = 0x1, - SHARED = 0x2, - TEXTURECUBE = 0x4, - DRAWINDIRECT_ARGS = 0x10, - BUFFER_ALLOW_RAW_VIEWS = 0x20, - BUFFER_STRUCTURED = 0x40, - RESOURCE_CLAMP = 0x80, - SHARED_KEYEDMUTEX = 0x100, - GDI_COMPATIBLE = 0x200, - SHARED_NTHANDLE = 0x800, - RESTRICTED_CONTENT = 0x1000, - RESTRICT_SHARED_RESOURCE = 0x2000, - RESTRICT_SHARED_RESOURCE_DRIVER = 0x4000, - GUARDED = 0x8000, - TILE_POOL = 0x20000, - TILED = 0x40000, - HW_PROTECTED = 0x80000, +RESOURCE_MISC_FLAGS :: distinct bit_set[RESOURCE_MISC_FLAG; u32] +RESOURCE_MISC_FLAG :: enum u32 { + GENERATE_MIPS = 0, + SHARED = 1, + TEXTURECUBE = 2, + DRAWINDIRECT_ARGS = 4, + BUFFER_ALLOW_RAW_VIEWS = 5, + BUFFER_STRUCTURED = 6, + RESOURCE_CLAMP = 7, + SHARED_KEYEDMUTEX = 8, + GDI_COMPATIBLE = 9, + SHARED_NTHANDLE = 11, + RESTRICTED_CONTENT = 12, + RESTRICT_SHARED_RESOURCE = 13, + RESTRICT_SHARED_RESOURCE_DRIVER = 14, + GUARDED = 15, + TILE_POOL = 17, + TILED = 18, + HW_PROTECTED = 19, } MAP :: enum i32 { @@ -1069,17 +1093,20 @@ MAP :: enum i32 { WRITE_NO_OVERWRITE = 5, } -MAP_FLAG :: enum u32 { // TODO: make bit_set - DO_NOT_WAIT = 0x100000, +MAP_FLAGS :: distinct bit_set[MAP_FLAG; u32] +MAP_FLAG :: enum u32 { + DO_NOT_WAIT = 20, } -RAISE_FLAG :: enum u32 { // TODO: make bit_set - DRIVER_INTERNAL_ERROR = 0x1, +RAISE_FLAGS :: distinct bit_set[RAISE_FLAG; u32] +RAISE_FLAG :: enum u32 { + DRIVER_INTERNAL_ERROR = 0, } -CLEAR_FLAG :: enum u32 { // TODO: make bit_set - DEPTH = 0x1, - STENCIL = 0x2, +CLEAR_FLAGS :: distinct bit_set[CLEAR_FLAG; u32] +CLEAR_FLAG :: enum u32 { + DEPTH = 0, + STENCIL = 1, } @@ -1206,7 +1233,15 @@ BLEND_OP :: enum i32 { MAX = 5, } -COLOR_WRITE_ENABLE :: enum i32 { // TODO: make bit_set +COLOR_WRITE_ENABLE_MASK :: distinct bit_set[COLOR_WRITE_ENABLE; u32] + +COLOR_WRITE_ENABLE_RED :: COLOR_WRITE_ENABLE_MASK{.RED} +COLOR_WRITE_ENABLE_GREEN :: COLOR_WRITE_ENABLE_MASK{.GREEN} +COLOR_WRITE_ENABLE_BLUE :: COLOR_WRITE_ENABLE_MASK{.BLUE} +COLOR_WRITE_ENABLE_ALPHA :: COLOR_WRITE_ENABLE_MASK{.ALPHA} +COLOR_WRITE_ENABLE_ALL :: COLOR_WRITE_ENABLE_MASK{.RED, .GREEN, .BLUE, .ALPHA} + +COLOR_WRITE_ENABLE :: enum i32 { RED = 1, GREEN = 2, BLUE = 4, @@ -1308,9 +1343,9 @@ IResource_VTable :: struct { BUFFER_DESC :: struct { ByteWidth: u32, Usage: USAGE, - BindFlags: BIND_FLAG, - CPUAccessFlags: CPU_ACCESS_FLAG, - MiscFlags: RESOURCE_MISC_FLAG, + BindFlags: BIND_FLAGS, + CPUAccessFlags: CPU_ACCESS_FLAGS, + MiscFlags: RESOURCE_MISC_FLAGS, StructureByteStride: u32, } @@ -1337,9 +1372,9 @@ TEXTURE1D_DESC :: struct { ArraySize: u32, Format: dxgi.FORMAT, Usage: USAGE, - BindFlags: BIND_FLAG, - CPUAccessFlags: CPU_ACCESS_FLAG, - MiscFlags: RESOURCE_MISC_FLAG, + BindFlags: BIND_FLAGS, + CPUAccessFlags: CPU_ACCESS_FLAGS, + MiscFlags: RESOURCE_MISC_FLAGS, } CTEXTURE1D_DESC :: struct { @@ -1367,9 +1402,9 @@ TEXTURE2D_DESC :: struct { Format: dxgi.FORMAT, SampleDesc: dxgi.SAMPLE_DESC, Usage: USAGE, - BindFlags: BIND_FLAG, - CPUAccessFlags: CPU_ACCESS_FLAG, - MiscFlags: RESOURCE_MISC_FLAG, + BindFlags: BIND_FLAGS, + CPUAccessFlags: CPU_ACCESS_FLAGS, + MiscFlags: RESOURCE_MISC_FLAGS, } CTEXTURE2D_DESC :: struct { @@ -1396,9 +1431,9 @@ TEXTURE3D_DESC :: struct { MipLevels: u32, Format: dxgi.FORMAT, Usage: USAGE, - BindFlags: BIND_FLAG, - CPUAccessFlags: CPU_ACCESS_FLAG, - MiscFlags: RESOURCE_MISC_FLAG, + BindFlags: BIND_FLAGS, + CPUAccessFlags: CPU_ACCESS_FLAGS, + MiscFlags: RESOURCE_MISC_FLAGS, } CTEXTURE3D_DESC :: struct { @@ -1451,14 +1486,15 @@ BUFFER_SRV :: struct { }, } -BUFFEREX_SRV_FLAG :: enum u32 { // TODO: make bit_set - RAW = 0x1, +BUFFEREX_SRV_FLAGS :: distinct bit_set[BUFFEREX_SRV_FLAG; u32] +BUFFEREX_SRV_FLAG :: enum u32 { + RAW = 0, } BUFFEREX_SRV :: struct { FirstElement: u32, NumElements: u32, - Flags: u32, + Flags: BUFFEREX_SRV_FLAGS, } TEX1D_SRV :: struct { @@ -1657,15 +1693,16 @@ TEX2DMS_ARRAY_DSV :: struct { ArraySize: u32, } -DSV_FLAG :: enum u32 { // TODO: make bit_set - DEPTH = 0x1, - STENCIL = 0x2, +DSV_FLAGS :: distinct bit_set[DSV_FLAG; u32] +DSV_FLAG :: enum u32 { + DEPTH = 0, + STENCIL = 1, } DEPTH_STENCIL_VIEW_DESC :: struct { Format: dxgi.FORMAT, ViewDimension: DSV_DIMENSION, - Flags: u32, + Flags: DSV_FLAGS, using _: struct #raw_union { Texture1D: TEX1D_DSV, Texture1DArray: TEX1D_ARRAY_DSV, @@ -1693,16 +1730,17 @@ IDepthStencilView_VTable :: struct { } -BUFFER_UAV_FLAG :: enum u32 { // TODO: make bit_set - RAW = 0x1, - APPEND = 0x2, - COUNTER = 0x4, +BUFFER_UAV_FLAGS :: distinct bit_set[BUFFER_UAV_FLAG; u32] +BUFFER_UAV_FLAG :: enum u32 { + RAW = 0, + APPEND = 1, + COUNTER = 2, } BUFFER_UAV :: struct { FirstElement: u32, NumElements: u32, - Flags: u32, + Flags: BUFFER_UAV_FLAGS, } TEX1D_UAV :: struct { @@ -1961,8 +1999,9 @@ IAsynchronous_VTable :: struct { } -ASYNC_GETDATA_FLAG :: enum u32 { // TODO: make bit_set - DONOTFLUSH = 0x1, +ASYNC_GETDATA_FLAGS :: distinct bit_set[ASYNC_GETDATA_FLAG; u32] +ASYNC_GETDATA_FLAG :: enum u32 { + DONOTFLUSH = 0, } QUERY :: enum i32 { @@ -1984,13 +2023,14 @@ QUERY :: enum i32 { SO_OVERFLOW_PREDICATE_STREAM3 = 15, } -QUERY_MISC_FLAG :: enum u32 { // TODO: make bit_set - QUERY_MISC_PREDICATEHINT = 0x1, +QUERY_MISC_FLAGS :: distinct bit_set[QUERY_MISC_FLAG; u32] +QUERY_MISC_FLAG :: enum u32 { + PREDICATEHINT = 0, } QUERY_DESC :: struct { Query: QUERY, - MiscFlags: RESOURCE_MISC_FLAG, + MiscFlags: QUERY_MISC_FLAGS, } CQUERY_DESC :: struct { @@ -2054,7 +2094,7 @@ COUNTER_TYPE :: enum i32 { COUNTER_DESC :: struct { Counter: COUNTER, - MiscFlags: RESOURCE_MISC_FLAG, + MiscFlags: RESOURCE_MISC_FLAGS, } CCOUNTER_DESC :: struct { @@ -2150,21 +2190,21 @@ FEATURE :: enum i32 { FORMAT_SUPPORT = 2, FORMAT_SUPPORT2 = 3, D3D10_X_HARDWARE_OPTIONS = 4, - OPTIONS = 5, + OPTIONS = 5, ARCHITECTURE_INFO = 6, D3D9_OPTIONS = 7, SHADER_MIN_PRECISION_SUPPORT = 8, D3D9_SHADOW_SUPPORT = 9, - OPTIONS1 = 10, + OPTIONS1 = 10, D3D9_SIMPLE_INSTANCING_SUPPORT = 11, MARKER_SUPPORT = 12, D3D9_OPTIONS1 = 13, - OPTIONS2 = 14, - OPTIONS3 = 15, + OPTIONS2 = 14, + OPTIONS3 = 15, GPU_VIRTUAL_ADDRESS_SUPPORT = 16, - OPTIONS4 = 17, + OPTIONS4 = 17, SHADER_CACHE = 18, - OPTIONS5 = 19, + OPTIONS5 = 19, } FEATURE_DATA_THREADING :: struct { @@ -2285,14 +2325,14 @@ FEATURE_DATA_GPU_VIRTUAL_ADDRESS_SUPPORT :: struct { MaxGPUVirtualAddressBitsPerProcess: u32, } -SHADER_CACHE_SUPPORT_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - AUTOMATIC_INPROC_CACHE = 0x1, - AUTOMATIC_DISK_CACHE = 0x2, +SHADER_CACHE_SUPPORT_FLAGS :: distinct bit_set[SHADER_CACHE_SUPPORT_FLAG; u32] +SHADER_CACHE_SUPPORT_FLAG :: enum u32 { + AUTOMATIC_INPROC_CACHE = 0, + AUTOMATIC_DISK_CACHE = 1, } FEATURE_DATA_SHADER_CACHE :: struct { - SupportFlags: u32, + SupportFlags: SHADER_CACHE_SUPPORT_FLAGS, } SHARED_RESOURCE_TIER :: enum i32 { @@ -2322,7 +2362,7 @@ IDeviceContext_VTable :: struct { VSSetShader: proc "stdcall" (this: ^IDeviceContext, pVertexShader: ^IVertexShader, ppClassInstances: ^^IClassInstance, NumClassInstances: u32), DrawIndexed: proc "stdcall" (this: ^IDeviceContext, IndexCount: u32, StartIndexLocation: u32, BaseVertexLocation: i32), Draw: proc "stdcall" (this: ^IDeviceContext, VertexCount: u32, StartVertexLocation: u32), - Map: proc "stdcall" (this: ^IDeviceContext, pResource: ^IResource, Subresource: u32, MapType: MAP, MapFlags: u32, pMappedResource: ^MAPPED_SUBRESOURCE) -> HRESULT, + Map: proc "stdcall" (this: ^IDeviceContext, pResource: ^IResource, Subresource: u32, MapType: MAP, MapFlags: MAP_FLAGS, pMappedResource: ^MAPPED_SUBRESOURCE) -> HRESULT, Unmap: proc "stdcall" (this: ^IDeviceContext, pResource: ^IResource, Subresource: u32), PSSetConstantBuffers: proc "stdcall" (this: ^IDeviceContext, StartSlot: u32, NumBuffers: u32, ppConstantBuffers: ^^IBuffer), IASetInputLayout: proc "stdcall" (this: ^IDeviceContext, pInputLayout: ^IInputLayout), @@ -2343,7 +2383,7 @@ IDeviceContext_VTable :: struct { GSSetSamplers: proc "stdcall" (this: ^IDeviceContext, StartSlot: u32, NumSamplers: u32, ppSamplers: ^^ISamplerState), OMSetRenderTargets: proc "stdcall" (this: ^IDeviceContext, NumViews: u32, ppRenderTargetViews: ^^IRenderTargetView, pDepthStencilView: ^IDepthStencilView), OMSetRenderTargetsAndUnorderedAccessViews: proc "stdcall" (this: ^IDeviceContext, NumRTVs: u32, ppRenderTargetViews: ^^IRenderTargetView, pDepthStencilView: ^IDepthStencilView, UAVStartSlot: u32, NumUAVs: u32, ppUnorderedAccessViews: ^^IUnorderedAccessView, pUAVInitialCounts: ^u32), - OMSetBlendState: proc "stdcall" (this: ^IDeviceContext, pBlendState: ^IBlendState, BlendFactor: ^[4]f32, SampleMask: u32), + OMSetBlendState: proc "stdcall" (this: ^IDeviceContext, pBlendState: ^IBlendState, BlendFactor: ^[4]f32, SampleMask: COLOR_WRITE_ENABLE_MASK), OMSetDepthStencilState: proc "stdcall" (this: ^IDeviceContext, pDepthStencilState: ^IDepthStencilState, StencilRef: u32), SOSetTargets: proc "stdcall" (this: ^IDeviceContext, NumBuffers: u32, ppSOTargets: ^^IBuffer, pOffsets: ^u32), DrawAuto: proc "stdcall" (this: ^IDeviceContext), @@ -2399,7 +2439,7 @@ IDeviceContext_VTable :: struct { GSGetSamplers: proc "stdcall" (this: ^IDeviceContext, StartSlot: u32, NumSamplers: u32, ppSamplers: ^^ISamplerState), OMGetRenderTargets: proc "stdcall" (this: ^IDeviceContext, NumViews: u32, ppRenderTargetViews: ^^IRenderTargetView, ppDepthStencilView: ^^IDepthStencilView), OMGetRenderTargetsAndUnorderedAccessViews: proc "stdcall" (this: ^IDeviceContext, NumRTVs: u32, ppRenderTargetViews: ^^IRenderTargetView, ppDepthStencilView: ^^IDepthStencilView, UAVStartSlot: u32, NumUAVs: u32, ppUnorderedAccessViews: ^^IUnorderedAccessView), - OMGetBlendState: proc "stdcall" (this: ^IDeviceContext, ppBlendState: ^^IBlendState, BlendFactor: ^[4]f32, pSampleMask: ^u32), + OMGetBlendState: proc "stdcall" (this: ^IDeviceContext, ppBlendState: ^^IBlendState, BlendFactor: ^[4]f32, pSampleMask: ^COLOR_WRITE_ENABLE_MASK), OMGetDepthStencilState: proc "stdcall" (this: ^IDeviceContext, ppDepthStencilState: ^^IDepthStencilState, pStencilRef: ^u32), SOGetTargets: proc "stdcall" (this: ^IDeviceContext, NumBuffers: u32, ppSOTargets: ^^IBuffer), RSGetState: proc "stdcall" (this: ^IDeviceContext, ppRasterizerState: ^^IRasterizerState), @@ -3315,13 +3355,13 @@ IDevice_VTable :: struct { GetCreationFlags: proc "stdcall" (this: ^IDevice) -> u32, GetDeviceRemovedReason: proc "stdcall" (this: ^IDevice) -> HRESULT, GetImmediateContext: proc "stdcall" (this: ^IDevice, ppImmediateContext: ^^IDeviceContext), - SetExceptionMode: proc "stdcall" (this: ^IDevice, RaiseFlags: u32) -> HRESULT, + SetExceptionMode: proc "stdcall" (this: ^IDevice, RaiseFlags: RAISE_FLAGS) -> HRESULT, GetExceptionMode: proc "stdcall" (this: ^IDevice) -> u32, } CREATE_DEVICE_FLAGS :: distinct bit_set[CREATE_DEVICE_FLAG; u32] -CREATE_DEVICE_FLAG :: enum u32 { // TODO: make bit_set +CREATE_DEVICE_FLAG :: enum u32 { SINGLETHREADED = 0, DEBUG = 1, SWITCH_TO_REF = 2, @@ -3367,14 +3407,14 @@ SHADER_BUFFER_DESC :: struct { Type: CBUFFER_TYPE, Variables: u32, Size: u32, - uFlags: u32, + uFlags: SHADER_CBUFFER_FLAGS, } SHADER_VARIABLE_DESC :: struct { Name: cstring, StartOffset: u32, Size: u32, - uFlags: u32, + uFlags: SHADER_VARIABLE_FLAGS, DefaultValue: rawptr, StartTexture: u32, TextureSize: u32, @@ -3443,7 +3483,7 @@ SHADER_INPUT_BIND_DESC :: struct { BindPoint: u32, BindCount: u32, - uFlags: u32, + uFlags: SHADER_INPUT_FLAGS, ReturnType: RESOURCE_RETURN_TYPE, Dimension: SRV_DIMENSION, NumSamples: u32, @@ -3485,7 +3525,7 @@ FUNCTION_DESC :: struct { ConversionInstructionCount: u32, BitwiseInstructionCount: u32, MinFeatureLevel: FEATURE_LEVEL, - RequiredFeatureFlags: u64, + RequiredFeatureFlags: SHADER_REQUIRES_FLAGS, Name: cstring, FunctionParameterCount: i32, @@ -3571,7 +3611,7 @@ IShaderReflection_VTable :: struct { GetNumInterfaceSlots: proc "stdcall" (this: ^IShaderReflection) -> u32, GetMinFeatureLevel: proc "stdcall" (this: ^IShaderReflection, pLevel: ^FEATURE_LEVEL) -> HRESULT, GetThreadGroupSize: proc "stdcall" (this: ^IShaderReflection, pSizeX: ^u32, pSizeY: ^u32, pSizeZ: ^u32) -> u32, - GetRequiresFlags: proc "stdcall" (this: ^IShaderReflection) -> u64, + GetRequiresFlags: proc "stdcall" (this: ^IShaderReflection) -> SHADER_REQUIRES_FLAGS, } @@ -3634,22 +3674,24 @@ IDebug :: struct #raw_union { using id3d11debug_vtable: ^IDebug_VTable, } -RLDO_FLAGS :: enum u32 { // TODO: make bit_set - SUMMARY = 0x1, - DETAIL = 0x2, - IGNORE_INTERNAL = 0x4, +RLDO_FLAGS :: distinct bit_set[RLDO_FLAG; u32] +RLDO_FLAG :: enum u32 { + SUMMARY = 0, + DETAIL = 1, + IGNORE_INTERNAL = 2, } -DEBUG_FEATURE :: enum u32 { // TODO: make bit_set - FLUSH_PER_RENDER_OP = 0x1, - FINISH_PER_RENDER_OP = 0x2, - FEATURE_PRESENT_PER_RENDER_OP = 0x4, +DEBUG_FEATURES :: distinct bit_set[DEBUG_FEATURE; u32] +DEBUG_FEATURE :: enum u32 { + FLUSH_PER_RENDER_OP = 0, + FINISH_PER_RENDER_OP = 1, + FEATURE_PRESENT_PER_RENDER_OP = 2, } IDebug_VTable :: struct { using iunkown_vtable: IUnknown_VTable, - SetFeatureMask: proc "stdcall" (this: ^IDebug, mask: DEBUG_FEATURE) -> HRESULT, - GetFeatureMask: proc "stdcall" (this: ^IDebug) -> DEBUG_FEATURE, + SetFeatureMask: proc "stdcall" (this: ^IDebug, mask: DEBUG_FEATURES) -> HRESULT, + GetFeatureMask: proc "stdcall" (this: ^IDebug) -> DEBUG_FEATURES, SetPresentPerRenderOpDelay: proc "stdcall" (this: ^IDebug, Milliseconds: u32) -> HRESULT, GetPresentPerRenderOpDelay: proc "stdcall" (this: ^IDebug) -> u32, SetSwapChain: proc "stdcall" (this: ^IDebug, pSwapChain: ^dxgi.ISwapChain) -> HRESULT, @@ -3667,7 +3709,7 @@ IInfoQueue :: struct #raw_union { using id3d11infoqueue_vtable: ^IInfoQueue_VTable, } -MESSAGE_SEVERITY :: enum u32 { // TODO: make bit_set +MESSAGE_SEVERITY :: enum u32 { CORRUPTION = 0, ERROR, WARNING, @@ -3675,7 +3717,7 @@ MESSAGE_SEVERITY :: enum u32 { // TODO: make bit_set MESSAGE, // Not supported until D3D 11.1 } -MESSAGE_CATEGORY :: enum u32 { // TODO: make bit_set +MESSAGE_CATEGORY :: enum u32 { APPLICATION_DEFINED = 0, MISCELLANEOUS, INITIALIZATION, @@ -3750,7 +3792,7 @@ IInfoQueue_VTable :: struct { SetMuteDebugOutput: proc "stdcall" (this: ^IInfoQueue, bMute: BOOL), } -MESSAGE_ID :: enum u32 { // TODO: make bit_set +MESSAGE_ID :: enum u32 { UNKNOWN = 0, DEVICE_IASETVERTEXBUFFERS_HAZARD, DEVICE_IASETINDEXBUFFER_HAZARD, From f58f922487cd5b2861b02065bd7f0229facb2199 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Tue, 25 Oct 2022 16:45:38 +0200 Subject: [PATCH 072/110] Detect `which` and complain if not found. --- build_odin.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/build_odin.sh b/build_odin.sh index 4d2e461dd..f131e088d 100755 --- a/build_odin.sh +++ b/build_odin.sh @@ -134,6 +134,14 @@ run_demo() { ./odin run examples/demo/demo.odin -file } +have_which() { + if ! which which > /dev/null 2>&1; then + panic "Could not find \`which\`" + fi +} + +have_which + case $OS in Linux) config_linux From 43890598344842921760b38da846f3248ecbb0e0 Mon Sep 17 00:00:00 2001 From: nowheredevel <113222579+nowheredevel@users.noreply.github.com> Date: Tue, 25 Oct 2022 19:06:15 -0400 Subject: [PATCH 073/110] Fix printf typo in documentation --- core/fmt/fmt_os.odin | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/fmt/fmt_os.odin b/core/fmt/fmt_os.odin index f5c8d75bd..52280a3f7 100644 --- a/core/fmt/fmt_os.odin +++ b/core/fmt/fmt_os.odin @@ -16,7 +16,7 @@ fprintln :: proc(fd: os.Handle, args: ..any, sep := " ") -> int { w := io.to_writer(os.stream_from_handle(fd)) return wprintln(w=w, args=args, sep=sep) } -// fprintf formats according to the specififed format string and writes to fd +// fprintf formats according to the specified format string and writes to fd fprintf :: proc(fd: os.Handle, fmt: string, args: ..any) -> int { w := io.to_writer(os.stream_from_handle(fd)) return wprintf(w, fmt, ..args) @@ -34,12 +34,12 @@ fprint_typeid :: proc(fd: os.Handle, id: typeid) -> (n: int, err: io.Error) { print :: proc(args: ..any, sep := " ") -> int { return fprint(fd=os.stdout, args=args, sep=sep) } // println formats using the default print settings and writes to os.stdout println :: proc(args: ..any, sep := " ") -> int { return fprintln(fd=os.stdout, args=args, sep=sep) } -// printf formats according to the specififed format string and writes to os.stdout +// printf formats according to the specified format string and writes to os.stdout printf :: proc(fmt: string, args: ..any) -> int { return fprintf(os.stdout, fmt, ..args) } // eprint formats using the default print settings and writes to os.stderr eprint :: proc(args: ..any, sep := " ") -> int { return fprint(fd=os.stderr, args=args, sep=sep) } // eprintln formats using the default print settings and writes to os.stderr eprintln :: proc(args: ..any, sep := " ") -> int { return fprintln(fd=os.stderr, args=args, sep=sep) } -// eprintf formats according to the specififed format string and writes to os.stderr +// eprintf formats according to the specified format string and writes to os.stderr eprintf :: proc(fmt: string, args: ..any) -> int { return fprintf(os.stderr, fmt, ..args) } From 7d217269b5b05b10dc45abde1e021dcf5b7eef42 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 26 Oct 2022 13:37:20 +0100 Subject: [PATCH 074/110] Add `Arena_Kind.Buffer` to `core:mem/virtual` --- core/mem/virtual/arena.odin | 51 ++++++++++++++++++++++++++++------- core/mem/virtual/virtual.odin | 4 +++ 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/core/mem/virtual/arena.odin b/core/mem/virtual/arena.odin index 45426eddc..a93430687 100644 --- a/core/mem/virtual/arena.odin +++ b/core/mem/virtual/arena.odin @@ -3,8 +3,9 @@ package mem_virtual import "core:mem" Arena_Kind :: enum uint { - Growing = 0, // chained memory blocks (singly linked list) - Static = 1, // fixed reservation sized + Growing = 0, // Chained memory blocks (singly linked list). + Static = 1, // Fixed reservation sized. + Buffer = 2, // Uses a fixed sized buffer. } Arena :: struct { @@ -28,9 +29,9 @@ DEFAULT_ARENA_STATIC_RESERVE_SIZE :: 1<<30 when size_of(uintptr) == 8 else 1<<27 @(require_results) arena_init_growing :: proc(arena: ^Arena, reserved: uint = DEFAULT_ARENA_GROWING_MINIMUM_BLOCK_SIZE) -> (err: Allocator_Error) { - arena.kind = .Growing - arena.curr_block = memory_block_alloc(0, reserved, {}) or_return - arena.total_used = 0 + arena.kind = .Growing + arena.curr_block = memory_block_alloc(0, reserved, {}) or_return + arena.total_used = 0 arena.total_reserved = arena.curr_block.reserved return } @@ -38,8 +39,31 @@ arena_init_growing :: proc(arena: ^Arena, reserved: uint = DEFAULT_ARENA_GROWING @(require_results) arena_init_static :: proc(arena: ^Arena, reserved: uint, commit_size: uint = DEFAULT_ARENA_STATIC_COMMIT_SIZE) -> (err: Allocator_Error) { - arena.kind = .Static - arena.curr_block = memory_block_alloc(commit_size, reserved, {}) or_return + arena.kind = .Static + arena.curr_block = memory_block_alloc(commit_size, reserved, {}) or_return + arena.total_used = 0 + arena.total_reserved = arena.curr_block.reserved + return +} + +@(require_results) +arena_init_buffer :: proc(arena: ^Arena, buffer: []byte) -> (err: Allocator_Error) { + if len(buffer) < size_of(Memory_Block) { + return .Out_Of_Memory + } + + arena.kind = .Buffer + + mem.zero_slice(buffer) + + block_base := raw_data(buffer) + block := (^Memory_Block)(block_base) + block.base = block_base[size_of(Memory_Block):] + block.reserved = len(buffer) - size_of(Memory_Block) + block.committed = block.reserved + block.used = 0 + + arena.curr_block = block arena.total_used = 0 arena.total_reserved = arena.curr_block.reserved return @@ -80,6 +104,11 @@ arena_alloc :: proc(arena: ^Arena, size: uint, alignment: uint, loc := #caller_l } arena_init_static(arena=arena, reserved=arena.minimum_block_size, commit_size=DEFAULT_ARENA_STATIC_COMMIT_SIZE) or_return } + fallthrough + case .Buffer: + if arena.curr_block == nil { + return nil, .Out_Of_Memory + } data, err = alloc_from_memory_block(arena.curr_block, size, alignment) arena.total_used = arena.curr_block.used } @@ -88,7 +117,7 @@ arena_alloc :: proc(arena: ^Arena, size: uint, alignment: uint, loc := #caller_l arena_static_reset_to :: proc(arena: ^Arena, pos: uint, loc := #caller_location) -> bool { if arena.curr_block != nil { - assert(arena.kind == .Static, "expected a .Static arena", loc) + assert(arena.kind != .Growing, "expected a non .Growing arena", loc) prev_pos := arena.curr_block.used arena.curr_block.used = clamp(pos, 0, arena.curr_block.reserved) @@ -120,7 +149,7 @@ arena_free_all :: proc(arena: ^Arena) { arena_growing_free_last_memory_block(arena) } arena.total_reserved = 0 - case .Static: + case .Static, .Buffer: arena_static_reset_to(arena, 0) } arena.total_used = 0 @@ -128,7 +157,9 @@ arena_free_all :: proc(arena: ^Arena) { arena_destroy :: proc(arena: ^Arena) { arena_free_all(arena) - memory_block_dealloc(arena.curr_block) + if arena.kind != .Buffer { + memory_block_dealloc(arena.curr_block) + } arena.curr_block = nil arena.total_used = 0 arena.total_reserved = 0 diff --git a/core/mem/virtual/virtual.odin b/core/mem/virtual/virtual.odin index c4a475dba..5e831a0c3 100644 --- a/core/mem/virtual/virtual.odin +++ b/core/mem/virtual/virtual.odin @@ -128,6 +128,10 @@ alloc_from_memory_block :: proc(block: ^Memory_Block, min_size, alignment: uint) return nil } + if block == nil { + return nil, .Out_Of_Memory + } + alignment_offset := calc_alignment_offset(block, uintptr(alignment)) size, size_ok := safe_add(min_size, alignment_offset) if !size_ok { From 4003b76fd34325f231418e94ca7f075d15dde733 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 26 Oct 2022 15:00:25 +0100 Subject: [PATCH 075/110] Add `GetSystemTimePreciseAsFileTime` --- core/sys/windows/kernel32.odin | 1 + 1 file changed, 1 insertion(+) diff --git a/core/sys/windows/kernel32.odin b/core/sys/windows/kernel32.odin index 05686b7d2..b8049674b 100644 --- a/core/sys/windows/kernel32.odin +++ b/core/sys/windows/kernel32.odin @@ -248,6 +248,7 @@ foreign kernel32 { GetModuleHandleW :: proc(lpModuleName: LPCWSTR) -> HMODULE --- GetModuleHandleA :: proc(lpModuleName: LPCSTR) -> HMODULE --- GetSystemTimeAsFileTime :: proc(lpSystemTimeAsFileTime: LPFILETIME) --- + GetSystemTimePreciseAsFileTime :: proc(lpSystemTimeAsFileTimeL LPFILETIME) --- CreateEventW :: proc( lpEventAttributes: LPSECURITY_ATTRIBUTES, bManualReset: BOOL, From 7743e34596a8a369334d8e6c2ee872800907d6cb Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 26 Oct 2022 15:01:35 +0100 Subject: [PATCH 076/110] Fix typo --- core/sys/windows/kernel32.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sys/windows/kernel32.odin b/core/sys/windows/kernel32.odin index b8049674b..304710be2 100644 --- a/core/sys/windows/kernel32.odin +++ b/core/sys/windows/kernel32.odin @@ -248,7 +248,7 @@ foreign kernel32 { GetModuleHandleW :: proc(lpModuleName: LPCWSTR) -> HMODULE --- GetModuleHandleA :: proc(lpModuleName: LPCSTR) -> HMODULE --- GetSystemTimeAsFileTime :: proc(lpSystemTimeAsFileTime: LPFILETIME) --- - GetSystemTimePreciseAsFileTime :: proc(lpSystemTimeAsFileTimeL LPFILETIME) --- + GetSystemTimePreciseAsFileTime :: proc(lpSystemTimeAsFileTime: LPFILETIME) --- CreateEventW :: proc( lpEventAttributes: LPSECURITY_ATTRIBUTES, bManualReset: BOOL, From 7bcde35651619f5990234d3e084dcbfdc8e69db4 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 26 Oct 2022 16:05:49 +0100 Subject: [PATCH 077/110] Heavily improve time handling on Windows for `time.now()` and `os.File_Info` --- core/os/dir_windows.odin | 4 +-- core/os/stat_windows.odin | 20 +++++------ core/sys/windows/kernel32.odin | 10 ++++++ core/sys/windows/types.odin | 13 ++++++- core/time/time.odin | 66 +++++++++++++++++----------------- core/time/time_windows.odin | 13 +++++-- 6 files changed, 77 insertions(+), 49 deletions(-) diff --git a/core/os/dir_windows.odin b/core/os/dir_windows.odin index 89a09d403..cf1452abd 100644 --- a/core/os/dir_windows.odin +++ b/core/os/dir_windows.odin @@ -41,9 +41,7 @@ read_dir :: proc(fd: Handle, n: int, allocator := context.allocator) -> (fi: []F // fi.mode |= file_type_mode(h); } - fi.creation_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftCreationTime)) - fi.modification_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftLastWriteTime)) - fi.access_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftLastAccessTime)) + window_set_file_info_times(&fi, d) fi.is_dir = fi.mode & File_Mode_Dir != 0 return diff --git a/core/os/stat_windows.odin b/core/os/stat_windows.odin index 79bb8c42e..54f8003d6 100644 --- a/core/os/stat_windows.odin +++ b/core/os/stat_windows.odin @@ -228,6 +228,13 @@ file_mode_from_file_attributes :: proc(FileAttributes: win32.DWORD, h: win32.HAN return } +@(private) +window_set_file_info_times :: proc(fi: ^File_Info, d: ^$T) { + fi.creation_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftCreationTime)) + fi.modification_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftLastWriteTime)) + fi.access_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftLastAccessTime)) +} + @(private) file_info_from_win32_file_attribute_data :: proc(d: ^win32.WIN32_FILE_ATTRIBUTE_DATA, name: string) -> (fi: File_Info, e: Errno) { fi.size = i64(d.nFileSizeHigh)<<32 + i64(d.nFileSizeLow) @@ -235,9 +242,7 @@ file_info_from_win32_file_attribute_data :: proc(d: ^win32.WIN32_FILE_ATTRIBUTE_ fi.mode |= file_mode_from_file_attributes(d.dwFileAttributes, nil, 0) fi.is_dir = fi.mode & File_Mode_Dir != 0 - fi.creation_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftCreationTime)) - fi.modification_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftLastWriteTime)) - fi.access_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftLastAccessTime)) + window_set_file_info_times(&fi, d) fi.fullpath, e = full_path_from_name(name) fi.name = basename(fi.fullpath) @@ -252,9 +257,7 @@ file_info_from_win32_find_data :: proc(d: ^win32.WIN32_FIND_DATAW, name: string) fi.mode |= file_mode_from_file_attributes(d.dwFileAttributes, nil, 0) fi.is_dir = fi.mode & File_Mode_Dir != 0 - fi.creation_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftCreationTime)) - fi.modification_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftLastWriteTime)) - fi.access_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftLastAccessTime)) + window_set_file_info_times(&fi, d) fi.fullpath, e = full_path_from_name(name) fi.name = basename(fi.fullpath) @@ -290,10 +293,7 @@ file_info_from_get_file_information_by_handle :: proc(path: string, h: win32.HAN fi.mode |= file_mode_from_file_attributes(ti.FileAttributes, h, ti.ReparseTag) fi.is_dir = fi.mode & File_Mode_Dir != 0 - fi.creation_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftCreationTime)) - fi.modification_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftLastWriteTime)) - fi.access_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftLastAccessTime)) - + window_set_file_info_times(&fi, &d) return fi, ERROR_NONE } diff --git a/core/sys/windows/kernel32.odin b/core/sys/windows/kernel32.odin index 304710be2..4f7d24ce8 100644 --- a/core/sys/windows/kernel32.odin +++ b/core/sys/windows/kernel32.odin @@ -249,6 +249,16 @@ foreign kernel32 { GetModuleHandleA :: proc(lpModuleName: LPCSTR) -> HMODULE --- GetSystemTimeAsFileTime :: proc(lpSystemTimeAsFileTime: LPFILETIME) --- GetSystemTimePreciseAsFileTime :: proc(lpSystemTimeAsFileTime: LPFILETIME) --- + FileTimeToSystemTime :: proc(lpFileTime: ^FILETIME, lpSystemTime: ^SYSTEMTIME) -> BOOL --- + SystemTimeToTzSpecificLocalTime :: proc( + lpTimeZoneInformation: ^TIME_ZONE_INFORMATION, + lpUniversalTime: ^SYSTEMTIME, + lpLocalTime: ^SYSTEMTIME, + ) -> BOOL --- + SystemTimeToFileTime :: proc( + lpSystemTime: ^SYSTEMTIME, + lpFileTime: LPFILETIME, + ) -> BOOL --- CreateEventW :: proc( lpEventAttributes: LPSECURITY_ATTRIBUTES, bManualReset: BOOL, diff --git a/core/sys/windows/types.odin b/core/sys/windows/types.odin index af28a9060..62b7d25a7 100644 --- a/core/sys/windows/types.odin +++ b/core/sys/windows/types.odin @@ -2267,9 +2267,10 @@ FILETIME :: struct { FILETIME_as_unix_nanoseconds :: proc "contextless" (ft: FILETIME) -> i64 { t := i64(u64(ft.dwLowDateTime) | u64(ft.dwHighDateTime) << 32) - return (t - 0x019db1ded53e8000) * 100 + return (t - 116444736000000000) * 100 } + OVERLAPPED :: struct { Internal: ^c_ulong, InternalHigh: ^c_ulong, @@ -2943,6 +2944,16 @@ SYSTEMTIME :: struct { milliseconds: WORD, } +TIME_ZONE_INFORMATION :: struct { + Bias: LONG, + StandardName: [32]WCHAR, + StandardDate: SYSTEMTIME, + StandardBias: LONG, + DaylightName: [32]WCHAR, + DaylightDate: SYSTEMTIME, + DaylightBias: LONG, +} + @(private="file") IMAGE_DOS_HEADER :: struct { diff --git a/core/time/time.odin b/core/time/time.odin index 6c6e47dc0..74c80c8f7 100644 --- a/core/time/time.odin +++ b/core/time/time.odin @@ -17,7 +17,7 @@ MAX_DURATION :: Duration(1<<63 - 1) IS_SUPPORTED :: _IS_SUPPORTED Time :: struct { - _nsec: i64, // zero is 1970-01-01 00:00:00 + _nsec: i64, // Measured in UNIX nanonseconds } Month :: enum int { @@ -59,36 +59,36 @@ sleep :: proc "contextless" (d: Duration) { _sleep(d) } -stopwatch_start :: proc(using stopwatch: ^Stopwatch) { +stopwatch_start :: proc "contextless" (using stopwatch: ^Stopwatch) { if !running { _start_time = tick_now() running = true } } -stopwatch_stop :: proc(using stopwatch: ^Stopwatch) { +stopwatch_stop :: proc "contextless" (using stopwatch: ^Stopwatch) { if running { _accumulation += tick_diff(_start_time, tick_now()) running = false } } -stopwatch_reset :: proc(using stopwatch: ^Stopwatch) { +stopwatch_reset :: proc "contextless" (using stopwatch: ^Stopwatch) { _accumulation = {} running = false } -stopwatch_duration :: proc(using stopwatch: Stopwatch) -> Duration { +stopwatch_duration :: proc "contextless" (using stopwatch: Stopwatch) -> Duration { if !running { return _accumulation } return _accumulation + tick_diff(_start_time, tick_now()) } -diff :: proc(start, end: Time) -> Duration { +diff :: proc "contextless" (start, end: Time) -> Duration { d := end._nsec - start._nsec return Duration(d) } -since :: proc(start: Time) -> Duration { +since :: proc "contextless" (start: Time) -> Duration { return diff(start, now()) } @@ -117,8 +117,8 @@ duration_hours :: proc "contextless" (d: Duration) -> f64 { return f64(hour) + f64(nsec)/(60*60*1e9) } -duration_round :: proc(d, m: Duration) -> Duration { - _less_than_half :: #force_inline proc(x, y: Duration) -> bool { +duration_round :: proc "contextless" (d, m: Duration) -> Duration { + _less_than_half :: #force_inline proc "contextless" (x, y: Duration) -> bool { return u64(x)+u64(x) < u64(y) } @@ -146,45 +146,45 @@ duration_round :: proc(d, m: Duration) -> Duration { return MAX_DURATION } -duration_truncate :: proc(d, m: Duration) -> Duration { +duration_truncate :: proc "contextless" (d, m: Duration) -> Duration { return d if m <= 0 else d - d%m } -date :: proc(t: Time) -> (year: int, month: Month, day: int) { +date :: proc "contextless" (t: Time) -> (year: int, month: Month, day: int) { year, month, day, _ = _abs_date(_time_abs(t), true) return } -year :: proc(t: Time) -> (year: int) { +year :: proc "contextless" (t: Time) -> (year: int) { year, _, _, _ = _date(t, true) return } -month :: proc(t: Time) -> (month: Month) { +month :: proc "contextless" (t: Time) -> (month: Month) { _, month, _, _ = _date(t, true) return } -day :: proc(t: Time) -> (day: int) { +day :: proc "contextless" (t: Time) -> (day: int) { _, _, day, _ = _date(t, true) return } clock :: proc { clock_from_time, clock_from_duration, clock_from_stopwatch } -clock_from_time :: proc(t: Time) -> (hour, min, sec: int) { +clock_from_time :: proc "contextless" (t: Time) -> (hour, min, sec: int) { return clock_from_seconds(_time_abs(t)) } -clock_from_duration :: proc(d: Duration) -> (hour, min, sec: int) { +clock_from_duration :: proc "contextless" (d: Duration) -> (hour, min, sec: int) { return clock_from_seconds(u64(d/1e9)) } -clock_from_stopwatch :: proc(s: Stopwatch) -> (hour, min, sec: int) { +clock_from_stopwatch :: proc "contextless" (s: Stopwatch) -> (hour, min, sec: int) { return clock_from_duration(stopwatch_duration(s)) } -clock_from_seconds :: proc(nsec: u64) -> (hour, min, sec: int) { +clock_from_seconds :: proc "contextless" (nsec: u64) -> (hour, min, sec: int) { sec = int(nsec % SECONDS_PER_DAY) hour = sec / SECONDS_PER_HOUR sec -= hour * SECONDS_PER_HOUR @@ -193,11 +193,11 @@ clock_from_seconds :: proc(nsec: u64) -> (hour, min, sec: int) { return } -read_cycle_counter :: proc() -> u64 { +read_cycle_counter :: proc "contextless" () -> u64 { return u64(intrinsics.read_cycle_counter()) } -unix :: proc(sec: i64, nsec: i64) -> Time { +unix :: proc "contextless" (sec: i64, nsec: i64) -> Time { sec, nsec := sec, nsec if nsec < 0 || nsec >= 1e9 { n := nsec / 1e9 @@ -208,20 +208,20 @@ unix :: proc(sec: i64, nsec: i64) -> Time { sec -= 1 } } - return Time{(sec*1e9 + nsec) + UNIX_TO_INTERNAL} + return Time{(sec*1e9 + nsec)} } to_unix_seconds :: time_to_unix -time_to_unix :: proc(t: Time) -> i64 { +time_to_unix :: proc "contextless" (t: Time) -> i64 { return t._nsec/1e9 } to_unix_nanoseconds :: time_to_unix_nano -time_to_unix_nano :: proc(t: Time) -> i64 { +time_to_unix_nano :: proc "contextless" (t: Time) -> i64 { return t._nsec } -time_add :: proc(t: Time, d: Duration) -> Time { +time_add :: proc "contextless" (t: Time, d: Duration) -> Time { return Time{t._nsec + i64(d)} } @@ -231,7 +231,7 @@ time_add :: proc(t: Time, d: Duration) -> Time { // On Windows it depends but is comparable with regular sleep in the worst case. // To get the same kind of accuracy as on Linux, have your program call `win32.time_begin_period(1)` to // tell Windows to use a more accurate timer for your process. -accurate_sleep :: proc(d: Duration) { +accurate_sleep :: proc "contextless" (d: Duration) { to_sleep, estimate, mean, m2, count: Duration to_sleep = d @@ -279,19 +279,19 @@ ABSOLUTE_TO_UNIX :: -UNIX_TO_ABSOLUTE @(private) -_date :: proc(t: Time, full: bool) -> (year: int, month: Month, day: int, yday: int) { +_date :: proc "contextless" (t: Time, full: bool) -> (year: int, month: Month, day: int, yday: int) { year, month, day, yday = _abs_date(_time_abs(t), full) return } @(private) -_time_abs :: proc(t: Time) -> u64 { +_time_abs :: proc "contextless" (t: Time) -> u64 { return u64(t._nsec/1e9 + UNIX_TO_ABSOLUTE) } @(private) -_abs_date :: proc(abs: u64, full: bool) -> (year: int, month: Month, day: int, yday: int) { - _is_leap_year :: proc(year: int) -> bool { +_abs_date :: proc "contextless" (abs: u64, full: bool) -> (year: int, month: Month, day: int, yday: int) { + _is_leap_year :: proc "contextless" (year: int) -> bool { return year%4 == 0 && (year%100 != 0 || year%400 == 0) } @@ -352,9 +352,11 @@ _abs_date :: proc(abs: u64, full: bool) -> (year: int, month: Month, day: int, y return } -datetime_to_time :: proc(year, month, day, hour, minute, second: int, nsec := int(0)) -> (t: Time, ok: bool) { - divmod :: proc(year: int, divisor: int) -> (div: int, mod: int) { - assert(divisor > 0) +datetime_to_time :: proc "contextless" (year, month, day, hour, minute, second: int, nsec := int(0)) -> (t: Time, ok: bool) { + divmod :: proc "contextless" (year: int, divisor: int) -> (div: int, mod: int) { + if divisor <= 0 { + intrinsics.debug_trap() + } div = int(year / divisor) mod = year % divisor return diff --git a/core/time/time_windows.odin b/core/time/time_windows.odin index 20863c323..378b914b0 100644 --- a/core/time/time_windows.odin +++ b/core/time/time_windows.odin @@ -7,9 +7,16 @@ _IS_SUPPORTED :: true _now :: proc "contextless" () -> Time { file_time: win32.FILETIME - win32.GetSystemTimeAsFileTime(&file_time) - ns := win32.FILETIME_as_unix_nanoseconds(file_time) - return Time{_nsec=ns} + + ns: i64 + + // monotonic + win32.GetSystemTimePreciseAsFileTime(&file_time) + + dt := u64(transmute(u64le)file_time) // in 100ns units + ns = i64((dt - 116444736000000000) * 100) // convert to ns + + return unix(0, ns) } _sleep :: proc "contextless" (d: Duration) { From 62ab2987b608b2320c93675d34410c9a59bb578a Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 26 Oct 2022 16:08:49 +0100 Subject: [PATCH 078/110] Change name to `windows_set_file_info_times` --- core/os/dir_windows.odin | 3 +-- core/os/stat_windows.odin | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/core/os/dir_windows.odin b/core/os/dir_windows.odin index cf1452abd..9333548cf 100644 --- a/core/os/dir_windows.odin +++ b/core/os/dir_windows.odin @@ -2,7 +2,6 @@ package os import win32 "core:sys/windows" import "core:strings" -import "core:time" read_dir :: proc(fd: Handle, n: int, allocator := context.allocator) -> (fi: []File_Info, err: Errno) { find_data_to_file_info :: proc(base_path: string, d: ^win32.WIN32_FIND_DATAW) -> (fi: File_Info) { @@ -41,7 +40,7 @@ read_dir :: proc(fd: Handle, n: int, allocator := context.allocator) -> (fi: []F // fi.mode |= file_type_mode(h); } - window_set_file_info_times(&fi, d) + windows_set_file_info_times(&fi, d) fi.is_dir = fi.mode & File_Mode_Dir != 0 return diff --git a/core/os/stat_windows.odin b/core/os/stat_windows.odin index 54f8003d6..c63fb4cf0 100644 --- a/core/os/stat_windows.odin +++ b/core/os/stat_windows.odin @@ -229,7 +229,7 @@ file_mode_from_file_attributes :: proc(FileAttributes: win32.DWORD, h: win32.HAN } @(private) -window_set_file_info_times :: proc(fi: ^File_Info, d: ^$T) { +windows_set_file_info_times :: proc(fi: ^File_Info, d: ^$T) { fi.creation_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftCreationTime)) fi.modification_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftLastWriteTime)) fi.access_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftLastAccessTime)) @@ -242,7 +242,7 @@ file_info_from_win32_file_attribute_data :: proc(d: ^win32.WIN32_FILE_ATTRIBUTE_ fi.mode |= file_mode_from_file_attributes(d.dwFileAttributes, nil, 0) fi.is_dir = fi.mode & File_Mode_Dir != 0 - window_set_file_info_times(&fi, d) + windows_set_file_info_times(&fi, d) fi.fullpath, e = full_path_from_name(name) fi.name = basename(fi.fullpath) @@ -257,7 +257,7 @@ file_info_from_win32_find_data :: proc(d: ^win32.WIN32_FIND_DATAW, name: string) fi.mode |= file_mode_from_file_attributes(d.dwFileAttributes, nil, 0) fi.is_dir = fi.mode & File_Mode_Dir != 0 - window_set_file_info_times(&fi, d) + windows_set_file_info_times(&fi, d) fi.fullpath, e = full_path_from_name(name) fi.name = basename(fi.fullpath) @@ -293,7 +293,7 @@ file_info_from_get_file_information_by_handle :: proc(path: string, h: win32.HAN fi.mode |= file_mode_from_file_attributes(ti.FileAttributes, h, ti.ReparseTag) fi.is_dir = fi.mode & File_Mode_Dir != 0 - window_set_file_info_times(&fi, &d) + windows_set_file_info_times(&fi, &d) return fi, ERROR_NONE } From dcb873c88dedb10b87cc884ded26880a038eb604 Mon Sep 17 00:00:00 2001 From: Oskar Nordquist Date: Wed, 26 Oct 2022 11:21:42 -0400 Subject: [PATCH 079/110] Fix behavior of fmt_string() to not truncate strings to width --- core/fmt/fmt.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin index 7429a093d..1cfd6ea33 100644 --- a/core/fmt/fmt.odin +++ b/core/fmt/fmt.odin @@ -975,7 +975,7 @@ fmt_string :: proc(fi: ^Info, s: string, verb: rune) { } } else { - io.write_string(fi.writer, s[:fi.width], &fi.n) + io.write_string(fi.writer, s, &fi.n) } } else From d19ae37af128a9b50ce94722a6486d3e29d60810 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Thu, 27 Oct 2022 02:39:18 +0200 Subject: [PATCH 080/110] Panic if LLVM > 14. --- build_odin.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/build_odin.sh b/build_odin.sh index f131e088d..5ecb7709a 100755 --- a/build_odin.sh +++ b/build_odin.sh @@ -44,6 +44,12 @@ config_darwin() { fi fi + MAX_LLVM_VERSION=("14.999.999") + if [ $(version $($LLVM_CONFIG --version)) -gt $(version $MAX_LLVM_VERSION) ]; then + echo "Tried to use " $(which $LLVM_CONFIG) "version" $($LLVM_CONFIG --version) + panic "Requirement: llvm-config must be base version smaller than 15" + fi + LDFLAGS="$LDFLAGS -liconv -ldl" CXXFLAGS="$CXXFLAGS $($LLVM_CONFIG --cxxflags --ldflags)" LDFLAGS="$LDFLAGS -lLLVM-C" @@ -97,6 +103,12 @@ config_linux() { panic "Requirement: llvm-config must be base version greater than 11" fi + MAX_LLVM_VERSION=("14.999.999") + if [ $(version $($LLVM_CONFIG --version)) -gt $(version $MAX_LLVM_VERSION) ]; then + echo "Tried to use " $(which $LLVM_CONFIG) "version" $($LLVM_CONFIG --version) + panic "Requirement: llvm-config must be base version smaller than 15" + fi + LDFLAGS="$LDFLAGS -ldl" CXXFLAGS="$CXXFLAGS $($LLVM_CONFIG --cxxflags --ldflags)" LDFLAGS="$LDFLAGS $($LLVM_CONFIG --libs core native --system-libs --libfiles) -Wl,-rpath=\$ORIGIN" From 85a263130d6161e1ceed1d8d82d4c96cd66e87cc Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Thu, 27 Oct 2022 02:55:38 +0200 Subject: [PATCH 081/110] Add LLVM > 14 check to main.cpp for Darwin. --- src/main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index a1daa51d1..4c6eaf521 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -53,6 +53,9 @@ gb_global Timings global_timings = {0}; #if LLVM_VERSION_MAJOR < 11 #error LLVM Version 11+ is required => "brew install llvm@11" #endif + #if LLVM_VERSION_MAJOR > 14 + #error LLVM Version 11..=14 is required => "brew install llvm@14" + #endif #endif #include "query_data.cpp" From 413f96553a912747be89fa79f88d82c6963acfa9 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Fri, 28 Oct 2022 21:38:20 +0200 Subject: [PATCH 082/110] Remove formerly deprecated `-opt` flag. --- src/main.cpp | 52 ++++++++++++++++------------------------------------ 1 file changed, 16 insertions(+), 36 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 4c6eaf521..9ceedbb7a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -591,7 +591,6 @@ enum BuildFlagKind { BuildFlag_SingleFile, BuildFlag_OutFile, - BuildFlag_OptimizationLevel, BuildFlag_OptimizationMode, BuildFlag_ShowTimings, BuildFlag_ShowUnused, @@ -745,13 +744,25 @@ ExactValue build_param_to_exact_value(String name, String param) { return value; } +// Writes a did-you-mean message for formerly deprecated flags. +void did_you_mean_flag(String flag) { + gbAllocator a = heap_allocator(); + String name = copy_string(a, flag); + defer (gb_free(a, name.text)); + string_to_lower(&name); + + if (name == "opt") { + gb_printf_err("`-opt` is an unrecognized option. Did you mean `-o`?"); + return; + } + gb_printf_err("Unknown flag: '%.*s'\n", LIT(flag)); +} bool parse_build_flags(Array args) { auto build_flags = array_make(heap_allocator(), 0, BuildFlag_COUNT); add_flag(&build_flags, BuildFlag_Help, str_lit("help"), BuildFlagParam_None, Command_all); add_flag(&build_flags, BuildFlag_SingleFile, str_lit("file"), BuildFlagParam_None, Command__does_build | Command__does_check); add_flag(&build_flags, BuildFlag_OutFile, str_lit("out"), BuildFlagParam_String, Command__does_build &~ Command_test); - add_flag(&build_flags, BuildFlag_OptimizationLevel, str_lit("opt"), BuildFlagParam_Integer, Command__does_build); add_flag(&build_flags, BuildFlag_OptimizationMode, str_lit("o"), BuildFlagParam_String, Command__does_build); add_flag(&build_flags, BuildFlag_OptimizationMode, str_lit("O"), BuildFlagParam_String, Command__does_build); add_flag(&build_flags, BuildFlag_ShowTimings, str_lit("show-timings"), BuildFlagParam_None, Command__does_check); @@ -853,16 +864,14 @@ bool parse_build_flags(Array args) { break; } } - name = substring(name, 0, end); - if (have_equals && name != "opt") { - gb_printf_err("`flag=value` has been deprecated and will be removed next release. Use `%.*s:` instead.\n", LIT(name)); - } + name = substring(name, 0, end); String param = {}; if (end < flag.len-1) param = substring(flag, 2+end, flag.len); bool is_supported = true; bool found = false; + BuildFlag found_bf = {}; for_array(build_flag_index, build_flags) { BuildFlag bf = build_flags[build_flag_index]; @@ -982,37 +991,8 @@ bool parse_build_flags(Array args) { } break; } - case BuildFlag_OptimizationLevel: { - GB_ASSERT(value.kind == ExactValue_Integer); - if (set_flags[BuildFlag_OptimizationMode]) { - gb_printf_err("Mixture of -opt and -o is not allowed\n"); - bad_flags = true; - break; - } - - build_context.optimization_level = cast(i32)big_int_to_i64(&value.value_integer); - if (build_context.optimization_level < 0 || build_context.optimization_level > 3) { - gb_printf_err("Invalid optimization level for -o:, got %d\n", build_context.optimization_level); - gb_printf_err("Valid optimization levels:\n"); - gb_printf_err("\t0\n"); - gb_printf_err("\t1\n"); - gb_printf_err("\t2\n"); - gb_printf_err("\t3\n"); - bad_flags = true; - } - - // Deprecation warning. - gb_printf_err("`-opt` has been deprecated and will be removed next release. Use `-o:minimal`, etc.\n"); - break; - } case BuildFlag_OptimizationMode: { GB_ASSERT(value.kind == ExactValue_String); - if (set_flags[BuildFlag_OptimizationLevel]) { - gb_printf_err("Mixture of -opt and -o is not allowed\n"); - bad_flags = true; - break; - } - if (value.value_string == "minimal") { build_context.optimization_level = 0; } else if (value.value_string == "size") { @@ -1628,7 +1608,7 @@ bool parse_build_flags(Array args) { gb_printf_err("\n"); bad_flags = true; } else if (!found) { - gb_printf_err("Unknown flag: '%.*s'\n", LIT(name)); + did_you_mean_flag(name); bad_flags = true; } } From ee89c0458fca6322bc4d2ad5844f1b61dd906903 Mon Sep 17 00:00:00 2001 From: Julian Ceipek Date: Sat, 29 Oct 2022 22:19:01 -0400 Subject: [PATCH 083/110] Fix STB lib import references on `ODIN_OS == .Darwin` --- vendor/stb/rect_pack/stb_rect_pack.odin | 2 +- vendor/stb/truetype/stb_truetype.odin | 2 +- vendor/stb/vorbis/stb_vorbis.odin | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/vendor/stb/rect_pack/stb_rect_pack.odin b/vendor/stb/rect_pack/stb_rect_pack.odin index c9f999bf7..8abb4710a 100644 --- a/vendor/stb/rect_pack/stb_rect_pack.odin +++ b/vendor/stb/rect_pack/stb_rect_pack.odin @@ -6,7 +6,7 @@ import c "core:c/libc" when ODIN_OS == .Windows { foreign import lib "../lib/stb_rect_pack.lib" } when ODIN_OS == .Linux { foreign import lib "../lib/stb_rect_pack.a" } -when ODIN_OS == .Darwin { foreign import lib "../lib/stb_rect_pack.a" } +when ODIN_OS == .Darwin { foreign import lib "../lib/darwin/stb_rect_pack.a" } Coord :: distinct c.int _MAXVAL :: max(Coord) diff --git a/vendor/stb/truetype/stb_truetype.odin b/vendor/stb/truetype/stb_truetype.odin index e0c03268e..56bb0667a 100644 --- a/vendor/stb/truetype/stb_truetype.odin +++ b/vendor/stb/truetype/stb_truetype.odin @@ -5,7 +5,7 @@ import stbrp "vendor:stb/rect_pack" when ODIN_OS == .Windows { foreign import stbtt "../lib/stb_truetype.lib" } when ODIN_OS == .Linux { foreign import stbtt "../lib/stb_truetype.a" } -when ODIN_OS == .Darwin { foreign import stbtt "../lib/stb_truetype.a" } +when ODIN_OS == .Darwin { foreign import stbtt "../lib/darwin/stb_truetype.a" } /////////////////////////////////////////////////////////////////////////////// diff --git a/vendor/stb/vorbis/stb_vorbis.odin b/vendor/stb/vorbis/stb_vorbis.odin index 43b9bc715..8804dda80 100644 --- a/vendor/stb/vorbis/stb_vorbis.odin +++ b/vendor/stb/vorbis/stb_vorbis.odin @@ -5,7 +5,7 @@ import c "core:c/libc" when ODIN_OS == .Windows { foreign import lib "../lib/stb_vorbis.lib" } when ODIN_OS == .Linux { foreign import lib "../lib/stb_vorbis.a" } -when ODIN_OS == .Darwin { foreign import lib "../lib/stb_vorbis.a" } +when ODIN_OS == .Darwin { foreign import lib "../lib/darwin/stb_vorbis.a" } From 6a14c3edb42fbbcc9ab0df962458f1da16f6f508 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 30 Oct 2022 22:05:29 +0000 Subject: [PATCH 084/110] Make `raw_data` an intrinsic rather a `@(builtin)` runtime procedure --- core/mem/raw.odin | 8 ++--- core/runtime/core_builtin.odin | 28 ------------------ src/check_builtin.cpp | 53 ++++++++++++++++++++++++++++++++++ src/checker_builtin_procs.hpp | 4 +++ src/llvm_backend_proc.cpp | 31 ++++++++++++++++++++ 5 files changed, 90 insertions(+), 34 deletions(-) diff --git a/core/mem/raw.odin b/core/mem/raw.odin index 8322ace30..144b6c8ab 100644 --- a/core/mem/raw.odin +++ b/core/mem/raw.odin @@ -1,5 +1,6 @@ package mem +import "core:builtin" import "core:runtime" Raw_Any :: runtime.Raw_Any @@ -21,12 +22,7 @@ make_any :: proc "contextless" (data: rawptr, id: typeid) -> any { return transmute(any)Raw_Any{data, id} } -raw_array_data :: runtime.raw_array_data -raw_simd_data :: runtime.raw_simd_data -raw_string_data :: runtime.raw_string_data -raw_slice_data :: runtime.raw_slice_data -raw_dynamic_array_data :: runtime.raw_dynamic_array_data -raw_data :: runtime.raw_data +raw_data :: builtin.raw_data Poly_Raw_Map_Entry :: struct($Key, $Value: typeid) { diff --git a/core/runtime/core_builtin.odin b/core/runtime/core_builtin.odin index b5b003122..b0f4cb25c 100644 --- a/core/runtime/core_builtin.odin +++ b/core/runtime/core_builtin.odin @@ -731,34 +731,6 @@ card :: proc(s: $S/bit_set[$E; $U]) -> int { -@builtin -raw_array_data :: proc "contextless" (a: $P/^($T/[$N]$E)) -> [^]E { - return ([^]E)(a) -} -@builtin -raw_simd_data :: proc "contextless" (a: $P/^($T/#simd[$N]$E)) -> [^]E { - return ([^]E)(a) -} -@builtin -raw_slice_data :: proc "contextless" (s: $S/[]$E) -> [^]E { - ptr := (transmute(Raw_Slice)s).data - return ([^]E)(ptr) -} -@builtin -raw_dynamic_array_data :: proc "contextless" (s: $S/[dynamic]$E) -> [^]E { - ptr := (transmute(Raw_Dynamic_Array)s).data - return ([^]E)(ptr) -} -@builtin -raw_string_data :: proc "contextless" (s: $S/string) -> [^]u8 { - return (transmute(Raw_String)s).data -} - -@builtin -raw_data :: proc{raw_array_data, raw_slice_data, raw_dynamic_array_data, raw_string_data, raw_simd_data} - - - @builtin @(disabled=ODIN_DISABLE_ASSERT) assert :: proc(condition: bool, message := "", loc := #caller_location) { diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index fc889fb28..b8bf1bcc7 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -3651,6 +3651,59 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 operand->mode = Addressing_NoValue; break; + case BuiltinProc_raw_data: + { + Operand x = {}; + check_expr(c, &x, ce->args[0]); + if (x.mode == Addressing_Invalid) { + return false; + } + if (!is_operand_value(x)) { + gbString s = expr_to_string(x.expr); + error(call, "'%.*s' expects a string, slice, dynamic array, or pointer to array type, got %s", LIT(builtin_name), s); + gb_string_free(s); + return false; + } + Type *t = base_type(x.type); + + operand->mode = Addressing_Value; + operand->type = nullptr; + switch (t->kind) { + case Type_Slice: + operand->type = alloc_type_multi_pointer(t->MultiPointer.elem); + break; + case Type_DynamicArray: + operand->type = alloc_type_multi_pointer(t->DynamicArray.elem); + break; + case Type_Basic: + if (t->Basic.kind == Basic_string) { + operand->type = alloc_type_multi_pointer(t_u8); + } + break; + case Type_Pointer: + case Type_MultiPointer: + { + Type *base = base_type(type_deref(t, true)); + switch (base->kind) { + case Type_Array: + case Type_EnumeratedArray: + case Type_SimdVector: + operand->type = alloc_type_multi_pointer(base_array_type(base)); + break; + } + } + break; + } + + if (operand->type == nullptr) { + gbString s = type_to_string(x.type); + error(call, "'%.*s' expects a string, slice, dynamic array, or pointer to array type, got %s", LIT(builtin_name), s); + gb_string_free(s); + return false; + } + } + break; + case BuiltinProc_read_cycle_counter: operand->mode = Addressing_Value; operand->type = t_i64; diff --git a/src/checker_builtin_procs.hpp b/src/checker_builtin_procs.hpp index b8cd84cc6..c59ae7867 100644 --- a/src/checker_builtin_procs.hpp +++ b/src/checker_builtin_procs.hpp @@ -42,6 +42,8 @@ enum BuiltinProcId { BuiltinProc_unreachable, + BuiltinProc_raw_data, + BuiltinProc_DIRECTIVE, // NOTE(bill): This is used for specialized hash-prefixed procedures // "Intrinsics" @@ -338,6 +340,8 @@ gb_global BuiltinProc builtin_procs[BuiltinProc_COUNT] = { {STR_LIT("unreachable"), 0, false, Expr_Expr, BuiltinProcPkg_builtin, /*diverging*/true}, + {STR_LIT("raw_data"), 1, false, Expr_Expr, BuiltinProcPkg_builtin}, + {STR_LIT(""), 0, true, Expr_Expr, BuiltinProcPkg_builtin}, // DIRECTIVE diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp index 4d7896c8a..a88c8f2ee 100644 --- a/src/llvm_backend_proc.cpp +++ b/src/llvm_backend_proc.cpp @@ -1850,6 +1850,37 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, lb_emit_unreachable(p); return {}; + case BuiltinProc_raw_data: + { + lbValue x = lb_build_expr(p, ce->args[0]); + Type *t = base_type(x.type); + lbValue res = {}; + switch (t->kind) { + case Type_Slice: + res = lb_slice_elem(p, x); + res = lb_emit_conv(p, res, tv.type); + break; + case Type_DynamicArray: + res = lb_dynamic_array_elem(p, x); + res = lb_emit_conv(p, res, tv.type); + break; + case Type_Basic: + if (t->Basic.kind == Basic_string) { + res = lb_string_elem(p, x); + res = lb_emit_conv(p, res, tv.type); + } else if (t->Basic.kind == Basic_cstring) { + res = lb_emit_conv(p, x, tv.type); + } + break; + case Type_Pointer: + case Type_MultiPointer: + res = lb_emit_conv(p, x, tv.type); + break; + } + GB_ASSERT(res.value != nullptr); + return res; + } + // "Intrinsics" From 83f3ae14d53bcc5fd16ace676535634e94fdf500 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 30 Oct 2022 22:50:24 +0000 Subject: [PATCH 085/110] Improve SysV ABI LLVM IR generation for development purposes --- src/llvm_abi.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/llvm_abi.cpp b/src/llvm_abi.cpp index 0654ed82a..298041aa6 100644 --- a/src/llvm_abi.cpp +++ b/src/llvm_abi.cpp @@ -537,6 +537,22 @@ namespace lbAbiAmd64SysV { return false; } + bool is_llvm_type_slice_like(LLVMTypeRef type) { + if (!lb_is_type_kind(type, LLVMStructTypeKind)) { + return false; + } + if (LLVMCountStructElementTypes(type) != 2) { + return false; + } + LLVMTypeRef fields[2] = {}; + LLVMGetStructElementTypes(type, fields); + if (!lb_is_type_kind(fields[0], LLVMPointerTypeKind)) { + return false; + } + return lb_is_type_kind(fields[1], LLVMIntegerTypeKind) && lb_sizeof(fields[1]) == 8; + + } + lbArgType amd64_type(LLVMContextRef c, LLVMTypeRef type, Amd64TypeAttributeKind attribute_kind, ProcCallingConvention calling_convention) { if (is_register(type)) { LLVMAttributeRef attribute = nullptr; @@ -559,7 +575,16 @@ namespace lbAbiAmd64SysV { } return lb_arg_type_indirect(type, attribute); } else { - return lb_arg_type_direct(type, llreg(c, cls), nullptr, nullptr); + LLVMTypeRef reg_type = nullptr; + if (is_llvm_type_slice_like(type)) { + // NOTE(bill): This is to make the ABI look closer to what the + // original code is just for slices/strings whilst still adhering + // the ABI rules for SysV + reg_type = type; + } else { + reg_type = llreg(c, cls); + } + return lb_arg_type_direct(type, reg_type, nullptr, nullptr); } } From 8fa571c283dca207e9eae7b2924db3bbc9d6aa39 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 30 Oct 2022 22:58:44 +0000 Subject: [PATCH 086/110] Use direct parameter value in `lb_find_ident` when possible --- src/llvm_backend.hpp | 1 + src/llvm_backend_general.cpp | 9 +++++++++ src/llvm_backend_proc.cpp | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/src/llvm_backend.hpp b/src/llvm_backend.hpp index e69d3a6ed..8bd038c16 100644 --- a/src/llvm_backend.hpp +++ b/src/llvm_backend.hpp @@ -298,6 +298,7 @@ struct lbProcedure { lbBlock * entry_block; lbBlock * curr_block; lbTargetList * target_list; + PtrMap direct_parameters; Ast *curr_stmt; diff --git a/src/llvm_backend_general.cpp b/src/llvm_backend_general.cpp index 0dabee076..18cdd196d 100644 --- a/src/llvm_backend_general.cpp +++ b/src/llvm_backend_general.cpp @@ -2590,6 +2590,15 @@ lbValue lb_find_or_add_entity_string_byte_slice_with_type(lbModule *m, String co lbValue lb_find_ident(lbProcedure *p, lbModule *m, Entity *e, Ast *expr) { + if (e->flags & EntityFlag_Param) { + // NOTE(bill): Bypass the stack copied variable for + // direct parameters as there is no need for the direct load + auto *found = map_get(&p->direct_parameters, e); + if (found) { + return *found; + } + } + auto *found = map_get(&m->values, e); if (found) { auto v = *found; diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp index a88c8f2ee..2347c6bc0 100644 --- a/src/llvm_backend_proc.cpp +++ b/src/llvm_backend_proc.cpp @@ -486,6 +486,8 @@ void lb_begin_procedure_body(lbProcedure *p) { p->entry_block = lb_create_block(p, "entry", true); lb_start_block(p, p->entry_block); + map_init(&p->direct_parameters, heap_allocator()); + GB_ASSERT(p->type != nullptr); lb_ensure_abi_function_type(p->module, p); @@ -539,6 +541,8 @@ void lb_begin_procedure_body(lbProcedure *p) { param.value = value; param.type = e->type; + map_set(&p->direct_parameters, e, param); + lbValue ptr = lb_address_from_load_or_generate_local(p, param); GB_ASSERT(LLVMIsAAllocaInst(ptr.value)); lb_add_entity(p->module, e, ptr); From 9da37ed394d866828cad91b83fe8674a5c3e5775 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 31 Oct 2022 00:04:15 +0000 Subject: [PATCH 087/110] Optimize `#caller_location` and `#location` to use read only data section where possible --- src/llvm_backend.cpp | 4 ++-- src/llvm_backend_const.cpp | 17 +++++++++++++++++ src/llvm_backend_expr.cpp | 4 ++-- src/llvm_backend_proc.cpp | 4 ++-- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp index 5502aaa58..b6e9cc423 100644 --- a/src/llvm_backend.cpp +++ b/src/llvm_backend.cpp @@ -646,7 +646,7 @@ void lb_insert_dynamic_map_key_and_value(lbProcedure *p, lbValue const &map_ptr, args[2] = key_hash; args[3] = key_ptr; args[4] = lb_emit_conv(p, value_addr.addr, t_rawptr); - args[5] = lb_emit_source_code_location(p, node); + args[5] = lb_emit_source_code_location_as_global(p, node); lb_emit_runtime_call(p, "__dynamic_map_set", args); } @@ -662,7 +662,7 @@ void lb_dynamic_map_reserve(lbProcedure *p, lbValue const &map_ptr, isize const args[0] = lb_emit_conv(p, map_ptr, t_rawptr); args[1] = lb_gen_map_header_table_internal(p, type_deref(map_ptr.type)); args[2] = lb_const_int(p->module, t_int, capacity); - args[3] = lb_emit_source_code_location(p, proc_name, pos); + args[3] = lb_emit_source_code_location_as_global(p, proc_name, pos); lb_emit_runtime_call(p, "__dynamic_map_reserve", args); } diff --git a/src/llvm_backend_const.cpp b/src/llvm_backend_const.cpp index 53c7c4dcb..a2209a89f 100644 --- a/src/llvm_backend_const.cpp +++ b/src/llvm_backend_const.cpp @@ -283,6 +283,23 @@ lbValue lb_emit_source_code_location(lbProcedure *p, Ast *node) { return lb_emit_source_code_location(p, proc_name, pos); } +lbValue lb_emit_source_code_location_as_global(lbProcedure *p, String const &procedure, TokenPos const &pos) { + lbValue loc = lb_emit_source_code_location(p, procedure, pos); + lbAddr addr = lb_add_global_generated(p->module, loc.type, loc, nullptr); + lb_make_global_private_const(addr); + return lb_addr_load(p, addr); +} + + +lbValue lb_emit_source_code_location_as_global(lbProcedure *p, Ast *node) { + lbValue loc = lb_emit_source_code_location(p, node); + lbAddr addr = lb_add_global_generated(p->module, loc.type, loc, nullptr); + lb_make_global_private_const(addr); + return lb_addr_load(p, addr); +} + + + LLVMValueRef lb_build_constant_array_values(lbModule *m, Type *type, Type *elem_type, isize count, LLVMValueRef *values, bool allow_local) { bool is_local = allow_local && m->curr_procedure != nullptr; bool is_const = true; diff --git a/src/llvm_backend_expr.cpp b/src/llvm_backend_expr.cpp index 6c046fa4a..f26b990ff 100644 --- a/src/llvm_backend_expr.cpp +++ b/src/llvm_backend_expr.cpp @@ -4232,7 +4232,7 @@ lbAddr lb_build_addr_compound_lit(lbProcedure *p, Ast *expr) { args[1] = size; args[2] = align; args[3] = lb_const_int(p->module, t_int, item_count); - args[4] = lb_emit_source_code_location(p, proc_name, pos); + args[4] = lb_emit_source_code_location_as_global(p, proc_name, pos); lb_emit_runtime_call(p, "__dynamic_array_reserve", args); } @@ -4253,7 +4253,7 @@ lbAddr lb_build_addr_compound_lit(lbProcedure *p, Ast *expr) { args[2] = align; args[3] = lb_emit_conv(p, items, t_rawptr); args[4] = lb_const_int(p->module, t_int, item_count); - args[5] = lb_emit_source_code_location(p, proc_name, pos); + args[5] = lb_emit_source_code_location_as_global(p, proc_name, pos); lb_emit_runtime_call(p, "__dynamic_array_append", args); } break; diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp index 2347c6bc0..ed7587bfd 100644 --- a/src/llvm_backend_proc.cpp +++ b/src/llvm_backend_proc.cpp @@ -1503,7 +1503,7 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, pos = e->token.pos; } - return lb_emit_source_code_location(p, procedure, pos); + return lb_emit_source_code_location_as_global(p, procedure, pos); } case BuiltinProc_type_info_of: { @@ -2874,7 +2874,7 @@ lbValue lb_handle_param_value(lbProcedure *p, Type *parameter_type, ParameterVal if (p->entity != nullptr) { proc_name = p->entity->token.string; } - return lb_emit_source_code_location(p, proc_name, pos); + return lb_emit_source_code_location_as_global(p, proc_name, pos); } case ParameterValue_Value: return lb_build_expr(p, param_value.ast_value); From c39ef1b25cc77f0179156430e45ef1d3c2028b7b Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 31 Oct 2022 00:25:53 +0000 Subject: [PATCH 088/110] Ad-hoc pass source code location directly by pointer without stack copy --- src/llvm_backend.hpp | 2 +- src/llvm_backend_const.cpp | 10 +++++----- src/llvm_backend_proc.cpp | 11 +++++++++-- src/llvm_backend_type.cpp | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/llvm_backend.hpp b/src/llvm_backend.hpp index 8bd038c16..a8ff1571c 100644 --- a/src/llvm_backend.hpp +++ b/src/llvm_backend.hpp @@ -457,7 +457,7 @@ lbValue lb_find_value_from_entity(lbModule *m, Entity *e); void lb_store_type_case_implicit(lbProcedure *p, Ast *clause, lbValue value); lbAddr lb_store_range_stmt_val(lbProcedure *p, Ast *stmt_val, lbValue value); -lbValue lb_emit_source_code_location(lbProcedure *p, String const &procedure, TokenPos const &pos); +lbValue lb_emit_source_code_location_const(lbProcedure *p, String const &procedure, TokenPos const &pos); lbValue lb_handle_param_value(lbProcedure *p, Type *parameter_type, ParameterValue const ¶m_value, TokenPos const &pos); diff --git a/src/llvm_backend_const.cpp b/src/llvm_backend_const.cpp index a2209a89f..a8b66a0ea 100644 --- a/src/llvm_backend_const.cpp +++ b/src/llvm_backend_const.cpp @@ -256,7 +256,7 @@ lbValue lb_expr_untyped_const_to_typed(lbModule *m, Ast *expr, Type *t) { return lb_const_value(m, t, tv.value); } -lbValue lb_emit_source_code_location(lbProcedure *p, String const &procedure, TokenPos const &pos) { +lbValue lb_emit_source_code_location_const(lbProcedure *p, String const &procedure, TokenPos const &pos) { lbModule *m = p->module; LLVMValueRef fields[4] = {}; @@ -271,7 +271,7 @@ lbValue lb_emit_source_code_location(lbProcedure *p, String const &procedure, To return res; } -lbValue lb_emit_source_code_location(lbProcedure *p, Ast *node) { +lbValue lb_emit_source_code_location_const(lbProcedure *p, Ast *node) { String proc_name = {}; if (p->entity) { proc_name = p->entity->token.string; @@ -280,11 +280,11 @@ lbValue lb_emit_source_code_location(lbProcedure *p, Ast *node) { if (node) { pos = ast_token(node).pos; } - return lb_emit_source_code_location(p, proc_name, pos); + return lb_emit_source_code_location_const(p, proc_name, pos); } lbValue lb_emit_source_code_location_as_global(lbProcedure *p, String const &procedure, TokenPos const &pos) { - lbValue loc = lb_emit_source_code_location(p, procedure, pos); + lbValue loc = lb_emit_source_code_location_const(p, procedure, pos); lbAddr addr = lb_add_global_generated(p->module, loc.type, loc, nullptr); lb_make_global_private_const(addr); return lb_addr_load(p, addr); @@ -292,7 +292,7 @@ lbValue lb_emit_source_code_location_as_global(lbProcedure *p, String const &pro lbValue lb_emit_source_code_location_as_global(lbProcedure *p, Ast *node) { - lbValue loc = lb_emit_source_code_location(p, node); + lbValue loc = lb_emit_source_code_location_const(p, node); lbAddr addr = lb_add_global_generated(p->module, loc.type, loc, nullptr); lb_make_global_private_const(addr); return lb_addr_load(p, addr); diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp index ed7587bfd..a9de7b231 100644 --- a/src/llvm_backend_proc.cpp +++ b/src/llvm_backend_proc.cpp @@ -911,6 +911,9 @@ lbValue lb_emit_call(lbProcedure *p, lbValue value, Array const &args, auto processed_args = array_make(permanent_allocator(), 0, args.count); { + + bool is_odin_cc = is_calling_convention_odin(pt->Proc.calling_convention); + lbFunctionType *ft = lb_get_function_type(m, p, pt); bool return_by_pointer = ft->ret.kind == lbArg_Indirect; @@ -946,8 +949,12 @@ lbValue lb_emit_call(lbProcedure *p, lbValue value, Array const &args, } else if (arg->kind == lbArg_Indirect) { lbValue ptr = {}; if (arg->is_byval) { - ptr = lb_copy_value_to_ptr(p, x, original_type, arg->byval_alignment); - } else if (is_calling_convention_odin(pt->Proc.calling_convention)) { + if (is_odin_cc && are_types_identical(original_type, t_source_code_location)) { + ptr = lb_address_from_load_or_generate_local(p, x); + } else { + ptr = lb_copy_value_to_ptr(p, x, original_type, arg->byval_alignment); + } + } else if (is_odin_cc) { // NOTE(bill): Odin parameters are immutable so the original value can be passed if possible // i.e. `T const &` in C++ ptr = lb_address_from_load_or_generate_local(p, x); diff --git a/src/llvm_backend_type.cpp b/src/llvm_backend_type.cpp index 8a0b794bc..4abf674c5 100644 --- a/src/llvm_backend_type.cpp +++ b/src/llvm_backend_type.cpp @@ -235,7 +235,7 @@ void lb_setup_type_info_data(lbProcedure *p) { // NOTE(bill): Setup type_info da } TokenPos pos = t->Named.type_name->token.pos; - lbValue loc = lb_emit_source_code_location(p, proc_name, pos); + lbValue loc = lb_emit_source_code_location_const(p, proc_name, pos); LLVMValueRef vals[4] = { lb_const_string(p->module, t->Named.type_name->token.string).value, From 0e7109cab21f0b028425ca6715b23c1c1b2c025b Mon Sep 17 00:00:00 2001 From: Colin Davidson Date: Mon, 31 Oct 2022 06:08:18 -0700 Subject: [PATCH 089/110] terminate read if we read EOF --- core/os/os_darwin.odin | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/os/os_darwin.odin b/core/os/os_darwin.odin index ac7376752..0a7d7e1fb 100644 --- a/core/os/os_darwin.odin +++ b/core/os/os_darwin.odin @@ -404,6 +404,9 @@ read :: proc(fd: Handle, data: []u8) -> (int, Errno) { if bytes_read == -1 { return bytes_read_total, 1 } + if bytes_read == 0 { + break + } bytes_read_total += bytes_read } From 71eb21aab7bd572c95feb21533eefeb328874a6f Mon Sep 17 00:00:00 2001 From: JopStro Date: Mon, 31 Oct 2022 21:21:10 +0000 Subject: [PATCH 090/110] implement open for wasi_wasm32 target --- core/os/os_wasi.odin | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/core/os/os_wasi.odin b/core/os/os_wasi.odin index 7bab1b949..95e37771e 100644 --- a/core/os/os_wasi.odin +++ b/core/os/os_wasi.odin @@ -24,7 +24,7 @@ O_CLOEXEC :: 0x80000 stdin: Handle = 0 stdout: Handle = 1 stderr: Handle = 2 - +default_dir: Handle = 3 write :: proc(fd: Handle, data: []byte) -> (int, Errno) { iovs := wasi.ciovec_t(data) @@ -47,7 +47,36 @@ read_at :: proc(fd: Handle, data: []byte, offset: i64) -> (int, Errno) { return int(n), Errno(err) } open :: proc(path: string, mode: int = O_RDONLY, perm: int = 0) -> (Handle, Errno) { - return 0, -1 + oflags: wasi.oflags_t + if mode & O_CREATE == O_CREATE { + oflags += {.CREATE} + } + if mode & O_EXCL == O_EXCL { + oflags += {.EXCL} + } + if mode & O_TRUNC == O_TRUNC { + oflags += {.TRUNC} + } + + rights: wasi.rights_t = {.FD_SEEK} + switch mode & (O_RDONLY|O_WRONLY|O_RDWR) { + case O_RDONLY: rights += {.FD_READ} + case O_WRONLY: rights += {.FD_WRITE} + case O_RDWR: rights += {.FD_READ, .FD_WRITE} + } + + fdflags: wasi.fdflags_t + if mode & O_APPEND == O_APPEND { + fdflags += {.APPEND} + } + if mode & O_NONBLOCK == O_NONBLOCK { + fdflags += {.NONBLOCK} + } + if mode & O_SYNC == O_SYNC { + fdflags += {.SYNC} + } + fd, err := wasi.path_open(wasi.fd_t(default_dir),{.SYMLINK_FOLLOW},path,oflags,rights,{},fdflags) + return Handle(fd), Errno(err) } close :: proc(fd: Handle) -> Errno { err := wasi.fd_close(wasi.fd_t(fd)) @@ -96,4 +125,4 @@ heap_free :: proc(ptr: rawptr) { exit :: proc "contextless" (code: int) -> ! { runtime._cleanup_runtime_contextless() wasi.proc_exit(wasi.exitcode_t(code)) -} \ No newline at end of file +} From dad10ef80052d668ad374b99773fa3f7d2fd2f05 Mon Sep 17 00:00:00 2001 From: JopStro Date: Mon, 31 Oct 2022 21:22:55 +0000 Subject: [PATCH 091/110] create _yeild stub for wasi_wasm32 target to avoid compile error --- core/time/time_wasi.odin | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/time/time_wasi.odin b/core/time/time_wasi.odin index 9360e3591..dacf911fc 100644 --- a/core/time/time_wasi.odin +++ b/core/time/time_wasi.odin @@ -22,3 +22,5 @@ _tick_now :: proc "contextless" () -> Tick { return {} } +_yield :: proc "contextless" () { +} From 91ad6b42c5232ebbca22887efffa3f3776011797 Mon Sep 17 00:00:00 2001 From: JopStro Date: Mon, 31 Oct 2022 21:46:47 +0000 Subject: [PATCH 092/110] rename default_dir to current_dir --- core/os/os_wasi.odin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/os/os_wasi.odin b/core/os/os_wasi.odin index 95e37771e..5d77b4d7c 100644 --- a/core/os/os_wasi.odin +++ b/core/os/os_wasi.odin @@ -24,7 +24,7 @@ O_CLOEXEC :: 0x80000 stdin: Handle = 0 stdout: Handle = 1 stderr: Handle = 2 -default_dir: Handle = 3 +current_dir: Handle = 3 write :: proc(fd: Handle, data: []byte) -> (int, Errno) { iovs := wasi.ciovec_t(data) @@ -75,7 +75,7 @@ open :: proc(path: string, mode: int = O_RDONLY, perm: int = 0) -> (Handle, Errn if mode & O_SYNC == O_SYNC { fdflags += {.SYNC} } - fd, err := wasi.path_open(wasi.fd_t(default_dir),{.SYMLINK_FOLLOW},path,oflags,rights,{},fdflags) + fd, err := wasi.path_open(wasi.fd_t(current_dir),{.SYMLINK_FOLLOW},path,oflags,rights,{},fdflags) return Handle(fd), Errno(err) } close :: proc(fd: Handle) -> Errno { From 53a030c65bce3bdf1d68cf9a65ed1a21d0e3ec8f Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Tue, 1 Nov 2022 00:38:54 +0100 Subject: [PATCH 093/110] Clarify -define help. --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 9ceedbb7a..b583e9843 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2039,8 +2039,8 @@ void print_show_help(String const arg0, String const &command) { print_usage_line(3, "import \"shared:foo\""); print_usage_line(0, ""); - print_usage_line(1, "-define:="); - print_usage_line(2, "Defines a global constant with a value"); + print_usage_line(1, "-define:="); + print_usage_line(2, "Defines a scalar boolean, integer or string as global constant"); print_usage_line(2, "Example: -define:SPAM=123"); print_usage_line(2, "To use: #config(SPAM, default_value)"); print_usage_line(0, ""); From 2d5779b66046c8cd75d969bdeb7192cb83f56b90 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Tue, 1 Nov 2022 00:47:16 +0100 Subject: [PATCH 094/110] Add missing newline. --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index b583e9843..ae6bd174a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -752,7 +752,7 @@ void did_you_mean_flag(String flag) { string_to_lower(&name); if (name == "opt") { - gb_printf_err("`-opt` is an unrecognized option. Did you mean `-o`?"); + gb_printf_err("`-opt` is an unrecognized option. Did you mean `-o`?\n"); return; } gb_printf_err("Unknown flag: '%.*s'\n", LIT(flag)); From 4812601e78c10d656ab53ec80fa3fb496a8da5b2 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 1 Nov 2022 12:56:17 +0000 Subject: [PATCH 095/110] Fix #2167 `context.assertion_failure_proc = nil` (context field assignments) --- src/llvm_backend_general.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/llvm_backend_general.cpp b/src/llvm_backend_general.cpp index 18cdd196d..87f8afa05 100644 --- a/src/llvm_backend_general.cpp +++ b/src/llvm_backend_general.cpp @@ -383,16 +383,27 @@ Type *lb_addr_type(lbAddr const &addr) { if (addr.addr.value == nullptr) { return nullptr; } - if (addr.kind == lbAddr_Map) { - Type *t = base_type(addr.map.type); - GB_ASSERT(is_type_map(t)); - return t->Map.value; - } - if (addr.kind == lbAddr_Swizzle) { + switch (addr.kind) { + case lbAddr_Map: + { + Type *t = base_type(addr.map.type); + GB_ASSERT(is_type_map(t)); + return t->Map.value; + } + case lbAddr_Swizzle: return addr.swizzle.type; - } - if (addr.kind == lbAddr_SwizzleLarge) { + case lbAddr_SwizzleLarge: return addr.swizzle_large.type; + case lbAddr_Context: + if (addr.ctx.sel.index.count > 0) { + Type *t = t_context; + for_array(i, addr.ctx.sel.index) { + GB_ASSERT(is_type_struct(t)); + t = base_type(t)->Struct.fields[addr.ctx.sel.index[i]]->type; + } + return t; + } + break; } return type_deref(addr.addr.type); } From 18d7ecc1a5237b7844579492fef9a8abce89e0d8 Mon Sep 17 00:00:00 2001 From: JopStro Date: Tue, 1 Nov 2022 12:56:36 +0000 Subject: [PATCH 096/110] wasi: Add FD_FILESTAT_GET to default file open rights --- core/os/os_wasi.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/os/os_wasi.odin b/core/os/os_wasi.odin index 5d77b4d7c..59eac74a9 100644 --- a/core/os/os_wasi.odin +++ b/core/os/os_wasi.odin @@ -58,7 +58,7 @@ open :: proc(path: string, mode: int = O_RDONLY, perm: int = 0) -> (Handle, Errn oflags += {.TRUNC} } - rights: wasi.rights_t = {.FD_SEEK} + rights: wasi.rights_t = {.FD_SEEK, .FD_FILESTAT_GET} switch mode & (O_RDONLY|O_WRONLY|O_RDWR) { case O_RDONLY: rights += {.FD_READ} case O_WRONLY: rights += {.FD_WRITE} From 411c0add3b2394a222ff341d88aef512c554c050 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 1 Nov 2022 13:03:35 +0000 Subject: [PATCH 097/110] Add safety check for #2161 --- src/checker.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/checker.cpp b/src/checker.cpp index 5bdc5b010..9b2f72205 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -1673,7 +1673,14 @@ bool could_entity_be_lazy(Entity *e, DeclInfo *d) { } void add_entity_and_decl_info(CheckerContext *c, Ast *identifier, Entity *e, DeclInfo *d, bool is_exported) { - GB_ASSERT(identifier->kind == Ast_Ident); + GB_ASSERT(identifier != nullptr); + if (identifier->kind != Ast_Ident) { + // NOTE(bill): This is a safety check + gbString s = expr_to_string(identifier); + error(identifier, "A variable declaration must be an identifer, got %s", s); + gb_string_free(s); + return; + } GB_ASSERT(e != nullptr && d != nullptr); GB_ASSERT(identifier->Ident.token.string == e->token.string); From 2b7ca2bdd6be41abeb8ab5c5fa91f24657996e88 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 1 Nov 2022 13:14:20 +0000 Subject: [PATCH 098/110] Fix #2160 (deep subtyping through `using` of `_`) --- src/llvm_backend_expr.cpp | 51 +++++++++++++++++++-------------------- src/types.cpp | 38 +++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 26 deletions(-) diff --git a/src/llvm_backend_expr.cpp b/src/llvm_backend_expr.cpp index f26b990ff..05a9fdfbf 100644 --- a/src/llvm_backend_expr.cpp +++ b/src/llvm_backend_expr.cpp @@ -1952,34 +1952,33 @@ lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t) { Type *dt = t; GB_ASSERT(is_type_struct(st) || is_type_raw_union(st)); - String field_name = lookup_subtype_polymorphic_field(t, src_type); - if (field_name.len > 0) { - // NOTE(bill): It can be casted - Selection sel = lookup_field(st, field_name, false, true); - if (sel.entity != nullptr) { - if (st_is_ptr) { - lbValue res = lb_emit_deep_field_gep(p, value, sel); - Type *rt = res.type; - if (!are_types_identical(rt, dt) && are_types_identical(type_deref(rt), dt)) { - res = lb_emit_load(p, res); - } - return res; - } else { - if (is_type_pointer(value.type)) { - Type *rt = value.type; - if (!are_types_identical(rt, dt) && are_types_identical(type_deref(rt), dt)) { - value = lb_emit_load(p, value); - } else { - value = lb_emit_deep_field_gep(p, value, sel); - return lb_emit_load(p, value); - } - } - - return lb_emit_deep_field_ev(p, value, sel); - + Selection sel = {}; + sel.index.allocator = heap_allocator(); + defer (array_free(&sel.index)); + if (lookup_subtype_polymorphic_selection(t, src_type, &sel)) { + if (sel.entity == nullptr) { + GB_PANIC("invalid subtype cast %s -> ", type_to_string(src_type), type_to_string(t)); + } + if (st_is_ptr) { + lbValue res = lb_emit_deep_field_gep(p, value, sel); + Type *rt = res.type; + if (!are_types_identical(rt, dt) && are_types_identical(type_deref(rt), dt)) { + res = lb_emit_load(p, res); } + return res; } else { - GB_PANIC("invalid subtype cast %s.%.*s", type_to_string(src_type), LIT(field_name)); + if (is_type_pointer(value.type)) { + Type *rt = value.type; + if (!are_types_identical(rt, dt) && are_types_identical(type_deref(rt), dt)) { + value = lb_emit_load(p, value); + } else { + value = lb_emit_deep_field_gep(p, value, sel); + return lb_emit_load(p, value); + } + } + + return lb_emit_deep_field_ev(p, value, sel); + } } } diff --git a/src/types.cpp b/src/types.cpp index fec324bf4..b9f2b375f 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -2526,6 +2526,44 @@ String lookup_subtype_polymorphic_field(Type *dst, Type *src) { return str_lit(""); } +bool lookup_subtype_polymorphic_selection(Type *dst, Type *src, Selection *sel) { + Type *prev_src = src; + // Type *prev_dst = dst; + src = base_type(type_deref(src)); + // dst = base_type(type_deref(dst)); + bool src_is_ptr = src != prev_src; + // bool dst_is_ptr = dst != prev_dst; + + GB_ASSERT(is_type_struct(src) || is_type_union(src)); + for_array(i, src->Struct.fields) { + Entity *f = src->Struct.fields[i]; + if (f->kind == Entity_Variable && f->flags & EntityFlags_IsSubtype) { + if (are_types_identical(dst, f->type)) { + array_add(&sel->index, cast(i32)i); + sel->entity = f; + return true; + } + if (src_is_ptr && is_type_pointer(dst)) { + if (are_types_identical(type_deref(dst), f->type)) { + array_add(&sel->index, cast(i32)i); + sel->indirect = true; + sel->entity = f; + return true; + } + } + if ((f->flags & EntityFlag_Using) != 0 && is_type_struct(f->type)) { + String name = lookup_subtype_polymorphic_field(dst, f->type); + if (name.len > 0) { + array_add(&sel->index, cast(i32)i); + return lookup_subtype_polymorphic_selection(dst, f->type, sel); + } + } + } + } + return false; +} + + Type *strip_type_aliasing(Type *x) { From 9eec9f57887a3b6d08488997a3a636a41494633f Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Tue, 1 Nov 2022 15:04:44 +0100 Subject: [PATCH 099/110] Add -minimum-os-version flag Allow for Darwin targets to specify the minimum OS version: e.g. -minimum-os-version:12.0.0 --- src/build_settings.cpp | 14 +++++++------- src/main.cpp | 26 ++++++++++++++++---------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/build_settings.cpp b/src/build_settings.cpp index 02de22ec4..97ee9f2a3 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -298,17 +298,17 @@ struct BuildContext { bool ignore_microsoft_magic; bool linker_map_file; - bool use_separate_modules; - bool threaded_checker; + bool use_separate_modules; + bool threaded_checker; - bool show_debug_messages; + bool show_debug_messages; - bool copy_file_contents; + bool copy_file_contents; - bool disallow_rtti; + bool disallow_rtti; RelocMode reloc_mode; - bool disable_red_zone; + bool disable_red_zone; u32 cmd_doc_flags; @@ -326,7 +326,7 @@ struct BuildContext { BlockingMutex target_features_mutex; StringSet target_features_set; String target_features_string; - + String minimum_os_version_string; }; gb_global BuildContext build_context = {0}; diff --git a/src/main.cpp b/src/main.cpp index ae6bd174a..b75137613 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -481,9 +481,9 @@ i32 linker_stage(lbGenerator *gen) { if (build_context.metrics.os == TargetOs_darwin) { // This sets a requirement of Mountain Lion and up, but the compiler doesn't work without this limit. - // NOTE: If you change this (although this minimum is as low as you can go with Odin working) - // make sure to also change the 'mtriple' param passed to 'opt' - if (build_context.metrics.arch == TargetArch_arm64) { + if (build_context.minimum_os_version_string.len) { + link_settings = gb_string_append_fmt(link_settings, " -mmacosx-version-min=%.*s ", LIT(build_context.minimum_os_version_string)); + } else if (build_context.metrics.arch == TargetArch_arm64) { link_settings = gb_string_appendc(link_settings, " -mmacosx-version-min=12.0.0 "); } else { link_settings = gb_string_appendc(link_settings, " -mmacosx-version-min=10.12.0 "); @@ -624,6 +624,7 @@ enum BuildFlagKind { BuildFlag_ExtraAssemblerFlags, BuildFlag_Microarch, BuildFlag_TargetFeatures, + BuildFlag_MinimumOSVersion, BuildFlag_RelocMode, BuildFlag_DisableRedZone, @@ -797,6 +798,7 @@ bool parse_build_flags(Array args) { add_flag(&build_flags, BuildFlag_ExtraAssemblerFlags, str_lit("extra-assembler-flags"), BuildFlagParam_String, Command__does_build); add_flag(&build_flags, BuildFlag_Microarch, str_lit("microarch"), BuildFlagParam_String, Command__does_build); add_flag(&build_flags, BuildFlag_TargetFeatures, str_lit("target-features"), BuildFlagParam_String, Command__does_build); + add_flag(&build_flags, BuildFlag_MinimumOSVersion, str_lit("minimum-os-version"), BuildFlagParam_String, Command__does_build); add_flag(&build_flags, BuildFlag_RelocMode, str_lit("reloc-mode"), BuildFlagParam_String, Command__does_build); add_flag(&build_flags, BuildFlag_DisableRedZone, str_lit("disable-red-zone"), BuildFlagParam_None, Command__does_build); @@ -1361,6 +1363,11 @@ bool parse_build_flags(Array args) { string_to_lower(&build_context.target_features_string); break; } + case BuildFlag_MinimumOSVersion: { + GB_ASSERT(value.kind == ExactValue_String); + build_context.minimum_os_version_string = value.value_string; + break; + } case BuildFlag_RelocMode: { GB_ASSERT(value.kind == ExactValue_String); String v = value.value_string; @@ -1972,12 +1979,6 @@ void print_show_help(String const arg0, String const &command) { print_usage_line(2, "Example: -out:foo.exe"); print_usage_line(0, ""); - print_usage_line(1, "-opt:"); - print_usage_line(2, "Set the optimization level for compilation"); - print_usage_line(2, "Accepted values: 0, 1, 2, 3"); - print_usage_line(2, "Example: -opt:2"); - print_usage_line(0, ""); - print_usage_line(1, "-o:"); print_usage_line(2, "Set the optimization mode for compilation"); print_usage_line(2, "Accepted values: minimal, size, speed"); @@ -2141,6 +2142,12 @@ void print_show_help(String const arg0, String const &command) { } if (run_or_build) { + print_usage_line(1, "-minimum-os-version:"); + print_usage_line(2, "Sets the minimum OS version targeted by the application"); + print_usage_line(2, "e.g. -minimum-os-version:12.0.0"); + print_usage_line(2, "(Only used when target is Darwin)"); + print_usage_line(0, ""); + print_usage_line(1, "-extra-linker-flags:"); print_usage_line(2, "Adds extra linker specific flags in a string"); print_usage_line(0, ""); @@ -2149,7 +2156,6 @@ void print_show_help(String const arg0, String const &command) { print_usage_line(2, "Adds extra assembler specific flags in a string"); print_usage_line(0, ""); - print_usage_line(1, "-microarch:"); print_usage_line(2, "Specifies the specific micro-architecture for the build in a string"); print_usage_line(2, "Examples:"); From c18e98e8c5659610127a24d33cacab2770668b1c Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 1 Nov 2022 14:45:51 +0000 Subject: [PATCH 100/110] Add extra check in `add_entity_and_decl_info` #2161 --- src/checker.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/checker.cpp b/src/checker.cpp index 9b2f72205..dd81e2a48 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -1673,7 +1673,11 @@ bool could_entity_be_lazy(Entity *e, DeclInfo *d) { } void add_entity_and_decl_info(CheckerContext *c, Ast *identifier, Entity *e, DeclInfo *d, bool is_exported) { - GB_ASSERT(identifier != nullptr); + if (identifier == nullptr) { + // NOTE(bill): Should only happen on errors + error(e->token, "Invalid variable declaration"); + return; + } if (identifier->kind != Ast_Ident) { // NOTE(bill): This is a safety check gbString s = expr_to_string(identifier); From 01cdd22a01b4133c791ed1d04ebdf22a044e35b0 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Tue, 1 Nov 2022 15:48:27 +0100 Subject: [PATCH 101/110] Temporarily disable certain tests. --- .github/workflows/ci.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5da70931f..882c21e75 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,10 +38,6 @@ jobs: cd tests/vendor make timeout-minutes: 10 - - name: Odin issues tests - run: | - cd tests/issues - ./run.sh - name: Odin check examples/all for Linux i386 run: ./odin check examples/all -vet -strict-style -target:linux_i386 timeout-minutes: 10 @@ -91,11 +87,6 @@ jobs: cd tests/vendor make timeout-minutes: 10 - - name: Odin issues tests - run: | - cd tests/issues - ./run.sh - timeout-minutes: 10 - name: Odin check examples/all for Darwin arm64 run: ./odin check examples/all -vet -strict-style -target:darwin_arm64 timeout-minutes: 10 @@ -155,10 +146,6 @@ jobs: cd tests\vendor call build.bat timeout-minutes: 10 - - name: Odin issues tests - run: | - cd tests/issues - ./run.bat - name: core:math/big tests shell: cmd run: | From 3b583cbac752435ec9385201f27438c96b6f8f7b Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 2 Nov 2022 00:05:51 +0000 Subject: [PATCH 102/110] Add debug symbols for global constants of integers, bools, enums, runes, & pointers. Variables are namespaced with `pkg::name` or `name` if built-in or the initial package for convenience. --- src/exact_value.cpp | 7 +++ src/llvm_backend.cpp | 27 +++++++++ src/llvm_backend_debug.cpp | 113 +++++++++++++++++++++++++++++++++++++ 3 files changed, 147 insertions(+) diff --git a/src/exact_value.cpp b/src/exact_value.cpp index 1572b564f..659db33b7 100644 --- a/src/exact_value.cpp +++ b/src/exact_value.cpp @@ -499,6 +499,13 @@ i64 exact_value_to_i64(ExactValue v) { } return 0; } +u64 exact_value_to_u64(ExactValue v) { + v = exact_value_to_integer(v); + if (v.kind == ExactValue_Integer) { + return big_int_to_u64(&v.value_integer); + } + return 0; +} f64 exact_value_to_f64(ExactValue v) { v = exact_value_to_float(v); if (v.kind == ExactValue_Float) { diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp index b6e9cc423..1d2c00700 100644 --- a/src/llvm_backend.cpp +++ b/src/llvm_backend.cpp @@ -1736,6 +1736,13 @@ void lb_generate_code(lbGenerator *gen) { lbProcedure *startup_runtime = lb_create_startup_runtime(default_module, startup_type_info, objc_names, global_variables); gb_unused(startup_runtime); + if (build_context.ODIN_DEBUG) { + for_array(i, builtin_pkg->scope->elements.entries) { + Entity *e = builtin_pkg->scope->elements.entries[i].value; + add_debug_info_for_global_constant_from_entity(gen, e); + } + } + TIME_SECTION("LLVM Global Procedures and Types"); for_array(i, info->entities) { Entity *e = info->entities[i]; @@ -1759,6 +1766,11 @@ void lb_generate_code(lbGenerator *gen) { case Entity_TypeName: case Entity_Procedure: break; + case Entity_Constant: + if (build_context.ODIN_DEBUG) { + add_debug_info_for_global_constant_from_entity(gen, e); + } + break; } bool polymorphic_struct = false; @@ -1820,6 +1832,21 @@ void lb_generate_code(lbGenerator *gen) { lb_finalize_objc_names(objc_names); if (build_context.ODIN_DEBUG) { + TIME_SECTION("LLVM Debug Info for global constant value declarations"); + { + // lbModule *m = default_module; + + + } + // if (gen->modules.entries.count == 1) { + // } else { + // for_array(j, gen->modules.entries) { + // lbModule *m = gen->modules.entries[j].value; + // if (m->debug_builder != nullptr) { + // } + // } + // } + TIME_SECTION("LLVM Debug Info Complete Types and Finalize"); for_array(j, gen->modules.entries) { lbModule *m = gen->modules.entries[j].value; diff --git a/src/llvm_backend_debug.cpp b/src/llvm_backend_debug.cpp index 29b0ab488..8a98b7f39 100644 --- a/src/llvm_backend_debug.cpp +++ b/src/llvm_backend_debug.cpp @@ -1080,3 +1080,116 @@ void lb_add_debug_context_variable(lbProcedure *p, lbAddr const &ctx) { lb_add_debug_local_variable(p, ptr, t_context, token); } + + +String debug_info_mangle_constant_name(Entity *e, bool *did_allocate_) { + String name = e->token.string; + if (e->pkg && e->pkg->name.len > 0) { + // NOTE(bill): C++ NONSENSE FOR DEBUG SHITE! + name = concatenate3_strings(heap_allocator(), e->pkg->name, str_lit("::"), name); + if (did_allocate_) *did_allocate_ = true; + } + return name; +} + +void add_debug_info_global_variable_expr(lbModule *m, String const &name, LLVMMetadataRef dtype, LLVMMetadataRef expr) { + LLVMMetadataRef scope = nullptr; + LLVMMetadataRef file = nullptr; + unsigned line = 0; + + LLVMMetadataRef decl = nullptr; + + LLVMDIBuilderCreateGlobalVariableExpression( + m->debug_builder, scope, + cast(char const *)name.text, cast(size_t)name.len, + "", 0, // Linkage + file, line, dtype, + false, // local to unit + expr, decl, 8/*AlignInBits*/); +} + +void add_debug_info_for_global_constant_internal_i64(lbModule *m, Entity *e, LLVMMetadataRef dtype, i64 v) { + LLVMMetadataRef expr = LLVMDIBuilderCreateConstantValueExpression(m->debug_builder, v); + + bool did_allocate = false; + String name = debug_info_mangle_constant_name(e, &did_allocate); + defer (if (did_allocate) { + gb_free(heap_allocator(), name.text); + }); + + add_debug_info_global_variable_expr(m, name, dtype, expr); + if ((e->pkg && e->pkg->kind == Package_Init) || + (e->scope && (e->scope->flags & ScopeFlag_Global))) { + add_debug_info_global_variable_expr(m, e->token.string, dtype, expr); + } +} + +void add_debug_info_for_global_constant_from_entity(lbGenerator *gen, Entity *e) { + if (e == nullptr || e->kind != Entity_Constant) { + return; + } + if (is_blank_ident(e->token)) { + return; + } + lbModule *m = &gen->default_module; + if (USE_SEPARATE_MODULES) { + m = lb_pkg_module(gen, e->pkg); + } + + if (is_type_integer(e->type)) { + ExactValue const &value = e->Constant.value; + if (value.kind == ExactValue_Integer) { + LLVMMetadataRef dtype = nullptr; + i64 v = 0; + bool is_signed = false; + if (big_int_is_neg(&value.value_integer)) { + v = exact_value_to_i64(value); + is_signed = true; + } else { + v = cast(i64)exact_value_to_u64(value); + } + if (is_type_untyped(e->type)) { + dtype = lb_debug_type(m, is_signed ? t_i64 : t_u64); + } else { + dtype = lb_debug_type(m, e->type); + } + + add_debug_info_for_global_constant_internal_i64(m, e, dtype, v); + } + } else if (is_type_rune(e->type)) { + ExactValue const &value = e->Constant.value; + if (value.kind == ExactValue_Integer) { + LLVMMetadataRef dtype = lb_debug_type(m, t_rune); + i64 v = exact_value_to_i64(value); + add_debug_info_for_global_constant_internal_i64(m, e, dtype, v); + } + } else if (is_type_boolean(e->type)) { + ExactValue const &value = e->Constant.value; + if (value.kind == ExactValue_Bool) { + LLVMMetadataRef dtype = lb_debug_type(m, default_type(e->type)); + i64 v = cast(i64)value.value_bool; + + add_debug_info_for_global_constant_internal_i64(m, e, dtype, v); + } + } else if (is_type_enum(e->type)) { + ExactValue const &value = e->Constant.value; + if (value.kind == ExactValue_Integer) { + LLVMMetadataRef dtype = lb_debug_type(m, default_type(e->type)); + i64 v = 0; + if (big_int_is_neg(&value.value_integer)) { + v = exact_value_to_i64(value); + } else { + v = cast(i64)exact_value_to_u64(value); + } + + add_debug_info_for_global_constant_internal_i64(m, e, dtype, v); + } + } else if (is_type_pointer(e->type)) { + ExactValue const &value = e->Constant.value; + if (value.kind == ExactValue_Integer) { + LLVMMetadataRef dtype = lb_debug_type(m, default_type(e->type)); + i64 v = cast(i64)exact_value_to_u64(value); + add_debug_info_for_global_constant_internal_i64(m, e, dtype, v); + } + } +} \ No newline at end of file From b7ea169c8122ddbc56de2ae6bba7d1c9b3bc7600 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 2 Nov 2022 11:36:49 +0000 Subject: [PATCH 103/110] Fixed #2170 --- vendor/directx/d3d11/d3d11.odin | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/vendor/directx/d3d11/d3d11.odin b/vendor/directx/d3d11/d3d11.odin index 42a860c4b..70cc6e9bb 100644 --- a/vendor/directx/d3d11/d3d11.odin +++ b/vendor/directx/d3d11/d3d11.odin @@ -1242,11 +1242,10 @@ COLOR_WRITE_ENABLE_ALPHA :: COLOR_WRITE_ENABLE_MASK{.ALPHA} COLOR_WRITE_ENABLE_ALL :: COLOR_WRITE_ENABLE_MASK{.RED, .GREEN, .BLUE, .ALPHA} COLOR_WRITE_ENABLE :: enum i32 { - RED = 1, - GREEN = 2, - BLUE = 4, - ALPHA = 8, - ALL = 15, + RED = 0, + GREEN = 1, + BLUE = 2, + ALPHA = 3, } RENDER_TARGET_BLEND_DESC :: struct { @@ -2401,7 +2400,7 @@ IDeviceContext_VTable :: struct { ClearRenderTargetView: proc "stdcall" (this: ^IDeviceContext, pRenderTargetView: ^IRenderTargetView, ColorRGBA: ^[4]f32), ClearUnorderedAccessViewUint: proc "stdcall" (this: ^IDeviceContext, pUnorderedAccessView: ^IUnorderedAccessView, Values: ^[4]u32), ClearUnorderedAccessViewFloat: proc "stdcall" (this: ^IDeviceContext, pUnorderedAccessView: ^IUnorderedAccessView, Values: ^[4]f32), - ClearDepthStencilView: proc "stdcall" (this: ^IDeviceContext, pDepthStencilView: ^IDepthStencilView, ClearFlags: CLEAR_FLAG, Depth: f32, Stencil: u8), + ClearDepthStencilView: proc "stdcall" (this: ^IDeviceContext, pDepthStencilView: ^IDepthStencilView, ClearFlags: CLEAR_FLAGS, Depth: f32, Stencil: u8), GenerateMips: proc "stdcall" (this: ^IDeviceContext, pShaderResourceView: ^IShaderResourceView), SetResourceMinLOD: proc "stdcall" (this: ^IDeviceContext, pResource: ^IResource, MinLOD: f32), GetResourceMinLOD: proc "stdcall" (this: ^IDeviceContext, pResource: ^IResource) -> f32, @@ -3734,10 +3733,10 @@ MESSAGE_CATEGORY :: enum u32 { INFO_QUEUE_FILTER_DESC :: struct { NumCategories: u32, pCategoryList: ^MESSAGE_CATEGORY, - + NumSeverities: u32, pSeverityList: ^MESSAGE_SEVERITY, - + NumIDs: u32, pIDList: ^MESSAGE_ID, } From 9e1576418fa3d619bf27af89db77060f68c1b211 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 2 Nov 2022 15:07:09 +0000 Subject: [PATCH 104/110] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9e46f80d0..f99174c46 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ A wiki maintained by the Odin community. #### [Odin Discord](https://discord.gg/sVBPHEv) -Get live support and talk with other odiners on the Odin Discord. +Get live support and talk with other Odin programmers on the Odin Discord. ### Articles From 0ca773114a2959176da06905857cdfc1e1a5327d Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Wed, 2 Nov 2022 16:48:39 +0100 Subject: [PATCH 105/110] Fix os.read implementation on Windows. --- core/os/file_windows.odin | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/os/file_windows.odin b/core/os/file_windows.odin index 8019b0440..91d206d2e 100644 --- a/core/os/file_windows.odin +++ b/core/os/file_windows.odin @@ -162,7 +162,8 @@ read :: proc(fd: Handle, data: []byte) -> (int, Errno) { total_read: int length := len(data) - to_read := min(win32.DWORD(length), MAX_RW) + // NOTE(Jeroen): `length` can't be casted to win32.DWORD here because it'll overflow if > 4 GiB and return 0 if exactly that. + to_read := min(i64(length), MAX_RW) e: win32.BOOL if is_console { @@ -172,7 +173,8 @@ read :: proc(fd: Handle, data: []byte) -> (int, Errno) { return int(total_read), err } } else { - e = win32.ReadFile(handle, &data[total_read], to_read, &single_read_length, nil) + // NOTE(Jeroen): So we cast it here *after* we've ensured that `to_read` is at most MAX_RW (1 GiB) + e = win32.ReadFile(handle, &data[total_read], win32.DWORD(to_read), &single_read_length, nil) } if single_read_length <= 0 || !e { err := Errno(win32.GetLastError()) From 765c1546c580530e20f9b2bd8a94b99c4c1c687a Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 2 Nov 2022 16:43:29 +0000 Subject: [PATCH 106/110] Make many d3d12 flags `enum`s into `bit_set` --- vendor/directx/d3d12/d3d12.odin | 566 +++++++++++++++++--------------- 1 file changed, 294 insertions(+), 272 deletions(-) diff --git a/vendor/directx/d3d12/d3d12.odin b/vendor/directx/d3d12/d3d12.odin index 6a7eed22b..f6c9bb49f 100644 --- a/vendor/directx/d3d12/d3d12.odin +++ b/vendor/directx/d3d12/d3d12.odin @@ -212,11 +212,12 @@ SHADER_VARIABLE_CLASS :: enum i32 { INTERFACE_POINTER = 7, } -SHADER_VARIABLE_FLAGS :: enum u32 { // TODO: make bit_set - USERPACKED = 0x1, - USED = 0x2, - INTERFACE_POINTER = 0x4, - INTERFACE_PARAMETER = 0x8, +SHADER_VARIABLE_FLAGS :: distinct bit_set[SHADER_VARIABLE_FLAG; u32] +SHADER_VARIABLE_FLAG :: enum u32 { + USERPACKED = 0, + USED = 1, + INTERFACE_POINTER = 2, + INTERFACE_PARAMETER = 3, } SHADER_VARIABLE_TYPE :: enum i32 { @@ -280,15 +281,16 @@ SHADER_VARIABLE_TYPE :: enum i32 { MIN16UINT = 57, } -SHADER_INPUT_FLAGS :: enum u32 { // TODO: make bit_set - USERPACKED = 0x1, - COMPARISON_SAMPLER = 0x2, - TEXTURE_COMPONENT_0 = 0x4, - TEXTURE_COMPONENT_1 = 0x8, - TEXTURE_COMPONENTS = 0xc, - UNUSED = 0x10, +SHADER_INPUT_FLAGS :: distinct bit_set[SHADER_INPUT_FLAG; u32] +SHADER_INPUT_FLAG :: enum u32 { + USERPACKED = 0, + COMPARISON_SAMPLER = 1, + TEXTURE_COMPONENT_0 = 2, + TEXTURE_COMPONENT_1 = 3, + UNUSED = 4, } + SHADER_INPUT_TYPE :: enum i32 { CBUFFER = 0, TBUFFER = 1, @@ -306,8 +308,9 @@ SHADER_INPUT_TYPE :: enum i32 { UAV_FEEDBACKTEXTURE = 13, } -SHADER_CBUFFER_FLAGS :: enum u32 { // TODO: make bit_set - USERPACKED = 0x1, +SHADER_CBUFFER_FLAGS :: distinct bit_set[SHADER_CBUFFER_FLAG; u32] +SHADER_CBUFFER_FLAG :: enum u32 { + USERPACKED = 0, } CBUFFER_TYPE :: enum i32 { @@ -410,13 +413,12 @@ INTERPOLATION_MODE :: enum i32 { LINEAR_NOPERSPECTIVE_SAMPLE = 7, } -PARAMETER_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - IN = 0x1, - OUT = 0x2, +PARAMETER_FLAGS :: distinct bit_set[PARAMETER_FLAG; u32] +PARAMETER_FLAG :: enum u32 { + IN = 0, + OUT = 1, } - GPU_VIRTUAL_ADDRESS :: u64 COMMAND_LIST_TYPE :: enum i32 { @@ -429,9 +431,9 @@ COMMAND_LIST_TYPE :: enum i32 { VIDEO_ENCODE = 6, } -COMMAND_QUEUE_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - DISABLE_GPU_TIMEOUT = 0x1, +COMMAND_QUEUE_FLAGS :: distinct bit_set[COMMAND_QUEUE_FLAG; u32] +COMMAND_QUEUE_FLAG :: enum u32 { + DISABLE_GPU_TIMEOUT = 0, } COMMAND_QUEUE_PRIORITY :: enum i32 { @@ -593,12 +595,19 @@ BLEND_OP :: enum i32 { MAX = 5, } -COLOR_WRITE_ENABLE :: enum i32 { // TODO: make bit_set - RED = 1, - GREEN = 2, - BLUE = 4, - ALPHA = 8, - ALL = 15, +COLOR_WRITE_ENABLE_MASK :: distinct bit_set[COLOR_WRITE_ENABLE; u32] + +COLOR_WRITE_ENABLE_RED :: COLOR_WRITE_ENABLE_MASK{.RED} +COLOR_WRITE_ENABLE_GREEN :: COLOR_WRITE_ENABLE_MASK{.GREEN} +COLOR_WRITE_ENABLE_BLUE :: COLOR_WRITE_ENABLE_MASK{.BLUE} +COLOR_WRITE_ENABLE_ALPHA :: COLOR_WRITE_ENABLE_MASK{.ALPHA} +COLOR_WRITE_ENABLE_ALL :: COLOR_WRITE_ENABLE_MASK{.RED, .GREEN, .BLUE, .ALPHA} + +COLOR_WRITE_ENABLE :: enum i32 { + RED = 0, + GREEN = 1, + BLUE = 2, + ALPHA = 3, } LOGIC_OP :: enum i32 { @@ -721,9 +730,9 @@ CACHED_PIPELINE_STATE :: struct { CachedBlobSizeInBytes: SIZE_T, } -PIPELINE_STATE_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - TOOL_DEBUG = 0x1, +PIPELINE_STATE_FLAGS :: distinct bit_set[PIPELINE_STATE_FLAG; u32] +PIPELINE_STATE_FLAG :: enum u32 { + TOOL_DEBUG = 0, } GRAPHICS_PIPELINE_STATE_DESC :: struct { @@ -853,58 +862,61 @@ CONSERVATIVE_RASTERIZATION_TIER :: enum i32 { _3 = 3, } -FORMAT_SUPPORT1 :: enum i32 { // TODO: make bit_set - NONE = 0, - BUFFER = 1, - IA_VERTEX_BUFFER = 2, - IA_INDEX_BUFFER = 4, - SO_BUFFER = 8, - TEXTURE1D = 16, - TEXTURE2D = 32, - TEXTURE3D = 64, - TEXTURECUBE = 128, - SHADER_LOAD = 256, - SHADER_SAMPLE = 512, - SHADER_SAMPLE_COMPARISON = 1024, - SHADER_SAMPLE_MONO_TEXT = 2048, - MIP = 4096, - RENDER_TARGET = 16384, - BLENDABLE = 32768, - DEPTH_STENCIL = 65536, - MULTISAMPLE_RESOLVE = 262144, - DISPLAY = 524288, - CAST_WITHIN_BIT_LAYOUT = 1048576, - MULTISAMPLE_RENDERTARGET = 2097152, - MULTISAMPLE_LOAD = 4194304, - SHADER_GATHER = 8388608, - BACK_BUFFER_CAST = 16777216, - TYPED_UNORDERED_ACCESS_VIEW = 33554432, - SHADER_GATHER_COMPARISON = 67108864, - DECODER_OUTPUT = 134217728, - VIDEO_PROCESSOR_OUTPUT = 268435456, - VIDEO_PROCESSOR_INPUT = 536870912, - VIDEO_ENCODER = 1073741824, +FORMAT_SUPPORT1 :: distinct bit_set[FORMAT_SUPPORT1_FLAG; u32] +FORMAT_SUPPORT1_FLAG :: enum i32 { + BUFFER = 0, + IA_VERTEX_BUFFER = 1, + IA_INDEX_BUFFER = 2, + SO_BUFFER = 3, + TEXTURE1D = 4, + TEXTURE2D = 5, + TEXTURE3D = 6, + TEXTURECUBE = 7, + SHADER_LOAD = 8, + SHADER_SAMPLE = 9, + SHADER_SAMPLE_COMPARISON = 10, + SHADER_SAMPLE_MONO_TEXT = 11, + MIP = 12, + + RENDER_TARGET = 14, + BLENDABLE = 15, + DEPTH_STENCIL = 16, + + MULTISAMPLE_RESOLVE = 18, + DISPLAY = 19, + CAST_WITHIN_BIT_LAYOUT = 20, + MULTISAMPLE_RENDERTARGET = 21, + MULTISAMPLE_LOAD = 22, + SHADER_GATHER = 23, + BACK_BUFFER_CAST = 24, + TYPED_UNORDERED_ACCESS_VIEW = 25, + SHADER_GATHER_COMPARISON = 26, + DECODER_OUTPUT = 27, + VIDEO_PROCESSOR_OUTPUT = 28, + VIDEO_PROCESSOR_INPUT = 29, + VIDEO_ENCODER = 30, } -FORMAT_SUPPORT2 :: enum i32 { // TODO: make bit_set - NONE = 0, - UAV_ATOMIC_ADD = 1, - UAV_ATOMIC_BITWISE_OPS = 2, - UAV_ATOMIC_COMPARE_STORE_OR_COMPARE_EXCHANGE = 4, - UAV_ATOMIC_EXCHANGE = 8, - UAV_ATOMIC_SIGNED_MIN_OR_MAX = 16, - UAV_ATOMIC_UNSIGNED_MIN_OR_MAX = 32, - UAV_TYPED_LOAD = 64, - UAV_TYPED_STORE = 128, - OUTPUT_MERGER_LOGIC_OP = 256, - TILED = 512, - MULTIPLANE_OVERLAY = 16384, - SAMPLER_FEEDBACK = 32768, +FORMAT_SUPPORT2 :: distinct bit_set[FORMAT_SUPPORT2_FLAG; u32] +FORMAT_SUPPORT2_FLAG :: enum i32 { + UAV_ATOMIC_ADD = 0, + UAV_ATOMIC_BITWISE_OPS = 1, + UAV_ATOMIC_COMPARE_STORE_OR_COMPARE_EXCHANGE = 2, + UAV_ATOMIC_EXCHANGE = 3, + UAV_ATOMIC_SIGNED_MIN_OR_MAX = 4, + UAV_ATOMIC_UNSIGNED_MIN_OR_MAX = 5, + UAV_TYPED_LOAD = 6, + UAV_TYPED_STORE = 7, + OUTPUT_MERGER_LOGIC_OP = 8, + TILED = 9, + + MULTIPLANE_OVERLAY = 14, + SAMPLER_FEEDBACK = 15, } -MULTISAMPLE_QUALITY_LEVEL_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - TILED_RESOURCE = 0x1, +MULTISAMPLE_QUALITY_LEVEL_FLAGS :: distinct bit_set[MULTISAMPLE_QUALITY_LEVEL_FLAG; u32] +MULTISAMPLE_QUALITY_LEVEL_FLAG :: enum u32 { + TILED_RESOURCE = 0, } CROSS_NODE_SHARING_TIER :: enum i32 { @@ -1034,12 +1046,12 @@ FEATURE_DATA_GPU_VIRTUAL_ADDRESS_SUPPORT :: struct { MaxGPUVirtualAddressBitsPerProcess: u32, } -SHADER_CACHE_SUPPORT_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - SINGLE_PSO = 0x1, - LIBRARY = 0x2, - AUTOMATIC_INPROC_CACHE = 0x4, - AUTOMATIC_DISK_CACHE = 0x8, +SHADER_CACHE_SUPPORT_FLAGS :: distinct bit_set[SHADER_CACHE_SUPPORT_FLAG; u32] +SHADER_CACHE_SUPPORT_FLAG :: enum u32 { + SINGLE_PSO = 0, + LIBRARY = 1, + AUTOMATIC_INPROC_CACHE = 2, + AUTOMATIC_DISK_CACHE = 3, } FEATURE_DATA_SHADER_CACHE :: struct { @@ -1052,15 +1064,15 @@ FEATURE_DATA_COMMAND_QUEUE_PRIORITY :: struct { PriorityForTypeIsSupported: BOOL, } -COMMAND_LIST_SUPPORT_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - DIRECT = 0x1, - BUNDLE = 0x2, - COMPUTE = 0x4, - COPY = 0x8, - VIDEO_DECODE = 0x10, - VIDEO_PROCESS = 0x20, - VIDEO_ENCODE = 0x40, +COMMAND_LIST_SUPPORT_FLAGS :: distinct bit_set[COMMAND_LIST_SUPPORT_FLAG; u32] +COMMAND_LIST_SUPPORT_FLAG :: enum u32 { + DIRECT = 0, + BUNDLE = 1, + COMPUTE = 2, + COPY = 3, + VIDEO_DECODE = 4, + VIDEO_PROCESS = 5, + VIDEO_ENCODE = 6, } FEATURE_DATA_OPTIONS3 :: struct { @@ -1198,25 +1210,26 @@ HEAP_PROPERTIES :: struct { VisibleNodeMask: u32, } -HEAP_FLAGS :: enum u32 { // TODO: make bit_set ??? - NONE = 0x0, - SHARED = 0x1, - DENY_BUFFERS = 0x4, - ALLOW_DISPLAY = 0x8, - SHARED_CROSS_ADAPTER = 0x20, - DENY_RT_DS_TEXTURES = 0x40, - DENY_NON_RT_DS_TEXTURES = 0x80, - HARDWARE_PROTECTED = 0x100, - ALLOW_WRITE_WATCH = 0x200, - ALLOW_SHADER_ATOMICS = 0x400, - CREATE_NOT_RESIDENT = 0x800, - CREATE_NOT_ZEROED = 0x1000, - ALLOW_ALL_BUFFERS_AND_TEXTURES = 0x0, - ALLOW_ONLY_BUFFERS = 0xc0, - ALLOW_ONLY_NON_RT_DS_TEXTURES = 0x44, - ALLOW_ONLY_RT_DS_TEXTURES = 0x84, +HEAP_FLAGS :: distinct bit_set[HEAP_FLAG; u32] +HEAP_FLAG :: enum u32 { + SHARED = 0, + DENY_BUFFERS = 2, + ALLOW_DISPLAY = 3, + SHARED_CROSS_ADAPTER = 5, + DENY_RT_DS_TEXTURES = 6, + DENY_NON_RT_DS_TEXTURES = 7, + HARDWARE_PROTECTED = 8, + ALLOW_WRITE_WATCH = 9, + ALLOW_SHADER_ATOMICS = 10, + CREATE_NOT_RESIDENT = 11, + CREATE_NOT_ZEROED = 12, } +HEAP_FLAG_ALLOW_ALL_BUFFERS_AND_TEXTURES :: HEAP_FLAGS{} +HEAP_FLAG_ALLOW_ONLY_BUFFERS :: HEAP_FLAGS{.DENY_BUFFERS, .ALLOW_DISPLAY} +HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES :: HEAP_FLAGS{.DENY_BUFFERS, .DENY_RT_DS_TEXTURES} +HEAP_FLAG_ALLOW_ONLY_RT_DS_TEXTURES :: HEAP_FLAGS{.DENY_BUFFERS, .DENY_NON_RT_DS_TEXTURES} + HEAP_DESC :: struct { SizeInBytes: u64, Properties: HEAP_PROPERTIES, @@ -1239,15 +1252,15 @@ TEXTURE_LAYOUT :: enum i32 { _64KB_STANDARD_SWIZZLE = 3, } -RESOURCE_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - ALLOW_RENDER_TARGET = 0x1, - ALLOW_DEPTH_STENCIL = 0x2, - ALLOW_UNORDERED_ACCESS = 0x4, - DENY_SHADER_RESOURCE = 0x8, - ALLOW_CROSS_ADAPTER = 0x10, - ALLOW_SIMULTANEOUS_ACCESS = 0x20, - VIDEO_DECODE_REFERENCE_ONLY = 0x40, +RESOURCE_FLAGS :: distinct bit_set[RESOURCE_FLAG; u32] +RESOURCE_FLAG :: enum u32 { + ALLOW_RENDER_TARGET = 0, + ALLOW_DEPTH_STENCIL = 1, + ALLOW_UNORDERED_ACCESS = 2, + DENY_SHADER_RESOURCE = 3, + ALLOW_CROSS_ADAPTER = 4, + ALLOW_SIMULTANEOUS_ACCESS = 5, + VIDEO_DECODE_REFERENCE_ONLY = 6, } MIP_REGION :: struct { @@ -1332,11 +1345,11 @@ TILE_REGION_SIZE :: struct { Depth: u16, } -TILE_RANGE_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - NULL = 0x1, - SKIP = 0x2, - REUSE_SINGLE_TILE = 0x4, +TILE_RANGE_FLAGS :: distinct bit_set[TILE_RANGE_FLAG; u32] +TILE_RANGE_FLAG :: enum u32 { + NULL = 0, + SKIP = 1, + REUSE_SINGLE_TILE = 2, } SUBRESOURCE_TILING :: struct { @@ -1359,12 +1372,13 @@ PACKED_MIP_INFO :: struct { StartTileIndexInOverallResource: u32, } -TILE_MAPPING_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - NO_HAZARD = 0x1, +TILE_MAPPING_FLAGS :: distinct bit_set[TILE_MAPPING_FLAG; u32] +TILE_MAPPING_FLAG :: enum u32 { + NO_HAZARD = 0, } -TILE_COPY_FLAGS :: enum u32 { // TODO: make bit_set +TILE_COPY_FLAGS :: distinct bit_set[TILE_COPY_FLAG; u32] +TILE_COPY_FLAG :: enum u32 { NONE = 0x0, NO_HAZARD = 0x1, LINEAR_BUFFER_TO_SWIZZLED_TILED_RESOURCE = 0x2, @@ -1422,10 +1436,10 @@ RESOURCE_UAV_BARRIER :: struct { pResource: ^IResource, } -RESOURCE_BARRIER_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - BEGIN_ONLY = 0x1, - END_ONLY = 0x2, +RESOURCE_BARRIER_FLAGS :: distinct bit_set[RESOURCE_BARRIER_FLAG; u32] +RESOURCE_BARRIER_FLAG :: enum u32 { + BEGIN_ONLY = 0, + END_ONLY = 1, } RESOURCE_BARRIER :: struct { @@ -1484,9 +1498,9 @@ VIEW_INSTANCE_LOCATION :: struct { RenderTargetArrayIndex: u32, } -VIEW_INSTANCING_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - ENABLE_VIEW_INSTANCE_MASKING = 0x1, +VIEW_INSTANCING_FLAGS :: distinct bit_set[VIEW_INSTANCING_FLAG; u32] +VIEW_INSTANCING_FLAG :: enum u32 { + ENABLE_VIEW_INSTANCE_MASKING = 0, } VIEW_INSTANCING_DESC :: struct { @@ -1504,9 +1518,9 @@ SHADER_COMPONENT_MAPPING :: enum i32 { FORCE_VALUE_1 = 5, } -BUFFER_SRV_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - RAW = 0x1, +BUFFER_SRV_FLAGS :: distinct bit_set[BUFFER_SRV_FLAG; u32] +BUFFER_SRV_FLAG :: enum u32 { + RAW = 0, } BUFFER_SRV :: struct { @@ -1675,9 +1689,9 @@ SAMPLER_DESC :: struct { MaxLOD: f32, } -BUFFER_UAV_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - RAW = 0x1, +BUFFER_UAV_FLAGS :: distinct bit_set[BUFFER_UAV_FLAG; u32] +BUFFER_UAV_FLAG :: enum u32 { + RAW = 0, } BUFFER_UAV :: struct { @@ -1837,10 +1851,10 @@ TEX2DMS_ARRAY_DSV :: struct { ArraySize: u32, } -DSV_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - READ_ONLY_DEPTH = 0x1, - READ_ONLY_STENCIL = 0x2, +DSV_FLAGS :: distinct bit_set[DSV_FLAG; u32] +DSV_FLAG :: enum u32 { + READ_ONLY_DEPTH = 0, + READ_ONLY_STENCIL = 1, } DSV_DIMENSION :: enum i32 { @@ -1867,16 +1881,17 @@ DEPTH_STENCIL_VIEW_DESC :: struct { }, } -CLEAR_FLAGS :: enum u32 { // TODO: make bit_set - DEPTH = 0x1, - STENCIL = 0x2, +CLEAR_FLAGS :: distinct bit_set[CLEAR_FLAG; u32] +CLEAR_FLAG :: enum u32 { + DEPTH = 0, + STENCIL = 1, } -FENCE_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - SHARED = 0x1, - SHARED_CROSS_ADAPTER = 0x2, - NON_MONITORED = 0x4, +FENCE_FLAGS :: distinct bit_set[FENCE_FLAG; u32] +FENCE_FLAG :: enum u32 { + SHARED = 0, + SHARED_CROSS_ADAPTER = 1, + NON_MONITORED = 2, } DESCRIPTOR_HEAP_TYPE :: enum i32 { @@ -1887,9 +1902,9 @@ DESCRIPTOR_HEAP_TYPE :: enum i32 { NUM_TYPES = 4, } -DESCRIPTOR_HEAP_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - SHADER_VISIBLE = 0x1, +DESCRIPTOR_HEAP_FLAGS :: distinct bit_set[DESCRIPTOR_HEAP_FLAG; u32] +DESCRIPTOR_HEAP_FLAG :: enum u32 { + SHADER_VISIBLE = 0, } DESCRIPTOR_HEAP_DESC :: struct { @@ -1959,18 +1974,18 @@ ROOT_PARAMETER :: struct { ShaderVisibility: SHADER_VISIBILITY, } -ROOT_SIGNATURE_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT = 0x1, - DENY_VERTEX_SHADER_ROOT_ACCESS = 0x2, - DENY_HULL_SHADER_ROOT_ACCESS = 0x4, - DENY_DOMAIN_SHADER_ROOT_ACCESS = 0x8, - DENY_GEOMETRY_SHADER_ROOT_ACCESS = 0x10, - DENY_PIXEL_SHADER_ROOT_ACCESS = 0x20, - ALLOW_STREAM_OUTPUT = 0x40, - LOCAL_ROOT_SIGNATURE = 0x80, - DENY_AMPLIFICATION_SHADER_ROOT_ACCESS = 0x100, - DENY_MESH_SHADER_ROOT_ACCESS = 0x200, +ROOT_SIGNATURE_FLAGS :: distinct bit_set[ROOT_SIGNATURE_FLAG; u32] +ROOT_SIGNATURE_FLAG :: enum u32 { + ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT = 0, + DENY_VERTEX_SHADER_ROOT_ACCESS = 1, + DENY_HULL_SHADER_ROOT_ACCESS = 2, + DENY_DOMAIN_SHADER_ROOT_ACCESS = 3, + DENY_GEOMETRY_SHADER_ROOT_ACCESS = 4, + DENY_PIXEL_SHADER_ROOT_ACCESS = 5, + ALLOW_STREAM_OUTPUT = 6, + LOCAL_ROOT_SIGNATURE = 7, + DENY_AMPLIFICATION_SHADER_ROOT_ACCESS = 8, + DENY_MESH_SHADER_ROOT_ACCESS = 9, } STATIC_BORDER_COLOR :: enum i32 { @@ -2003,13 +2018,13 @@ ROOT_SIGNATURE_DESC :: struct { Flags: ROOT_SIGNATURE_FLAGS, } -DESCRIPTOR_RANGE_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - DESCRIPTORS_VOLATILE = 0x1, - DATA_VOLATILE = 0x2, - DATA_STATIC_WHILE_SET_AT_EXECUTE = 0x4, - DATA_STATIC = 0x8, - DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS = 0x10000, +DESCRIPTOR_RANGE_FLAGS :: distinct bit_set[DESCRIPTOR_RANGE_FLAG; u32] +DESCRIPTOR_RANGE_FLAG :: enum u32 { + DESCRIPTORS_VOLATILE = 0, + DATA_VOLATILE = 1, + DATA_STATIC_WHILE_SET_AT_EXECUTE = 2, + DATA_STATIC = 3, + DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS = 16, } DESCRIPTOR_RANGE1 :: struct { @@ -2026,11 +2041,11 @@ ROOT_DESCRIPTOR_TABLE1 :: struct { pDescriptorRanges: ^DESCRIPTOR_RANGE1, } -ROOT_DESCRIPTOR_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - DATA_VOLATILE = 0x2, - DATA_STATIC_WHILE_SET_AT_EXECUTE = 0x4, - DATA_STATIC = 0x8, +ROOT_DESCRIPTOR_FLAGS :: distinct bit_set[ROOT_DESCRIPTOR_FLAG; u32] +ROOT_DESCRIPTOR_FLAG :: enum u32 { + DATA_VOLATILE = 2, + DATA_STATIC_WHILE_SET_AT_EXECUTE = 3, + DATA_STATIC = 4, } ROOT_DESCRIPTOR1 :: struct { @@ -2571,11 +2586,13 @@ IPipelineLibrary1_VTable :: struct { LoadPipeline: proc "stdcall" (this: ^IPipelineLibrary1, pName: [^]u16, pDesc: ^PIPELINE_STATE_STREAM_DESC, riid: ^IID, ppPipelineState: ^rawptr) -> HRESULT, } -MULTIPLE_FENCE_WAIT_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - ANY = 0x1, - ALL = 0x0, +MULTIPLE_FENCE_WAIT_FLAGS :: distinct bit_set[MULTIPLE_FENCE_WAIT_FLAG; u32] +MULTIPLE_FENCE_WAIT_FLAG :: enum u32 { + ANY = 0, } +MULTIPLE_FENCE_WAIT_FLAG_NONE :: MULTIPLE_FENCE_WAIT_FLAGS{} +MULTIPLE_FENCE_WAIT_FLAG_ANY :: MULTIPLE_FENCE_WAIT_FLAGS{.ANY} +MULTIPLE_FENCE_WAIT_FLAG_ALL :: MULTIPLE_FENCE_WAIT_FLAGS{} RESIDENCY_PRIORITY :: enum i32 { MINIMUM = 671088640, @@ -2611,9 +2628,9 @@ IDevice2_VTable :: struct { CreatePipelineState: proc "stdcall" (this: ^IDevice2, pDesc: ^PIPELINE_STATE_STREAM_DESC, riid: ^IID, ppPipelineState: ^rawptr) -> HRESULT, } -RESIDENCY_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - DENY_OVERBUDGET = 0x1, +RESIDENCY_FLAGS :: distinct bit_set[RESIDENCY_FLAG; u32] +RESIDENCY_FLAG :: enum u32 { + DENY_OVERBUDGET = 0, } @@ -2630,16 +2647,16 @@ IDevice3_VTable :: struct { EnqueueMakeResident: proc "stdcall" (this: ^IDevice3, Flags: RESIDENCY_FLAGS, NumObjects: u32, ppObjects: ^^IPageable, pFenceToSignal: ^IFence, FenceValueToSignal: u64) -> HRESULT, } -COMMAND_LIST_FLAGS :: enum u32 { // TODO: make bit_set - COMMAND_LIST_FLAG_NONE = 0x0, +COMMAND_LIST_FLAGS :: distinct bit_set[COMMAND_LIST_FLAG; u32] +COMMAND_LIST_FLAG :: enum u32 { } -COMMAND_POOL_FLAGS :: enum u32 { // TODO: make bit_set - COMMAND_POOL_FLAG_NONE = 0x0, +COMMAND_POOL_FLAGS :: distinct bit_set[COMMAND_POOL_FLAG; u32] +COMMAND_POOL_FLAG :: enum u32 { } -COMMAND_RECORDER_FLAGS :: enum u32 { // TODO: make bit_set - COMMAND_RECORDER_FLAG_NONE = 0x0, +COMMAND_RECORDER_FLAGS :: distinct bit_set[COMMAND_RECORDER_FLAG; u32] +COMMAND_RECORDER_FLAG :: enum u32 { } PROTECTED_SESSION_STATUS :: enum i32 { @@ -2660,9 +2677,9 @@ IProtectedSession_VTable :: struct { GetSessionStatus: proc "stdcall" (this: ^IProtectedSession) -> PROTECTED_SESSION_STATUS, } -PROTECTED_RESOURCE_SESSION_SUPPORT_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - SUPPORTED = 0x1, +PROTECTED_RESOURCE_SESSION_SUPPORT_FLAGS :: distinct bit_set[PROTECTED_RESOURCE_SESSION_SUPPORT_FLAG; u32] +PROTECTED_RESOURCE_SESSION_SUPPORT_FLAG :: enum u32 { + SUPPORTED = 0, } FEATURE_DATA_PROTECTED_RESOURCE_SESSION_SUPPORT :: struct { @@ -2670,8 +2687,8 @@ FEATURE_DATA_PROTECTED_RESOURCE_SESSION_SUPPORT :: struct { Support: PROTECTED_RESOURCE_SESSION_SUPPORT_FLAGS, } -PROTECTED_RESOURCE_SESSION_FLAGS :: enum u32 { // TODO: make bit_set - PROTECTED_RESOURCE_SESSION_FLAG_NONE = 0x0, +PROTECTED_RESOURCE_SESSION_FLAGS :: distinct bit_set[PROTECTED_RESOURCE_SESSION_FLAG; u32] +PROTECTED_RESOURCE_SESSION_FLAG :: enum u32 { } PROTECTED_RESOURCE_SESSION_DESC :: struct { @@ -2760,9 +2777,10 @@ META_COMMAND_PARAMETER_TYPE :: enum i32 { GPU_DESCRIPTOR_HANDLE_HEAP_TYPE_CBV_SRV_UAV = 4, } -META_COMMAND_PARAMETER_FLAGS :: enum u32 { // TODO: make bit_set - INPUT = 0x1, - OUTPUT = 0x2, +META_COMMAND_PARAMETER_FLAGS :: distinct bit_set[META_COMMAND_PARAMETER_FLAG; u32] +META_COMMAND_PARAMETER_FLAG :: enum u32 { + INPUT = 0, + OUTPUT = 1, } META_COMMAND_PARAMETER_STAGE :: enum i32 { @@ -2850,11 +2868,11 @@ STATE_SUBOBJECT :: struct { pDesc: rawptr, } -STATE_OBJECT_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - ALLOW_LOCAL_DEPENDENCIES_ON_EXTERNAL_DEFINITIONS = 0x1, - ALLOW_EXTERNAL_DEPENDENCIES_ON_LOCAL_DEFINITIONS = 0x2, - ALLOW_STATE_OBJECT_ADDITIONS = 0x4, +STATE_OBJECT_FLAGS :: distinct bit_set[STATE_OBJECT_FLAG; u32] +STATE_OBJECT_FLAG :: enum u32 { + ALLOW_LOCAL_DEPENDENCIES_ON_EXTERNAL_DEFINITIONS = 0, + ALLOW_EXTERNAL_DEPENDENCIES_ON_LOCAL_DEFINITIONS = 1, + ALLOW_STATE_OBJECT_ADDITIONS = 2, } STATE_OBJECT_CONFIG :: struct { @@ -2873,8 +2891,8 @@ NODE_MASK :: struct { NodeMask: u32, } -EXPORT_FLAGS :: enum u32 { // TODO: make bit_set - EXPORT_FLAG_NONE = 0x0, +EXPORT_FLAGS :: distinct bit_set[EXPORT_FLAG; u32] +EXPORT_FLAG :: enum u32 { } EXPORT_DESC :: struct { @@ -2929,10 +2947,10 @@ RAYTRACING_PIPELINE_CONFIG :: struct { MaxTraceRecursionDepth: u32, } -RAYTRACING_PIPELINE_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - SKIP_TRIANGLES = 0x100, - SKIP_PROCEDURAL_PRIMITIVES = 0x200, +RAYTRACING_PIPELINE_FLAGS :: distinct bit_set[RAYTRACING_PIPELINE_FLAG; u32] +RAYTRACING_PIPELINE_FLAG :: enum u32 { + SKIP_TRIANGLES = 8, + SKIP_PROCEDURAL_PRIMITIVES = 9, } RAYTRACING_PIPELINE_CONFIG1 :: struct { @@ -2951,10 +2969,10 @@ STATE_OBJECT_DESC :: struct { pSubobjects: ^STATE_SUBOBJECT, } -RAYTRACING_GEOMETRY_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - OPAQUE = 0x1, - NO_DUPLICATE_ANYHIT_INVOCATION = 0x2, +RAYTRACING_GEOMETRY_FLAGS :: distinct bit_set[RAYTRACING_GEOMETRY_FLAG; u32] +RAYTRACING_GEOMETRY_FLAG :: enum u32 { + OPAQUE = 0, + NO_DUPLICATE_ANYHIT_INVOCATION = 1, } RAYTRACING_GEOMETRY_TYPE :: enum i32 { @@ -2962,12 +2980,12 @@ RAYTRACING_GEOMETRY_TYPE :: enum i32 { PROCEDURAL_PRIMITIVE_AABBS = 1, } -RAYTRACING_INSTANCE_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - TRIANGLE_CULL_DISABLE = 0x1, - TRIANGLE_FRONT_COUNTERCLOCKWISE = 0x2, - FORCE_OPAQUE = 0x4, - FORCE_NON_OPAQUE = 0x8, +RAYTRACING_INSTANCE_FLAGS :: distinct bit_set[RAYTRACING_INSTANCE_FLAG; u32] +RAYTRACING_INSTANCE_FLAG :: enum u32 { + TRIANGLE_CULL_DISABLE = 0, + TRIANGLE_FRONT_COUNTERCLOCKWISE = 1, + FORCE_OPAQUE = 2, + FORCE_NON_OPAQUE = 3, } GPU_VIRTUAL_ADDRESS_AND_STRIDE :: struct { @@ -3010,14 +3028,14 @@ RAYTRACING_GEOMETRY_AABBS_DESC :: struct { AABBs: GPU_VIRTUAL_ADDRESS_AND_STRIDE, } -RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - ALLOW_UPDATE = 0x1, - ALLOW_COMPACTION = 0x2, - PREFER_FAST_TRACE = 0x4, - PREFER_FAST_BUILD = 0x8, - MINIMIZE_MEMORY = 0x10, - PERFORM_UPDATE = 0x20, +RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS :: distinct bit_set[RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG; u32] +RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG :: enum u32 { + ALLOW_UPDATE = 0, + ALLOW_COMPACTION = 1, + PREFER_FAST_TRACE = 2, + PREFER_FAST_BUILD = 3, + MINIMIZE_MEMORY = 4, + PERFORM_UPDATE = 5, } RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE :: enum i32 { @@ -3137,18 +3155,18 @@ RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO :: struct { UpdateScratchDataSizeInBytes: u64, } -RAY_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - FORCE_OPAQUE = 0x1, - FORCE_NON_OPAQUE = 0x2, - ACCEPT_FIRST_HIT_AND_END_SEARCH = 0x4, - SKIP_CLOSEST_HIT_SHADER = 0x8, - CULL_BACK_FACING_TRIANGLES = 0x10, - CULL_FRONT_FACING_TRIANGLES = 0x20, - CULL_OPAQUE = 0x40, - CULL_NON_OPAQUE = 0x80, - SKIP_TRIANGLES = 0x100, - SKIP_PROCEDURAL_PRIMITIVES = 0x200, +RAY_FLAGS :: distinct bit_set[RAY_FLAG; u32] +RAY_FLAG :: enum u32 { + FORCE_OPAQUE = 0, + FORCE_NON_OPAQUE = 1, + ACCEPT_FIRST_HIT_AND_END_SEARCH = 2, + SKIP_CLOSEST_HIT_SHADER = 3, + CULL_BACK_FACING_TRIANGLES = 4, + CULL_FRONT_FACING_TRIANGLES = 5, + CULL_OPAQUE = 6, + CULL_NON_OPAQUE = 7, + SKIP_TRIANGLES = 8, + SKIP_PROCEDURAL_PRIMITIVES = 9, } HIT_KIND :: enum i32 { @@ -3260,10 +3278,10 @@ DRED_VERSION :: enum i32 { _1_2 = 3, } -DRED_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - FORCE_ENABLE = 0x1, - DISABLE_AUTOBREADCRUMBS = 0x2, +DRED_FLAGS :: distinct bit_set[DRED_FLAG; u32] +DRED_FLAG :: enum u32 { + FORCE_ENABLE = 0, + DISABLE_AUTOBREADCRUMBS = 1, } DRED_ENABLEMENT :: enum i32 { @@ -3611,11 +3629,11 @@ RENDER_PASS_DEPTH_STENCIL_DESC :: struct { StencilEndingAccess: RENDER_PASS_ENDING_ACCESS, } -RENDER_PASS_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - ALLOW_UAV_WRITES = 0x1, - SUSPENDING_PASS = 0x2, - RESUMING_PASS = 0x4, +RENDER_PASS_FLAGS :: distinct bit_set[RENDER_PASS_FLAG; u32] +RENDER_PASS_FLAG :: enum u32 { + ALLOW_UAV_WRITES = 0, + SUSPENDING_PASS = 1, + RESUMING_PASS = 2, } @@ -3697,9 +3715,9 @@ IDebug_VTable :: struct { EnableDebugLayer: proc "stdcall" (this: ^IDebug), } -GPU_BASED_VALIDATION_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - DISABLE_STATE_TRACKING = 0x1, +GPU_BASED_VALIDATION_FLAGS :: distinct bit_set[GPU_BASED_VALIDATION_FLAG; u32] +GPU_BASED_VALIDATION_FLAG :: enum u32 { + DISABLE_STATE_TRACKING = 0, } @@ -3741,11 +3759,11 @@ IDebug3_VTable :: struct { SetGPUBasedValidationFlags: proc "stdcall" (this: ^IDebug3, Flags: GPU_BASED_VALIDATION_FLAGS), } -RLDO_FLAGS :: enum u32 { // TODO: make bit_set - NONE = 0x0, - SUMMARY = 0x1, - DETAIL = 0x2, - IGNORE_INTERNAL = 0x4, +RLDO_FLAGS :: distinct bit_set[RLDO_FLAG; u32] +RLDO_FLAG :: enum u32 { + SUMMARY = 0, + DETAIL = 1, + IGNORE_INTERNAL = 2, } DEBUG_DEVICE_PARAMETER_TYPE :: enum i32 { @@ -3754,12 +3772,12 @@ DEBUG_DEVICE_PARAMETER_TYPE :: enum i32 { GPU_SLOWDOWN_PERFORMANCE_FACTOR = 2, } -DEBUG_FEATURE :: enum i32 { // TODO: make bit_set - NONE = 0, - ALLOW_BEHAVIOR_CHANGING_DEBUG_AIDS = 1, - CONSERVATIVE_RESOURCE_STATE_TRACKING = 2, - DISABLE_VIRTUALIZED_BUNDLES_VALIDATION = 4, - EMULATE_WINDOWS7 = 8, +DEBUG_FEATURE :: distinct bit_set[DEBUG_FEATURE_FLAG; u32] +DEBUG_FEATURE_FLAG :: enum i32 { + ALLOW_BEHAVIOR_CHANGING_DEBUG_AIDS = 0, + CONSERVATIVE_RESOURCE_STATE_TRACKING = 1, + DISABLE_VIRTUALIZED_BUNDLES_VALIDATION = 2, + EMULATE_WINDOWS7 = 3, } GPU_BASED_VALIDATION_SHADER_PATCH_MODE :: enum i32 { @@ -3770,12 +3788,16 @@ GPU_BASED_VALIDATION_SHADER_PATCH_MODE :: enum i32 { NUM_GPU_BASED_VALIDATION_SHADER_PATCH_MODES = 4, } -GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAGS :: enum u32 { // TODO: make bit_set - GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAG_NONE = 0x0, - GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAG_FRONT_LOAD_CREATE_TRACKING_ONLY_SHADERS = 0x1, - GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAG_FRONT_LOAD_CREATE_UNGUARDED_VALIDATION_SHADERS = 0x2, - GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAG_FRONT_LOAD_CREATE_GUARDED_VALIDATION_SHADERS = 0x4, - VALID_MASK = 0x7, +GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAGS :: distinct bit_set[GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAG; u32] +GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAG :: enum u32 { + FRONT_LOAD_CREATE_TRACKING_ONLY_SHADERS = 0, + FRONT_LOAD_CREATE_UNGUARDED_VALIDATION_SHADERS = 1, + FRONT_LOAD_CREATE_GUARDED_VALIDATION_SHADERS = 2, +} +GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAG_VALID_MASK :: GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAGS{ + .FRONT_LOAD_CREATE_TRACKING_ONLY_SHADERS, + .FRONT_LOAD_CREATE_UNGUARDED_VALIDATION_SHADERS, + .FRONT_LOAD_CREATE_GUARDED_VALIDATION_SHADERS, } DEBUG_DEVICE_GPU_BASED_VALIDATION_SETTINGS :: struct { From 717522efe4476db2bd2589098225f73b11d53f07 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 2 Nov 2022 22:45:05 +0000 Subject: [PATCH 107/110] Correct more flags for d3d12 --- vendor/directx/d3d12/d3d12.odin | 68 ++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/vendor/directx/d3d12/d3d12.odin b/vendor/directx/d3d12/d3d12.odin index f6c9bb49f..9813b8e42 100644 --- a/vendor/directx/d3d12/d3d12.odin +++ b/vendor/directx/d3d12/d3d12.odin @@ -1379,39 +1379,45 @@ TILE_MAPPING_FLAG :: enum u32 { TILE_COPY_FLAGS :: distinct bit_set[TILE_COPY_FLAG; u32] TILE_COPY_FLAG :: enum u32 { - NONE = 0x0, - NO_HAZARD = 0x1, - LINEAR_BUFFER_TO_SWIZZLED_TILED_RESOURCE = 0x2, - SWIZZLED_TILED_RESOURCE_TO_LINEAR_BUFFER = 0x4, + NO_HAZARD = 0, + LINEAR_BUFFER_TO_SWIZZLED_TILED_RESOURCE = 1, + SWIZZLED_TILED_RESOURCE_TO_LINEAR_BUFFER = 2, } -RESOURCE_STATES :: enum i32 { // TODO: make bit_set - COMMON = 0, - VERTEX_AND_CONSTANT_BUFFER = 1, - INDEX_BUFFER = 2, - RENDER_TARGET = 4, - UNORDERED_ACCESS = 8, - DEPTH_WRITE = 16, - DEPTH_READ = 32, - NON_PIXEL_SHADER_RESOURCE = 64, - PIXEL_SHADER_RESOURCE = 128, - STREAM_OUT = 256, - INDIRECT_ARGUMENT = 512, - COPY_DEST = 1024, - COPY_SOURCE = 2048, - RESOLVE_DEST = 4096, - RESOLVE_SOURCE = 8192, - RAYTRACING_ACCELERATION_STRUCTURE = 4194304, - SHADING_RATE_SOURCE = 16777216, - GENERIC_READ = 2755, - PRESENT = 0, - PREDICATION = 512, - VIDEO_DECODE_READ = 65536, - VIDEO_DECODE_WRITE = 131072, - VIDEO_PROCESS_READ = 262144, - VIDEO_PROCESS_WRITE = 524288, - VIDEO_ENCODE_READ = 2097152, - VIDEO_ENCODE_WRITE = 8388608, +RESOURCE_STATES :: distinct bit_set[RESOURCE_STATE; u32] +RESOURCE_STATE :: enum i32 { + VERTEX_AND_CONSTANT_BUFFER = 0, + INDEX_BUFFER = 1, + RENDER_TARGET = 2, + UNORDERED_ACCESS = 3, + DEPTH_WRITE = 4, + DEPTH_READ = 5, + NON_PIXEL_SHADER_RESOURCE = 6, + PIXEL_SHADER_RESOURCE = 7, + STREAM_OUT = 8, + INDIRECT_ARGUMENT = 9, + COPY_DEST = 10, + COPY_SOURCE = 11, + RESOLVE_DEST = 12, + RESOLVE_SOURCE = 13, + RAYTRACING_ACCELERATION_STRUCTURE = 22, + SHADING_RATE_SOURCE = 24, + PREDICATION = 9, + VIDEO_DECODE_READ = 16, + VIDEO_DECODE_WRITE = 17, + VIDEO_PROCESS_READ = 18, + VIDEO_PROCESS_WRITE = 19, + VIDEO_ENCODE_READ = 21, + VIDEO_ENCODE_WRITE = 23, +} + +RESOURCE_STATE_COMMON :: RESOURCE_STATES{} +RESOURCE_STATE_PRESENT :: RESOURCE_STATES{} +RESOURCE_STATE_GENERIC_READ :: RESOURCE_STATES{ + .SHADING_RATE_SOURCE, .VERTEX_AND_CONSTANT_BUFFER, +} +RESOURCE_STATE_ALL_SHADER_RESOURCE :: RESOURCE_STATES{ + .SHADING_RATE_SOURCE, .INDEX_BUFFER, } RESOURCE_BARRIER_TYPE :: enum i32 { From 1a6d4c955ab198e4e01d0e7cc5fc2be365806c29 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 2 Nov 2022 23:12:43 +0000 Subject: [PATCH 108/110] Add more `bit_set`s to direct packages --- vendor/directx/d3d_compiler/d3d_compiler.odin | 91 ++++++++++--------- vendor/directx/dxgi/dxgi.odin | 67 ++++++++------ 2 files changed, 87 insertions(+), 71 deletions(-) diff --git a/vendor/directx/d3d_compiler/d3d_compiler.odin b/vendor/directx/d3d_compiler/d3d_compiler.odin index 2506f239c..e4a7d8df4 100644 --- a/vendor/directx/d3d_compiler/d3d_compiler.odin +++ b/vendor/directx/d3d_compiler/d3d_compiler.odin @@ -45,50 +45,57 @@ foreign d3dcompiler { -D3DCOMPILE :: enum u32 { // TODO: make bit_field - DEBUG = 1 << 0, - SKIP_VALIDATION = 1 << 1, - SKIP_OPTIMIZATION = 1 << 2, - PACK_MATRIX_ROW_MAJOR = 1 << 3, - PACK_MATRIX_COLUMN_MAJOR = 1 << 4, - PARTIAL_PRECISION = 1 << 5, - FORCE_VS_SOFTWARE_NO_OPT = 1 << 6, - FORCE_PS_SOFTWARE_NO_OPT = 1 << 7, - NO_PRESHADER = 1 << 8, - AVOID_FLOW_CONTROL = 1 << 9, - PREFER_FLOW_CONTROL = 1 << 10, - ENABLE_STRICTNESS = 1 << 11, - ENABLE_BACKWARDS_COMPATIBILITY = 1 << 12, - IEEE_STRICTNESS = 1 << 13, - OPTIMIZATION_LEVEL0 = 1 << 14, - OPTIMIZATION_LEVEL1 = 0, - OPTIMIZATION_LEVEL2 = (1 << 14)|(1 << 15), // Added manually - OPTIMIZATION_LEVEL3 = 1 << 15, - RESERVED16 = 1 << 16, - RESERVED17 = 1 << 17, - WARNINGS_ARE_ERRORS = 1 << 18, - RESOURCES_MAY_ALIAS = 1 << 19, - ENABLE_UNBOUNDED_DESCRIPTOR_TABLES = 1 << 20, - ALL_RESOURCES_BOUND = 1 << 21, - DEBUG_NAME_FOR_SOURCE = 1 << 22, - DEBUG_NAME_FOR_BINARY = 1 << 23, +D3DCOMPILE :: distinct bit_set[D3DCOMPILE_FLAG; u32] +D3DCOMPILE_FLAG :: enum u32 { + DEBUG = 0, + SKIP_VALIDATION = 1, + SKIP_OPTIMIZATION = 2, + PACK_MATRIX_ROW_MAJOR = 3, + PACK_MATRIX_COLUMN_MAJOR = 4, + PARTIAL_PRECISION = 5, + FORCE_VS_SOFTWARE_NO_OPT = 6, + FORCE_PS_SOFTWARE_NO_OPT = 7, + NO_PRESHADER = 8, + AVOID_FLOW_CONTROL = 9, + PREFER_FLOW_CONTROL = 10, + ENABLE_STRICTNESS = 11, + ENABLE_BACKWARDS_COMPATIBILITY = 12, + IEEE_STRICTNESS = 13, + OPTIMIZATION_LEVEL0 = 14, + OPTIMIZATION_LEVEL3 = 15, + RESERVED16 = 16, + RESERVED17 = 17, + WARNINGS_ARE_ERRORS = 18, + RESOURCES_MAY_ALIAS = 19, + ENABLE_UNBOUNDED_DESCRIPTOR_TABLES = 20, + ALL_RESOURCES_BOUND = 21, + DEBUG_NAME_FOR_SOURCE = 22, + DEBUG_NAME_FOR_BINARY = 23, } -EFFECT :: enum u32 { // TODO: make bit_field - CHILD_EFFECT = 1 << 0, - ALLOW_SLOW_OPS = 1 << 1, +D3DCOMPILE_OPTIMIZATION_LEVEL0 :: D3DCOMPILE{.OPTIMIZATION_LEVEL0} +D3DCOMPILE_OPTIMIZATION_LEVEL1 :: D3DCOMPILE{} +D3DCOMPILE_OPTIMIZATION_LEVEL2 :: D3DCOMPILE{.IEEE_STRICTNESS, .OPTIMIZATION_LEVEL3} +D3DCOMPILE_OPTIMIZATION_LEVEL3 :: D3DCOMPILE{.OPTIMIZATION_LEVEL3} + + +EFFECT :: distinct bit_set[EFFECT_FLAG; u32] +EFFECT_FLAG :: enum u32 { + CHILD_EFFECT = 0, + ALLOW_SLOW_OPS = 1, } -FLAGS2 :: enum u32 { // TODO: make bit_field +FLAGS2 :: enum u32 { FORCE_ROOT_SIGNATURE_LATEST = 0, FORCE_ROOT_SIGNATURE_1_0 = 1 << 4, FORCE_ROOT_SIGNATURE_1_1 = 1 << 5, } -SECDATA :: enum u32 { // TODO: make bit_field - MERGE_UAV_SLOTS = 0x00000001, - PRESERVE_TEMPLATE_SLOTS = 0x00000002, - REQUIRE_TEMPLATE_MATCH = 0x00000004, +SECDATA :: distinct bit_set[SECDATA_FLAG; u32] +SECDATA_FLAG :: enum u32 { + MERGE_UAV_SLOTS = 0, + PRESERVE_TEMPLATE_SLOTS = 1, + REQUIRE_TEMPLATE_MATCH = 2, } DISASM_ENABLE_COLOR_CODE :: 0x00000001 @@ -188,13 +195,13 @@ pD3DCompile :: #type proc "c" (a0: rawptr, a1: SIZE_T, a2: cstring, a3: ^SHA pD3DPreprocess :: #type proc "c" (a0: rawptr, a1: SIZE_T, a2: cstring, a3: ^SHADER_MACRO, a4: ^ID3DInclude, a5: ^^ID3DBlob, a6: ^^ID3DBlob) -> HRESULT pD3DDisassemble :: #type proc "c" (a0: rawptr, a1: SIZE_T, a2: u32, a3: cstring, a4: ^^ID3DBlob) -> HRESULT -D3DCOMPILER_STRIP_FLAGS :: enum u32 { // TODO: make bit_field - REFLECTION_DATA = 0x1, - DEBUG_INFO = 0x2, - TEST_BLOBS = 0x4, - PRIVATE_DATA = 0x8, - ROOT_SIGNATURE = 0x10, - FORCE_DWORD = 0x7fffffff, +D3DCOMPILER_STRIP_FLAGS :: distinct bit_set[D3DCOMPILER_STRIP_FLAG; u32] +D3DCOMPILER_STRIP_FLAG :: enum u32 { + REFLECTION_DATA = 0, + DEBUG_INFO = 1, + TEST_BLOBS = 2, + PRIVATE_DATA = 3, + ROOT_SIGNATURE = 4, } BLOB_PART :: enum i32 { diff --git a/vendor/directx/dxgi/dxgi.odin b/vendor/directx/dxgi/dxgi.odin index 24b85e9f3..5ad938ba0 100644 --- a/vendor/directx/dxgi/dxgi.odin +++ b/vendor/directx/dxgi/dxgi.odin @@ -57,14 +57,15 @@ CPU_ACCESS :: enum u32 { FIELD = 15, } -USAGE :: enum u32 { // TODO: convert to bit_set - SHADER_INPUT = 0x00000010, - RENDER_TARGET_OUTPUT = 0x00000020, - BACK_BUFFER = 0x00000040, - SHARED = 0x00000080, - READ_ONLY = 0x00000100, - DISCARD_ON_PRESENT = 0x00000200, - UNORDERED_ACCESS = 0x00000400, +USAGE :: distinct bit_set[USAGE_FLAG; u32] +USAGE_FLAG :: enum u32 { + SHADER_INPUT = 4, + RENDER_TARGET_OUTPUT = 5, + BACK_BUFFER = 6, + SHARED = 7, + READ_ONLY = 8, + DISCARD_ON_PRESENT = 9, + UNORDERED_ACCESS = 10, } RESOURCE_PRIORITY :: enum u32 { @@ -75,37 +76,45 @@ RESOURCE_PRIORITY :: enum u32 { MAXIMUM = 0xc8000000, } -MAP :: enum u32 { // TODO: convert to bit_set +MAP :: enum u32 { READ = 1, WRITE = 2, DISCARD = 4, } -ENUM_MODES :: enum u32 { // TODO: convert to bit_set - INTERLACED = 1, - SCALING = 2, - STEREO = 4, - DISABLED_STEREO = 8, +ENUM_MODES :: distinct bit_set[ENUM_MODE; u32] +ENUM_MODE :: enum u32 { + INTERLACED = 0, + SCALING = 1, + STEREO = 2, + DISABLED_STEREO = 3, } MAX_SWAP_CHAIN_BUFFERS :: 16 -PRESENT :: enum u32 { // TODO: convert to bit_set - TEST = 0x00000001, - DO_NOT_SEQUENCE = 0x00000002, - RESTART = 0x00000004, - DO_NOT_WAIT = 0x00000008, - STEREO_PREFER_RIGHT = 0x00000010, - STEREO_TEMPORARY_MONO = 0x00000020, - RESTRICT_TO_OUTPUT = 0x00000040, - USE_DURATION = 0x00000100, - ALLOW_TEARING = 0x00000200, +PRESENT :: distinct bit_set[PRESENT_FLAG; u32] +PRESENT_FLAG :: enum u32 { + TEST = 0, + DO_NOT_SEQUENCE = 1, + RESTART = 2, + DO_NOT_WAIT = 3, + STEREO_PREFER_RIGHT = 4, + STEREO_TEMPORARY_MONO = 5, + RESTRICT_TO_OUTPUT = 6, + + USE_DURATION = 8, + ALLOW_TEARING = 9, } -MWA :: enum u32 { // TODO: convert to bit_set - NO_WINDOW_CHANGES = 1 << 0, - NO_ALT_ENTER = 1 << 1, - NO_PRINT_SCREEN = 1 << 2, - VALID = 0x7, +MWA :: distinct bit_set[MWA_FLAG; u32] +MWA_FLAG :: enum u32 { + NO_WINDOW_CHANGES = 0, + NO_ALT_ENTER = 1, + NO_PRINT_SCREEN = 2, +} +MWA_VALID :: MWA{ + .NO_WINDOW_CHANGES, + .NO_ALT_ENTER, + .NO_PRINT_SCREEN, } SHARED_RESOURCE_READ :: 0x80000000 From 1d9d79542c0179808b02a4b6503a6629bc1cb4f2 Mon Sep 17 00:00:00 2001 From: Hyp-X Date: Thu, 3 Nov 2022 10:49:45 +0100 Subject: [PATCH 109/110] d3d12: Fixed RESOURCE_STATE_GENERIC_READ flags --- vendor/directx/d3d12/d3d12.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/directx/d3d12/d3d12.odin b/vendor/directx/d3d12/d3d12.odin index 9813b8e42..b2e2d52df 100644 --- a/vendor/directx/d3d12/d3d12.odin +++ b/vendor/directx/d3d12/d3d12.odin @@ -1414,7 +1414,7 @@ RESOURCE_STATE :: enum i32 { RESOURCE_STATE_COMMON :: RESOURCE_STATES{} RESOURCE_STATE_PRESENT :: RESOURCE_STATES{} RESOURCE_STATE_GENERIC_READ :: RESOURCE_STATES{ - .SHADING_RATE_SOURCE, .VERTEX_AND_CONSTANT_BUFFER, + .VERTEX_AND_CONSTANT_BUFFER, .INDEX_BUFFER, .NON_PIXEL_SHADER_RESOURCE, .PIXEL_SHADER_RESOURCE, .INDIRECT_ARGUMENT, .COPY_SOURCE, } RESOURCE_STATE_ALL_SHADER_RESOURCE :: RESOURCE_STATES{ .SHADING_RATE_SOURCE, .INDEX_BUFFER, From e8bc576b238178e44d91f0fad6bf541ecb875a91 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 3 Nov 2022 11:44:19 +0000 Subject: [PATCH 110/110] Rename `fnv32` and `fnv64` to `fnv32_no_a` and `fnv64_no_a` --- core/hash/hash.odin | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/hash/hash.odin b/core/hash/hash.odin index 870d6a638..37c15b994 100644 --- a/core/hash/hash.odin +++ b/core/hash/hash.odin @@ -72,8 +72,9 @@ djbx33a :: proc(data: []byte, seed := u32(5381)) -> (result: [16]byte) #no_bound return } +// If you have a choice, prefer fnv32a @(optimization_mode="speed") -fnv32 :: proc(data: []byte, seed := u32(0x811c9dc5)) -> u32 { +fnv32_no_a :: proc(data: []byte, seed := u32(0x811c9dc5)) -> u32 { h: u32 = seed for b in data { h = (h * 0x01000193) ~ u32(b) @@ -81,8 +82,9 @@ fnv32 :: proc(data: []byte, seed := u32(0x811c9dc5)) -> u32 { return h } +// If you have a choice, prefer fnv64a @(optimization_mode="speed") -fnv64 :: proc(data: []byte, seed := u64(0xcbf29ce484222325)) -> u64 { +fnv64_no_a :: proc(data: []byte, seed := u64(0xcbf29ce484222325)) -> u64 { h: u64 = seed for b in data { h = (h * 0x100000001b3) ~ u64(b)