diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2022-02-15 16:18:07 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-15 16:18:07 +0000 |
| commit | d45ff0694d193fd15b0153ff1696de2b0a8606c3 (patch) | |
| tree | 594aa38dc02832c92f2b7dc8fd1a155a1c23bc2b /core/runtime | |
| parent | 0380a288a9e7d5bb775abec00900488659d1c784 (diff) | |
| parent | d695a8a52631aafcedeb2472c4d405c51547c651 (diff) | |
Merge pull request #1438 from odin-lang/odin-global-constants-as-enums
Odin global constants as enums
Diffstat (limited to 'core/runtime')
| -rw-r--r-- | core/runtime/core.odin | 31 | ||||
| -rw-r--r-- | core/runtime/default_allocators_nil.odin | 2 | ||||
| -rw-r--r-- | core/runtime/default_temporary_allocator.odin | 2 | ||||
| -rw-r--r-- | core/runtime/entry_windows.odin | 2 | ||||
| -rw-r--r-- | core/runtime/error_checks.odin | 4 | ||||
| -rw-r--r-- | core/runtime/internal.odin | 2 | ||||
| -rw-r--r-- | core/runtime/procs.odin | 4 |
7 files changed, 38 insertions, 9 deletions
diff --git a/core/runtime/core.odin b/core/runtime/core.odin index 35144473b..fec51f236 100644 --- a/core/runtime/core.odin +++ b/core/runtime/core.odin @@ -389,6 +389,35 @@ Raw_Cstring :: struct { /* // Defined internally by the compiler + Odin_OS_Type :: enum int { + Unknown, + Windows, + Darwin, + Linux, + Essence, + FreeBSD, + WASI, + JS, + Freestanding, + } +*/ +Odin_OS_Type :: type_of(ODIN_OS) + +/* + // Defined internally by the compiler + Odin_Arch_Type :: enum int { + Unknown, + amd64, + i386, + arm64, + wasm32, + wasm64, + } +*/ +Odin_Arch_Type :: type_of(ODIN_ARCH) + +/* + // Defined internally by the compiler Odin_Build_Mode_Type :: enum int { Executable, Dynamic, @@ -540,7 +569,7 @@ __init_context :: proc "contextless" (c: ^Context) { } default_assertion_failure_proc :: proc(prefix, message: string, loc: Source_Code_Location) -> ! { - when ODIN_OS == "freestanding" { + when ODIN_OS == .Freestanding { // Do nothing } else { print_caller_location(loc) diff --git a/core/runtime/default_allocators_nil.odin b/core/runtime/default_allocators_nil.odin index ccb4a3381..04dea0e19 100644 --- a/core/runtime/default_allocators_nil.odin +++ b/core/runtime/default_allocators_nil.odin @@ -32,7 +32,7 @@ nil_allocator :: proc() -> Allocator { -when ODIN_OS == "freestanding" { +when ODIN_OS == .Freestanding { default_allocator_proc :: nil_allocator_proc default_allocator :: nil_allocator }
\ No newline at end of file diff --git a/core/runtime/default_temporary_allocator.odin b/core/runtime/default_temporary_allocator.odin index 01143e222..4337e555b 100644 --- a/core/runtime/default_temporary_allocator.odin +++ b/core/runtime/default_temporary_allocator.odin @@ -3,7 +3,7 @@ package runtime DEFAULT_TEMP_ALLOCATOR_BACKING_SIZE: int : #config(DEFAULT_TEMP_ALLOCATOR_BACKING_SIZE, 1<<22) -when ODIN_OS == "freestanding" || ODIN_OS == "js" || ODIN_DEFAULT_TO_NIL_ALLOCATOR { +when ODIN_OS == .Freestanding || ODIN_OS == .JS || ODIN_DEFAULT_TO_NIL_ALLOCATOR { Default_Temp_Allocator :: struct {} default_temp_allocator_init :: proc(s: ^Default_Temp_Allocator, size: int, backup_allocator := context.allocator) {} diff --git a/core/runtime/entry_windows.odin b/core/runtime/entry_windows.odin index 35a6bb421..2f323cb41 100644 --- a/core/runtime/entry_windows.odin +++ b/core/runtime/entry_windows.odin @@ -22,7 +22,7 @@ when ODIN_BUILD_MODE == .Dynamic { return true } } else when !ODIN_TEST && !ODIN_NO_ENTRY_POINT { - when ODIN_ARCH == "i386" || ODIN_NO_CRT { + when ODIN_ARCH == .i386 || ODIN_NO_CRT { @(link_name="mainCRTStartup", linkage="strong", require) mainCRTStartup :: proc "stdcall" () -> i32 { context = default_context() diff --git a/core/runtime/error_checks.odin b/core/runtime/error_checks.odin index 7f1aeb2d7..ed75cbea6 100644 --- a/core/runtime/error_checks.odin +++ b/core/runtime/error_checks.odin @@ -1,7 +1,7 @@ package runtime bounds_trap :: proc "contextless" () -> ! { - when ODIN_OS == "windows" { + when ODIN_OS == .Windows { windows_trap_array_bounds() } else { trap() @@ -9,7 +9,7 @@ bounds_trap :: proc "contextless" () -> ! { } type_assertion_trap :: proc "contextless" () -> ! { - when ODIN_OS == "windows" { + when ODIN_OS == .Windows { windows_trap_type_assertion() } else { trap() diff --git a/core/runtime/internal.odin b/core/runtime/internal.odin index c07bcc60d..30798f623 100644 --- a/core/runtime/internal.odin +++ b/core/runtime/internal.odin @@ -3,7 +3,7 @@ package runtime import "core:intrinsics" @(private="file") -IS_WASM :: ODIN_ARCH == "wasm32" || ODIN_ARCH == "wasm64" +IS_WASM :: ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64 @(private) RUNTIME_LINKAGE :: "strong" when ( diff --git a/core/runtime/procs.odin b/core/runtime/procs.odin index 961f6376f..5a1d11fe0 100644 --- a/core/runtime/procs.odin +++ b/core/runtime/procs.odin @@ -1,6 +1,6 @@ package runtime -when ODIN_NO_CRT && ODIN_OS == "windows" { +when ODIN_NO_CRT && ODIN_OS == .Windows { foreign import lib "system:NtDll.lib" @(private="file") @@ -25,7 +25,7 @@ when ODIN_NO_CRT && ODIN_OS == "windows" { RtlMoveMemory(dst, src, len) return dst } -} else when ODIN_NO_CRT || (ODIN_ARCH == "wasm32" || ODIN_ARCH == "wasm64") { +} else when ODIN_NO_CRT || (ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64) { @(link_name="memset", linkage="strong", require) memset :: proc "c" (ptr: rawptr, val: i32, len: int) -> rawptr { if ptr != nil && len != 0 { |