@grain/stdlib 0.5.4 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/array.gr +60 -57
- package/array.md +24 -6
- package/buffer.gr +71 -1
- package/buffer.md +142 -0
- package/bytes.gr +52 -3
- package/bytes.md +117 -0
- package/char.gr +21 -18
- package/char.md +18 -3
- package/immutablepriorityqueue.gr +13 -13
- package/int32.gr +39 -37
- package/int32.md +6 -0
- package/int64.gr +39 -37
- package/int64.md +6 -0
- package/list.gr +31 -22
- package/list.md +39 -10
- package/map.gr +19 -28
- package/number.gr +81 -5
- package/number.md +64 -2
- package/option.gr +30 -26
- package/option.md +12 -0
- package/package.json +1 -1
- package/path.gr +787 -0
- package/path.md +727 -0
- package/pervasives.gr +3 -4
- package/pervasives.md +6 -1
- package/queue.gr +11 -9
- package/queue.md +2 -0
- package/regex.gr +76 -3
- package/regex.md +70 -0
- package/result.gr +24 -20
- package/result.md +12 -0
- package/runtime/atof/common.gr +198 -0
- package/runtime/atof/common.md +243 -0
- package/runtime/atof/decimal.gr +663 -0
- package/runtime/atof/decimal.md +59 -0
- package/runtime/atof/lemire.gr +264 -0
- package/runtime/atof/lemire.md +6 -0
- package/runtime/atof/parse.gr +615 -0
- package/runtime/atof/parse.md +12 -0
- package/runtime/atof/slow.gr +238 -0
- package/runtime/atof/slow.md +6 -0
- package/runtime/atof/table.gr +2016 -0
- package/runtime/atof/table.md +12 -0
- package/runtime/{stringUtils.gr → atoi/parse.gr} +1 -1
- package/runtime/{stringUtils.md → atoi/parse.md} +1 -1
- package/runtime/bigint.gr +3 -3
- package/runtime/equal.gr +1 -1
- package/runtime/numberUtils.gr +2 -2
- package/runtime/numberUtils.md +6 -0
- package/runtime/numbers.gr +4 -4
- package/runtime/unsafe/conv.gr +21 -41
- package/runtime/unsafe/conv.md +0 -3
- package/runtime/unsafe/printWasm.gr +4 -40
- package/runtime/utils/printing.gr +3 -3
- package/stack.gr +4 -2
- package/stack.md +2 -0
- package/string.gr +1 -1
- package/sys/time.gr +4 -4
|
@@ -18,7 +18,7 @@ import BI from "runtime/bigint"
|
|
|
18
18
|
import { reducedInteger } from "runtime/numbers"
|
|
19
19
|
|
|
20
20
|
@unsafe
|
|
21
|
-
export let
|
|
21
|
+
export let parseInt = (string: String, radix: Number) => {
|
|
22
22
|
let _CHAR_0 = 0x30n
|
|
23
23
|
let _CHAR_B = 0x42n
|
|
24
24
|
let _CHAR_b = 0x62n
|
package/runtime/bigint.gr
CHANGED
|
@@ -786,7 +786,7 @@ let _SIZES = [>
|
|
|
786
786
|
]
|
|
787
787
|
|
|
788
788
|
@unsafe
|
|
789
|
-
export let
|
|
789
|
+
export let bigIntToString = (num: WasmI32, base: WasmI32) => {
|
|
790
790
|
let getDigit = n =>
|
|
791
791
|
WasmI32.load8U(WasmI32.add(WasmI32.fromGrain(_DIGITS), n), 8n)
|
|
792
792
|
if (WasmI32.ltS(base, 2n) || WasmI32.gtS(base, 32n)) {
|
|
@@ -1339,7 +1339,7 @@ export let shl = (num: WasmI32, places: WasmI32) => {
|
|
|
1339
1339
|
let (&) = WasmI64.and
|
|
1340
1340
|
let a = places / 32n
|
|
1341
1341
|
let b = places % 32n
|
|
1342
|
-
let mask = (1N << WasmI64.extendI32U(b)) - 1N << 64N - WasmI64.extendI32U(b)
|
|
1342
|
+
let mask = ((1N << WasmI64.extendI32U(b)) - 1N) << 64N - WasmI64.extendI32U(b)
|
|
1343
1343
|
let result = init(numLimbs + a)
|
|
1344
1344
|
setFlag(result, _IS_NEGATIVE, getFlag(num, _IS_NEGATIVE))
|
|
1345
1345
|
let numHalfLimbs = WasmI32.shl(numLimbs, 1n)
|
|
@@ -1350,7 +1350,7 @@ export let shl = (num: WasmI32, places: WasmI32) => {
|
|
|
1350
1350
|
setHalfLimb(
|
|
1351
1351
|
result,
|
|
1352
1352
|
i + a,
|
|
1353
|
-
WasmI32.wrapI64(acc << WasmI64.extendI32U(b) >> 32N)
|
|
1353
|
+
WasmI32.wrapI64((acc << WasmI64.extendI32U(b)) >> 32N)
|
|
1354
1354
|
)
|
|
1355
1355
|
}
|
|
1356
1356
|
let (>) = WasmI64.gtU
|
package/runtime/equal.gr
CHANGED
package/runtime/numberUtils.gr
CHANGED
|
@@ -46,7 +46,7 @@ let _I32_MAX = 0xffffffffN
|
|
|
46
46
|
let mut _POWERS10 = -1n
|
|
47
47
|
|
|
48
48
|
@unsafe
|
|
49
|
-
let get_POWERS10 = () => {
|
|
49
|
+
export let get_POWERS10 = () => {
|
|
50
50
|
if (_POWERS10 == -1n) {
|
|
51
51
|
_POWERS10 = Memory.malloc(40n)
|
|
52
52
|
WasmI32.store(_POWERS10, 1n, 0n)
|
|
@@ -1277,7 +1277,7 @@ let genDigits = (buffer, w_frc, mp_frc, mp_exp, delta, sign) => {
|
|
|
1277
1277
|
wp_w_frc = WasmI64.mul(
|
|
1278
1278
|
wp_w_frc,
|
|
1279
1279
|
WasmI64.extendI32U(
|
|
1280
|
-
WasmI32.load(get_POWERS10() + (0n - kappa << 2n), 0n)
|
|
1280
|
+
WasmI32.load(get_POWERS10() + ((0n - kappa) << 2n), 0n)
|
|
1281
1281
|
)
|
|
1282
1282
|
)
|
|
1283
1283
|
grisuRound(buffer, len, delta, p2, one_frc, wp_w_frc)
|
package/runtime/numberUtils.md
CHANGED
package/runtime/numbers.gr
CHANGED
|
@@ -1426,7 +1426,7 @@ let numberTimesDivideBigIntHelp = (x, y, isDivide) => {
|
|
|
1426
1426
|
},
|
|
1427
1427
|
t when WasmI32.eq(t, Tags._GRAIN_BIGINT_BOXED_NUM_TAG) => {
|
|
1428
1428
|
if (isDivide) {
|
|
1429
|
-
|
|
1429
|
+
reducedFractionBigInt(x, y)
|
|
1430
1430
|
} else {
|
|
1431
1431
|
reducedBigInteger(BI.mul(x, y))
|
|
1432
1432
|
}
|
|
@@ -2220,7 +2220,7 @@ export let (>>) = (x: Number, y: Number) => {
|
|
|
2220
2220
|
// we will fail if attempting to coerce to an int!
|
|
2221
2221
|
|
|
2222
2222
|
@unsafe
|
|
2223
|
-
export let
|
|
2223
|
+
export let coerceNumberToInt32 = (x: Number) => {
|
|
2224
2224
|
let x = WasmI32.fromGrain(x)
|
|
2225
2225
|
let result = if (
|
|
2226
2226
|
!isSimpleNumber(x) &&
|
|
@@ -2239,7 +2239,7 @@ export let rec coerceNumberToInt32 = (x: Number) => {
|
|
|
2239
2239
|
}
|
|
2240
2240
|
|
|
2241
2241
|
@unsafe
|
|
2242
|
-
export let
|
|
2242
|
+
export let coerceNumberToInt64 = (x: Number) => {
|
|
2243
2243
|
let x = WasmI32.fromGrain(x)
|
|
2244
2244
|
let result = if (
|
|
2245
2245
|
!isSimpleNumber(x) &&
|
|
@@ -2257,7 +2257,7 @@ export let rec coerceNumberToInt64 = (x: Number) => {
|
|
|
2257
2257
|
}
|
|
2258
2258
|
|
|
2259
2259
|
@unsafe
|
|
2260
|
-
export let
|
|
2260
|
+
export let coerceNumberToBigInt = (x: Number) => {
|
|
2261
2261
|
let x = WasmI32.fromGrain(x)
|
|
2262
2262
|
let result = if (isBigInt(x)) {
|
|
2263
2263
|
// avoid extra malloc and prevent x from being freed
|
package/runtime/unsafe/conv.gr
CHANGED
|
@@ -1,69 +1,53 @@
|
|
|
1
|
-
import Memory from "runtime/unsafe/memory"
|
|
2
1
|
import WasmI32 from "runtime/unsafe/wasmi32"
|
|
3
2
|
import WasmI64 from "runtime/unsafe/wasmi64"
|
|
4
3
|
import WasmF32 from "runtime/unsafe/wasmf32"
|
|
5
4
|
import WasmF64 from "runtime/unsafe/wasmf64"
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import {
|
|
6
|
+
newInt32,
|
|
7
|
+
newInt64,
|
|
8
|
+
newFloat32,
|
|
9
|
+
newFloat64,
|
|
10
|
+
} from "runtime/dataStructures"
|
|
11
|
+
|
|
12
|
+
@unsafe
|
|
9
13
|
export let toInt32 = n => {
|
|
10
|
-
|
|
11
|
-
WasmI32.store(ptr, Tags._GRAIN_BOXED_NUM_HEAP_TAG, 0n)
|
|
12
|
-
WasmI32.store(ptr, Tags._GRAIN_INT32_BOXED_NUM_TAG, 4n)
|
|
13
|
-
WasmI32.store(ptr, n, 8n)
|
|
14
|
-
|
|
15
|
-
WasmI32.toGrain(ptr): Int32
|
|
14
|
+
WasmI32.toGrain(newInt32(n)): Int32
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
@
|
|
17
|
+
@unsafe
|
|
19
18
|
export let fromInt32 = (n: Int32) => {
|
|
20
19
|
let ptr = WasmI32.fromGrain(n)
|
|
21
20
|
WasmI32.load(ptr, 8n)
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
@
|
|
23
|
+
@unsafe
|
|
25
24
|
export let toInt64 = n => {
|
|
26
|
-
|
|
27
|
-
WasmI32.store(ptr, Tags._GRAIN_BOXED_NUM_HEAP_TAG, 0n)
|
|
28
|
-
WasmI32.store(ptr, Tags._GRAIN_INT64_BOXED_NUM_TAG, 4n)
|
|
29
|
-
WasmI64.store(ptr, n, 8n)
|
|
30
|
-
|
|
31
|
-
WasmI32.toGrain(ptr): Int64
|
|
25
|
+
WasmI32.toGrain(newInt64(n)): Int64
|
|
32
26
|
}
|
|
33
27
|
|
|
34
|
-
@
|
|
28
|
+
@unsafe
|
|
35
29
|
export let fromInt64 = (n: Int64) => {
|
|
36
30
|
let ptr = WasmI32.fromGrain(n)
|
|
37
31
|
WasmI64.load(ptr, 8n)
|
|
38
32
|
}
|
|
39
33
|
|
|
40
|
-
@
|
|
34
|
+
@unsafe
|
|
41
35
|
export let toFloat32 = n => {
|
|
42
|
-
|
|
43
|
-
WasmI32.store(ptr, Tags._GRAIN_BOXED_NUM_HEAP_TAG, 0n)
|
|
44
|
-
WasmI32.store(ptr, Tags._GRAIN_FLOAT32_BOXED_NUM_TAG, 4n)
|
|
45
|
-
WasmF32.store(ptr, n, 8n)
|
|
46
|
-
|
|
47
|
-
WasmI32.toGrain(ptr): Float32
|
|
36
|
+
WasmI32.toGrain(newFloat32(n)): Float32
|
|
48
37
|
}
|
|
49
38
|
|
|
50
|
-
@
|
|
39
|
+
@unsafe
|
|
51
40
|
export let fromFloat32 = (n: Float32) => {
|
|
52
41
|
let ptr = WasmI32.fromGrain(n)
|
|
53
42
|
WasmF32.load(ptr, 8n)
|
|
54
43
|
}
|
|
55
44
|
|
|
56
|
-
@
|
|
45
|
+
@unsafe
|
|
57
46
|
export let toFloat64 = n => {
|
|
58
|
-
|
|
59
|
-
WasmI32.store(ptr, Tags._GRAIN_BOXED_NUM_HEAP_TAG, 0n)
|
|
60
|
-
WasmI32.store(ptr, Tags._GRAIN_FLOAT64_BOXED_NUM_TAG, 4n)
|
|
61
|
-
WasmF64.store(ptr, n, 8n)
|
|
62
|
-
|
|
63
|
-
WasmI32.toGrain(ptr): Float64
|
|
47
|
+
WasmI32.toGrain(newFloat64(n)): Float64
|
|
64
48
|
}
|
|
65
49
|
|
|
66
|
-
@
|
|
50
|
+
@unsafe
|
|
67
51
|
export let fromFloat64 = (n: Float64) => {
|
|
68
52
|
let ptr = WasmI32.fromGrain(n)
|
|
69
53
|
WasmF64.load(ptr, 8n)
|
|
@@ -72,13 +56,10 @@ export let fromFloat64 = (n: Float64) => {
|
|
|
72
56
|
/**
|
|
73
57
|
* Converts a WasmI32 value to Number.
|
|
74
58
|
*
|
|
75
|
-
* This function is meant to be called from a `@disableGC` context without
|
|
76
|
-
* need to call incRef on the function.
|
|
77
|
-
*
|
|
78
59
|
* @param n: The WasmI32 to convert
|
|
79
60
|
* @returns The value converted to either a simple or a 32 bit heap allocated number.
|
|
80
61
|
*/
|
|
81
|
-
@
|
|
62
|
+
@unsafe
|
|
82
63
|
export let wasmI32ToNumber = (n: WasmI32) => {
|
|
83
64
|
// Follows a little optimization. Instead of testing if n is range of allowed
|
|
84
65
|
// non heap allocated simple numbers (-1073741824n..1073741823n), actually
|
|
@@ -106,8 +87,7 @@ export let wasmI32ToNumber = (n: WasmI32) => {
|
|
|
106
87
|
// If it did overflow, then the value differs and we need to discard it and
|
|
107
88
|
// allocate the number on the heap. A boxed 32 bit number actually is the
|
|
108
89
|
// same thing as an Int32. It only needs to be cast into Number.
|
|
109
|
-
|
|
110
|
-
WasmI32.toGrain(WasmI32.fromGrain(asInt32)): Number
|
|
90
|
+
WasmI32.toGrain(newInt32(n)): Number
|
|
111
91
|
}
|
|
112
92
|
result
|
|
113
93
|
}
|
package/runtime/unsafe/conv.md
CHANGED
|
@@ -4,74 +4,38 @@ import Memory from "runtime/unsafe/memory"
|
|
|
4
4
|
|
|
5
5
|
// [FIXME] These all leak ATM (grain-lang/grain#791)
|
|
6
6
|
|
|
7
|
-
@
|
|
7
|
+
@unsafe
|
|
8
8
|
export let printI32 = val => {
|
|
9
|
-
Memory.incRef(WasmI32.fromGrain(print))
|
|
10
|
-
Memory.incRef(WasmI32.fromGrain(toString))
|
|
11
9
|
let conv = Conv.toInt32(val)
|
|
12
|
-
Memory.incRef(WasmI32.fromGrain(conv))
|
|
13
|
-
Memory.incRef(WasmI32.fromGrain(toString))
|
|
14
10
|
let s1 = toString(conv)
|
|
15
11
|
let s2 = "n"
|
|
16
|
-
Memory.incRef(WasmI32.fromGrain(s1))
|
|
17
|
-
Memory.incRef(WasmI32.fromGrain(s2))
|
|
18
|
-
Memory.incRef(WasmI32.fromGrain((++)))
|
|
19
12
|
let s = s1 ++ s2
|
|
20
|
-
Memory.incRef(WasmI32.fromGrain(print))
|
|
21
|
-
Memory.incRef(WasmI32.fromGrain(s))
|
|
22
13
|
print(s)
|
|
23
14
|
}
|
|
24
15
|
|
|
25
|
-
@
|
|
16
|
+
@unsafe
|
|
26
17
|
export let printI64 = val => {
|
|
27
|
-
Memory.incRef(WasmI32.fromGrain(print))
|
|
28
|
-
Memory.incRef(WasmI32.fromGrain(toString))
|
|
29
18
|
let conv = Conv.toInt64(val)
|
|
30
|
-
Memory.incRef(WasmI32.fromGrain(conv))
|
|
31
|
-
Memory.incRef(WasmI32.fromGrain(toString))
|
|
32
19
|
let s1 = toString(conv)
|
|
33
20
|
let s2 = "N"
|
|
34
|
-
Memory.incRef(WasmI32.fromGrain(s1))
|
|
35
|
-
Memory.incRef(WasmI32.fromGrain(s2))
|
|
36
|
-
Memory.incRef(WasmI32.fromGrain((++)))
|
|
37
21
|
let s = s1 ++ s2
|
|
38
|
-
Memory.incRef(WasmI32.fromGrain(print))
|
|
39
|
-
Memory.incRef(WasmI32.fromGrain(s))
|
|
40
22
|
print(s)
|
|
41
23
|
}
|
|
42
24
|
|
|
43
|
-
@
|
|
25
|
+
@unsafe
|
|
44
26
|
export let printF32 = val => {
|
|
45
|
-
Memory.incRef(WasmI32.fromGrain(print))
|
|
46
|
-
Memory.incRef(WasmI32.fromGrain(toString))
|
|
47
27
|
let conv = Conv.toFloat32(val)
|
|
48
|
-
Memory.incRef(WasmI32.fromGrain(conv))
|
|
49
|
-
Memory.incRef(WasmI32.fromGrain(toString))
|
|
50
28
|
let s1 = toString(conv)
|
|
51
29
|
let s2 = "w"
|
|
52
|
-
Memory.incRef(WasmI32.fromGrain(s1))
|
|
53
|
-
Memory.incRef(WasmI32.fromGrain(s2))
|
|
54
|
-
Memory.incRef(WasmI32.fromGrain((++)))
|
|
55
30
|
let s = s1 ++ s2
|
|
56
|
-
Memory.incRef(WasmI32.fromGrain(print))
|
|
57
|
-
Memory.incRef(WasmI32.fromGrain(s))
|
|
58
31
|
print(s)
|
|
59
32
|
}
|
|
60
33
|
|
|
61
|
-
@
|
|
34
|
+
@unsafe
|
|
62
35
|
export let printF64 = val => {
|
|
63
|
-
Memory.incRef(WasmI32.fromGrain(print))
|
|
64
|
-
Memory.incRef(WasmI32.fromGrain(toString))
|
|
65
36
|
let conv = Conv.toFloat64(val)
|
|
66
|
-
Memory.incRef(WasmI32.fromGrain(conv))
|
|
67
|
-
Memory.incRef(WasmI32.fromGrain(toString))
|
|
68
37
|
let s1 = toString(conv)
|
|
69
38
|
let s2 = "W"
|
|
70
|
-
Memory.incRef(WasmI32.fromGrain(s1))
|
|
71
|
-
Memory.incRef(WasmI32.fromGrain(s2))
|
|
72
|
-
Memory.incRef(WasmI32.fromGrain((++)))
|
|
73
39
|
let s = s1 ++ s2
|
|
74
|
-
Memory.incRef(WasmI32.fromGrain(print))
|
|
75
|
-
Memory.incRef(WasmI32.fromGrain(s))
|
|
76
40
|
print(s)
|
|
77
41
|
}
|
|
@@ -12,12 +12,12 @@ import foreign wasm fd_write: (
|
|
|
12
12
|
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
13
13
|
|
|
14
14
|
@unsafe
|
|
15
|
-
export let
|
|
15
|
+
export let numberToString = (n: WasmI64) => {
|
|
16
16
|
NumberUtils.itoa64(n, 10n)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
@unsafe
|
|
20
|
-
export let
|
|
20
|
+
export let printNumber = (n: WasmI64) => {
|
|
21
21
|
// like print(), but `s` should be a Grain string
|
|
22
22
|
let (+) = WasmI32.add
|
|
23
23
|
let s = numberToString(n)
|
|
@@ -40,7 +40,7 @@ export let rec printNumber = (n: WasmI64) => {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
@unsafe
|
|
43
|
-
export let
|
|
43
|
+
export let printString = (s: String) => {
|
|
44
44
|
// like print(), but `s` should be a Grain string
|
|
45
45
|
let (+) = WasmI32.add
|
|
46
46
|
let ptr = WasmI32.fromGrain(s)
|
package/stack.gr
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Stack: An immutable stack implementation. A stack is a LIFO (last-in-first-out) data structure where new values are added, retrieved, and removed from the end.
|
|
3
3
|
* @example import Stack from "stack"
|
|
4
|
+
*
|
|
5
|
+
* @deprecated This module will be renamed to ImmutableStack in the v0.6.0 release of Grain.
|
|
4
6
|
*/
|
|
5
7
|
|
|
6
8
|
import List from "list"
|
|
@@ -22,7 +24,7 @@ record Stack<a> {
|
|
|
22
24
|
|
|
23
25
|
/**
|
|
24
26
|
* An empty stack.
|
|
25
|
-
*
|
|
27
|
+
*
|
|
26
28
|
* @since v0.5.4
|
|
27
29
|
*/
|
|
28
30
|
export let empty = {
|
|
@@ -34,7 +36,7 @@ export let empty = {
|
|
|
34
36
|
* Creates a new stack.
|
|
35
37
|
*
|
|
36
38
|
* @returns An empty stack
|
|
37
|
-
*
|
|
39
|
+
*
|
|
38
40
|
* @deprecated This will be removed in the v0.6.0 release of Grain.
|
|
39
41
|
*/
|
|
40
42
|
export let make = () => {
|
package/stack.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
title: Stack
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
> **Deprecated:** This module will be renamed to ImmutableStack in the v0.6.0 release of Grain.
|
|
6
|
+
|
|
5
7
|
An immutable stack implementation. A stack is a LIFO (last-in-first-out) data structure where new values are added, retrieved, and removed from the end.
|
|
6
8
|
|
|
7
9
|
```grain
|
package/string.gr
CHANGED
package/sys/time.gr
CHANGED
|
@@ -38,7 +38,7 @@ let getClockTime = (clockid, precision) => {
|
|
|
38
38
|
* @returns `Ok(time)` of the current time if successful or `Err(exception)` otherwise
|
|
39
39
|
*/
|
|
40
40
|
@unsafe
|
|
41
|
-
export let
|
|
41
|
+
export let realTime = () => {
|
|
42
42
|
getClockTime(Wasi._CLOCK_REALTIME, 1000N)
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -51,7 +51,7 @@ export let rec realTime = () => {
|
|
|
51
51
|
* @returns `Ok(time)` of the current time if successful or `Err(exception)` otherwise
|
|
52
52
|
*/
|
|
53
53
|
@unsafe
|
|
54
|
-
export let
|
|
54
|
+
export let monotonicTime = () => {
|
|
55
55
|
getClockTime(Wasi._CLOCK_MONOTONIC, 1N)
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -61,7 +61,7 @@ export let rec monotonicTime = () => {
|
|
|
61
61
|
* @returns `Ok(elapsed)` of the elapsed nanoseconds if successful or `Err(exception)` otherwise
|
|
62
62
|
*/
|
|
63
63
|
@unsafe
|
|
64
|
-
export let
|
|
64
|
+
export let processCpuTime = () => {
|
|
65
65
|
getClockTime(Wasi._CLOCK_PROCESS_CPUTIME, 1N)
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -71,6 +71,6 @@ export let rec processCpuTime = () => {
|
|
|
71
71
|
* @returns `Ok(elapsed)` of the elapsed nanoseconds if successful or `Err(exception)` otherwise
|
|
72
72
|
*/
|
|
73
73
|
@unsafe
|
|
74
|
-
export let
|
|
74
|
+
export let threadCpuTime = () => {
|
|
75
75
|
getClockTime(Wasi._CLOCK_THREAD_CPUTIME, 1N)
|
|
76
76
|
}
|