diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2024-01-29 16:18:38 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-29 16:18:38 +0000 |
| commit | f588593ff15fa13e89bd869a52b2ff9bf9d91341 (patch) | |
| tree | 8f2c0a32259c405c53396ead12b1c8f3f5c261d0 /base/runtime/procs_wasm.odin | |
| parent | a78f062499c7f0112558872a500904e6fbc6761b (diff) | |
| parent | a626adac8e8e0ca0506401cf3376727ad801091c (diff) | |
Merge pull request #3147 from odin-lang/base-work
`base` library collection work
Diffstat (limited to 'base/runtime/procs_wasm.odin')
| -rw-r--r-- | base/runtime/procs_wasm.odin | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/base/runtime/procs_wasm.odin b/base/runtime/procs_wasm.odin new file mode 100644 index 000000000..26dcfef77 --- /dev/null +++ b/base/runtime/procs_wasm.odin @@ -0,0 +1,40 @@ +//+build wasm32, wasm64p32 +package runtime + +@(private="file") +ti_int :: struct #raw_union { + using s: struct { lo, hi: u64 }, + all: i128, +} + +@(link_name="__ashlti3", linkage="strong") +__ashlti3 :: proc "contextless" (a: i128, b_: u32) -> i128 { + bits_in_dword :: size_of(u32)*8 + b := u32(b_) + + 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.lo = input.lo<<b + result.hi = (input.hi<<b) | (input.lo>>(bits_in_dword-b)) + } + return result.all +} + + +@(link_name="__multi3", linkage="strong") +__multi3 :: proc "contextless" (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 +}
\ No newline at end of file |