Replace usage of inline proc with #force_inline proc in the core library

This commit is contained in:
gingerBill
2021-02-23 16:14:47 +00:00
parent 41b854f192
commit aa93305015
26 changed files with 182 additions and 182 deletions
+11 -11
View File
@@ -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^;
}
+6 -6
View File
@@ -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..<N {
@@ -88,7 +88,7 @@ _default_hasher_const :: inline proc "contextless" (data: rawptr, seed: uintptr,
return uintptr(h);
}
default_hasher_n :: inline proc "contextless" (data: rawptr, seed: uintptr, N: int) -> 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..<N {
@@ -307,7 +307,7 @@ __dynamic_map_grow :: proc(using h: Map_Header, loc := #caller_location) {
__dynamic_map_rehash(h, new_count, loc);
}
__dynamic_map_full :: inline proc "contextless" (using h: Map_Header) -> bool {
__dynamic_map_full :: #force_inline proc "contextless" (using h: Map_Header) -> bool {
return int(0.75 * f64(len(m.hashes))) <= m.entries.cap;
}
+7 -7
View File
@@ -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);
}
+29 -29
View File
@@ -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);
}