mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 23:58:50 +00:00
Merge branch 'master' of https://github.com/odin-lang/Odin
This commit is contained in:
@@ -1,23 +1,40 @@
|
||||
//+build wasm32
|
||||
package runtime
|
||||
|
||||
@(private="file")
|
||||
ti_int :: struct #raw_union {
|
||||
using s: struct { lo, hi: u64 },
|
||||
all: i128,
|
||||
}
|
||||
|
||||
@(link_name="__ashlti3", linkage="strong")
|
||||
__ashlti3 :: proc "c" (a: i64, b_: i32) -> i64 {
|
||||
/*
|
||||
__ashlti3 :: proc "c" (a: i128, b_: u32) -> i128 {
|
||||
bits_in_dword :: size_of(u32)*8
|
||||
b := u32(b_)
|
||||
input := transmute([2]i32)a
|
||||
result: [2]i32
|
||||
if b & 32 != 0 {
|
||||
result[0] = 0
|
||||
result[1] = input[0] << (b - 32)
|
||||
|
||||
input, result: ti_int
|
||||
input.all = a
|
||||
if b & bits_in_dword != 0 {
|
||||
result.lo = 0
|
||||
result.hi = input.lo << (b-bits_in_dword)
|
||||
} else {
|
||||
if b == 0 {
|
||||
return a
|
||||
}
|
||||
result[0] = input[0]<<b
|
||||
result[1] = (input[1]<<b) | (input[0]>>(32-b))
|
||||
result.lo = input.lo<<b
|
||||
result.hi = (input.hi<<b) | (input.lo>>(bits_in_dword-b))
|
||||
}
|
||||
return transmute(i64)result
|
||||
*/
|
||||
return 0
|
||||
return result.all
|
||||
}
|
||||
|
||||
|
||||
@(link_name="__multi3", linkage="strong")
|
||||
__multi3 :: proc "c" (a, b: i128) -> i128 {
|
||||
x, y, r: ti_int
|
||||
|
||||
x.all = a
|
||||
y.all = b
|
||||
r.all = i128(x.lo * y.lo) // TODO this is incorrect
|
||||
r.hi += x.hi*y.lo + x.lo*y.hi
|
||||
return r.all
|
||||
}
|
||||
Reference in New Issue
Block a user