aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-01-20 19:56:05 +0000
committergingerBill <bill@gingerbill.org>2022-01-20 19:56:05 +0000
commit3d7d3471924574beee08fc304a6daf6a8707d723 (patch)
tree6151973548aef5ac937e780170e9fe1448d154d4 /core
parentcfbc1a447bba4e3648d9e15c1f776d6d8068951e (diff)
Convert `ODIN_OS` and `ODIN_ARCH` to use enums rather than use strings
Diffstat (limited to 'core')
-rw-r--r--core/c/c.odin8
-rw-r--r--core/c/libc/complex.odin4
-rw-r--r--core/c/libc/ctype.odin4
-rw-r--r--core/c/libc/errno.odin10
-rw-r--r--core/c/libc/math.odin4
-rw-r--r--core/c/libc/setjmp.odin6
-rw-r--r--core/c/libc/signal.odin10
-rw-r--r--core/c/libc/stdio.odin10
-rw-r--r--core/c/libc/stdlib.odin10
-rw-r--r--core/c/libc/string.odin4
-rw-r--r--core/c/libc/threads.odin6
-rw-r--r--core/c/libc/time.odin8
-rw-r--r--core/c/libc/uchar.odin4
-rw-r--r--core/c/libc/wchar.odin4
-rw-r--r--core/c/libc/wctype.odin10
-rw-r--r--core/crypto/_fiat/field_poly1305/field.odin2
-rw-r--r--core/crypto/chacha20/chacha20.odin2
-rw-r--r--core/crypto/rand_generic.odin2
-rw-r--r--core/image/png/example.odin2
-rw-r--r--core/image/png/helpers.odin2
-rw-r--r--core/os/file_windows.odin2
-rw-r--r--core/os/os.odin2
-rw-r--r--core/os/os2/user.odin16
-rw-r--r--core/os/os_darwin.odin2
-rw-r--r--core/os/os_linux.odin26
-rw-r--r--core/os/stream.odin6
-rw-r--r--core/path/filepath/match.odin10
-rw-r--r--core/path/filepath/path.odin4
-rw-r--r--core/path/filepath/path_unix.odin4
-rw-r--r--core/runtime/core.odin2
-rw-r--r--core/runtime/default_allocators_nil.odin2
-rw-r--r--core/runtime/default_temporary_allocator.odin2
-rw-r--r--core/runtime/entry_windows.odin2
-rw-r--r--core/runtime/error_checks.odin4
-rw-r--r--core/runtime/internal.odin2
-rw-r--r--core/runtime/procs.odin4
-rw-r--r--core/sync/sync2/primitives.odin2
-rw-r--r--core/sync/sync2/primitives_internal.odin2
-rw-r--r--core/sys/unix/syscalls_linux.odin8
-rw-r--r--core/time/time_unix.odin2
40 files changed, 108 insertions, 108 deletions
diff --git a/core/c/c.odin b/core/c/c.odin
index d0b8e377f..05732476f 100644
--- a/core/c/c.odin
+++ b/core/c/c.odin
@@ -7,20 +7,20 @@ char :: builtin.u8 // assuming -funsigned-char
schar :: builtin.i8
short :: builtin.i16
int :: builtin.i32
-long :: builtin.i32 when (ODIN_OS == "windows" || size_of(builtin.rawptr) == 4) else builtin.i64
+long :: builtin.i32 when (ODIN_OS == .Windows || size_of(builtin.rawptr) == 4) else builtin.i64
longlong :: builtin.i64
uchar :: builtin.u8
ushort :: builtin.u16
uint :: builtin.u32
-ulong :: builtin.u32 when (ODIN_OS == "windows" || size_of(builtin.rawptr) == 4) else builtin.u64
+ulong :: builtin.u32 when (ODIN_OS == .Windows || size_of(builtin.rawptr) == 4) else builtin.u64
ulonglong :: builtin.u64
bool :: builtin.bool
size_t :: builtin.uint
ssize_t :: builtin.int
-wchar_t :: builtin.u16 when (ODIN_OS == "windows") else builtin.u32
+wchar_t :: builtin.u16 when (ODIN_OS == .Windows) else builtin.u32
float :: builtin.f32
double :: builtin.f64
@@ -48,7 +48,7 @@ int_least64_t :: builtin.i64
uint_least64_t :: builtin.u64
// Same on Windows, Linux, and FreeBSD
-when ODIN_ARCH == "i386" || ODIN_ARCH == "amd64" {
+when ODIN_ARCH == .i386 || ODIN_ARCH == .amd64 {
int_fast8_t :: builtin.i8
uint_fast8_t :: builtin.u8
int_fast16_t :: builtin.i32
diff --git a/core/c/libc/complex.odin b/core/c/libc/complex.odin
index 62b28f0cd..22c422cce 100644
--- a/core/c/libc/complex.odin
+++ b/core/c/libc/complex.odin
@@ -2,9 +2,9 @@ package libc
// 7.3 Complex arithmetic
-when ODIN_OS == "windows" {
+when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib"
-} else when ODIN_OS == "darwin" {
+} else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework"
} else {
foreign import libc "system:c"
diff --git a/core/c/libc/ctype.odin b/core/c/libc/ctype.odin
index 05d9dcd37..185385a5e 100644
--- a/core/c/libc/ctype.odin
+++ b/core/c/libc/ctype.odin
@@ -1,8 +1,8 @@
package libc
-when ODIN_OS == "windows" {
+when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib"
-} else when ODIN_OS == "darwin" {
+} else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework"
} else {
foreign import libc "system:c"
diff --git a/core/c/libc/errno.odin b/core/c/libc/errno.odin
index 8ebe2f734..ecde6af59 100644
--- a/core/c/libc/errno.odin
+++ b/core/c/libc/errno.odin
@@ -2,9 +2,9 @@ package libc
// 7.5 Errors
-when ODIN_OS == "windows" {
+when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib"
-} else when ODIN_OS == "darwin" {
+} else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework"
} else {
foreign import libc "system:c"
@@ -14,7 +14,7 @@ when ODIN_OS == "windows" {
// EDOM,
// EILSEQ
// ERANGE
-when ODIN_OS == "linux" || ODIN_OS == "freebsd" {
+when ODIN_OS == .Linux || ODIN_OS == .FreeBSD {
@(private="file")
@(default_calling_convention="c")
foreign libc {
@@ -27,7 +27,7 @@ when ODIN_OS == "linux" || ODIN_OS == "freebsd" {
ERANGE :: 34
}
-when ODIN_OS == "windows" {
+when ODIN_OS == .Windows {
@(private="file")
@(default_calling_convention="c")
foreign libc {
@@ -40,7 +40,7 @@ when ODIN_OS == "windows" {
ERANGE :: 34
}
-when ODIN_OS == "darwin" {
+when ODIN_OS == .Darwin {
@(private="file")
@(default_calling_convention="c")
foreign libc {
diff --git a/core/c/libc/math.odin b/core/c/libc/math.odin
index ee702b82e..97f77236f 100644
--- a/core/c/libc/math.odin
+++ b/core/c/libc/math.odin
@@ -4,9 +4,9 @@ package libc
import "core:intrinsics"
-when ODIN_OS == "windows" {
+when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib"
-} else when ODIN_OS == "darwin" {
+} else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework"
} else {
foreign import libc "system:c"
diff --git a/core/c/libc/setjmp.odin b/core/c/libc/setjmp.odin
index dcd4a9c64..c2cd1d047 100644
--- a/core/c/libc/setjmp.odin
+++ b/core/c/libc/setjmp.odin
@@ -2,14 +2,14 @@ package libc
// 7.13 Nonlocal jumps
-when ODIN_OS == "windows" {
+when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib"
-} else when ODIN_OS == "darwin" {
+} else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework"
} else {
foreign import libc "system:c"
}
-when ODIN_OS == "windows" {
+when ODIN_OS == .Windows {
@(default_calling_convention="c")
foreign libc {
// 7.13.1 Save calling environment
diff --git a/core/c/libc/signal.odin b/core/c/libc/signal.odin
index e1044dc02..186b74d8c 100644
--- a/core/c/libc/signal.odin
+++ b/core/c/libc/signal.odin
@@ -2,9 +2,9 @@ package libc
// 7.14 Signal handling
-when ODIN_OS == "windows" {
+when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib"
-} else when ODIN_OS == "darwin" {
+} else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework"
} else {
foreign import libc "system:c"
@@ -21,7 +21,7 @@ foreign libc {
raise :: proc(sig: int) -> int ---
}
-when ODIN_OS == "windows" {
+when ODIN_OS == .Windows {
SIG_ERR :: rawptr(~uintptr(0))
SIG_DFL :: rawptr(uintptr(0))
SIG_IGN :: rawptr(uintptr(1))
@@ -34,7 +34,7 @@ when ODIN_OS == "windows" {
SIGTERM :: 15
}
-when ODIN_OS == "linux" || ODIN_OS == "freebsd" {
+when ODIN_OS == .Linux || ODIN_OS == .FreeBSD {
SIG_ERR :: rawptr(~uintptr(0))
SIG_DFL :: rawptr(uintptr(0))
SIG_IGN :: rawptr(uintptr(1))
@@ -47,7 +47,7 @@ when ODIN_OS == "linux" || ODIN_OS == "freebsd" {
SIGTERM :: 15
}
-when ODIN_OS == "darwin" {
+when ODIN_OS == .Darwin {
SIG_ERR :: rawptr(~uintptr(0))
SIG_DFL :: rawptr(uintptr(0))
SIG_IGN :: rawptr(uintptr(1))
diff --git a/core/c/libc/stdio.odin b/core/c/libc/stdio.odin
index 4a39c22e9..33be34625 100644
--- a/core/c/libc/stdio.odin
+++ b/core/c/libc/stdio.odin
@@ -1,8 +1,8 @@
package libc
-when ODIN_OS == "windows" {
+when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib"
-} else when ODIN_OS == "darwin" {
+} else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework"
} else {
foreign import libc "system:c"
@@ -13,7 +13,7 @@ when ODIN_OS == "windows" {
FILE :: struct {}
// MSVCRT compatible.
-when ODIN_OS == "windows" {
+when ODIN_OS == .Windows {
_IOFBF :: 0x0000
_IONBF :: 0x0004
_IOLBF :: 0x0040
@@ -48,7 +48,7 @@ when ODIN_OS == "windows" {
}
// GLIBC and MUSL compatible.
-when ODIN_OS == "linux" {
+when ODIN_OS == .Linux {
fpos_t :: struct #raw_union { _: [16]char, _: longlong, _: double, }
_IOFBF :: 0
@@ -78,7 +78,7 @@ when ODIN_OS == "linux" {
}
}
-when ODIN_OS == "darwin" {
+when ODIN_OS == .Darwin {
fpos_t :: distinct i64
_IOFBF :: 0
diff --git a/core/c/libc/stdlib.odin b/core/c/libc/stdlib.odin
index b368c0cee..a278db0ef 100644
--- a/core/c/libc/stdlib.odin
+++ b/core/c/libc/stdlib.odin
@@ -2,15 +2,15 @@ package libc
// 7.22 General utilities
-when ODIN_OS == "windows" {
+when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib"
-} else when ODIN_OS == "darwin" {
+} else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework"
} else {
foreign import libc "system:c"
}
-when ODIN_OS == "windows" {
+when ODIN_OS == .Windows {
RAND_MAX :: 0x7fff
@(private="file")
@@ -24,7 +24,7 @@ when ODIN_OS == "windows" {
}
}
-when ODIN_OS == "linux" {
+when ODIN_OS == .Linux {
RAND_MAX :: 0x7fffffff
// GLIBC and MUSL only
@@ -40,7 +40,7 @@ when ODIN_OS == "linux" {
}
-when ODIN_OS == "darwin" {
+when ODIN_OS == .Darwin {
RAND_MAX :: 0x7fffffff
// GLIBC and MUSL only
diff --git a/core/c/libc/string.odin b/core/c/libc/string.odin
index c91124dcb..8f83ee1b9 100644
--- a/core/c/libc/string.odin
+++ b/core/c/libc/string.odin
@@ -4,9 +4,9 @@ import "core:runtime"
// 7.24 String handling
-when ODIN_OS == "windows" {
+when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib"
-} else when ODIN_OS == "darwin" {
+} else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework"
} else {
foreign import libc "system:c"
diff --git a/core/c/libc/threads.odin b/core/c/libc/threads.odin
index ad305b517..a7a45150d 100644
--- a/core/c/libc/threads.odin
+++ b/core/c/libc/threads.odin
@@ -5,7 +5,7 @@ package libc
thrd_start_t :: proc "c" (rawptr) -> int
tss_dtor_t :: proc "c" (rawptr)
-when ODIN_OS == "windows" {
+when ODIN_OS == .Windows {
foreign import libc {
"system:libucrt.lib",
"system:msvcprt.lib"
@@ -74,7 +74,7 @@ when ODIN_OS == "windows" {
}
// GLIBC and MUSL compatible constants and types.
-when ODIN_OS == "linux" {
+when ODIN_OS == .Linux {
foreign import libc {
"system:c",
"system:pthread"
@@ -138,6 +138,6 @@ when ODIN_OS == "linux" {
}
-when ODIN_OS == "darwin" {
+when ODIN_OS == .Darwin {
// TODO: find out what this is meant to be!
}
diff --git a/core/c/libc/time.odin b/core/c/libc/time.odin
index 96e80e216..b3539a227 100644
--- a/core/c/libc/time.odin
+++ b/core/c/libc/time.odin
@@ -2,9 +2,9 @@ package libc
// 7.27 Date and time
-when ODIN_OS == "windows" {
+when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib"
-} else when ODIN_OS == "darwin" {
+} else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework"
} else {
foreign import libc "system:c"
@@ -12,7 +12,7 @@ when ODIN_OS == "windows" {
// We enforce 64-bit time_t and timespec as there is no reason to use 32-bit as
// we approach the 2038 problem. Windows has defaulted to this since VC8 (2005).
-when ODIN_OS == "windows" {
+when ODIN_OS == .Windows {
foreign libc {
// 7.27.2 Time manipulation functions
clock :: proc() -> clock_t ---
@@ -45,7 +45,7 @@ when ODIN_OS == "windows" {
}
}
-when ODIN_OS == "linux" || ODIN_OS == "freebsd" || ODIN_OS == "darwin" {
+when ODIN_OS == .Linux || ODIN_OS == .FreeBSD || ODIN_OS == .Darwin {
@(default_calling_convention="c")
foreign libc {
// 7.27.2 Time manipulation functions
diff --git a/core/c/libc/uchar.odin b/core/c/libc/uchar.odin
index e49c29e51..a10969ceb 100644
--- a/core/c/libc/uchar.odin
+++ b/core/c/libc/uchar.odin
@@ -2,9 +2,9 @@ package libc
// 7.28 Unicode utilities
-when ODIN_OS == "windows" {
+when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib"
-} else when ODIN_OS == "darwin" {
+} else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework"
} else {
foreign import libc "system:c"
diff --git a/core/c/libc/wchar.odin b/core/c/libc/wchar.odin
index fc206e494..f2aa8410e 100644
--- a/core/c/libc/wchar.odin
+++ b/core/c/libc/wchar.odin
@@ -2,9 +2,9 @@ package libc
// 7.29 Extended multibyte and wide character utilities
-when ODIN_OS == "windows" {
+when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib"
-} else when ODIN_OS == "darwin" {
+} else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework"
} else {
foreign import libc "system:c"
diff --git a/core/c/libc/wctype.odin b/core/c/libc/wctype.odin
index 47f17e0b4..942726ba6 100644
--- a/core/c/libc/wctype.odin
+++ b/core/c/libc/wctype.odin
@@ -2,25 +2,25 @@ package libc
// 7.30 Wide character classification and mapping utilities
-when ODIN_OS == "windows" {
+when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib"
-} else when ODIN_OS == "darwin" {
+} else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework"
} else {
foreign import libc "system:c"
}
-when ODIN_OS == "windows" {
+when ODIN_OS == .Windows {
wctrans_t :: distinct wchar_t
wctype_t :: distinct ushort
}
-when ODIN_OS == "linux" {
+when ODIN_OS == .Linux {
wctrans_t :: distinct intptr_t
wctype_t :: distinct ulong
}
-when ODIN_OS == "darwin" {
+when ODIN_OS == .Darwin {
wctrans_t :: distinct int
wctype_t :: distinct u32
}
diff --git a/core/crypto/_fiat/field_poly1305/field.odin b/core/crypto/_fiat/field_poly1305/field.odin
index 4ed8acbff..ca458e079 100644
--- a/core/crypto/_fiat/field_poly1305/field.odin
+++ b/core/crypto/_fiat/field_poly1305/field.odin
@@ -22,7 +22,7 @@ fe_from_bytes :: #force_inline proc (out1: ^Tight_Field_Element, arg1: []byte, a
assert(len(arg1) == 16)
- when ODIN_ARCH == "i386" || ODIN_ARCH == "amd64" {
+ when ODIN_ARCH == .i386 || ODIN_ARCH == .amd64 {
// While it may be unwise to do deserialization here on our
// own when fiat-crypto provides equivalent functionality,
// doing it this way provides a little under 3x performance
diff --git a/core/crypto/chacha20/chacha20.odin b/core/crypto/chacha20/chacha20.odin
index e32dacb2c..229949c22 100644
--- a/core/crypto/chacha20/chacha20.odin
+++ b/core/crypto/chacha20/chacha20.odin
@@ -346,7 +346,7 @@ _do_blocks :: proc (ctx: ^Context, dst, src: []byte, nr_blocks: int) {
// Until dedicated assembly can be written leverage the fact that
// the callers of this routine ensure that src/dst are valid.
- when ODIN_ARCH == "i386" || ODIN_ARCH == "amd64" {
+ when ODIN_ARCH == .i386 || ODIN_ARCH == .amd64 {
// util.PUT_U32_LE/util.U32_LE are not required on little-endian
// systems that also happen to not be strict about aligned
// memory access.
diff --git a/core/crypto/rand_generic.odin b/core/crypto/rand_generic.odin
index 98890b5b1..be6987ee2 100644
--- a/core/crypto/rand_generic.odin
+++ b/core/crypto/rand_generic.odin
@@ -1,6 +1,6 @@
package crypto
-when ODIN_OS != "linux" {
+when ODIN_OS != .Linux {
_rand_bytes :: proc (dst: []byte) {
unimplemented("crypto: rand_bytes not supported on this OS")
}
diff --git a/core/image/png/example.odin b/core/image/png/example.odin
index f4eb5128e..17436c260 100644
--- a/core/image/png/example.odin
+++ b/core/image/png/example.odin
@@ -207,7 +207,7 @@ write_image_as_ppm :: proc(filename: string, image: ^image.Image) -> (success: b
}
mode: int = 0
- when ODIN_OS == "linux" || ODIN_OS == "darwin" {
+ when ODIN_OS == .Linux || ODIN_OS == .Darwin {
// NOTE(justasd): 644 (owner read, write; group read; others read)
mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
}
diff --git a/core/image/png/helpers.odin b/core/image/png/helpers.odin
index ecc0183bc..6ec674544 100644
--- a/core/image/png/helpers.odin
+++ b/core/image/png/helpers.odin
@@ -443,7 +443,7 @@ when false {
}
mode: int = 0
- when ODIN_OS == "linux" || ODIN_OS == "darwin" {
+ when ODIN_OS == .Linux || ODIN_OS == .Darwin {
// NOTE(justasd): 644 (owner read, write; group read; others read)
mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
}
diff --git a/core/os/file_windows.odin b/core/os/file_windows.odin
index 419f8bbc2..8a0f2ed64 100644
--- a/core/os/file_windows.odin
+++ b/core/os/file_windows.odin
@@ -399,7 +399,7 @@ is_abs :: proc(path: string) -> bool {
if len(path) > 0 && path[0] == '/' {
return true
}
- when ODIN_OS == "windows" {
+ when ODIN_OS == .Windows {
if len(path) > 2 {
switch path[0] {
case 'A'..='Z', 'a'..='z':
diff --git a/core/os/os.odin b/core/os/os.odin
index 83158be80..19a8099ef 100644
--- a/core/os/os.odin
+++ b/core/os/os.odin
@@ -139,7 +139,7 @@ write_entire_file :: proc(name: string, data: []byte, truncate := true) -> (succ
}
mode: int = 0
- when OS == "linux" || OS == "darwin" {
+ when OS == .Linux || OS == .Darwin {
// NOTE(justasd): 644 (owner read, write; group read; others read)
mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
}
diff --git a/core/os/os2/user.odin b/core/os/os2/user.odin
index 6dd99c621..976e61bb1 100644
--- a/core/os/os2/user.odin
+++ b/core/os/os2/user.odin
@@ -3,13 +3,13 @@ package os2
import "core:strings"
user_cache_dir :: proc(allocator := context.allocator) -> (dir: string, is_defined: bool) {
- switch ODIN_OS {
- case "windows":
+ #partial switch ODIN_OS {
+ case .Windows:
dir = get_env("LocalAppData")
if dir != "" {
dir = strings.clone(dir, allocator)
}
- case "darwin":
+ case .Darwin:
dir = get_env("HOME")
if dir != "" {
dir = strings.concatenate({dir, "/Library/Caches"}, allocator)
@@ -29,13 +29,13 @@ user_cache_dir :: proc(allocator := context.allocator) -> (dir: string, is_defin
}
user_config_dir :: proc(allocator := context.allocator) -> (dir: string, is_defined: bool) {
- switch ODIN_OS {
- case "windows":
+ #partial switch ODIN_OS {
+ case .Windows:
dir = get_env("AppData")
if dir != "" {
dir = strings.clone(dir, allocator)
}
- case "darwin":
+ case .Darwin:
dir = get_env("HOME")
if dir != "" {
dir = strings.concatenate({dir, "/Library/Application Support"}, allocator)
@@ -56,8 +56,8 @@ user_config_dir :: proc(allocator := context.allocator) -> (dir: string, is_defi
user_home_dir :: proc() -> (dir: string, is_defined: bool) {
env := "HOME"
- switch ODIN_OS {
- case "windows":
+ #partial switch ODIN_OS {
+ case .Windows:
env = "USERPROFILE"
}
if v := get_env(env); v != "" {
diff --git a/core/os/os_darwin.odin b/core/os/os_darwin.odin
index b32453a5d..4828c5167 100644
--- a/core/os/os_darwin.odin
+++ b/core/os/os_darwin.odin
@@ -335,7 +335,7 @@ open :: proc(path: string, flags: int = O_RDWR, mode: int = 0) -> (Handle, Errno
return INVALID_HANDLE, 1
}
-when ODIN_OS == "darwin" && ODIN_ARCH == "arm64" {
+when ODIN_OS == .Darwin && ODIN_ARCH == .arm64 {
if mode != 0 {
err := fchmod(handle, cast(u16)mode)
if err != 0 {
diff --git a/core/os/os_linux.odin b/core/os/os_linux.odin
index 1c796f1b8..3eb76249c 100644
--- a/core/os/os_linux.odin
+++ b/core/os/os_linux.odin
@@ -271,7 +271,7 @@ AT_REMOVEDIR :: uintptr(0x200)
AT_SYMLINK_NOFOLLOW :: uintptr(0x100)
_unix_open :: proc(path: cstring, flags: int, mode: int = 0o000) -> Handle {
- when ODIN_ARCH != "arm64" {
+ when ODIN_ARCH != .arm64 {
res := int(intrinsics.syscall(unix.SYS_open, uintptr(rawptr(path)), uintptr(flags), uintptr(mode)))
} else { // NOTE: arm64 does not have open
res := int(intrinsics.syscall(unix.SYS_openat, uintptr(AT_FDCWD), uintptr(rawptr(path), uintptr(flags), uintptr(mode))))
@@ -292,7 +292,7 @@ _unix_write :: proc(fd: Handle, buf: rawptr, size: uint) -> int {
}
_unix_seek :: proc(fd: Handle, offset: i64, whence: int) -> i64 {
- when ODIN_ARCH == "amd64" || ODIN_ARCH == "arm64" {
+ when ODIN_ARCH == .amd64 || ODIN_ARCH == .arm64 {
return i64(intrinsics.syscall(unix.SYS_lseek, uintptr(fd), uintptr(offset), uintptr(whence)))
} else {
low := uintptr(offset & 0xFFFFFFFF)
@@ -304,9 +304,9 @@ _unix_seek :: proc(fd: Handle, offset: i64, whence: int) -> i64 {
}
_unix_stat :: proc(path: cstring, stat: ^OS_Stat) -> int {
- when ODIN_ARCH == "amd64" {
+ when ODIN_ARCH == .amd64 {
return int(intrinsics.syscall(unix.SYS_stat, uintptr(rawptr(path)), uintptr(stat)))
- } else when ODIN_ARCH != "arm64" {
+ } else when ODIN_ARCH != .arm64 {
return int(intrinsics.syscall(unix.SYS_stat64, uintptr(rawptr(path)), uintptr(stat)))
} else { // NOTE: arm64 does not have stat
return int(intrinsics.syscall(unix.SYS_fstatat, uintptr(AT_FDCWD), uintptr(rawptr(path)), uintptr(stat), 0))
@@ -314,7 +314,7 @@ _unix_stat :: proc(path: cstring, stat: ^OS_Stat) -> int {
}
_unix_fstat :: proc(fd: Handle, stat: ^OS_Stat) -> int {
- when ODIN_ARCH == "amd64" || ODIN_ARCH == "arm64" {
+ when ODIN_ARCH == .amd64 || ODIN_ARCH == .arm64 {
return int(intrinsics.syscall(unix.SYS_fstat, uintptr(fd), uintptr(stat)))
} else {
return int(intrinsics.syscall(unix.SYS_fstat64, uintptr(fd), uintptr(stat)))
@@ -322,9 +322,9 @@ _unix_fstat :: proc(fd: Handle, stat: ^OS_Stat) -> int {
}
_unix_lstat :: proc(path: cstring, stat: ^OS_Stat) -> int {
- when ODIN_ARCH == "amd64" {
+ when ODIN_ARCH == .amd64 {
return int(intrinsics.syscall(unix.SYS_lstat, uintptr(rawptr(path)), uintptr(stat)))
- } else when ODIN_ARCH != "arm64" {
+ } else when ODIN_ARCH != .arm64 {
return int(intrinsics.syscall(unix.SYS_lstat64, uintptr(rawptr(path)), uintptr(stat)))
} else { // NOTE: arm64 does not have any lstat
return int(intrinsics.syscall(unix.SYS_fstatat, uintptr(AT_FDCWD), uintptr(rawptr(path)), uintptr(stat), AT_SYMLINK_NOFOLLOW))
@@ -332,7 +332,7 @@ _unix_lstat :: proc(path: cstring, stat: ^OS_Stat) -> int {
}
_unix_readlink :: proc(path: cstring, buf: rawptr, bufsiz: uint) -> int {
- when ODIN_ARCH != "arm64" {
+ when ODIN_ARCH != .arm64 {
return int(intrinsics.syscall(unix.SYS_readlink, uintptr(rawptr(path)), uintptr(buf), uintptr(bufsiz)))
} else { // NOTE: arm64 does not have readlink
return int(intrinsics.syscall(unix.SYS_readlinkat, uintptr(AT_FDCWD), uintptr(rawptr(path)), uintptr(buf), uintptr(bufsiz)))
@@ -340,7 +340,7 @@ _unix_readlink :: proc(path: cstring, buf: rawptr, bufsiz: uint) -> int {
}
_unix_access :: proc(path: cstring, mask: int) -> int {
- when ODIN_ARCH != "arm64" {
+ when ODIN_ARCH != .arm64 {
return int(intrinsics.syscall(unix.SYS_access, uintptr(rawptr(path)), uintptr(mask)))
} else { // NOTE: arm64 does not have access
return int(intrinsics.syscall(unix.SYS_faccessat, uintptr(AT_FDCWD), uintptr(rawptr(path)), uintptr(mask)))
@@ -356,7 +356,7 @@ _unix_chdir :: proc(path: cstring) -> int {
}
_unix_rename :: proc(old, new: cstring) -> int {
- when ODIN_ARCH != "arm64" {
+ when ODIN_ARCH != .arm64 {
return int(intrinsics.syscall(unix.SYS_rename, uintptr(rawptr(old)), uintptr(rawptr(new))))
} else { // NOTE: arm64 does not have rename
return int(intrinsics.syscall(unix.SYS_renameat, uintptr(AT_FDCWD), uintptr(rawptr(old)), uintptr(rawptr(new))))
@@ -364,7 +364,7 @@ _unix_rename :: proc(old, new: cstring) -> int {
}
_unix_unlink :: proc(path: cstring) -> int {
- when ODIN_ARCH != "arm64" {
+ when ODIN_ARCH != .arm64 {
return int(intrinsics.syscall(unix.SYS_unlink, uintptr(rawptr(path))))
} else { // NOTE: arm64 does not have unlink
return int(intrinsics.syscall(unix.SYS_unlinkat, uintptr(AT_FDCWD), uintptr(rawptr(path), 0)))
@@ -372,7 +372,7 @@ _unix_unlink :: proc(path: cstring) -> int {
}
_unix_rmdir :: proc(path: cstring) -> int {
- when ODIN_ARCH != "arm64" {
+ when ODIN_ARCH != .arm64 {
return int(intrinsics.syscall(unix.SYS_rmdir, uintptr(rawptr(path))))
} else { // NOTE: arm64 does not have rmdir
return int(intrinsics.syscall(unix.SYS_unlinkat, uintptr(AT_FDCWD), uintptr(rawptr(path)), AT_REMOVEDIR))
@@ -380,7 +380,7 @@ _unix_rmdir :: proc(path: cstring) -> int {
}
_unix_mkdir :: proc(path: cstring, mode: u32) -> int {
- when ODIN_ARCH != "arm64" {
+ when ODIN_ARCH != .arm64 {
return int(intrinsics.syscall(unix.SYS_mkdir, uintptr(rawptr(path)), uintptr(mode)))
} else { // NOTE: arm64 does not have mkdir
return int(intrinsics.syscall(unix.SYS_mkdirat, uintptr(AT_FDCWD), uintptr(rawptr(path)), uintptr(mode)))
diff --git a/core/os/stream.odin b/core/os/stream.odin
index 5cf5c8405..2c6e1d47f 100644
--- a/core/os/stream.odin
+++ b/core/os/stream.odin
@@ -19,7 +19,7 @@ _file_stream_vtable := &io.Stream_VTable{
return
},
impl_read_at = proc(s: io.Stream, p: []byte, offset: i64) -> (n: int, err: io.Error) {
- when ODIN_OS == "windows" || ODIN_OS == "wasi" {
+ when ODIN_OS == .Windows || ODIN_OS == .WASI {
fd := Handle(uintptr(s.stream_data))
os_err: Errno
n, os_err = read_at(fd, p, offset)
@@ -33,7 +33,7 @@ _file_stream_vtable := &io.Stream_VTable{
return
},
impl_write_at = proc(s: io.Stream, p: []byte, offset: i64) -> (n: int, err: io.Error) {
- when ODIN_OS == "windows" || ODIN_OS == "wasi" {
+ when ODIN_OS == .Windows || ODIN_OS == .WASI {
fd := Handle(uintptr(s.stream_data))
os_err: Errno
n, os_err = write_at(fd, p, offset)
@@ -53,7 +53,7 @@ _file_stream_vtable := &io.Stream_VTable{
return sz
},
impl_flush = proc(s: io.Stream) -> io.Error {
- when ODIN_OS == "windows" {
+ when ODIN_OS == .Windows {
fd := Handle(uintptr(s.stream_data))
flush(fd)
} else {
diff --git a/core/path/filepath/match.odin b/core/path/filepath/match.odin
index cba44953d..c045f3ece 100644
--- a/core/path/filepath/match.odin
+++ b/core/path/filepath/match.odin
@@ -89,7 +89,7 @@ scan_chunk :: proc(pattern: string) -> (star: bool, chunk, rest: string) {
scan_loop: for i = 0; i < len(pattern); i += 1 {
switch pattern[i] {
case '\\':
- when ODIN_OS != "windows" {
+ when ODIN_OS != .Windows {
if i+1 < len(pattern) {
i += 1
}
@@ -161,7 +161,7 @@ match_chunk :: proc(chunk, s: string) -> (rest: string, ok: bool, err: Match_Err
chunk = chunk[1:]
case '\\':
- when ODIN_OS != "windows" {
+ when ODIN_OS != .Windows {
chunk = chunk[1:]
if len(chunk) == 0 {
err = .Syntax_Error
@@ -188,7 +188,7 @@ get_escape :: proc(chunk: string) -> (r: rune, next_chunk: string, err: Match_Er
return
}
chunk := chunk
- if chunk[0] == '\\' && ODIN_OS != "windows" {
+ if chunk[0] == '\\' && ODIN_OS != .Windows {
chunk = chunk[1:]
if len(chunk) == 0 {
err = .Syntax_Error
@@ -231,7 +231,7 @@ glob :: proc(pattern: string, allocator := context.allocator) -> (matches: []str
dir, file := split(pattern)
volume_len := 0
- when ODIN_OS == "windows" {
+ when ODIN_OS == .Windows {
volume_len, dir = clean_glob_path_windows(dir, temp_buf[:])
} else {
dir = clean_glob_path(dir)
@@ -308,7 +308,7 @@ _glob :: proc(dir, pattern: string, matches: ^[dynamic]string) -> (m: [dynamic]s
@(private)
has_meta :: proc(path: string) -> bool {
- when ODIN_OS == "windows" {
+ when ODIN_OS == .Windows {
CHARS :: `*?[`
} else {
CHARS :: `*?[\`
diff --git a/core/path/filepath/path.odin b/core/path/filepath/path.odin
index 39cd80a47..d6e36f649 100644
--- a/core/path/filepath/path.odin
+++ b/core/path/filepath/path.odin
@@ -8,7 +8,7 @@ import "core:strings"
is_separator :: proc(c: byte) -> bool {
switch c {
case '/': return true
- case '\\': return ODIN_OS == "windows"
+ case '\\': return ODIN_OS == .Windows
}
return false
}
@@ -32,7 +32,7 @@ volume_name :: proc(path: string) -> string {
}
volume_name_len :: proc(path: string) -> int {
- if ODIN_OS == "windows" {
+ if ODIN_OS == .Windows {
if len(path) < 2 {
return 0
}
diff --git a/core/path/filepath/path_unix.odin b/core/path/filepath/path_unix.odin
index 1db528a2f..3e49c4710 100644
--- a/core/path/filepath/path_unix.odin
+++ b/core/path/filepath/path_unix.odin
@@ -1,7 +1,7 @@
//+build linux, darwin, freebsd
package filepath
-when ODIN_OS == "darwin" {
+when ODIN_OS == .Darwin {
foreign import libc "System.framework"
} else {
foreign import libc "system:c"
@@ -54,7 +54,7 @@ foreign libc {
@(link_name="free") _unix_free :: proc(ptr: rawptr) ---
}
-when ODIN_OS == "darwin" {
+when ODIN_OS == .Darwin {
@(private)
foreign libc {
@(link_name="__error") __error :: proc() -> ^i32 ---
diff --git a/core/runtime/core.odin b/core/runtime/core.odin
index 424650828..cd76b0bb5 100644
--- a/core/runtime/core.odin
+++ b/core/runtime/core.odin
@@ -539,7 +539,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 7b283a132..0d0e196c4 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 {
diff --git a/core/sync/sync2/primitives.odin b/core/sync/sync2/primitives.odin
index 6d056d439..046ecbc35 100644
--- a/core/sync/sync2/primitives.odin
+++ b/core/sync/sync2/primitives.odin
@@ -11,7 +11,7 @@ current_thread_id :: proc "contextless" () -> int {
//
// A Mutex must not be copied after first use
Mutex :: struct {
- impl: _Mutex,
+ impl: _Mutex `This is a tag`,
}
// mutex_lock locks m
diff --git a/core/sync/sync2/primitives_internal.odin b/core/sync/sync2/primitives_internal.odin
index ae7e2599c..eb692c6ae 100644
--- a/core/sync/sync2/primitives_internal.odin
+++ b/core/sync/sync2/primitives_internal.odin
@@ -93,7 +93,7 @@ when #config(ODIN_SYNC_RECURSIVE_MUTEX_USE_FUTEX, true) {
}
-when ODIN_OS != "windows" {
+when ODIN_OS != .Windows {
RW_Mutex_State :: distinct uint
RW_Mutex_State_Half_Width :: size_of(RW_Mutex_State)*8/2
RW_Mutex_State_Is_Writing :: RW_Mutex_State(1)
diff --git a/core/sys/unix/syscalls_linux.odin b/core/sys/unix/syscalls_linux.odin
index 3dc3d2c74..0082c7261 100644
--- a/core/sys/unix/syscalls_linux.odin
+++ b/core/sys/unix/syscalls_linux.odin
@@ -15,7 +15,7 @@ import "core:intrinsics"
// 386: arch/x86/entry/syscalls/sycall_32.tbl
// arm: arch/arm/tools/syscall.tbl
-when ODIN_ARCH == "amd64" {
+when ODIN_ARCH == .amd64 {
SYS_read : uintptr : 0
SYS_write : uintptr : 1
SYS_open : uintptr : 2
@@ -374,7 +374,7 @@ when ODIN_ARCH == "amd64" {
SYS_landlock_add_rule : uintptr : 445
SYS_landlock_restrict_self : uintptr : 446
SYS_memfd_secret : uintptr : 447
-} else when ODIN_ARCH == "arm64" {
+} else when ODIN_ARCH == .arm64 {
SYS_io_setup : uintptr : 0
SYS_io_destroy : uintptr : 1
SYS_io_submit : uintptr : 2
@@ -675,7 +675,7 @@ when ODIN_ARCH == "amd64" {
SYS_landlock_create_ruleset : uintptr : 444
SYS_landlock_add_rule : uintptr : 445
SYS_landlock_restrict_self : uintptr : 446
-} else when ODIN_ARCH == "i386" {
+} else when ODIN_ARCH == .i386 {
SYS_restart_syscall : uintptr : 0
SYS_exit : uintptr : 1
SYS_fork : uintptr : 2
@@ -1112,7 +1112,7 @@ when ODIN_ARCH == "amd64" {
SYS_landlock_add_rule : uintptr : 445
SYS_landlock_restrict_self : uintptr : 446
SYS_memfd_secret : uintptr : 447
-} else when ODIN_ARCH == "arm" {
+} else when false /*ODIN_ARCH == .arm*/ { // TODO
SYS_restart_syscall : uintptr : 0
SYS_exit : uintptr : 1
SYS_fork : uintptr : 2
diff --git a/core/time/time_unix.odin b/core/time/time_unix.odin
index 0d765b72d..9c5c5cc35 100644
--- a/core/time/time_unix.odin
+++ b/core/time/time_unix.odin
@@ -3,7 +3,7 @@ package time
IS_SUPPORTED :: true // NOTE: Times on Darwin are UTC.
-when ODIN_OS == "darwin" {
+when ODIN_OS == .Darwin {
foreign import libc "System.framework"
} else {
foreign import libc "system:c"