goscript 0.0.35 → 0.0.36

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.
@@ -0,0 +1,168 @@
1
+ import * as $ from "@goscript/builtin/builtin.js";
2
+
3
+ // SwapInt64 atomically stores new into *addr and returns the previous *addr value.
4
+ // Consider using the more ergonomic and less error-prone [Int64.Swap] instead
5
+ // (particularly if you target 32-bit platforms; see the bugs section).
6
+ //
7
+ //go:noescape
8
+ export function SwapInt64(addr: $.VarRef<number> | null, _new: number): number {
9
+ if (!addr) return 0;
10
+ let old = addr.value;
11
+ addr.value = _new;
12
+ return old;
13
+ }
14
+
15
+ // SwapUint64 atomically stores new into *addr and returns the previous *addr value.
16
+ // Consider using the more ergonomic and less error-prone [Uint64.Swap] instead
17
+ // (particularly if you target 32-bit platforms; see the bugs section).
18
+ //
19
+ //go:noescape
20
+ export function SwapUint64(addr: $.VarRef<number> | null, _new: number): number {
21
+ if (!addr) return 0;
22
+ let old = addr.value;
23
+ addr.value = _new;
24
+ return old;
25
+ }
26
+
27
+ // CompareAndSwapInt64 executes the compare-and-swap operation for an int64 value.
28
+ // Consider using the more ergonomic and less error-prone [Int64.CompareAndSwap] instead
29
+ // (particularly if you target 32-bit platforms; see the bugs section).
30
+ //
31
+ //go:noescape
32
+ export function CompareAndSwapInt64(addr: $.VarRef<number> | null, old: number, _new: number): boolean {
33
+ if (!addr) return false;
34
+ if (addr.value === old) {
35
+ addr.value = _new;
36
+ return true;
37
+ }
38
+ return false;
39
+ }
40
+
41
+ // CompareAndSwapUint64 executes the compare-and-swap operation for a uint64 value.
42
+ // Consider using the more ergonomic and less error-prone [Uint64.CompareAndSwap] instead
43
+ // (particularly if you target 32-bit platforms; see the bugs section).
44
+ //
45
+ //go:noescape
46
+ export function CompareAndSwapUint64(addr: $.VarRef<number> | null, old: number, _new: number): boolean {
47
+ if (!addr) return false;
48
+ if (addr.value === old) {
49
+ addr.value = _new;
50
+ return true;
51
+ }
52
+ return false;
53
+ }
54
+
55
+ // AddInt64 atomically adds delta to *addr and returns the new value.
56
+ // Consider using the more ergonomic and less error-prone [Int64.Add] instead
57
+ // (particularly if you target 32-bit platforms; see the bugs section).
58
+ //
59
+ //go:noescape
60
+ export function AddInt64(addr: $.VarRef<number> | null, delta: number): number {
61
+ if (!addr) return 0;
62
+ addr.value = addr.value + delta;
63
+ return addr.value;
64
+ }
65
+
66
+ // AddUint64 atomically adds delta to *addr and returns the new value.
67
+ // To subtract a signed positive constant value c from x, do AddUint64(&x, ^uint64(c-1)).
68
+ // In particular, to decrement x, do AddUint64(&x, ^uint64(0)).
69
+ // Consider using the more ergonomic and less error-prone [Uint64.Add] instead
70
+ // (particularly if you target 32-bit platforms; see the bugs section).
71
+ //
72
+ //go:noescape
73
+ export function AddUint64(addr: $.VarRef<number> | null, delta: number): number {
74
+ if (!addr) return 0;
75
+ addr.value = addr.value + delta;
76
+ return addr.value;
77
+ }
78
+
79
+ // AndInt64 atomically performs a bitwise AND operation on *addr using the bitmask provided as mask
80
+ // and returns the old value.
81
+ // Consider using the more ergonomic and less error-prone [Int64.And] instead.
82
+ //
83
+ //go:noescape
84
+ export function AndInt64(addr: $.VarRef<number> | null, mask: number): number {
85
+ if (!addr) return 0;
86
+ let old = addr.value;
87
+ addr.value = addr.value & mask;
88
+ return old;
89
+ }
90
+
91
+ // AndUint64 atomically performs a bitwise AND operation on *addr using the bitmask provided as mask
92
+ // and returns the old.
93
+ // Consider using the more ergonomic and less error-prone [Uint64.And] instead.
94
+ //
95
+ //go:noescape
96
+ export function AndUint64(addr: $.VarRef<number> | null, mask: number): number {
97
+ if (!addr) return 0;
98
+ let old = addr.value;
99
+ addr.value = addr.value & mask;
100
+ return old;
101
+ }
102
+
103
+ // OrInt64 atomically performs a bitwise OR operation on *addr using the bitmask provided as mask
104
+ // and returns the old value.
105
+ // Consider using the more ergonomic and less error-prone [Int64.Or] instead.
106
+ //
107
+ //go:noescape
108
+ export function OrInt64(addr: $.VarRef<number> | null, mask: number): number {
109
+ if (!addr) return 0;
110
+ let old = addr.value;
111
+ addr.value = addr.value | mask;
112
+ return old;
113
+ }
114
+
115
+ // OrUint64 atomically performs a bitwise OR operation on *addr using the bitmask provided as mask
116
+ // and returns the old value.
117
+ // Consider using the more ergonomic and less error-prone [Uint64.Or] instead.
118
+ //
119
+ //go:noescape
120
+ export function OrUint64(addr: $.VarRef<number> | null, mask: number): number {
121
+ if (!addr) return 0;
122
+ let old = addr.value;
123
+ addr.value = addr.value | mask;
124
+ return old;
125
+ }
126
+
127
+ // LoadInt64 atomically loads *addr.
128
+ // Consider using the more ergonomic and less error-prone [Int64.Load] instead
129
+ // (particularly if you target 32-bit platforms; see the bugs section).
130
+ //
131
+ //go:noescape
132
+ export function LoadInt64(addr: $.VarRef<number> | null): number {
133
+ if (!addr) return 0;
134
+ return addr.value;
135
+ }
136
+
137
+ // LoadUint64 atomically loads *addr.
138
+ // Consider using the more ergonomic and less error-prone [Uint64.Load] instead
139
+ // (particularly if you target 32-bit platforms; see the bugs section).
140
+ //
141
+ //go:noescape
142
+ export function LoadUint64(addr: $.VarRef<number> | null): number {
143
+ if (!addr) return 0;
144
+ return addr.value;
145
+ }
146
+
147
+ // StoreInt64 atomically stores val into *addr.
148
+ // Consider using the more ergonomic and less error-prone [Int64.Store] instead
149
+ // (particularly if you target 32-bit platforms; see the bugs section).
150
+ //
151
+ //go:noescape
152
+ export function StoreInt64(addr: $.VarRef<number> | null, val: number): void {
153
+ if (addr) {
154
+ addr.value = val;
155
+ }
156
+ }
157
+
158
+ // StoreUint64 atomically stores val into *addr.
159
+ // Consider using the more ergonomic and less error-prone [Uint64.Store] instead
160
+ // (particularly if you target 32-bit platforms; see the bugs section).
161
+ //
162
+ //go:noescape
163
+ export function StoreUint64(addr: $.VarRef<number> | null, val: number): void {
164
+ if (addr) {
165
+ addr.value = val;
166
+ }
167
+ }
168
+
@@ -0,0 +1,4 @@
1
+ export { AddInt32, AddUint32, AddUintptr, AndInt32, AndUint32, AndUintptr, CompareAndSwapInt32, CompareAndSwapPointer, CompareAndSwapUint32, CompareAndSwapUintptr, LoadInt32, LoadPointer, LoadUint32, LoadUintptr, OrInt32, OrUint32, OrUintptr, StoreInt32, StorePointer, StoreUint32, StoreUintptr, SwapInt32, SwapPointer, SwapUint32, SwapUintptr } from "./doc.gs.js"
2
+ export { AddInt64, AddUint64, AndInt64, AndUint64, CompareAndSwapInt64, CompareAndSwapUint64, LoadInt64, LoadUint64, OrInt64, OrUint64, StoreInt64, StoreUint64, SwapInt64, SwapUint64 } from "./doc_64.gs.js"
3
+ export { Bool, Int32, Int64, Pointer, Uint32, Uint64, Uintptr } from "./type.gs.js"
4
+ export { Value } from "./value.gs.js"