Merge pull request #1438 from odin-lang/odin-global-constants-as-enums

Odin global constants as enums
This commit is contained in:
gingerBill
2022-02-15 16:18:07 +00:00
committed by GitHub
104 changed files with 382 additions and 322 deletions
+30 -1
View File
@@ -387,6 +387,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 {
@@ -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)
+1 -1
View File
@@ -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
}
@@ -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) {}
+1 -1
View File
@@ -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()
+2 -2
View File
@@ -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()
+1 -1
View File
@@ -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 (
+2 -2
View File
@@ -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 {