diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/math/math_sincos.odin | 28 | ||||
| -rw-r--r-- | core/slice/slice.odin | 4 | ||||
| -rw-r--r-- | core/sort/sort.odin | 4 | ||||
| -rw-r--r-- | core/sys/wasm/js/memory_all_targets.odin | 6 | ||||
| -rw-r--r-- | core/sys/wasm/js/memory_js.odin | 12 | ||||
| -rw-r--r-- | core/sys/windows/gdi32.odin | 4 |
6 files changed, 34 insertions, 24 deletions
diff --git a/core/math/math_sincos.odin b/core/math/math_sincos.odin index 9b4d3de40..a17f39fe5 100644 --- a/core/math/math_sincos.odin +++ b/core/math/math_sincos.odin @@ -1,6 +1,6 @@ package math -import "core:math/bits" +import "base:intrinsics" // The original C code, the long comment, and the constants // below were from http://netlib.sandia.gov/cephes/cmath/sin.c, @@ -280,16 +280,16 @@ _trig_reduce_f64 :: proc "contextless" (x: f64) -> (j: u64, z: f64) #no_bounds_c z1 := (bd_pi4[digit+1] << bitshift) | (bd_pi4[digit+2] >> (64 - bitshift)) z2 := (bd_pi4[digit+2] << bitshift) | (bd_pi4[digit+3] >> (64 - bitshift)) // Multiply mantissa by the digits and extract the upper two digits (hi, lo). - z2hi, _ := bits.mul(z2, ix) - z1hi, z1lo := bits.mul(z1, ix) + z2hi, _ := mul_u64(z2, ix) + z1hi, z1lo := mul_u64(z1, ix) z0lo := z0 * ix - lo, c := bits.add(z1lo, z2hi, 0) - hi, _ := bits.add(z0lo, z1hi, c) + lo, c := add_u64(z1lo, z2hi, 0) + hi, _ := add_u64(z0lo, z1hi, c) // The top 3 bits are j. j = hi >> 61 // Extract the fraction and find its magnitude. hi = hi<<3 | lo>>61 - lz := uint(bits.leading_zeros(hi)) + lz := uint(intrinsics.count_leading_zeros(hi)) e := u64(BIAS - (lz + 1)) // Clear implicit mantissa bit and shift into place. hi = (hi << (lz + 1)) | (lo >> (64 - (lz + 1))) @@ -305,4 +305,20 @@ _trig_reduce_f64 :: proc "contextless" (x: f64) -> (j: u64, z: f64) #no_bounds_c } // Multiply the fractional part by pi/4. return j, z * PI4 + + @(require_results) + add_u64 :: proc "contextless" (x, y, carry: u64) -> (sum, carry_out: u64) { + tmp_carry, tmp_carry2: bool + sum, tmp_carry = intrinsics.overflow_add(x, y) + sum, tmp_carry2 = intrinsics.overflow_add(sum, carry) + carry_out = u64(tmp_carry | tmp_carry2) + return + } + + @(require_results) + mul_u64 :: proc "contextless" (x, y: u64) -> (hi, lo: u64) { + prod_wide := u128(x) * u128(y) + hi, lo = u64(prod_wide>>64), u64(prod_wide) + return + } } diff --git a/core/slice/slice.odin b/core/slice/slice.odin index 12ebfce3b..0df55320b 100644 --- a/core/slice/slice.odin +++ b/core/slice/slice.odin @@ -3,12 +3,10 @@ package slice import "base:intrinsics" import "base:builtin" -import "core:math/bits" import "base:runtime" _ :: intrinsics _ :: builtin -_ :: bits _ :: runtime /* @@ -933,7 +931,7 @@ If `elems` is out of bounds (more than the total) this will trigger a bounds che Example: import "core:fmt" import "core:slice" - + advance_slices_example :: proc() { slices := [][]byte { {1, 2, 3, 4}, diff --git a/core/sort/sort.odin b/core/sort/sort.odin index 63cb50490..30abc5336 100644 --- a/core/sort/sort.odin +++ b/core/sort/sort.odin @@ -2,11 +2,9 @@ package sort import "core:mem" -import _slice "core:slice" import "base:intrinsics" _ :: intrinsics -_ :: _slice ORD :: intrinsics.type_is_ordered Interface :: struct { @@ -639,7 +637,7 @@ compare_f64s :: proc(a, b: f64) -> int { compare_strings :: proc(a, b: string) -> int { x := transmute(mem.Raw_String)a y := transmute(mem.Raw_String)b - + ret := mem.compare_byte_ptrs(x.data, y.data, min(x.len, y.len)) if ret == 0 && x.len != y.len { return -1 if x.len < y.len else +1 diff --git a/core/sys/wasm/js/memory_all_targets.odin b/core/sys/wasm/js/memory_all_targets.odin index e80d13c0b..69a789145 100644 --- a/core/sys/wasm/js/memory_all_targets.odin +++ b/core/sys/wasm/js/memory_all_targets.odin @@ -1,14 +1,14 @@ #+build !js package wasm_js_interface -import "core:mem" +import "base:runtime" PAGE_SIZE :: 64 * 1024 -page_alloc :: proc(page_count: int) -> (data: []byte, err: mem.Allocator_Error) { +page_alloc :: proc(page_count: int) -> (data: []byte, err: runtime.Allocator_Error) { panic("vendor:wasm/js not supported on non-js targets") } -page_allocator :: proc() -> mem.Allocator { +page_allocator :: proc() -> runtime.Allocator { panic("vendor:wasm/js not supported on non-js targets") } diff --git a/core/sys/wasm/js/memory_js.odin b/core/sys/wasm/js/memory_js.odin index 8232cd0c9..df3191b29 100644 --- a/core/sys/wasm/js/memory_js.odin +++ b/core/sys/wasm/js/memory_js.odin @@ -1,11 +1,11 @@ #+build js wasm32, js wasm64p32 package wasm_js_interface -import "core:mem" +import "base:runtime" import "base:intrinsics" PAGE_SIZE :: 64 * 1024 -page_alloc :: proc(page_count: int) -> (data: []byte, err: mem.Allocator_Error) { +page_alloc :: proc(page_count: int) -> (data: []byte, err: runtime.Allocator_Error) { prev_page_count := intrinsics.wasm_memory_grow(0, uintptr(page_count)) if prev_page_count < 0 { return nil, .Out_Of_Memory @@ -15,11 +15,11 @@ page_alloc :: proc(page_count: int) -> (data: []byte, err: mem.Allocator_Error) return ptr[:page_count * PAGE_SIZE], nil } -page_allocator :: proc() -> mem.Allocator { - procedure :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode, +page_allocator :: proc() -> runtime.Allocator { + procedure :: proc(allocator_data: rawptr, mode: runtime.Allocator_Mode, size, alignment: int, old_memory: rawptr, old_size: int, - location := #caller_location) -> ([]byte, mem.Allocator_Error) { + location := #caller_location) -> ([]byte, runtime.Allocator_Error) { switch mode { case .Alloc, .Alloc_Non_Zeroed: assert(size % PAGE_SIZE == 0) @@ -27,7 +27,7 @@ page_allocator :: proc() -> mem.Allocator { case .Resize, .Free, .Free_All, .Query_Info, .Resize_Non_Zeroed: return nil, .Mode_Not_Implemented case .Query_Features: - set := (^mem.Allocator_Mode_Set)(old_memory) + set := (^runtime.Allocator_Mode_Set)(old_memory) if set != nil { set^ = {.Alloc, .Query_Features} } diff --git a/core/sys/windows/gdi32.odin b/core/sys/windows/gdi32.odin index ad2243b56..e607aafcc 100644 --- a/core/sys/windows/gdi32.odin +++ b/core/sys/windows/gdi32.odin @@ -1,8 +1,6 @@ #+build windows package sys_windows -import "core:math/fixed" - foreign import gdi32 "system:Gdi32.lib" @(default_calling_convention="system") @@ -100,7 +98,7 @@ PALETTEINDEX :: #force_inline proc "contextless" (#any_int i: int) -> COLORREF { return COLORREF(DWORD(0x01000000) | DWORD(WORD(i))) } -FXPT2DOT30 :: distinct fixed.Fixed(i32, 30) +FXPT2DOT30 :: distinct i32 // fixed.Fixed(i32, 30) CIEXYZ :: struct { ciexyzX, ciexyzY, ciexyzZ: FXPT2DOT30, |