From aa933050155b288e0d6eb3c9327fc2726927f90b Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 23 Feb 2021 16:14:47 +0000 Subject: [PATCH] Replace usage of `inline proc` with `#force_inline proc` in the core library --- core/bytes/bytes.odin | 8 ++-- core/c/frontend/tokenizer/tokenizer.odin | 2 +- core/fmt/fmt.odin | 2 +- core/mem/alloc.odin | 16 +++---- core/mem/mem.odin | 46 +++++++++---------- core/mem/raw.odin | 8 ++-- core/odin/parser/parser.odin | 6 +-- core/odin/tokenizer/tokenizer.odin | 2 +- core/os/os_darwin.odin | 32 ++++++------- core/os/os_freebsd.odin | 26 +++++------ core/os/os_linux.odin | 38 ++++++++-------- core/path/path.odin | 4 +- core/reflect/reflect.odin | 2 +- core/runtime/core_builtin.odin | 22 ++++----- core/runtime/dynamic_map_internal.odin | 12 ++--- core/runtime/error_checks.odin | 14 +++--- core/runtime/internal.odin | 58 ++++++++++++------------ core/strconv/strconv.odin | 8 ++-- core/strings/strings.odin | 8 ++-- core/sync/atomic.odin | 26 +++++------ core/sync/sync.odin | 6 +-- core/sys/win32/general.odin | 2 +- core/sys/windows/kernel32.odin | 2 +- core/sys/windows/util.odin | 4 +- core/time/time.odin | 2 +- core/unicode/utf8/utf8.odin | 8 ++-- 26 files changed, 182 insertions(+), 182 deletions(-) diff --git a/core/bytes/bytes.odin b/core/bytes/bytes.odin index de640421f..a18772086 100644 --- a/core/bytes/bytes.odin +++ b/core/bytes/bytes.odin @@ -185,19 +185,19 @@ _split :: proc(s, sep: []byte, sep_save, n: int, allocator := context.allocator) return res[:i+1]; } -split :: inline proc(s, sep: []byte, allocator := context.allocator) -> [][]byte { +split :: proc(s, sep: []byte, allocator := context.allocator) -> [][]byte { return _split(s, sep, 0, -1, allocator); } -split_n :: inline proc(s, sep: []byte, n: int, allocator := context.allocator) -> [][]byte { +split_n :: proc(s, sep: []byte, n: int, allocator := context.allocator) -> [][]byte { return _split(s, sep, 0, n, allocator); } -split_after :: inline proc(s, sep: []byte, allocator := context.allocator) -> [][]byte { +split_after :: proc(s, sep: []byte, allocator := context.allocator) -> [][]byte { return _split(s, sep, len(sep), -1, allocator); } -split_after_n :: inline proc(s, sep: []byte, n: int, allocator := context.allocator) -> [][]byte { +split_after_n :: proc(s, sep: []byte, n: int, allocator := context.allocator) -> [][]byte { return _split(s, sep, len(sep), n, allocator); } diff --git a/core/c/frontend/tokenizer/tokenizer.odin b/core/c/frontend/tokenizer/tokenizer.odin index a2ac51952..254806cf4 100644 --- a/core/c/frontend/tokenizer/tokenizer.odin +++ b/core/c/frontend/tokenizer/tokenizer.odin @@ -372,7 +372,7 @@ scan_number :: proc(t: ^Tokenizer, seen_decimal_point: bool) -> (Token_Kind, str scan_exponent(t); } else { if t.ch == '0' { - int_base :: inline proc(t: ^Tokenizer, base: int, msg: string) { + int_base :: proc(t: ^Tokenizer, base: int, msg: string) { prev := t.offset; advance_rune(t); scan_mantissa(t, base); diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin index 4ae6747fd..eae4f6fa5 100644 --- a/core/fmt/fmt.odin +++ b/core/fmt/fmt.odin @@ -545,7 +545,7 @@ wprint_typeid :: proc(w: io.Writer, id: typeid) -> int { _parse_int :: proc(s: string, offset: int) -> (result: int, new_offset: int, ok: bool) { - is_digit :: inline proc(r: byte) -> bool { return '0' <= r && r <= '9' } + is_digit :: #force_inline proc(r: byte) -> bool { return '0' <= r && r <= '9' } new_offset = offset; for new_offset <= len(s) { diff --git a/core/mem/alloc.odin b/core/mem/alloc.odin index 6347b236c..1e5903845 100644 --- a/core/mem/alloc.odin +++ b/core/mem/alloc.odin @@ -45,7 +45,7 @@ Allocator :: struct { DEFAULT_ALIGNMENT :: 2*align_of(rawptr); -alloc :: inline proc(size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, loc := #caller_location) -> rawptr { +alloc :: proc(size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, loc := #caller_location) -> rawptr { if size == 0 { return nil; } @@ -55,7 +55,7 @@ alloc :: inline proc(size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := return allocator.procedure(allocator.data, Allocator_Mode.Alloc, size, alignment, nil, 0, 0, loc); } -free :: inline proc(ptr: rawptr, allocator := context.allocator, loc := #caller_location) { +free :: proc(ptr: rawptr, allocator := context.allocator, loc := #caller_location) { if ptr == nil { return; } @@ -65,13 +65,13 @@ free :: inline proc(ptr: rawptr, allocator := context.allocator, loc := #caller_ allocator.procedure(allocator.data, Allocator_Mode.Free, 0, 0, ptr, 0, 0, loc); } -free_all :: inline proc(allocator := context.allocator, loc := #caller_location) { +free_all :: proc(allocator := context.allocator, loc := #caller_location) { if allocator.procedure != nil { allocator.procedure(allocator.data, Allocator_Mode.Free_All, 0, 0, nil, 0, 0, loc); } } -resize :: inline proc(ptr: rawptr, old_size, new_size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, loc := #caller_location) -> rawptr { +resize :: proc(ptr: rawptr, old_size, new_size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, loc := #caller_location) -> rawptr { if allocator.procedure == nil { return nil; } @@ -132,22 +132,22 @@ delete :: proc{ }; -new :: inline proc($T: typeid, allocator := context.allocator, loc := #caller_location) -> ^T { +new :: proc($T: typeid, allocator := context.allocator, loc := #caller_location) -> ^T { return new_aligned(T, align_of(T), allocator, loc); } -new_aligned :: inline proc($T: typeid, alignment: int, allocator := context.allocator, loc := #caller_location) -> ^T { +new_aligned :: proc($T: typeid, alignment: int, allocator := context.allocator, loc := #caller_location) -> ^T { ptr := (^T)(alloc(size_of(T), alignment, allocator, loc)); if ptr != nil { ptr^ = T{}; } return ptr; } -new_clone :: inline proc(data: $T, allocator := context.allocator, loc := #caller_location) -> ^T { +new_clone :: proc(data: $T, allocator := context.allocator, loc := #caller_location) -> ^T { ptr := (^T)(alloc(size_of(T), align_of(T), allocator, loc)); if ptr != nil { ptr^ = data; } return ptr; } -make_slice :: inline proc($T: typeid/[]$E, auto_cast len: int, allocator := context.allocator, loc := #caller_location) -> T { +make_slice :: proc($T: typeid/[]$E, auto_cast len: int, allocator := context.allocator, loc := #caller_location) -> T { return make_aligned(T, len, align_of(E), allocator, loc); } make_aligned :: proc($T: typeid/[]$E, auto_cast len: int, alignment: int, allocator := context.allocator, loc := #caller_location) -> T { diff --git a/core/mem/mem.odin b/core/mem/mem.odin index 79e3b5529..6a4fdcb4c 100644 --- a/core/mem/mem.odin +++ b/core/mem/mem.odin @@ -6,10 +6,10 @@ import "core:intrinsics" set :: proc(data: rawptr, value: byte, len: int) -> rawptr { return runtime.memset(data, i32(value), len); } -zero :: inline proc(data: rawptr, len: int) -> rawptr { +zero :: proc(data: rawptr, len: int) -> rawptr { return set(data, 0, len); } -zero_item :: inline proc(item: $P/^$T) { +zero_item :: proc(item: $P/^$T) { set(item, 0, size_of(T)); } zero_slice :: proc(data: $T/[]$E) { @@ -23,7 +23,7 @@ copy :: proc(dst, src: rawptr, len: int) -> rawptr { copy_non_overlapping :: proc(dst, src: rawptr, len: int) -> rawptr { return runtime.mem_copy_non_overlapping(dst, src, len); } -compare :: inline proc(a, b: []byte) -> int { +compare :: proc(a, b: []byte) -> int { res := compare_byte_ptrs(raw_data(a), raw_data(b), min(len(a), len(b))); if res == 0 && len(a) != len(b) { return len(a) <= len(b) ? -1 : +1; @@ -121,20 +121,20 @@ simple_equal :: proc(a, b: $T) -> bool where intrinsics.type_is_simple_compare(T return compare_byte_ptrs((^byte)(&a), (^byte)(&b), size_of(T)) == 0; } -compare_ptrs :: inline proc(a, b: rawptr, n: int) -> int { +compare_ptrs :: proc(a, b: rawptr, n: int) -> int { return compare_byte_ptrs((^byte)(a), (^byte)(b), n); } -ptr_offset :: inline proc(ptr: $P/^$T, n: int) -> P { +ptr_offset :: proc(ptr: $P/^$T, n: int) -> P { new := int(uintptr(ptr)) + size_of(T)*n; return P(uintptr(new)); } -ptr_sub :: inline proc(a, b: $P/^$T) -> int { +ptr_sub :: proc(a, b: $P/^$T) -> int { return (int(uintptr(a)) - int(uintptr(b)))/size_of(T); } -slice_ptr :: inline proc(ptr: ^$T, len: int) -> []T { +slice_ptr :: proc(ptr: ^$T, len: int) -> []T { assert(len >= 0); return transmute([]T)Raw_Slice{data = ptr, len = len}; } @@ -144,13 +144,13 @@ slice_ptr_to_bytes :: proc(ptr: rawptr, len: int) -> []byte { return transmute([]byte)Raw_Slice{data = ptr, len = len}; } -slice_to_bytes :: inline proc(slice: $E/[]$T) -> []byte { +slice_to_bytes :: proc(slice: $E/[]$T) -> []byte { s := transmute(Raw_Slice)slice; s.len *= size_of(T); return transmute([]byte)s; } -slice_data_cast :: inline proc($T: typeid/[]$A, slice: $S/[]$B) -> T { +slice_data_cast :: proc($T: typeid/[]$A, slice: $S/[]$B) -> T { when size_of(A) == 0 || size_of(B) == 0 { return nil; } else { @@ -165,7 +165,7 @@ slice_to_components :: proc(slice: $E/[]$T) -> (data: ^T, len: int) { return s.data, s.len; } -buffer_from_slice :: inline proc(backing: $T/[]$E) -> [dynamic]E { +buffer_from_slice :: proc(backing: $T/[]$E) -> [dynamic]E { return transmute([dynamic]E)Raw_Dynamic_Array{ data = raw_data(backing), len = 0, @@ -174,31 +174,31 @@ buffer_from_slice :: inline proc(backing: $T/[]$E) -> [dynamic]E { }; } -ptr_to_bytes :: inline proc(ptr: ^$T, len := 1) -> []byte { +ptr_to_bytes :: proc(ptr: ^$T, len := 1) -> []byte { assert(len >= 0); return transmute([]byte)Raw_Slice{ptr, len*size_of(T)}; } -any_to_bytes :: inline proc(val: any) -> []byte { +any_to_bytes :: proc(val: any) -> []byte { ti := type_info_of(val.id); size := ti != nil ? ti.size : 0; return transmute([]byte)Raw_Slice{val.data, size}; } -kilobytes :: inline proc(x: int) -> int { return (x) * 1024; } -megabytes :: inline proc(x: int) -> int { return kilobytes(x) * 1024; } -gigabytes :: inline proc(x: int) -> int { return megabytes(x) * 1024; } -terabytes :: inline proc(x: int) -> int { return gigabytes(x) * 1024; } +kilobytes :: proc(x: int) -> int { return (x) * 1024; } +megabytes :: proc(x: int) -> int { return kilobytes(x) * 1024; } +gigabytes :: proc(x: int) -> int { return megabytes(x) * 1024; } +terabytes :: proc(x: int) -> int { return gigabytes(x) * 1024; } -is_power_of_two :: inline proc(x: uintptr) -> bool { +is_power_of_two :: proc(x: uintptr) -> bool { if x <= 0 { return false; } return (x & (x-1)) == 0; } -align_forward :: inline proc(ptr: rawptr, align: uintptr) -> rawptr { +align_forward :: proc(ptr: rawptr, align: uintptr) -> rawptr { return rawptr(align_forward_uintptr(uintptr(ptr), align)); } @@ -213,14 +213,14 @@ align_forward_uintptr :: proc(ptr, align: uintptr) -> uintptr { return p; } -align_forward_int :: inline proc(ptr, align: int) -> int { +align_forward_int :: proc(ptr, align: int) -> int { return int(align_forward_uintptr(uintptr(ptr), uintptr(align))); } -align_forward_uint :: inline proc(ptr, align: uint) -> uint { +align_forward_uint :: proc(ptr, align: uint) -> uint { return uint(align_forward_uintptr(uintptr(ptr), uintptr(align))); } -align_backward :: inline proc(ptr: rawptr, align: uintptr) -> rawptr { +align_backward :: proc(ptr: rawptr, align: uintptr) -> rawptr { return rawptr(align_backward_uintptr(uintptr(ptr), align)); } @@ -229,10 +229,10 @@ align_backward_uintptr :: proc(ptr, align: uintptr) -> uintptr { return align_forward_uintptr(ptr - align + 1, align); } -align_backward_int :: inline proc(ptr, align: int) -> int { +align_backward_int :: proc(ptr, align: int) -> int { return int(align_backward_uintptr(uintptr(ptr), uintptr(align))); } -align_backward_uint :: inline proc(ptr, align: uint) -> uint { +align_backward_uint :: proc(ptr, align: uint) -> uint { return uint(align_backward_uintptr(uintptr(ptr), uintptr(align))); } diff --git a/core/mem/raw.odin b/core/mem/raw.odin index 2551122f5..c4c5182e6 100644 --- a/core/mem/raw.odin +++ b/core/mem/raw.odin @@ -38,20 +38,20 @@ Raw_Quaternion256 :: struct {imag, jmag, kmag: f64, real: f64}; Raw_Quaternion128_Vector_Scalar :: struct {vector: [3]f32, scalar: f32}; Raw_Quaternion256_Vector_Scalar :: struct {vector: [3]f64, scalar: f64}; -make_any :: inline proc(data: rawptr, id: typeid) -> any { +make_any :: proc(data: rawptr, id: typeid) -> any { return transmute(any)Raw_Any{data, id}; } raw_array_data :: proc(a: $P/^($T/[$N]$E)) -> ^E { return (^E)(a); } -raw_string_data :: inline proc(s: $T/string) -> ^byte { +raw_string_data :: proc(s: $T/string) -> ^byte { return (transmute(Raw_String)s).data; } -raw_slice_data :: inline proc(a: $T/[]$E) -> ^E { +raw_slice_data :: proc(a: $T/[]$E) -> ^E { return cast(^E)(transmute(Raw_Slice)a).data; } -raw_dynamic_array_data :: inline proc(a: $T/[dynamic]$E) -> ^E { +raw_dynamic_array_data :: proc(a: $T/[dynamic]$E) -> ^E { return cast(^E)(transmute(Raw_Dynamic_Array)a).data; } diff --git a/core/odin/parser/parser.odin b/core/odin/parser/parser.odin index 92d0dfcb0..82f6c8ddf 100644 --- a/core/odin/parser/parser.odin +++ b/core/odin/parser/parser.odin @@ -379,16 +379,16 @@ is_blank_ident :: proc{ is_blank_ident_token, is_blank_ident_node, }; -is_blank_ident_string :: inline proc(str: string) -> bool { +is_blank_ident_string :: proc(str: string) -> bool { return str == "_"; } -is_blank_ident_token :: inline proc(tok: tokenizer.Token) -> bool { +is_blank_ident_token :: proc(tok: tokenizer.Token) -> bool { if tok.kind == .Ident { return is_blank_ident_string(tok.text); } return false; } -is_blank_ident_node :: inline proc(node: ^ast.Node) -> bool { +is_blank_ident_node :: proc(node: ^ast.Node) -> bool { if ident, ok := node.derived.(ast.Ident); ok { return is_blank_ident(ident.name); } diff --git a/core/odin/tokenizer/tokenizer.odin b/core/odin/tokenizer/tokenizer.odin index 64a060850..0e9360166 100644 --- a/core/odin/tokenizer/tokenizer.odin +++ b/core/odin/tokenizer/tokenizer.odin @@ -397,7 +397,7 @@ scan_number :: proc(t: ^Tokenizer, seen_decimal_point: bool) -> (Token_Kind, str scan_exponent(t, &kind); } else { if t.ch == '0' { - int_base :: inline proc(t: ^Tokenizer, kind: ^Token_Kind, base: int, msg: string) { + int_base :: proc(t: ^Tokenizer, kind: ^Token_Kind, base: int, msg: string) { prev := t.offset; advance_rune(t); scan_mantissa(t, base); diff --git a/core/os/os_darwin.odin b/core/os/os_darwin.odin index 818909923..bd99e967d 100644 --- a/core/os/os_darwin.odin +++ b/core/os/os_darwin.odin @@ -248,13 +248,13 @@ S_ISUID :: 0o4000; // Set user id on execution S_ISGID :: 0o2000; // Set group id on execution S_ISVTX :: 0o1000; // Directory restrcted delete -S_ISLNK :: inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFLNK; } -S_ISREG :: inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFREG; } -S_ISDIR :: inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFDIR; } -S_ISCHR :: inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFCHR; } -S_ISBLK :: inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFBLK; } -S_ISFIFO :: inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFIFO; } -S_ISSOCK :: inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFSOCK; } +S_ISLNK :: #force_inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFLNK; } +S_ISREG :: #force_inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFREG; } +S_ISDIR :: #force_inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFDIR; } +S_ISCHR :: #force_inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFCHR; } +S_ISBLK :: #force_inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFBLK; } +S_ISFIFO :: #force_inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFIFO; } +S_ISSOCK :: #force_inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFSOCK; } R_OK :: 4; // Test for read permission W_OK :: 2; // Test for write permission @@ -366,7 +366,7 @@ is_path_separator :: proc(r: rune) -> bool { return r == '/'; } -stat :: inline proc(path: string) -> (Stat, Errno) { +stat :: proc(path: string) -> (Stat, Errno) { s: Stat; cstr := strings.clone_to_cstring(path); defer delete(cstr); @@ -374,20 +374,20 @@ stat :: inline proc(path: string) -> (Stat, Errno) { return s, Errno(ret_int); } -access :: inline proc(path: string, mask: int) -> bool { +access :: proc(path: string, mask: int) -> bool { cstr := strings.clone_to_cstring(path); defer delete(cstr); return _unix_access(cstr, mask) == 0; } -heap_alloc :: inline proc(size: int) -> rawptr { +heap_alloc :: proc(size: int) -> rawptr { assert(size > 0); return _unix_calloc(1, size); } -heap_resize :: inline proc(ptr: rawptr, new_size: int) -> rawptr { +heap_resize :: proc(ptr: rawptr, new_size: int) -> rawptr { return _unix_realloc(ptr, new_size); } -heap_free :: inline proc(ptr: rawptr) { +heap_free :: proc(ptr: rawptr) { _unix_free(ptr); } @@ -426,7 +426,7 @@ set_current_directory :: proc(path: string) -> (err: Errno) { return ERROR_NONE; } -exit :: inline proc(code: int) -> ! { +exit :: proc(code: int) -> ! { _unix_exit(code); } @@ -440,20 +440,20 @@ current_thread_id :: proc "contextless" () -> int { return int(tid); } -dlopen :: inline proc(filename: string, flags: int) -> rawptr { +dlopen :: proc(filename: string, flags: int) -> rawptr { cstr := strings.clone_to_cstring(filename); defer delete(cstr); handle := _unix_dlopen(cstr, flags); return handle; } -dlsym :: inline proc(handle: rawptr, symbol: string) -> rawptr { +dlsym :: proc(handle: rawptr, symbol: string) -> rawptr { assert(handle != nil); cstr := strings.clone_to_cstring(symbol); defer delete(cstr); proc_handle := _unix_dlsym(handle, cstr); return proc_handle; } -dlclose :: inline proc(handle: rawptr) -> bool { +dlclose :: proc(handle: rawptr) -> bool { assert(handle != nil); return _unix_dlclose(handle) == 0; } diff --git a/core/os/os_freebsd.odin b/core/os/os_freebsd.odin index fa439141e..21b68f293 100644 --- a/core/os/os_freebsd.odin +++ b/core/os/os_freebsd.odin @@ -211,13 +211,13 @@ S_ISGID :: 0o2000; // Set group id on execution S_ISVTX :: 0o1000; // Directory restrcted delete -S_ISLNK :: inline proc(m: u32) -> bool do return (m & S_IFMT) == S_IFLNK; -S_ISREG :: inline proc(m: u32) -> bool do return (m & S_IFMT) == S_IFREG; -S_ISDIR :: inline proc(m: u32) -> bool do return (m & S_IFMT) == S_IFDIR; -S_ISCHR :: inline proc(m: u32) -> bool do return (m & S_IFMT) == S_IFCHR; -S_ISBLK :: inline proc(m: u32) -> bool do return (m & S_IFMT) == S_IFBLK; -S_ISFIFO :: inline proc(m: u32) -> bool do return (m & S_IFMT) == S_IFIFO; -S_ISSOCK :: inline proc(m: u32) -> bool do return (m & S_IFMT) == S_IFSOCK; +S_ISLNK :: #force_inline proc(m: u32) -> bool do return (m & S_IFMT) == S_IFLNK; +S_ISREG :: #force_inline proc(m: u32) -> bool do return (m & S_IFMT) == S_IFREG; +S_ISDIR :: #force_inline proc(m: u32) -> bool do return (m & S_IFMT) == S_IFDIR; +S_ISCHR :: #force_inline proc(m: u32) -> bool do return (m & S_IFMT) == S_IFCHR; +S_ISBLK :: #force_inline proc(m: u32) -> bool do return (m & S_IFMT) == S_IFBLK; +S_ISFIFO :: #force_inline proc(m: u32) -> bool do return (m & S_IFMT) == S_IFIFO; +S_ISSOCK :: #force_inline proc(m: u32) -> bool do return (m & S_IFMT) == S_IFSOCK; F_OK :: 0; // Test for file existance X_OK :: 1; // Test for execute permission @@ -341,7 +341,7 @@ last_write_time_by_name :: proc(name: string) -> (File_Time, Errno) { return File_Time(modified), ERROR_NONE; } -stat :: inline proc(path: string) -> (Stat, Errno) { +stat :: proc(path: string) -> (Stat, Errno) { cstr := strings.clone_to_cstring(path); defer delete(cstr); @@ -353,7 +353,7 @@ stat :: inline proc(path: string) -> (Stat, Errno) { return s, ERROR_NONE; } -fstat :: inline proc(fd: Handle) -> (Stat, Errno) { +fstat :: proc(fd: Handle) -> (Stat, Errno) { s: Stat; result := _unix_fstat(fd, &s); if result == -1 { @@ -362,7 +362,7 @@ fstat :: inline proc(fd: Handle) -> (Stat, Errno) { return s, ERROR_NONE; } -access :: inline proc(path: string, mask: int) -> (bool, Errno) { +access :: proc(path: string, mask: int) -> (bool, Errno) { cstr := strings.clone_to_cstring(path); defer delete(cstr); result := _unix_access(cstr, c.int(mask)); @@ -429,20 +429,20 @@ current_thread_id :: proc "contextless" () -> int { return cast(int) pthread_getthreadid_np(); } -dlopen :: inline proc(filename: string, flags: int) -> rawptr { +dlopen :: proc(filename: string, flags: int) -> rawptr { cstr := strings.clone_to_cstring(filename); defer delete(cstr); handle := _unix_dlopen(cstr, c.int(flags)); return handle; } -dlsym :: inline proc(handle: rawptr, symbol: string) -> rawptr { +dlsym :: proc(handle: rawptr, symbol: string) -> rawptr { assert(handle != nil); cstr := strings.clone_to_cstring(symbol); defer delete(cstr); proc_handle := _unix_dlsym(handle, cstr); return proc_handle; } -dlclose :: inline proc(handle: rawptr) -> bool { +dlclose :: proc(handle: rawptr) -> bool { assert(handle != nil); return _unix_dlclose(handle) == 0; } diff --git a/core/os/os_linux.odin b/core/os/os_linux.odin index 517570686..eb2c6a663 100644 --- a/core/os/os_linux.odin +++ b/core/os/os_linux.odin @@ -252,13 +252,13 @@ S_ISGID :: 0o2000; // Set group id on execution S_ISVTX :: 0o1000; // Directory restrcted delete -S_ISLNK :: inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFLNK; } -S_ISREG :: inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFREG; } -S_ISDIR :: inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFDIR; } -S_ISCHR :: inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFCHR; } -S_ISBLK :: inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFBLK; } -S_ISFIFO :: inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFIFO; } -S_ISSOCK :: inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFSOCK; } +S_ISLNK :: #force_inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFLNK; } +S_ISREG :: #force_inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFREG; } +S_ISDIR :: #force_inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFDIR; } +S_ISCHR :: #force_inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFCHR; } +S_ISBLK :: #force_inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFBLK; } +S_ISFIFO :: #force_inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFIFO; } +S_ISSOCK :: #force_inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFSOCK; } F_OK :: 0; // Test for file existance X_OK :: 1; // Test for execute permission @@ -397,7 +397,7 @@ last_write_time_by_name :: proc(name: string) -> (File_Time, Errno) { } @private -_stat :: inline proc(path: string) -> (Stat, Errno) { +_stat :: proc(path: string) -> (Stat, Errno) { cstr := strings.clone_to_cstring(path); defer delete(cstr); @@ -410,7 +410,7 @@ _stat :: inline proc(path: string) -> (Stat, Errno) { } @private -_lstat :: inline proc(path: string) -> (Stat, Errno) { +_lstat :: proc(path: string) -> (Stat, Errno) { cstr := strings.clone_to_cstring(path); defer delete(cstr); @@ -423,7 +423,7 @@ _lstat :: inline proc(path: string) -> (Stat, Errno) { } @private -_fstat :: inline proc(fd: Handle) -> (Stat, Errno) { +_fstat :: proc(fd: Handle) -> (Stat, Errno) { s: Stat; result := _unix_fstat(fd, &s); if result == -1 { @@ -433,7 +433,7 @@ _fstat :: inline proc(fd: Handle) -> (Stat, Errno) { } @private -_fdopendir :: inline proc(fd: Handle) -> (Dir, Errno) { +_fdopendir :: proc(fd: Handle) -> (Dir, Errno) { dirp := _unix_fdopendir(fd); if dirp == cast(Dir)nil { return nil, Errno(get_last_error()); @@ -442,7 +442,7 @@ _fdopendir :: inline proc(fd: Handle) -> (Dir, Errno) { } @private -_closedir :: inline proc(dirp: Dir) -> Errno { +_closedir :: proc(dirp: Dir) -> Errno { rc := _unix_closedir(dirp); if rc != 0 { return Errno(get_last_error()); @@ -451,12 +451,12 @@ _closedir :: inline proc(dirp: Dir) -> Errno { } @private -_rewinddir :: inline proc(dirp: Dir) { +_rewinddir :: proc(dirp: Dir) { _unix_rewinddir(dirp); } @private -_readdir :: inline proc(dirp: Dir) -> (entry: Dirent, err: Errno, end_of_stream: bool) { +_readdir :: proc(dirp: Dir) -> (entry: Dirent, err: Errno, end_of_stream: bool) { result: ^Dirent; rc := _unix_readdir_r(dirp, &entry, &result); @@ -476,7 +476,7 @@ _readdir :: inline proc(dirp: Dir) -> (entry: Dirent, err: Errno, end_of_stream: } @private -_readlink :: inline proc(path: string) -> (string, Errno) { +_readlink :: proc(path: string) -> (string, Errno) { path_cstr := strings.clone_to_cstring(path); defer delete(path_cstr); @@ -529,7 +529,7 @@ absolute_path_from_relative :: proc(rel: string) -> (path: string, err: Errno) { return path, ERROR_NONE; } -access :: inline proc(path: string, mask: int) -> (bool, Errno) { +access :: proc(path: string, mask: int) -> (bool, Errno) { cstr := strings.clone_to_cstring(path); defer delete(cstr); result := _unix_access(cstr, c.int(mask)); @@ -598,20 +598,20 @@ current_thread_id :: proc "contextless" () -> int { return syscall(SYS_GETTID); } -dlopen :: inline proc(filename: string, flags: int) -> rawptr { +dlopen :: proc(filename: string, flags: int) -> rawptr { cstr := strings.clone_to_cstring(filename); defer delete(cstr); handle := _unix_dlopen(cstr, c.int(flags)); return handle; } -dlsym :: inline proc(handle: rawptr, symbol: string) -> rawptr { +dlsym :: proc(handle: rawptr, symbol: string) -> rawptr { assert(handle != nil); cstr := strings.clone_to_cstring(symbol); defer delete(cstr); proc_handle := _unix_dlsym(handle, cstr); return proc_handle; } -dlclose :: inline proc(handle: rawptr) -> bool { +dlclose :: proc(handle: rawptr) -> bool { assert(handle != nil); return _unix_dlclose(handle) == 0; } diff --git a/core/path/path.odin b/core/path/path.odin index 7bda85cf8..ed6f2bfcf 100644 --- a/core/path/path.odin +++ b/core/path/path.odin @@ -8,13 +8,13 @@ package path import "core:strings" // is_separator checks whether the byte is a valid separator character -is_separator :: inline proc(c: byte) -> bool { +is_separator :: proc(c: byte) -> bool { return c == '/'; } // is_abs checks whether the path is absolute -is_abs :: inline proc(path: string) -> bool { +is_abs :: proc(path: string) -> bool { return len(path) > 0 && path[0] == '/'; } diff --git a/core/reflect/reflect.odin b/core/reflect/reflect.odin index 5e6b265d8..638216339 100644 --- a/core/reflect/reflect.odin +++ b/core/reflect/reflect.odin @@ -201,7 +201,7 @@ as_bytes :: proc(v: any) -> []byte { return nil; } -any_data :: inline proc(v: any) -> (data: rawptr, id: typeid) { +any_data :: #force_inline proc(v: any) -> (data: rawptr, id: typeid) { return v.data, v.id; } diff --git a/core/runtime/core_builtin.odin b/core/runtime/core_builtin.odin index 043010470..8a60e33d5 100644 --- a/core/runtime/core_builtin.odin +++ b/core/runtime/core_builtin.odin @@ -163,14 +163,14 @@ delete :: proc{ // The new built-in procedure allocates memory. The first argument is a type, not a value, and the value // return is a pointer to a newly allocated value of that type using the specified allocator, default is context.allocator @builtin -new :: inline proc($T: typeid, allocator := context.allocator, loc := #caller_location) -> ^T { +new :: proc($T: typeid, allocator := context.allocator, loc := #caller_location) -> ^T { ptr := (^T)(mem_alloc(size_of(T), align_of(T), allocator, loc)); if ptr != nil { ptr^ = T{}; } return ptr; } @builtin -new_clone :: inline proc(data: $T, allocator := context.allocator, loc := #caller_location) -> ^T { +new_clone :: proc(data: $T, allocator := context.allocator, loc := #caller_location) -> ^T { ptr := (^T)(mem_alloc(size_of(T), align_of(T), allocator, loc)); if ptr != nil { ptr^ = data; } return ptr; @@ -188,7 +188,7 @@ make_aligned :: proc($T: typeid/[]$E, auto_cast len: int, alignment: int, alloca } @builtin -make_slice :: inline proc($T: typeid/[]$E, auto_cast len: int, allocator := context.allocator, loc := #caller_location) -> T { +make_slice :: proc($T: typeid/[]$E, auto_cast len: int, allocator := context.allocator, loc := #caller_location) -> T { return make_aligned(T, len, align_of(E), allocator, loc); } @@ -240,7 +240,7 @@ make :: proc{ @builtin -clear_map :: inline proc "contextless" (m: ^$T/map[$K]$V) { +clear_map :: proc "contextless" (m: ^$T/map[$K]$V) { if m == nil { return; } @@ -626,7 +626,7 @@ insert_at_elem_string :: proc(array: ^$T/[dynamic]$E/u8, index: int, arg: string @builtin -clear_dynamic_array :: inline proc "contextless" (array: ^$T/[dynamic]$E) { +clear_dynamic_array :: proc "contextless" (array: ^$T/[dynamic]$E) { if array != nil { (^Raw_Dynamic_Array)(array).len = 0; } @@ -703,36 +703,36 @@ resize_dynamic_array :: proc(array: ^$T/[dynamic]$E, length: int, loc := #caller @builtin -incl_elem :: inline proc(s: ^$S/bit_set[$E; $U], elem: E) -> S { +incl_elem :: proc(s: ^$S/bit_set[$E; $U], elem: E) -> S { s^ |= {elem}; return s^; } @builtin -incl_elems :: inline proc(s: ^$S/bit_set[$E; $U], elems: ..E) -> S { +incl_elems :: proc(s: ^$S/bit_set[$E; $U], elems: ..E) -> S { for elem in elems { s^ |= {elem}; } return s^; } @builtin -incl_bit_set :: inline proc(s: ^$S/bit_set[$E; $U], other: S) -> S { +incl_bit_set :: proc(s: ^$S/bit_set[$E; $U], other: S) -> S { s^ |= other; return s^; } @builtin -excl_elem :: inline proc(s: ^$S/bit_set[$E; $U], elem: E) -> S { +excl_elem :: proc(s: ^$S/bit_set[$E; $U], elem: E) -> S { s^ &~= {elem}; return s^; } @builtin -excl_elems :: inline proc(s: ^$S/bit_set[$E; $U], elems: ..E) -> S { +excl_elems :: proc(s: ^$S/bit_set[$E; $U], elems: ..E) -> S { for elem in elems { s^ &~= {elem}; } return s^; } @builtin -excl_bit_set :: inline proc(s: ^$S/bit_set[$E; $U], other: S) -> S { +excl_bit_set :: proc(s: ^$S/bit_set[$E; $U], other: S) -> S { s^ &~= other; return s^; } diff --git a/core/runtime/dynamic_map_internal.odin b/core/runtime/dynamic_map_internal.odin index d6583a6d3..4c3c3929f 100644 --- a/core/runtime/dynamic_map_internal.odin +++ b/core/runtime/dynamic_map_internal.odin @@ -65,19 +65,19 @@ _fnv64a :: proc "contextless" (data: []byte, seed: u64 = INITIAL_HASH_SEED) -> u return h; } -default_hash :: inline proc "contextless" (data: []byte) -> uintptr { +default_hash :: #force_inline proc "contextless" (data: []byte) -> uintptr { return uintptr(_fnv64a(data)); } -default_hash_string :: inline proc "contextless" (s: string) -> uintptr { +default_hash_string :: #force_inline proc "contextless" (s: string) -> uintptr { return default_hash(transmute([]byte)(s)); } -default_hash_ptr :: inline proc "contextless" (data: rawptr, size: int) -> uintptr { +default_hash_ptr :: #force_inline proc "contextless" (data: rawptr, size: int) -> uintptr { s := Raw_Slice{data, size}; return default_hash(transmute([]byte)(s)); } @(private) -_default_hasher_const :: inline proc "contextless" (data: rawptr, seed: uintptr, $N: uint) -> uintptr where N <= 16 { +_default_hasher_const :: #force_inline proc "contextless" (data: rawptr, seed: uintptr, $N: uint) -> uintptr where N <= 16 { h := u64(seed) + 0xcbf29ce484222325; p := uintptr(data); #unroll for _ in 0.. uintptr { +default_hasher_n :: #force_inline proc "contextless" (data: rawptr, seed: uintptr, N: int) -> uintptr { h := u64(seed) + 0xcbf29ce484222325; p := uintptr(data); for _ in 0.. bool { +__dynamic_map_full :: #force_inline proc "contextless" (using h: Map_Header) -> bool { return int(0.75 * f64(len(m.hashes))) <= m.entries.cap; } diff --git a/core/runtime/error_checks.odin b/core/runtime/error_checks.odin index 38d6641ab..a0a15590f 100644 --- a/core/runtime/error_checks.odin +++ b/core/runtime/error_checks.odin @@ -151,7 +151,7 @@ type_assertion_check2 :: proc "contextless" (ok: bool, file: string, line, colum } -make_slice_error_loc :: inline proc "contextless" (loc := #caller_location, len: int) { +make_slice_error_loc :: #force_inline proc "contextless" (loc := #caller_location, len: int) { if 0 <= len { return; } @@ -166,7 +166,7 @@ make_slice_error_loc :: inline proc "contextless" (loc := #caller_location, len: handle_error(loc, len); } -make_dynamic_array_error_loc :: inline proc "contextless" (using loc := #caller_location, len, cap: int) { +make_dynamic_array_error_loc :: #force_inline proc "contextless" (using loc := #caller_location, len, cap: int) { if 0 <= len && len <= cap { return; } @@ -183,7 +183,7 @@ make_dynamic_array_error_loc :: inline proc "contextless" (using loc := #caller_ handle_error(loc, len, cap); } -make_map_expr_error_loc :: inline proc "contextless" (loc := #caller_location, cap: int) { +make_map_expr_error_loc :: #force_inline proc "contextless" (loc := #caller_location, cap: int) { if 0 <= cap { return; } @@ -202,18 +202,18 @@ make_map_expr_error_loc :: inline proc "contextless" (loc := #caller_location, c -bounds_check_error_loc :: inline proc "contextless" (using loc := #caller_location, index, count: int) { +bounds_check_error_loc :: #force_inline proc "contextless" (using loc := #caller_location, index, count: int) { bounds_check_error(file_path, int(line), int(column), index, count); } -slice_expr_error_hi_loc :: inline proc "contextless" (using loc := #caller_location, hi: int, len: int) { +slice_expr_error_hi_loc :: #force_inline proc "contextless" (using loc := #caller_location, hi: int, len: int) { slice_expr_error_hi(file_path, int(line), int(column), hi, len); } -slice_expr_error_lo_hi_loc :: inline proc "contextless" (using loc := #caller_location, lo, hi: int, len: int) { +slice_expr_error_lo_hi_loc :: #force_inline proc "contextless" (using loc := #caller_location, lo, hi: int, len: int) { slice_expr_error_lo_hi(file_path, int(line), int(column), lo, hi, len); } -dynamic_array_expr_error_loc :: inline proc "contextless" (using loc := #caller_location, low, high, max: int) { +dynamic_array_expr_error_loc :: #force_inline proc "contextless" (using loc := #caller_location, low, high, max: int) { dynamic_array_expr_error(file_path, int(line), int(column), low, high, max); } diff --git a/core/runtime/internal.odin b/core/runtime/internal.odin index 27cd3e767..46e0ca92b 100644 --- a/core/runtime/internal.odin +++ b/core/runtime/internal.odin @@ -32,19 +32,19 @@ bswap_f64 :: proc "none" (f: f64) -> f64 { -ptr_offset :: inline proc "contextless" (ptr: $P/^$T, n: int) -> P { +ptr_offset :: #force_inline proc "contextless" (ptr: $P/^$T, n: int) -> P { new := int(uintptr(ptr)) + size_of(T)*n; return P(uintptr(new)); } -is_power_of_two_int :: inline proc(x: int) -> bool { +is_power_of_two_int :: #force_inline proc(x: int) -> bool { if x <= 0 { return false; } return (x & (x-1)) == 0; } -align_forward_int :: inline proc(ptr, align: int) -> int { +align_forward_int :: #force_inline proc(ptr, align: int) -> int { assert(is_power_of_two_int(align)); p := ptr; @@ -55,14 +55,14 @@ align_forward_int :: inline proc(ptr, align: int) -> int { return p; } -is_power_of_two_uintptr :: inline proc(x: uintptr) -> bool { +is_power_of_two_uintptr :: #force_inline proc(x: uintptr) -> bool { if x <= 0 { return false; } return (x & (x-1)) == 0; } -align_forward_uintptr :: inline proc(ptr, align: uintptr) -> uintptr { +align_forward_uintptr :: #force_inline proc(ptr, align: uintptr) -> uintptr { assert(is_power_of_two_uintptr(align)); p := ptr; @@ -142,7 +142,7 @@ mem_copy_non_overlapping :: proc "contextless" (dst, src: rawptr, len: int) -> r DEFAULT_ALIGNMENT :: 2*align_of(rawptr); -mem_alloc :: inline proc(size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, loc := #caller_location) -> rawptr { +mem_alloc :: #force_inline proc(size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, loc := #caller_location) -> rawptr { if size == 0 { return nil; } @@ -152,7 +152,7 @@ mem_alloc :: inline proc(size: int, alignment: int = DEFAULT_ALIGNMENT, allocato return allocator.procedure(allocator.data, .Alloc, size, alignment, nil, 0, 0, loc); } -mem_free :: inline proc(ptr: rawptr, allocator := context.allocator, loc := #caller_location) { +mem_free :: #force_inline proc(ptr: rawptr, allocator := context.allocator, loc := #caller_location) { if ptr == nil { return; } @@ -162,13 +162,13 @@ mem_free :: inline proc(ptr: rawptr, allocator := context.allocator, loc := #cal allocator.procedure(allocator.data, .Free, 0, 0, ptr, 0, 0, loc); } -mem_free_all :: inline proc(allocator := context.allocator, loc := #caller_location) { +mem_free_all :: #force_inline proc(allocator := context.allocator, loc := #caller_location) { if allocator.procedure != nil { allocator.procedure(allocator.data, .Free_All, 0, 0, nil, 0, 0, loc); } } -mem_resize :: inline proc(ptr: rawptr, old_size, new_size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, loc := #caller_location) -> rawptr { +mem_resize :: #force_inline proc(ptr: rawptr, old_size, new_size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, loc := #caller_location) -> rawptr { switch { case allocator.procedure == nil: return nil; @@ -278,11 +278,11 @@ string_cmp :: proc "contextless" (a, b: string) -> int { return memory_compare(x.data, y.data, min(x.len, y.len)); } -string_ne :: inline proc "contextless" (a, b: string) -> bool { return !string_eq(a, b); } -string_lt :: inline proc "contextless" (a, b: string) -> bool { return string_cmp(a, b) < 0; } -string_gt :: inline proc "contextless" (a, b: string) -> bool { return string_cmp(a, b) > 0; } -string_le :: inline proc "contextless" (a, b: string) -> bool { return string_cmp(a, b) <= 0; } -string_ge :: inline proc "contextless" (a, b: string) -> bool { return string_cmp(a, b) >= 0; } +string_ne :: #force_inline proc "contextless" (a, b: string) -> bool { return !string_eq(a, b); } +string_lt :: #force_inline proc "contextless" (a, b: string) -> bool { return string_cmp(a, b) < 0; } +string_gt :: #force_inline proc "contextless" (a, b: string) -> bool { return string_cmp(a, b) > 0; } +string_le :: #force_inline proc "contextless" (a, b: string) -> bool { return string_cmp(a, b) <= 0; } +string_ge :: #force_inline proc "contextless" (a, b: string) -> bool { return string_cmp(a, b) >= 0; } cstring_len :: proc "contextless" (s: cstring) -> int { p0 := uintptr((^byte)(s)); @@ -303,21 +303,21 @@ cstring_to_string :: proc "contextless" (s: cstring) -> string { } -complex64_eq :: inline proc "contextless" (a, b: complex64) -> bool { return real(a) == real(b) && imag(a) == imag(b); } -complex64_ne :: inline proc "contextless" (a, b: complex64) -> bool { return real(a) != real(b) || imag(a) != imag(b); } +complex64_eq :: #force_inline proc "contextless" (a, b: complex64) -> bool { return real(a) == real(b) && imag(a) == imag(b); } +complex64_ne :: #force_inline proc "contextless" (a, b: complex64) -> bool { return real(a) != real(b) || imag(a) != imag(b); } -complex128_eq :: inline proc "contextless" (a, b: complex128) -> bool { return real(a) == real(b) && imag(a) == imag(b); } -complex128_ne :: inline proc "contextless" (a, b: complex128) -> bool { return real(a) != real(b) || imag(a) != imag(b); } +complex128_eq :: #force_inline proc "contextless" (a, b: complex128) -> bool { return real(a) == real(b) && imag(a) == imag(b); } +complex128_ne :: #force_inline proc "contextless" (a, b: complex128) -> bool { return real(a) != real(b) || imag(a) != imag(b); } -quaternion128_eq :: inline proc "contextless" (a, b: quaternion128) -> bool { return real(a) == real(b) && imag(a) == imag(b) && jmag(a) == jmag(b) && kmag(a) == kmag(b); } -quaternion128_ne :: inline proc "contextless" (a, b: quaternion128) -> bool { return real(a) != real(b) || imag(a) != imag(b) || jmag(a) != jmag(b) || kmag(a) != kmag(b); } +quaternion128_eq :: #force_inline proc "contextless" (a, b: quaternion128) -> bool { return real(a) == real(b) && imag(a) == imag(b) && jmag(a) == jmag(b) && kmag(a) == kmag(b); } +quaternion128_ne :: #force_inline proc "contextless" (a, b: quaternion128) -> bool { return real(a) != real(b) || imag(a) != imag(b) || jmag(a) != jmag(b) || kmag(a) != kmag(b); } -quaternion256_eq :: inline proc "contextless" (a, b: quaternion256) -> bool { return real(a) == real(b) && imag(a) == imag(b) && jmag(a) == jmag(b) && kmag(a) == kmag(b); } -quaternion256_ne :: inline proc "contextless" (a, b: quaternion256) -> bool { return real(a) != real(b) || imag(a) != imag(b) || jmag(a) != jmag(b) || kmag(a) != kmag(b); } +quaternion256_eq :: #force_inline proc "contextless" (a, b: quaternion256) -> bool { return real(a) == real(b) && imag(a) == imag(b) && jmag(a) == jmag(b) && kmag(a) == kmag(b); } +quaternion256_ne :: #force_inline proc "contextless" (a, b: quaternion256) -> bool { return real(a) != real(b) || imag(a) != imag(b) || jmag(a) != jmag(b) || kmag(a) != kmag(b); } -string_decode_rune :: inline proc "contextless" (s: string) -> (rune, int) { +string_decode_rune :: #force_inline proc "contextless" (s: string) -> (rune, int) { // NOTE(bill): Duplicated here to remove dependency on package unicode/utf8 @static accept_sizes := [256]u8{ @@ -401,13 +401,13 @@ foreign { @(link_name="llvm.sqrt.f32") _sqrt_f32 :: proc(x: f32) -> f32 --- @(link_name="llvm.sqrt.f64") _sqrt_f64 :: proc(x: f64) -> f64 --- } -abs_f32 :: inline proc "contextless" (x: f32) -> f32 { +abs_f32 :: #force_inline proc "contextless" (x: f32) -> f32 { foreign { @(link_name="llvm.fabs.f32") _abs :: proc "none" (x: f32) -> f32 --- } return _abs(x); } -abs_f64 :: inline proc "contextless" (x: f64) -> f64 { +abs_f64 :: #force_inline proc "contextless" (x: f64) -> f64 { foreign { @(link_name="llvm.fabs.f64") _abs :: proc "none" (x: f64) -> f64 --- } @@ -439,19 +439,19 @@ max_f64 :: proc(a, b: f64) -> f64 { return _max(a, b); } -abs_complex64 :: inline proc "contextless" (x: complex64) -> f32 { +abs_complex64 :: #force_inline proc "contextless" (x: complex64) -> f32 { r, i := real(x), imag(x); return _sqrt_f32(r*r + i*i); } -abs_complex128 :: inline proc "contextless" (x: complex128) -> f64 { +abs_complex128 :: #force_inline proc "contextless" (x: complex128) -> f64 { r, i := real(x), imag(x); return _sqrt_f64(r*r + i*i); } -abs_quaternion128 :: inline proc "contextless" (x: quaternion128) -> f32 { +abs_quaternion128 :: #force_inline proc "contextless" (x: quaternion128) -> f32 { r, i, j, k := real(x), imag(x), jmag(x), kmag(x); return _sqrt_f32(r*r + i*i + j*j + k*k); } -abs_quaternion256 :: inline proc "contextless" (x: quaternion256) -> f64 { +abs_quaternion256 :: #force_inline proc "contextless" (x: quaternion256) -> f64 { r, i, j, k := real(x), imag(x), jmag(x), kmag(x); return _sqrt_f64(r*r + i*i + j*j + k*k); } diff --git a/core/strconv/strconv.odin b/core/strconv/strconv.odin index 93fef3031..87026fe22 100644 --- a/core/strconv/strconv.odin +++ b/core/strconv/strconv.odin @@ -458,7 +458,7 @@ append_float :: proc(buf: []byte, f: f64, fmt: byte, prec, bit_size: int) -> str quote :: proc(buf: []byte, str: string) -> string { - write_byte :: inline proc(buf: []byte, i: ^int, bytes: ..byte) { + write_byte :: proc(buf: []byte, i: ^int, bytes: ..byte) { if i^ >= len(buf) { return; } @@ -496,19 +496,19 @@ quote :: proc(buf: []byte, str: string) -> string { } quote_rune :: proc(buf: []byte, r: rune) -> string { - write_byte :: inline proc(buf: []byte, i: ^int, bytes: ..byte) { + write_byte :: proc(buf: []byte, i: ^int, bytes: ..byte) { if i^ < len(buf) { n := copy(buf[i^:], bytes[:]); i^ += n; } } - write_string :: inline proc(buf: []byte, i: ^int, s: string) { + write_string :: proc(buf: []byte, i: ^int, s: string) { if i^ < len(buf) { n := copy(buf[i^:], s); i^ += n; } } - write_rune :: inline proc(buf: []byte, i: ^int, r: rune) { + write_rune :: proc(buf: []byte, i: ^int, r: rune) { if i^ < len(buf) { b, w := utf8.encode_rune(r); n := copy(buf[i^:], b[:w]); diff --git a/core/strings/strings.odin b/core/strings/strings.odin index 09c39050f..658bf4b7d 100644 --- a/core/strings/strings.odin +++ b/core/strings/strings.odin @@ -198,19 +198,19 @@ _split :: proc(s_, sep: string, sep_save, n_: int, allocator := context.allocato return res[:i+1]; } -split :: inline proc(s, sep: string, allocator := context.allocator) -> []string { +split :: proc(s, sep: string, allocator := context.allocator) -> []string { return _split(s, sep, 0, -1, allocator); } -split_n :: inline proc(s, sep: string, n: int, allocator := context.allocator) -> []string { +split_n :: proc(s, sep: string, n: int, allocator := context.allocator) -> []string { return _split(s, sep, 0, n, allocator); } -split_after :: inline proc(s, sep: string, allocator := context.allocator) -> []string { +split_after :: proc(s, sep: string, allocator := context.allocator) -> []string { return _split(s, sep, len(sep), -1, allocator); } -split_after_n :: inline proc(s, sep: string, n: int, allocator := context.allocator) -> []string { +split_after_n :: proc(s, sep: string, n: int, allocator := context.allocator) -> []string { return _split(s, sep, len(sep), n, allocator); } diff --git a/core/sync/atomic.odin b/core/sync/atomic.odin index f2c7e6ba1..489d3e407 100644 --- a/core/sync/atomic.odin +++ b/core/sync/atomic.odin @@ -18,11 +18,11 @@ strongest_failure_ordering_table := [Ordering]Ordering{ .Sequentially_Consistent = .Sequentially_Consistent, }; -strongest_failure_ordering :: inline proc(order: Ordering) -> Ordering { +strongest_failure_ordering :: #force_inline proc(order: Ordering) -> Ordering { return strongest_failure_ordering_table[order]; } -fence :: inline proc($order: Ordering) { +fence :: #force_inline proc($order: Ordering) { when order == .Relaxed { #panic("there is no such thing as a relaxed fence"); } else when order == .Release { intrinsics.atomic_fence_rel(); } else when order == .Acquire { intrinsics.atomic_fence_acq(); } @@ -32,7 +32,7 @@ fence :: inline proc($order: Ordering) { } -atomic_store :: inline proc(dst: ^$T, val: T, $order: Ordering) { +atomic_store :: #force_inline proc(dst: ^$T, val: T, $order: Ordering) { when order == .Relaxed { intrinsics.atomic_store_relaxed(dst, val); } else when order == .Release { intrinsics.atomic_store_rel(dst, val); } else when order == .Sequentially_Consistent { intrinsics.atomic_store(dst, val); } @@ -41,7 +41,7 @@ atomic_store :: inline proc(dst: ^$T, val: T, $order: Ordering) { else { #panic("unknown order"); } } -atomic_load :: inline proc(dst: ^$T, $order: Ordering) -> T { +atomic_load :: #force_inline proc(dst: ^$T, $order: Ordering) -> T { when order == .Relaxed { return intrinsics.atomic_load_relaxed(dst); } else when order == .Acquire { return intrinsics.atomic_load_acq(dst); } else when order == .Sequentially_Consistent { return intrinsics.atomic_load(dst); } @@ -50,7 +50,7 @@ atomic_load :: inline proc(dst: ^$T, $order: Ordering) -> T { else { #panic("unknown order"); } } -atomic_swap :: inline proc(dst: ^$T, val: T, $order: Ordering) -> T { +atomic_swap :: #force_inline proc(dst: ^$T, val: T, $order: Ordering) -> T { when order == .Relaxed { return intrinsics.atomic_xchg_relaxed(dst, val); } else when order == .Release { return intrinsics.atomic_xchg_rel(dst, val); } else when order == .Acquire { return intrinsics.atomic_xchg_acq(dst, val); } @@ -59,7 +59,7 @@ atomic_swap :: inline proc(dst: ^$T, val: T, $order: Ordering) -> T { else { #panic("unknown order"); } } -atomic_compare_exchange :: inline proc(dst: ^$T, old, new: T, $success, $failure: Ordering) -> (val: T, ok: bool) { +atomic_compare_exchange :: #force_inline proc(dst: ^$T, old, new: T, $success, $failure: Ordering) -> (val: T, ok: bool) { when failure == .Relaxed { when success == .Relaxed { return intrinsics.atomic_cxchg_relaxed(dst, old, new); } else when success == .Acquire { return intrinsics.atomic_cxchg_acq_failrelaxed(dst, old, new); } @@ -85,7 +85,7 @@ atomic_compare_exchange :: inline proc(dst: ^$T, old, new: T, $success, $failure } -atomic_compare_exchange_weak :: inline proc(dst: ^$T, old, new: T, $success, $failure: Ordering) -> (val: T, ok: bool) { +atomic_compare_exchange_weak :: #force_inline proc(dst: ^$T, old, new: T, $success, $failure: Ordering) -> (val: T, ok: bool) { when failure == .Relaxed { when success == .Relaxed { return intrinsics.atomic_cxchgweak_relaxed(dst, old, new); } else when success == .Acquire { return intrinsics.atomic_cxchgweak_acq_failrelaxed(dst, old, new); } @@ -112,7 +112,7 @@ atomic_compare_exchange_weak :: inline proc(dst: ^$T, old, new: T, $success, $fa } -atomic_add :: inline proc(dst: ^$T, val: T, $order: Ordering) -> T { +atomic_add :: #force_inline proc(dst: ^$T, val: T, $order: Ordering) -> T { when order == .Relaxed { return intrinsics.atomic_add_relaxed(dst, val); } else when order == .Release { return intrinsics.atomic_add_rel(dst, val); } else when order == .Acquire { return intrinsics.atomic_add_acq(dst, val); } @@ -121,7 +121,7 @@ atomic_add :: inline proc(dst: ^$T, val: T, $order: Ordering) -> T { else { #panic("unknown order"); } } -atomic_sub :: inline proc(dst: ^$T, val: T, $order: Ordering) -> T { +atomic_sub :: #force_inline proc(dst: ^$T, val: T, $order: Ordering) -> T { when order == .Relaxed { return intrinsics.atomic_sub_relaxed(dst, val); } else when order == .Release { return intrinsics.atomic_sub_rel(dst, val); } else when order == .Acquire { return intrinsics.atomic_sub_acq(dst, val); } @@ -130,7 +130,7 @@ atomic_sub :: inline proc(dst: ^$T, val: T, $order: Ordering) -> T { else { #panic("unknown order"); } } -atomic_and :: inline proc(dst: ^$T, val: T, $order: Ordering) -> T { +atomic_and :: #force_inline proc(dst: ^$T, val: T, $order: Ordering) -> T { when order == .Relaxed { return intrinsics.atomic_and_relaxed(dst, val); } else when order == .Release { return intrinsics.atomic_and_rel(dst, val); } else when order == .Acquire { return intrinsics.atomic_and_acq(dst, val); } @@ -139,7 +139,7 @@ atomic_and :: inline proc(dst: ^$T, val: T, $order: Ordering) -> T { else { #panic("unknown order"); } } -atomic_nand :: inline proc(dst: ^$T, val: T, $order: Ordering) -> T { +atomic_nand :: #force_inline proc(dst: ^$T, val: T, $order: Ordering) -> T { when order == .Relaxed { return intrinsics.atomic_nand_relaxed(dst, val); } else when order == .Release { return intrinsics.atomic_nand_rel(dst, val); } else when order == .Acquire { return intrinsics.atomic_nand_acq(dst, val); } @@ -148,7 +148,7 @@ atomic_nand :: inline proc(dst: ^$T, val: T, $order: Ordering) -> T { else { #panic("unknown order"); } } -atomic_or :: inline proc(dst: ^$T, val: T, $order: Ordering) -> T { +atomic_or :: #force_inline proc(dst: ^$T, val: T, $order: Ordering) -> T { when order == .Relaxed { return intrinsics.atomic_or_relaxed(dst, val); } else when order == .Release { return intrinsics.atomic_or_rel(dst, val); } else when order == .Acquire { return intrinsics.atomic_or_acq(dst, val); } @@ -157,7 +157,7 @@ atomic_or :: inline proc(dst: ^$T, val: T, $order: Ordering) -> T { else { #panic("unknown order"); } } -atomic_xor :: inline proc(dst: ^$T, val: T, $order: Ordering) -> T { +atomic_xor :: #force_inline proc(dst: ^$T, val: T, $order: Ordering) -> T { when order == .Relaxed { return intrinsics.atomic_xor_relaxed(dst, val); } else when order == .Release { return intrinsics.atomic_xor_rel(dst, val); } else when order == .Acquire { return intrinsics.atomic_xor_acq(dst, val); } diff --git a/core/sync/sync.odin b/core/sync/sync.odin index b7c832213..06ec043bc 100644 --- a/core/sync/sync.odin +++ b/core/sync/sync.odin @@ -3,7 +3,7 @@ package sync import "intrinsics" import "core:runtime" -cpu_relax :: inline proc "contextless" () { +cpu_relax :: #force_inline proc "contextless" () { intrinsics.cpu_relax(); } @@ -20,14 +20,14 @@ ticket_mutex_init :: proc(m: ^Ticket_Mutex) { atomic_store(&m.serving, 0, .Relaxed); } -ticket_mutex_lock :: inline proc(m: ^Ticket_Mutex) { +ticket_mutex_lock :: #force_inline proc(m: ^Ticket_Mutex) { ticket := atomic_add(&m.ticket, 1, .Relaxed); for ticket != atomic_load(&m.serving, .Acquire) { intrinsics.cpu_relax(); } } -ticket_mutex_unlock :: inline proc(m: ^Ticket_Mutex) { +ticket_mutex_unlock :: #force_inline proc(m: ^Ticket_Mutex) { atomic_add(&m.serving, 1, .Relaxed); } diff --git a/core/sys/win32/general.odin b/core/sys/win32/general.odin index da3cc37ad..4c4eaa289 100644 --- a/core/sys/win32/general.odin +++ b/core/sys/win32/general.odin @@ -852,7 +852,7 @@ HIWORD_L :: proc(lParam: Lparam) -> u16 { return u16((u32(lParam) >> 16) & 0xfff LOWORD_W :: proc(wParam: Wparam) -> u16 { return u16(wParam); } LOWORD_L :: proc(lParam: Lparam) -> u16 { return u16(lParam); } -is_key_down :: inline proc(key: Key_Code) -> bool { return get_async_key_state(i32(key)) < 0; } +is_key_down :: #force_inline proc(key: Key_Code) -> bool { return get_async_key_state(i32(key)) < 0; } diff --git a/core/sys/windows/kernel32.odin b/core/sys/windows/kernel32.odin index bfbc1d2dc..b839336bb 100644 --- a/core/sys/windows/kernel32.odin +++ b/core/sys/windows/kernel32.odin @@ -690,7 +690,7 @@ foreign kernel32 { NUMA_NO_PREFERRED_NODE :: 0xffffffff; -MapViewOfFile2 :: inline proc( +MapViewOfFile2 :: #force_inline proc( FileMappingHandle: HANDLE, ProcessHandle: HANDLE, Offset: ULONG64, diff --git a/core/sys/windows/util.odin b/core/sys/windows/util.odin index 9d620bc78..2718faf20 100644 --- a/core/sys/windows/util.odin +++ b/core/sys/windows/util.odin @@ -1,10 +1,10 @@ package sys_windows -LOWORD :: inline proc "contextless" (x: DWORD) -> WORD { +LOWORD :: #force_inline proc "contextless" (x: DWORD) -> WORD { return WORD(x & 0xffff); } -HIWORD :: inline proc "contextless" (x: DWORD) -> WORD { +HIWORD :: #force_inline proc "contextless" (x: DWORD) -> WORD { return WORD(x >> 16); } diff --git a/core/time/time.odin b/core/time/time.odin index 740a0df5b..df65f85f6 100644 --- a/core/time/time.odin +++ b/core/time/time.odin @@ -76,7 +76,7 @@ duration_hours :: proc(d: Duration) -> f64 { return f64(hour) + f64(nsec)/(60*60*1e9); } -_less_than_half :: inline proc(x, y: Duration) -> bool { +_less_than_half :: #force_inline proc(x, y: Duration) -> bool { return u64(x)+u64(x) < u64(y); } diff --git a/core/unicode/utf8/utf8.odin b/core/unicode/utf8/utf8.odin index 50d24d562..61f54e07f 100644 --- a/core/unicode/utf8/utf8.odin +++ b/core/unicode/utf8/utf8.odin @@ -90,7 +90,7 @@ encode_rune :: proc(c: rune) -> ([4]u8, int) { return buf, 4; } -decode_rune_in_string :: inline proc(s: string) -> (rune, int) { +decode_rune_in_string :: #force_inline proc(s: string) -> (rune, int) { return decode_rune(transmute([]u8)s); } decode_rune :: proc(s: []u8) -> (rune, int) { @@ -161,7 +161,7 @@ runes_to_string :: proc(runes: []rune, allocator := context.allocator) -> string } -decode_last_rune_in_string :: inline proc(s: string) -> (rune, int) { +decode_last_rune_in_string :: #force_inline proc(s: string) -> (rune, int) { return decode_last_rune(transmute([]u8)s); } decode_last_rune :: proc(s: []u8) -> (rune, int) { @@ -293,11 +293,11 @@ valid_string :: proc(s: string) -> bool { return true; } -rune_start :: inline proc(b: u8) -> bool { +rune_start :: #force_inline proc(b: u8) -> bool { return b&0xc0 != 0x80; } -rune_count_in_string :: inline proc(s: string) -> int { +rune_count_in_string :: #force_inline proc(s: string) -> int { return rune_count(transmute([]u8)s); } rune_count :: proc(s: []u8) -> int {