slidge-whatsapp 0.3.0__cp311-cp311-manylinux_2_36_aarch64.whl → 0.3.1__cp311-cp311-manylinux_2_36_aarch64.whl
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.
Potentially problematic release.
This version of slidge-whatsapp might be problematic. Click here for more details.
- slidge_whatsapp/event.go +33 -9
- slidge_whatsapp/generated/_whatsapp.cpython-311-aarch64-linux-gnu.h +150 -150
- slidge_whatsapp/generated/_whatsapp.cpython-311-aarch64-linux-gnu.so +0 -0
- slidge_whatsapp/generated/build.py +130 -130
- slidge_whatsapp/generated/whatsapp.c +1478 -1478
- slidge_whatsapp/generated/whatsapp.go +1123 -1123
- slidge_whatsapp/generated/whatsapp.py +863 -863
- slidge_whatsapp/generated/whatsapp_go.h +150 -150
- slidge_whatsapp/go.mod +5 -5
- slidge_whatsapp/go.sum +14 -14
- slidge_whatsapp/session.go +3 -3
- slidge_whatsapp/vendor/github.com/ebitengine/purego/README.md +21 -5
- slidge_whatsapp/vendor/github.com/ebitengine/purego/abi_loong64.h +60 -0
- slidge_whatsapp/vendor/github.com/ebitengine/purego/cgo.go +1 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/dlerror.go +1 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/dlfcn.go +1 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/dlfcn_netbsd.go +15 -0
- slidge_whatsapp/vendor/github.com/ebitengine/purego/dlfcn_nocgo_netbsd.go +9 -0
- slidge_whatsapp/vendor/github.com/ebitengine/purego/dlfcn_stubs.s +1 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/func.go +113 -60
- slidge_whatsapp/vendor/github.com/ebitengine/purego/gen.go +6 -0
- slidge_whatsapp/vendor/github.com/ebitengine/purego/go_runtime.go +1 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/cgo/dlfcn_cgo_unix.go +2 -2
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/cgo/syscall_cgo_unix.go +2 -2
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/abi_loong64.h +60 -0
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/asm_loong64.s +40 -0
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/callbacks.go +1 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/doc.go +1 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/go_libinit.go +1 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/go_linux_loong64.go +92 -0
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/go_netbsd.go +106 -0
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/go_setenv.go +1 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/go_util.go +1 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/iscgo.go +1 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo.go +1 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_darwin.go +4 -0
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_freebsd.go +4 -0
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_linux.go +4 -0
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_netbsd.go +26 -0
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/netbsd.go +23 -0
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/setenv.go +1 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols.go +11 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_darwin.go +1 -0
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_freebsd.go +1 -0
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_linux.go +1 -0
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_netbsd.go +30 -0
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_loong64.s +71 -0
- slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_stubs.s +5 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/nocgo.go +1 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/struct_amd64.go +8 -4
- slidge_whatsapp/vendor/github.com/ebitengine/purego/struct_arm64.go +16 -6
- slidge_whatsapp/vendor/github.com/ebitengine/purego/struct_loong64.go +190 -0
- slidge_whatsapp/vendor/github.com/ebitengine/purego/struct_other.go +6 -2
- slidge_whatsapp/vendor/github.com/ebitengine/purego/sys_amd64.s +1 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/sys_arm64.s +1 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/sys_loong64.s +96 -0
- slidge_whatsapp/vendor/github.com/ebitengine/purego/sys_unix_arm64.s +1 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/sys_unix_loong64.s +75 -0
- slidge_whatsapp/vendor/github.com/ebitengine/purego/syscall.go +6 -3
- slidge_whatsapp/vendor/github.com/ebitengine/purego/syscall_cgo_linux.go +3 -3
- slidge_whatsapp/vendor/github.com/ebitengine/purego/syscall_sysv.go +13 -10
- slidge_whatsapp/vendor/github.com/ebitengine/purego/syscall_windows.go +1 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/zcallback_amd64.s +2002 -2002
- slidge_whatsapp/vendor/github.com/ebitengine/purego/zcallback_arm64.s +4002 -4002
- slidge_whatsapp/vendor/github.com/ebitengine/purego/zcallback_loong64.s +4014 -0
- slidge_whatsapp/vendor/go.mau.fi/util/dbutil/log.go +1 -0
- slidge_whatsapp/vendor/go.mau.fi/util/dbutil/module.go +118 -0
- slidge_whatsapp/vendor/go.mau.fi/util/dbutil/upgradetable.go +0 -34
- slidge_whatsapp/vendor/go.mau.fi/util/exbytes/string.go +20 -0
- slidge_whatsapp/vendor/go.mau.fi/util/exbytes/writer.go +78 -0
- slidge_whatsapp/vendor/go.mau.fi/util/exslices/cast.go +42 -0
- slidge_whatsapp/vendor/go.mau.fi/util/exslices/chunk.go +28 -0
- slidge_whatsapp/vendor/go.mau.fi/util/exslices/deduplicate.go +67 -0
- slidge_whatsapp/vendor/go.mau.fi/util/exslices/diff.go +63 -0
- slidge_whatsapp/vendor/go.mau.fi/util/exsync/event.go +15 -1
- slidge_whatsapp/vendor/go.mau.fi/util/random/string.go +47 -7
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate/decode.go +1 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate/encode.go +34 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate/hash.go +1 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate.go +3 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/armadillomessage.go +1 -2
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/call.go +6 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/errors.go +1 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/group.go +63 -42
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/internals.go +14 -10
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/message.go +45 -18
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/msgsecret.go +23 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/notification.go +5 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/pair.go +3 -7
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waAICommon/WAAICommon.pb.go +7747 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/{waBotMetadata/WABotMetadata.proto → waAICommon/WAAICommon.proto} +269 -9
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waDeviceCapabilities/WAProtobufsDeviceCapabilities.pb.go +128 -14
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waDeviceCapabilities/WAProtobufsDeviceCapabilities.proto +10 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waE2E/WAWebProtobufsE2E.pb.go +3236 -4732
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waE2E/WAWebProtobufsE2E.proto +125 -273
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waHistorySync/WAWebProtobufsHistorySync.pb.go +11 -2
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waHistorySync/WAWebProtobufsHistorySync.proto +1 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waStatusAttributions/WAStatusAttributions.pb.go +220 -81
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waStatusAttributions/WAStatusAttributions.proto +13 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waSyncAction/WASyncAction.pb.go +705 -449
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waSyncAction/WASyncAction.proto +23 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWa6/WAWebProtobufsWa6.pb.go +78 -24
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWa6/WAWebProtobufsWa6.proto +6 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWeb/WAWebProtobufsWeb.pb.go +516 -267
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWeb/WAWebProtobufsWeb.proto +22 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/receipt.go +2 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/request.go +4 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/retry.go +2 -3
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/send.go +110 -28
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/clientpayload.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/noop.go +12 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/lidmap.go +82 -4
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/store.go +112 -55
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrades/00-latest-schema.sql +8 -7
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrades/11-redacted-phone-contacts.sql +2 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/store.go +20 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/call.go +6 -5
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/message.go +7 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/user.go +3 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/user.go +31 -2
- slidge_whatsapp/vendor/google.golang.org/protobuf/internal/filedesc/desc.go +35 -17
- slidge_whatsapp/vendor/google.golang.org/protobuf/internal/filedesc/desc_init.go +14 -0
- slidge_whatsapp/vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go +20 -0
- slidge_whatsapp/vendor/google.golang.org/protobuf/internal/version/version.go +1 -1
- slidge_whatsapp/vendor/modules.txt +8 -6
- {slidge_whatsapp-0.3.0.dist-info → slidge_whatsapp-0.3.1.dist-info}/METADATA +1 -1
- {slidge_whatsapp-0.3.0.dist-info → slidge_whatsapp-0.3.1.dist-info}/RECORD +130 -106
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waBotMetadata/WABotMetadata.pb.go +0 -5156
- {slidge_whatsapp-0.3.0.dist-info → slidge_whatsapp-0.3.1.dist-info}/WHEEL +0 -0
- {slidge_whatsapp-0.3.0.dist-info → slidge_whatsapp-0.3.1.dist-info}/entry_points.txt +0 -0
- {slidge_whatsapp-0.3.0.dist-info → slidge_whatsapp-0.3.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2025 The Ebitengine Authors
|
|
3
|
+
|
|
4
|
+
package purego
|
|
5
|
+
|
|
6
|
+
import (
|
|
7
|
+
"math"
|
|
8
|
+
"reflect"
|
|
9
|
+
"unsafe"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
func getStruct(outType reflect.Type, syscall syscall15Args) (v reflect.Value) {
|
|
13
|
+
outSize := outType.Size()
|
|
14
|
+
switch {
|
|
15
|
+
case outSize == 0:
|
|
16
|
+
return reflect.New(outType).Elem()
|
|
17
|
+
case outSize <= 8:
|
|
18
|
+
r1 := syscall.a1
|
|
19
|
+
if isAllFloats, numFields := isAllSameFloat(outType); isAllFloats {
|
|
20
|
+
r1 = syscall.f1
|
|
21
|
+
if numFields == 2 {
|
|
22
|
+
r1 = syscall.f2<<32 | syscall.f1
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return reflect.NewAt(outType, unsafe.Pointer(&struct{ a uintptr }{r1})).Elem()
|
|
26
|
+
case outSize <= 16:
|
|
27
|
+
r1, r2 := syscall.a1, syscall.a2
|
|
28
|
+
if isAllFloats, numFields := isAllSameFloat(outType); isAllFloats {
|
|
29
|
+
switch numFields {
|
|
30
|
+
case 4:
|
|
31
|
+
r1 = syscall.f2<<32 | syscall.f1
|
|
32
|
+
r2 = syscall.f4<<32 | syscall.f3
|
|
33
|
+
case 3:
|
|
34
|
+
r1 = syscall.f2<<32 | syscall.f1
|
|
35
|
+
r2 = syscall.f3
|
|
36
|
+
case 2:
|
|
37
|
+
r1 = syscall.f1
|
|
38
|
+
r2 = syscall.f2
|
|
39
|
+
default:
|
|
40
|
+
panic("unreachable")
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return reflect.NewAt(outType, unsafe.Pointer(&struct{ a, b uintptr }{r1, r2})).Elem()
|
|
44
|
+
default:
|
|
45
|
+
// create struct from the Go pointer created above
|
|
46
|
+
// weird pointer dereference to circumvent go vet
|
|
47
|
+
return reflect.NewAt(outType, *(*unsafe.Pointer)(unsafe.Pointer(&syscall.a1))).Elem()
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const (
|
|
52
|
+
_NO_CLASS = 0b00
|
|
53
|
+
_FLOAT = 0b01
|
|
54
|
+
_INT = 0b11
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
func addStruct(v reflect.Value, numInts, numFloats, numStack *int, addInt, addFloat, addStack func(uintptr), keepAlive []any) []any {
|
|
58
|
+
if v.Type().Size() == 0 {
|
|
59
|
+
return keepAlive
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if size := v.Type().Size(); size <= 16 {
|
|
63
|
+
placeRegisters(v, addFloat, addInt)
|
|
64
|
+
} else {
|
|
65
|
+
keepAlive = placeStack(v, keepAlive, addInt)
|
|
66
|
+
}
|
|
67
|
+
return keepAlive // the struct was allocated so don't panic
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
func placeRegisters(v reflect.Value, addFloat func(uintptr), addInt func(uintptr)) {
|
|
71
|
+
var val uint64
|
|
72
|
+
var shift byte
|
|
73
|
+
var flushed bool
|
|
74
|
+
class := _NO_CLASS
|
|
75
|
+
var place func(v reflect.Value)
|
|
76
|
+
place = func(v reflect.Value) {
|
|
77
|
+
var numFields int
|
|
78
|
+
if v.Kind() == reflect.Struct {
|
|
79
|
+
numFields = v.Type().NumField()
|
|
80
|
+
} else {
|
|
81
|
+
numFields = v.Type().Len()
|
|
82
|
+
}
|
|
83
|
+
for k := 0; k < numFields; k++ {
|
|
84
|
+
flushed = false
|
|
85
|
+
var f reflect.Value
|
|
86
|
+
if v.Kind() == reflect.Struct {
|
|
87
|
+
f = v.Field(k)
|
|
88
|
+
} else {
|
|
89
|
+
f = v.Index(k)
|
|
90
|
+
}
|
|
91
|
+
align := byte(f.Type().Align()*8 - 1)
|
|
92
|
+
shift = (shift + align) &^ align
|
|
93
|
+
if shift >= 64 {
|
|
94
|
+
shift = 0
|
|
95
|
+
flushed = true
|
|
96
|
+
if class == _FLOAT {
|
|
97
|
+
addFloat(uintptr(val))
|
|
98
|
+
} else {
|
|
99
|
+
addInt(uintptr(val))
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
switch f.Type().Kind() {
|
|
103
|
+
case reflect.Struct:
|
|
104
|
+
place(f)
|
|
105
|
+
case reflect.Bool:
|
|
106
|
+
if f.Bool() {
|
|
107
|
+
val |= 1
|
|
108
|
+
}
|
|
109
|
+
shift += 8
|
|
110
|
+
class |= _INT
|
|
111
|
+
case reflect.Uint8:
|
|
112
|
+
val |= f.Uint() << shift
|
|
113
|
+
shift += 8
|
|
114
|
+
class |= _INT
|
|
115
|
+
case reflect.Uint16:
|
|
116
|
+
val |= f.Uint() << shift
|
|
117
|
+
shift += 16
|
|
118
|
+
class |= _INT
|
|
119
|
+
case reflect.Uint32:
|
|
120
|
+
val |= f.Uint() << shift
|
|
121
|
+
shift += 32
|
|
122
|
+
class |= _INT
|
|
123
|
+
case reflect.Uint64, reflect.Uint, reflect.Uintptr:
|
|
124
|
+
addInt(uintptr(f.Uint()))
|
|
125
|
+
shift = 0
|
|
126
|
+
flushed = true
|
|
127
|
+
class = _NO_CLASS
|
|
128
|
+
case reflect.Int8:
|
|
129
|
+
val |= uint64(f.Int()&0xFF) << shift
|
|
130
|
+
shift += 8
|
|
131
|
+
class |= _INT
|
|
132
|
+
case reflect.Int16:
|
|
133
|
+
val |= uint64(f.Int()&0xFFFF) << shift
|
|
134
|
+
shift += 16
|
|
135
|
+
class |= _INT
|
|
136
|
+
case reflect.Int32:
|
|
137
|
+
val |= uint64(f.Int()&0xFFFF_FFFF) << shift
|
|
138
|
+
shift += 32
|
|
139
|
+
class |= _INT
|
|
140
|
+
case reflect.Int64, reflect.Int:
|
|
141
|
+
addInt(uintptr(f.Int()))
|
|
142
|
+
shift = 0
|
|
143
|
+
flushed = true
|
|
144
|
+
class = _NO_CLASS
|
|
145
|
+
case reflect.Float32:
|
|
146
|
+
if class == _FLOAT {
|
|
147
|
+
addFloat(uintptr(val))
|
|
148
|
+
val = 0
|
|
149
|
+
shift = 0
|
|
150
|
+
}
|
|
151
|
+
val |= uint64(math.Float32bits(float32(f.Float()))) << shift
|
|
152
|
+
shift += 32
|
|
153
|
+
class |= _FLOAT
|
|
154
|
+
case reflect.Float64:
|
|
155
|
+
addFloat(uintptr(math.Float64bits(float64(f.Float()))))
|
|
156
|
+
shift = 0
|
|
157
|
+
flushed = true
|
|
158
|
+
class = _NO_CLASS
|
|
159
|
+
case reflect.Ptr:
|
|
160
|
+
addInt(f.Pointer())
|
|
161
|
+
shift = 0
|
|
162
|
+
flushed = true
|
|
163
|
+
class = _NO_CLASS
|
|
164
|
+
case reflect.Array:
|
|
165
|
+
place(f)
|
|
166
|
+
default:
|
|
167
|
+
panic("purego: unsupported kind " + f.Kind().String())
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
place(v)
|
|
172
|
+
if !flushed {
|
|
173
|
+
if class == _FLOAT {
|
|
174
|
+
addFloat(uintptr(val))
|
|
175
|
+
} else {
|
|
176
|
+
addInt(uintptr(val))
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
func placeStack(v reflect.Value, keepAlive []any, addInt func(uintptr)) []any {
|
|
182
|
+
// Struct is too big to be placed in registers.
|
|
183
|
+
// Copy to heap and place the pointer in register
|
|
184
|
+
ptrStruct := reflect.New(v.Type())
|
|
185
|
+
ptrStruct.Elem().Set(v)
|
|
186
|
+
ptr := ptrStruct.Elem().Addr().UnsafePointer()
|
|
187
|
+
keepAlive = append(keepAlive, ptr)
|
|
188
|
+
addInt(uintptr(ptr))
|
|
189
|
+
return keepAlive
|
|
190
|
+
}
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// SPDX-FileCopyrightText: 2024 The Ebitengine Authors
|
|
3
3
|
|
|
4
|
-
//go:build !amd64 && !arm64
|
|
4
|
+
//go:build !amd64 && !arm64 && !loong64
|
|
5
5
|
|
|
6
6
|
package purego
|
|
7
7
|
|
|
8
8
|
import "reflect"
|
|
9
9
|
|
|
10
|
-
func addStruct(v reflect.Value, numInts, numFloats, numStack *int, addInt, addFloat, addStack func(uintptr), keepAlive []
|
|
10
|
+
func addStruct(v reflect.Value, numInts, numFloats, numStack *int, addInt, addFloat, addStack func(uintptr), keepAlive []any) []any {
|
|
11
11
|
panic("purego: struct arguments are not supported")
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
func getStruct(outType reflect.Type, syscall syscall15Args) (v reflect.Value) {
|
|
15
15
|
panic("purego: struct returns are not supported")
|
|
16
16
|
}
|
|
17
|
+
|
|
18
|
+
func placeRegisters(v reflect.Value, addFloat func(uintptr), addInt func(uintptr)) {
|
|
19
|
+
panic("purego: not needed on other platforms")
|
|
20
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2025 The Ebitengine Authors
|
|
3
|
+
|
|
4
|
+
//go:build linux
|
|
5
|
+
|
|
6
|
+
#include "textflag.h"
|
|
7
|
+
#include "go_asm.h"
|
|
8
|
+
#include "funcdata.h"
|
|
9
|
+
|
|
10
|
+
#define STACK_SIZE 64
|
|
11
|
+
#define PTR_ADDRESS (STACK_SIZE - 8)
|
|
12
|
+
|
|
13
|
+
// syscall15X calls a function in libc on behalf of the syscall package.
|
|
14
|
+
// syscall15X takes a pointer to a struct like:
|
|
15
|
+
// struct {
|
|
16
|
+
// fn uintptr
|
|
17
|
+
// a1 uintptr
|
|
18
|
+
// a2 uintptr
|
|
19
|
+
// a3 uintptr
|
|
20
|
+
// a4 uintptr
|
|
21
|
+
// a5 uintptr
|
|
22
|
+
// a6 uintptr
|
|
23
|
+
// a7 uintptr
|
|
24
|
+
// a8 uintptr
|
|
25
|
+
// a9 uintptr
|
|
26
|
+
// a10 uintptr
|
|
27
|
+
// a11 uintptr
|
|
28
|
+
// a12 uintptr
|
|
29
|
+
// a13 uintptr
|
|
30
|
+
// a14 uintptr
|
|
31
|
+
// a15 uintptr
|
|
32
|
+
// r1 uintptr
|
|
33
|
+
// r2 uintptr
|
|
34
|
+
// err uintptr
|
|
35
|
+
// }
|
|
36
|
+
// syscall15X must be called on the g0 stack with the
|
|
37
|
+
// C calling convention (use libcCall).
|
|
38
|
+
GLOBL ·syscall15XABI0(SB), NOPTR|RODATA, $8
|
|
39
|
+
DATA ·syscall15XABI0(SB)/8, $syscall15X(SB)
|
|
40
|
+
TEXT syscall15X(SB), NOSPLIT, $0
|
|
41
|
+
// push structure pointer
|
|
42
|
+
SUBV $STACK_SIZE, R3
|
|
43
|
+
MOVV R4, PTR_ADDRESS(R3)
|
|
44
|
+
MOVV R4, R13
|
|
45
|
+
|
|
46
|
+
MOVD syscall15Args_f1(R13), F0 // f1
|
|
47
|
+
MOVD syscall15Args_f2(R13), F1 // f2
|
|
48
|
+
MOVD syscall15Args_f3(R13), F2 // f3
|
|
49
|
+
MOVD syscall15Args_f4(R13), F3 // f4
|
|
50
|
+
MOVD syscall15Args_f5(R13), F4 // f5
|
|
51
|
+
MOVD syscall15Args_f6(R13), F5 // f6
|
|
52
|
+
MOVD syscall15Args_f7(R13), F6 // f7
|
|
53
|
+
MOVD syscall15Args_f8(R13), F7 // f8
|
|
54
|
+
|
|
55
|
+
MOVV syscall15Args_a1(R13), R4 // a1
|
|
56
|
+
MOVV syscall15Args_a2(R13), R5 // a2
|
|
57
|
+
MOVV syscall15Args_a3(R13), R6 // a3
|
|
58
|
+
MOVV syscall15Args_a4(R13), R7 // a4
|
|
59
|
+
MOVV syscall15Args_a5(R13), R8 // a5
|
|
60
|
+
MOVV syscall15Args_a6(R13), R9 // a6
|
|
61
|
+
MOVV syscall15Args_a7(R13), R10 // a7
|
|
62
|
+
MOVV syscall15Args_a8(R13), R11 // a8
|
|
63
|
+
|
|
64
|
+
// push a9-a15 onto stack
|
|
65
|
+
MOVV syscall15Args_a9(R13), R12
|
|
66
|
+
MOVV R12, 0(R3)
|
|
67
|
+
MOVV syscall15Args_a10(R13), R12
|
|
68
|
+
MOVV R12, 8(R3)
|
|
69
|
+
MOVV syscall15Args_a11(R13), R12
|
|
70
|
+
MOVV R12, 16(R3)
|
|
71
|
+
MOVV syscall15Args_a12(R13), R12
|
|
72
|
+
MOVV R12, 24(R3)
|
|
73
|
+
MOVV syscall15Args_a13(R13), R12
|
|
74
|
+
MOVV R12, 32(R3)
|
|
75
|
+
MOVV syscall15Args_a14(R13), R12
|
|
76
|
+
MOVV R12, 40(R3)
|
|
77
|
+
MOVV syscall15Args_a15(R13), R12
|
|
78
|
+
MOVV R12, 48(R3)
|
|
79
|
+
|
|
80
|
+
MOVV syscall15Args_fn(R13), R12
|
|
81
|
+
JAL (R12)
|
|
82
|
+
|
|
83
|
+
// pop structure pointer
|
|
84
|
+
MOVV PTR_ADDRESS(R3), R13
|
|
85
|
+
ADDV $STACK_SIZE, R3
|
|
86
|
+
|
|
87
|
+
// save R4, R5
|
|
88
|
+
MOVV R4, syscall15Args_a1(R13)
|
|
89
|
+
MOVV R5, syscall15Args_a2(R13)
|
|
90
|
+
|
|
91
|
+
// save f0-f3
|
|
92
|
+
MOVD F0, syscall15Args_f1(R13)
|
|
93
|
+
MOVD F1, syscall15Args_f2(R13)
|
|
94
|
+
MOVD F2, syscall15Args_f3(R13)
|
|
95
|
+
MOVD F3, syscall15Args_f4(R13)
|
|
96
|
+
RET
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2025 The Ebitengine Authors
|
|
3
|
+
|
|
4
|
+
//go:build linux
|
|
5
|
+
|
|
6
|
+
#include "textflag.h"
|
|
7
|
+
#include "go_asm.h"
|
|
8
|
+
#include "funcdata.h"
|
|
9
|
+
#include "abi_loong64.h"
|
|
10
|
+
|
|
11
|
+
TEXT callbackasm1(SB), NOSPLIT|NOFRAME, $0
|
|
12
|
+
NO_LOCAL_POINTERS
|
|
13
|
+
|
|
14
|
+
SUBV $(16*8), R3, R14
|
|
15
|
+
MOVD F0, 0(R14)
|
|
16
|
+
MOVD F1, 8(R14)
|
|
17
|
+
MOVD F2, 16(R14)
|
|
18
|
+
MOVD F3, 24(R14)
|
|
19
|
+
MOVD F4, 32(R14)
|
|
20
|
+
MOVD F5, 40(R14)
|
|
21
|
+
MOVD F6, 48(R14)
|
|
22
|
+
MOVD F7, 56(R14)
|
|
23
|
+
MOVV R4, 64(R14)
|
|
24
|
+
MOVV R5, 72(R14)
|
|
25
|
+
MOVV R6, 80(R14)
|
|
26
|
+
MOVV R7, 88(R14)
|
|
27
|
+
MOVV R8, 96(R14)
|
|
28
|
+
MOVV R9, 104(R14)
|
|
29
|
+
MOVV R10, 112(R14)
|
|
30
|
+
MOVV R11, 120(R14)
|
|
31
|
+
|
|
32
|
+
// Adjust SP by frame size.
|
|
33
|
+
SUBV $(22*8), R3
|
|
34
|
+
|
|
35
|
+
// It is important to save R30 because the go assembler
|
|
36
|
+
// uses it for move instructions for a variable.
|
|
37
|
+
// This line:
|
|
38
|
+
// MOVV ·callbackWrap_call(SB), R4
|
|
39
|
+
// Creates the instructions:
|
|
40
|
+
// PCALAU12I off1(PC), R30
|
|
41
|
+
// MOVV off2(R30), R4
|
|
42
|
+
// R30 is a callee saved register so we are responsible
|
|
43
|
+
// for ensuring its value doesn't change. So save it and
|
|
44
|
+
// restore it at the end of this function.
|
|
45
|
+
// R1 is the link register. crosscall2 doesn't save it
|
|
46
|
+
// so it's saved here.
|
|
47
|
+
MOVV R1, 0(R3)
|
|
48
|
+
MOVV R30, 8(R3)
|
|
49
|
+
|
|
50
|
+
// Create a struct callbackArgs on our stack.
|
|
51
|
+
MOVV $(callbackArgs__size)(R3), R13
|
|
52
|
+
MOVV R12, callbackArgs_index(R13) // callback index
|
|
53
|
+
MOVV R14, callbackArgs_args(R13) // address of args vector
|
|
54
|
+
MOVV $0, callbackArgs_result(R13) // result
|
|
55
|
+
|
|
56
|
+
// Move parameters into registers
|
|
57
|
+
// Get the ABIInternal function pointer
|
|
58
|
+
// without <ABIInternal> by using a closure.
|
|
59
|
+
MOVV ·callbackWrap_call(SB), R4
|
|
60
|
+
MOVV (R4), R4 // fn unsafe.Pointer
|
|
61
|
+
MOVV R13, R5 // frame (&callbackArgs{...})
|
|
62
|
+
MOVV $0, R7 // ctxt uintptr
|
|
63
|
+
|
|
64
|
+
JAL crosscall2(SB)
|
|
65
|
+
|
|
66
|
+
// Get callback result.
|
|
67
|
+
MOVV $(callbackArgs__size)(R3), R13
|
|
68
|
+
MOVV callbackArgs_result(R13), R4
|
|
69
|
+
|
|
70
|
+
// Restore LR and R30
|
|
71
|
+
MOVV 0(R3), R1
|
|
72
|
+
MOVV 8(R3), R30
|
|
73
|
+
ADDV $(22*8), R3
|
|
74
|
+
|
|
75
|
+
RET
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
|
3
3
|
|
|
4
|
-
//go:build darwin || freebsd || linux || windows
|
|
4
|
+
//go:build darwin || freebsd || linux || netbsd || windows
|
|
5
5
|
|
|
6
6
|
package purego
|
|
7
7
|
|
|
@@ -13,8 +13,8 @@ package purego
|
|
|
13
13
|
type CDecl struct{}
|
|
14
14
|
|
|
15
15
|
const (
|
|
16
|
-
maxArgs
|
|
17
|
-
|
|
16
|
+
maxArgs = 15
|
|
17
|
+
numOfFloatRegisters = 8 // arm64 and amd64 both have 8 float registers
|
|
18
18
|
)
|
|
19
19
|
|
|
20
20
|
type syscall15Args struct {
|
|
@@ -27,6 +27,9 @@ type syscall15Args struct {
|
|
|
27
27
|
// There is an internal maximum number of arguments that SyscallN can take. It panics
|
|
28
28
|
// when the maximum is exceeded. It returns the result and the libc error code if there is one.
|
|
29
29
|
//
|
|
30
|
+
// In order to call this function properly make sure to follow all the rules specified in [unsafe.Pointer]
|
|
31
|
+
// especially point 4.
|
|
32
|
+
//
|
|
30
33
|
// NOTE: SyscallN does not properly call functions that have both integer and float parameters.
|
|
31
34
|
// See discussion comment https://github.com/ebiten/purego/pull/1#issuecomment-1128057607
|
|
32
35
|
// for an explanation of why that is.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
|
3
3
|
|
|
4
|
-
//go:build cgo && !(amd64 || arm64)
|
|
4
|
+
//go:build cgo && !(amd64 || arm64 || loong64)
|
|
5
5
|
|
|
6
6
|
package purego
|
|
7
7
|
|
|
@@ -16,6 +16,6 @@ func syscall_syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a
|
|
|
16
16
|
return cgo.Syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
func NewCallback(_
|
|
20
|
-
panic("purego: NewCallback on Linux is only supported on amd64/arm64")
|
|
19
|
+
func NewCallback(_ any) uintptr {
|
|
20
|
+
panic("purego: NewCallback on Linux is only supported on amd64/arm64/loong64")
|
|
21
21
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
|
3
3
|
|
|
4
|
-
//go:build darwin || freebsd || (linux && (amd64 || arm64))
|
|
4
|
+
//go:build darwin || freebsd || (linux && (amd64 || arm64 || loong64)) || netbsd
|
|
5
5
|
|
|
6
6
|
package purego
|
|
7
7
|
|
|
@@ -14,14 +14,17 @@ import (
|
|
|
14
14
|
|
|
15
15
|
var syscall15XABI0 uintptr
|
|
16
16
|
|
|
17
|
-
//go:nosplit
|
|
18
17
|
func syscall_syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr) (r1, r2, err uintptr) {
|
|
19
|
-
args := syscall15Args
|
|
18
|
+
args := thePool.Get().(*syscall15Args)
|
|
19
|
+
defer thePool.Put(args)
|
|
20
|
+
|
|
21
|
+
*args = syscall15Args{
|
|
20
22
|
fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15,
|
|
21
23
|
a1, a2, a3, a4, a5, a6, a7, a8,
|
|
22
24
|
0,
|
|
23
25
|
}
|
|
24
|
-
|
|
26
|
+
|
|
27
|
+
runtime_cgocall(syscall15XABI0, unsafe.Pointer(args))
|
|
25
28
|
return args.a1, args.a2, 0
|
|
26
29
|
}
|
|
27
30
|
|
|
@@ -31,7 +34,7 @@ func syscall_syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a
|
|
|
31
34
|
// of uintptr. Only a limited number of callbacks may be created in a single Go process, and any memory allocated
|
|
32
35
|
// for these callbacks is never released. At least 2000 callbacks can always be created. Although this function
|
|
33
36
|
// provides similar functionality to windows.NewCallback it is distinct.
|
|
34
|
-
func NewCallback(fn
|
|
37
|
+
func NewCallback(fn any) uintptr {
|
|
35
38
|
ty := reflect.TypeOf(fn)
|
|
36
39
|
for i := 0; i < ty.NumIn(); i++ {
|
|
37
40
|
in := ty.In(i)
|
|
@@ -71,7 +74,7 @@ type callbackArgs struct {
|
|
|
71
74
|
result uintptr
|
|
72
75
|
}
|
|
73
76
|
|
|
74
|
-
func compileCallback(fn
|
|
77
|
+
func compileCallback(fn any) uintptr {
|
|
75
78
|
val := reflect.ValueOf(fn)
|
|
76
79
|
if val.Kind() != reflect.Func {
|
|
77
80
|
panic("purego: the type must be a function but was not")
|
|
@@ -146,12 +149,12 @@ func callbackWrap(a *callbackArgs) {
|
|
|
146
149
|
var intsN int // intsN represents the number of integer arguments processed
|
|
147
150
|
// stack points to the index into frame of the current stack element.
|
|
148
151
|
// The stack begins after the float and integer registers.
|
|
149
|
-
stack := numOfIntegerRegisters() +
|
|
152
|
+
stack := numOfIntegerRegisters() + numOfFloatRegisters
|
|
150
153
|
for i := range args {
|
|
151
154
|
var pos int
|
|
152
155
|
switch fnType.In(i).Kind() {
|
|
153
156
|
case reflect.Float32, reflect.Float64:
|
|
154
|
-
if floatsN >=
|
|
157
|
+
if floatsN >= numOfFloatRegisters {
|
|
155
158
|
pos = stack
|
|
156
159
|
stack++
|
|
157
160
|
} else {
|
|
@@ -169,7 +172,7 @@ func callbackWrap(a *callbackArgs) {
|
|
|
169
172
|
stack++
|
|
170
173
|
} else {
|
|
171
174
|
// the integers begin after the floats in frame
|
|
172
|
-
pos = intsN +
|
|
175
|
+
pos = intsN + numOfFloatRegisters
|
|
173
176
|
}
|
|
174
177
|
intsN++
|
|
175
178
|
}
|
|
@@ -214,7 +217,7 @@ func callbackasmAddr(i int) uintptr {
|
|
|
214
217
|
panic("purego: unsupported architecture")
|
|
215
218
|
case "386", "amd64":
|
|
216
219
|
entrySize = 5
|
|
217
|
-
case "arm", "arm64":
|
|
220
|
+
case "arm", "arm64", "loong64":
|
|
218
221
|
// On ARM and ARM64, each entry is a MOV instruction
|
|
219
222
|
// followed by a branch instruction
|
|
220
223
|
entrySize = 8
|
|
@@ -22,7 +22,7 @@ func syscall_syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a
|
|
|
22
22
|
// allocated for these callbacks is never released. Between NewCallback and NewCallbackCDecl, at least 1024
|
|
23
23
|
// callbacks can always be created. Although this function is similiar to the darwin version it may act
|
|
24
24
|
// differently.
|
|
25
|
-
func NewCallback(fn
|
|
25
|
+
func NewCallback(fn any) uintptr {
|
|
26
26
|
isCDecl := false
|
|
27
27
|
ty := reflect.TypeOf(fn)
|
|
28
28
|
for i := 0; i < ty.NumIn(); i++ {
|