slidge-whatsapp 0.3.0b0__cp312-cp312-manylinux_2_36_aarch64.whl → 0.3.1__cp312-cp312-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.

Files changed (132) hide show
  1. slidge_whatsapp/contact.py +2 -0
  2. slidge_whatsapp/event.go +72 -22
  3. slidge_whatsapp/generated/_whatsapp.cpython-312-aarch64-linux-gnu.h +195 -195
  4. slidge_whatsapp/generated/_whatsapp.cpython-312-aarch64-linux-gnu.so +0 -0
  5. slidge_whatsapp/generated/build.py +148 -148
  6. slidge_whatsapp/generated/whatsapp.c +1542 -1542
  7. slidge_whatsapp/generated/whatsapp.go +1210 -1210
  8. slidge_whatsapp/generated/whatsapp.py +1355 -1355
  9. slidge_whatsapp/generated/whatsapp_go.h +195 -195
  10. slidge_whatsapp/go.mod +5 -5
  11. slidge_whatsapp/go.sum +14 -14
  12. slidge_whatsapp/session.go +4 -4
  13. slidge_whatsapp/vendor/github.com/ebitengine/purego/README.md +21 -5
  14. slidge_whatsapp/vendor/github.com/ebitengine/purego/abi_loong64.h +60 -0
  15. slidge_whatsapp/vendor/github.com/ebitengine/purego/cgo.go +1 -1
  16. slidge_whatsapp/vendor/github.com/ebitengine/purego/dlerror.go +1 -1
  17. slidge_whatsapp/vendor/github.com/ebitengine/purego/dlfcn.go +1 -1
  18. slidge_whatsapp/vendor/github.com/ebitengine/purego/dlfcn_netbsd.go +15 -0
  19. slidge_whatsapp/vendor/github.com/ebitengine/purego/dlfcn_nocgo_netbsd.go +9 -0
  20. slidge_whatsapp/vendor/github.com/ebitengine/purego/dlfcn_stubs.s +1 -1
  21. slidge_whatsapp/vendor/github.com/ebitengine/purego/func.go +113 -60
  22. slidge_whatsapp/vendor/github.com/ebitengine/purego/gen.go +6 -0
  23. slidge_whatsapp/vendor/github.com/ebitengine/purego/go_runtime.go +1 -1
  24. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/cgo/dlfcn_cgo_unix.go +2 -2
  25. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/cgo/syscall_cgo_unix.go +2 -2
  26. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/abi_loong64.h +60 -0
  27. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/asm_loong64.s +40 -0
  28. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/callbacks.go +1 -1
  29. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/doc.go +1 -1
  30. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/go_libinit.go +1 -1
  31. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/go_linux_loong64.go +92 -0
  32. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/go_netbsd.go +106 -0
  33. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/go_setenv.go +1 -1
  34. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/go_util.go +1 -1
  35. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/iscgo.go +1 -1
  36. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo.go +1 -1
  37. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_darwin.go +4 -0
  38. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_freebsd.go +4 -0
  39. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_linux.go +4 -0
  40. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_netbsd.go +26 -0
  41. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/netbsd.go +23 -0
  42. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/setenv.go +1 -1
  43. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols.go +11 -1
  44. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_darwin.go +1 -0
  45. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_freebsd.go +1 -0
  46. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_linux.go +1 -0
  47. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols_netbsd.go +30 -0
  48. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_loong64.s +71 -0
  49. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_stubs.s +5 -1
  50. slidge_whatsapp/vendor/github.com/ebitengine/purego/nocgo.go +1 -1
  51. slidge_whatsapp/vendor/github.com/ebitengine/purego/struct_amd64.go +8 -4
  52. slidge_whatsapp/vendor/github.com/ebitengine/purego/struct_arm64.go +16 -6
  53. slidge_whatsapp/vendor/github.com/ebitengine/purego/struct_loong64.go +190 -0
  54. slidge_whatsapp/vendor/github.com/ebitengine/purego/struct_other.go +6 -2
  55. slidge_whatsapp/vendor/github.com/ebitengine/purego/sys_amd64.s +1 -1
  56. slidge_whatsapp/vendor/github.com/ebitengine/purego/sys_arm64.s +1 -1
  57. slidge_whatsapp/vendor/github.com/ebitengine/purego/sys_loong64.s +96 -0
  58. slidge_whatsapp/vendor/github.com/ebitengine/purego/sys_unix_arm64.s +1 -1
  59. slidge_whatsapp/vendor/github.com/ebitengine/purego/sys_unix_loong64.s +75 -0
  60. slidge_whatsapp/vendor/github.com/ebitengine/purego/syscall.go +6 -3
  61. slidge_whatsapp/vendor/github.com/ebitengine/purego/syscall_cgo_linux.go +3 -3
  62. slidge_whatsapp/vendor/github.com/ebitengine/purego/syscall_sysv.go +13 -10
  63. slidge_whatsapp/vendor/github.com/ebitengine/purego/syscall_windows.go +1 -1
  64. slidge_whatsapp/vendor/github.com/ebitengine/purego/zcallback_amd64.s +2002 -2002
  65. slidge_whatsapp/vendor/github.com/ebitengine/purego/zcallback_arm64.s +4002 -4002
  66. slidge_whatsapp/vendor/github.com/ebitengine/purego/zcallback_loong64.s +4014 -0
  67. slidge_whatsapp/vendor/go.mau.fi/util/dbutil/log.go +1 -0
  68. slidge_whatsapp/vendor/go.mau.fi/util/dbutil/module.go +118 -0
  69. slidge_whatsapp/vendor/go.mau.fi/util/dbutil/upgradetable.go +0 -34
  70. slidge_whatsapp/vendor/go.mau.fi/util/exbytes/string.go +20 -0
  71. slidge_whatsapp/vendor/go.mau.fi/util/exbytes/writer.go +78 -0
  72. slidge_whatsapp/vendor/go.mau.fi/util/exslices/cast.go +42 -0
  73. slidge_whatsapp/vendor/go.mau.fi/util/exslices/chunk.go +28 -0
  74. slidge_whatsapp/vendor/go.mau.fi/util/exslices/deduplicate.go +67 -0
  75. slidge_whatsapp/vendor/go.mau.fi/util/exslices/diff.go +63 -0
  76. slidge_whatsapp/vendor/go.mau.fi/util/exsync/event.go +15 -1
  77. slidge_whatsapp/vendor/go.mau.fi/util/random/string.go +47 -7
  78. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate/decode.go +1 -0
  79. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate/encode.go +34 -0
  80. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate/hash.go +1 -0
  81. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate.go +3 -0
  82. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/armadillomessage.go +1 -2
  83. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/call.go +6 -0
  84. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/errors.go +1 -0
  85. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/group.go +63 -42
  86. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/internals.go +14 -10
  87. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/message.go +45 -18
  88. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/msgsecret.go +23 -0
  89. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/notification.go +5 -1
  90. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/pair.go +3 -7
  91. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waAICommon/WAAICommon.pb.go +7747 -0
  92. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/{waBotMetadata/WABotMetadata.proto → waAICommon/WAAICommon.proto} +269 -9
  93. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waDeviceCapabilities/WAProtobufsDeviceCapabilities.pb.go +128 -14
  94. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waDeviceCapabilities/WAProtobufsDeviceCapabilities.proto +10 -0
  95. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waE2E/WAWebProtobufsE2E.pb.go +3236 -4732
  96. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waE2E/WAWebProtobufsE2E.proto +125 -273
  97. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waHistorySync/WAWebProtobufsHistorySync.pb.go +11 -2
  98. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waHistorySync/WAWebProtobufsHistorySync.proto +1 -0
  99. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waStatusAttributions/WAStatusAttributions.pb.go +220 -81
  100. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waStatusAttributions/WAStatusAttributions.proto +13 -0
  101. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waSyncAction/WASyncAction.pb.go +705 -449
  102. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waSyncAction/WASyncAction.proto +23 -0
  103. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWa6/WAWebProtobufsWa6.pb.go +78 -24
  104. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWa6/WAWebProtobufsWa6.proto +6 -0
  105. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWeb/WAWebProtobufsWeb.pb.go +516 -267
  106. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWeb/WAWebProtobufsWeb.proto +22 -0
  107. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/receipt.go +2 -0
  108. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/request.go +4 -0
  109. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/retry.go +2 -3
  110. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/send.go +110 -28
  111. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/clientpayload.go +1 -1
  112. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/noop.go +12 -0
  113. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/lidmap.go +82 -4
  114. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/store.go +112 -55
  115. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrades/00-latest-schema.sql +8 -7
  116. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrades/11-redacted-phone-contacts.sql +2 -0
  117. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/store.go +20 -0
  118. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/call.go +6 -5
  119. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/message.go +7 -1
  120. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/user.go +3 -0
  121. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/user.go +31 -2
  122. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/filedesc/desc.go +35 -17
  123. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/filedesc/desc_init.go +14 -0
  124. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go +20 -0
  125. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/version/version.go +1 -1
  126. slidge_whatsapp/vendor/modules.txt +8 -6
  127. {slidge_whatsapp-0.3.0b0.dist-info → slidge_whatsapp-0.3.1.dist-info}/METADATA +4 -3
  128. {slidge_whatsapp-0.3.0b0.dist-info → slidge_whatsapp-0.3.1.dist-info}/RECORD +131 -107
  129. {slidge_whatsapp-0.3.0b0.dist-info → slidge_whatsapp-0.3.1.dist-info}/WHEEL +1 -1
  130. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waBotMetadata/WABotMetadata.pb.go +0 -5156
  131. {slidge_whatsapp-0.3.0b0.dist-info → slidge_whatsapp-0.3.1.dist-info}/entry_points.txt +0 -0
  132. {slidge_whatsapp-0.3.0b0.dist-info → slidge_whatsapp-0.3.1.dist-info/licenses}/LICENSE +0 -0
@@ -0,0 +1,60 @@
1
+ // Copyright 2022 The Go Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style
3
+ // license that can be found in the LICENSE file.
4
+
5
+ // Macros for transitioning from the host ABI to Go ABI0.
6
+ //
7
+ // These macros save and restore the callee-saved registers
8
+ // from the stack, but they don't adjust stack pointer, so
9
+ // the user should prepare stack space in advance.
10
+ // SAVE_R22_TO_R31(offset) saves R22 ~ R31 to the stack space
11
+ // of ((offset)+0*8)(R3) ~ ((offset)+9*8)(R3).
12
+ //
13
+ // SAVE_F24_TO_F31(offset) saves F24 ~ F31 to the stack space
14
+ // of ((offset)+0*8)(R3) ~ ((offset)+7*8)(R3).
15
+ //
16
+ // Note: g is R22
17
+
18
+ #define SAVE_R22_TO_R31(offset) \
19
+ MOVV g, ((offset)+(0*8))(R3) \
20
+ MOVV R23, ((offset)+(1*8))(R3) \
21
+ MOVV R24, ((offset)+(2*8))(R3) \
22
+ MOVV R25, ((offset)+(3*8))(R3) \
23
+ MOVV R26, ((offset)+(4*8))(R3) \
24
+ MOVV R27, ((offset)+(5*8))(R3) \
25
+ MOVV R28, ((offset)+(6*8))(R3) \
26
+ MOVV R29, ((offset)+(7*8))(R3) \
27
+ MOVV R30, ((offset)+(8*8))(R3) \
28
+ MOVV R31, ((offset)+(9*8))(R3)
29
+
30
+ #define SAVE_F24_TO_F31(offset) \
31
+ MOVD F24, ((offset)+(0*8))(R3) \
32
+ MOVD F25, ((offset)+(1*8))(R3) \
33
+ MOVD F26, ((offset)+(2*8))(R3) \
34
+ MOVD F27, ((offset)+(3*8))(R3) \
35
+ MOVD F28, ((offset)+(4*8))(R3) \
36
+ MOVD F29, ((offset)+(5*8))(R3) \
37
+ MOVD F30, ((offset)+(6*8))(R3) \
38
+ MOVD F31, ((offset)+(7*8))(R3)
39
+
40
+ #define RESTORE_R22_TO_R31(offset) \
41
+ MOVV ((offset)+(0*8))(R3), g \
42
+ MOVV ((offset)+(1*8))(R3), R23 \
43
+ MOVV ((offset)+(2*8))(R3), R24 \
44
+ MOVV ((offset)+(3*8))(R3), R25 \
45
+ MOVV ((offset)+(4*8))(R3), R26 \
46
+ MOVV ((offset)+(5*8))(R3), R27 \
47
+ MOVV ((offset)+(6*8))(R3), R28 \
48
+ MOVV ((offset)+(7*8))(R3), R29 \
49
+ MOVV ((offset)+(8*8))(R3), R30 \
50
+ MOVV ((offset)+(9*8))(R3), R31
51
+
52
+ #define RESTORE_F24_TO_F31(offset) \
53
+ MOVD ((offset)+(0*8))(R3), F24 \
54
+ MOVD ((offset)+(1*8))(R3), F25 \
55
+ MOVD ((offset)+(2*8))(R3), F26 \
56
+ MOVD ((offset)+(3*8))(R3), F27 \
57
+ MOVD ((offset)+(4*8))(R3), F28 \
58
+ MOVD ((offset)+(5*8))(R3), F29 \
59
+ MOVD ((offset)+(6*8))(R3), F30 \
60
+ MOVD ((offset)+(7*8))(R3), F31
@@ -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 && (darwin || freebsd || linux)
4
+ //go:build cgo && (darwin || freebsd || linux || netbsd)
5
5
 
6
6
  package purego
7
7
 
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  // SPDX-FileCopyrightText: 2023 The Ebitengine Authors
3
3
 
4
- //go:build darwin || freebsd || linux
4
+ //go:build darwin || freebsd || linux || netbsd
5
5
 
6
6
  package purego
7
7
 
@@ -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) && !android && !faketime
4
+ //go:build (darwin || freebsd || linux || netbsd) && !android && !faketime
5
5
 
6
6
  package purego
7
7
 
@@ -0,0 +1,15 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // SPDX-FileCopyrightText: 2025 The Ebitengine Authors
3
+
4
+ package purego
5
+
6
+ // Source for constants: https://github.com/NetBSD/src/blob/trunk/include/dlfcn.h
7
+
8
+ const (
9
+ intSize = 32 << (^uint(0) >> 63) // 32 or 64
10
+ RTLD_DEFAULT = 1<<intSize - 2 // Pseudo-handle for dlsym so search for any loaded symbol
11
+ RTLD_LAZY = 0x00000001 // Relocations are performed at an implementation-dependent time.
12
+ RTLD_NOW = 0x00000002 // Relocations are performed when the object is loaded.
13
+ RTLD_LOCAL = 0x00000000 // All symbols are not made available for relocation processing by other modules.
14
+ RTLD_GLOBAL = 0x00000100 // All symbols are available for relocation processing of other modules.
15
+ )
@@ -0,0 +1,9 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // SPDX-FileCopyrightText: 2025 The Ebitengine Authors
3
+
4
+ package purego
5
+
6
+ //go:cgo_import_dynamic purego_dlopen dlopen "libc.so"
7
+ //go:cgo_import_dynamic purego_dlsym dlsym "libc.so"
8
+ //go:cgo_import_dynamic purego_dlerror dlerror "libc.so"
9
+ //go:cgo_import_dynamic purego_dlclose dlclose "libc.so"
@@ -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 || !cgo && (freebsd || linux) && !faketime
4
+ //go:build darwin || !cgo && (freebsd || linux || netbsd) && !faketime
5
5
 
6
6
  #include "textflag.h"
7
7
 
@@ -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
 
@@ -10,14 +10,20 @@ import (
10
10
  "math"
11
11
  "reflect"
12
12
  "runtime"
13
+ "strconv"
14
+ "sync"
13
15
  "unsafe"
14
16
 
15
17
  "github.com/ebitengine/purego/internal/strings"
16
18
  )
17
19
 
20
+ var thePool = sync.Pool{New: func() any {
21
+ return new(syscall15Args)
22
+ }}
23
+
18
24
  // RegisterLibFunc is a wrapper around RegisterFunc that uses the C function returned from Dlsym(handle, name).
19
25
  // It panics if it can't find the name symbol.
20
- func RegisterLibFunc(fptr interface{}, handle uintptr, name string) {
26
+ func RegisterLibFunc(fptr any, handle uintptr, name string) {
21
27
  sym, err := loadSymbol(handle, name)
22
28
  if err != nil {
23
29
  panic(err)
@@ -60,7 +66,7 @@ func RegisterLibFunc(fptr interface{}, handle uintptr, name string) {
60
66
  //
61
67
  // There is a special case when the last argument of fptr is a variadic interface (or []interface}
62
68
  // it will be expanded into a call to the C function as if it had the arguments in that slice.
63
- // This means that using arg ...interface{} is like a cast to the function with the arguments inside arg.
69
+ // This means that using arg ...any is like a cast to the function with the arguments inside arg.
64
70
  // This is not the same as C variadic.
65
71
  //
66
72
  // # Memory
@@ -105,7 +111,7 @@ func RegisterLibFunc(fptr interface{}, handle uintptr, name string) {
105
111
  // defer free(mustFree)
106
112
  //
107
113
  // [Cgo rules]: https://pkg.go.dev/cmd/cgo#hdr-Go_references_to_C
108
- func RegisterFunc(fptr interface{}, cfn uintptr) {
114
+ func RegisterFunc(fptr any, cfn uintptr) {
109
115
  fn := reflect.ValueOf(fptr).Elem()
110
116
  ty := fn.Type()
111
117
  if ty.Kind() != reflect.Func {
@@ -118,7 +124,7 @@ func RegisterFunc(fptr interface{}, cfn uintptr) {
118
124
  panic("purego: cfn is nil")
119
125
  }
120
126
  if ty.NumOut() == 1 && (ty.Out(0).Kind() == reflect.Float32 || ty.Out(0).Kind() == reflect.Float64) &&
121
- runtime.GOARCH != "arm64" && runtime.GOARCH != "amd64" {
127
+ runtime.GOARCH != "arm64" && runtime.GOARCH != "amd64" && runtime.GOARCH != "loong64" {
122
128
  panic("purego: float returns are not supported")
123
129
  }
124
130
  {
@@ -156,7 +162,7 @@ func RegisterFunc(fptr interface{}, cfn uintptr) {
156
162
  if is32bit {
157
163
  panic("purego: floats only supported on 64bit platforms")
158
164
  }
159
- if floats < numOfFloats {
165
+ if floats < numOfFloatRegisters {
160
166
  floats++
161
167
  } else {
162
168
  stack++
@@ -200,21 +206,8 @@ func RegisterFunc(fptr interface{}, cfn uintptr) {
200
206
  }
201
207
  }
202
208
  v := reflect.MakeFunc(ty, func(args []reflect.Value) (results []reflect.Value) {
203
- if len(args) > 0 {
204
- if variadic, ok := args[len(args)-1].Interface().([]interface{}); ok {
205
- // subtract one from args bc the last argument in args is []interface{}
206
- // which we are currently expanding
207
- tmp := make([]reflect.Value, len(args)-1+len(variadic))
208
- n := copy(tmp, args[:len(args)-1])
209
- for i, v := range variadic {
210
- tmp[n+i] = reflect.ValueOf(v)
211
- }
212
- args = tmp
213
- }
214
- }
215
209
  var sysargs [maxArgs]uintptr
216
- stack := sysargs[numOfIntegerRegisters():]
217
- var floats [numOfFloats]uintptr
210
+ var floats [numOfFloatRegisters]uintptr
218
211
  var numInts int
219
212
  var numFloats int
220
213
  var numStack int
@@ -222,7 +215,7 @@ func RegisterFunc(fptr interface{}, cfn uintptr) {
222
215
  if runtime.GOARCH == "arm64" || runtime.GOOS != "windows" {
223
216
  // Windows arm64 uses the same calling convention as macOS and Linux
224
217
  addStack = func(x uintptr) {
225
- stack[numStack] = x
218
+ sysargs[numOfIntegerRegisters()+numStack] = x
226
219
  numStack++
227
220
  }
228
221
  addInt = func(x uintptr) {
@@ -255,15 +248,16 @@ func RegisterFunc(fptr interface{}, cfn uintptr) {
255
248
  addFloat = addStack
256
249
  }
257
250
 
258
- var keepAlive []interface{}
251
+ var keepAlive []any
259
252
  defer func() {
260
253
  runtime.KeepAlive(keepAlive)
261
254
  runtime.KeepAlive(args)
262
255
  }()
263
- var syscall syscall15Args
256
+
257
+ var arm64_r8 uintptr
264
258
  if ty.NumOut() == 1 && ty.Out(0).Kind() == reflect.Struct {
265
259
  outType := ty.Out(0)
266
- if runtime.GOARCH == "amd64" && outType.Size() > maxRegAllocStructSize {
260
+ if (runtime.GOARCH == "amd64" || runtime.GOARCH == "loong64") && outType.Size() > maxRegAllocStructSize {
267
261
  val := reflect.New(outType)
268
262
  keepAlive = append(keepAlive, val)
269
263
  addInt(val.Pointer())
@@ -272,53 +266,73 @@ func RegisterFunc(fptr interface{}, cfn uintptr) {
272
266
  if !isAllFloats || numFields > 4 {
273
267
  val := reflect.New(outType)
274
268
  keepAlive = append(keepAlive, val)
275
- syscall.arm64_r8 = val.Pointer()
269
+ arm64_r8 = val.Pointer()
276
270
  }
277
271
  }
278
272
  }
279
- for _, v := range args {
280
- switch v.Kind() {
281
- case reflect.String:
282
- ptr := strings.CString(v.String())
283
- keepAlive = append(keepAlive, ptr)
284
- addInt(uintptr(unsafe.Pointer(ptr)))
285
- case reflect.Uintptr, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
286
- addInt(uintptr(v.Uint()))
287
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
288
- addInt(uintptr(v.Int()))
289
- case reflect.Ptr, reflect.UnsafePointer, reflect.Slice:
290
- // There is no need to keepAlive this pointer separately because it is kept alive in the args variable
291
- addInt(v.Pointer())
292
- case reflect.Func:
293
- addInt(NewCallback(v.Interface()))
294
- case reflect.Bool:
295
- if v.Bool() {
296
- addInt(1)
297
- } else {
298
- addInt(0)
273
+ for i, v := range args {
274
+ if variadic, ok := args[i].Interface().([]any); ok {
275
+ if i != len(args)-1 {
276
+ panic("purego: can only expand last parameter")
299
277
  }
300
- case reflect.Float32:
301
- addFloat(uintptr(math.Float32bits(float32(v.Float()))))
302
- case reflect.Float64:
303
- addFloat(uintptr(math.Float64bits(v.Float())))
304
- case reflect.Struct:
305
- keepAlive = addStruct(v, &numInts, &numFloats, &numStack, addInt, addFloat, addStack, keepAlive)
306
- default:
307
- panic("purego: unsupported kind: " + v.Kind().String())
278
+ for _, x := range variadic {
279
+ keepAlive = addValue(reflect.ValueOf(x), keepAlive, addInt, addFloat, addStack, &numInts, &numFloats, &numStack)
280
+ }
281
+ continue
282
+ }
283
+ if runtime.GOARCH == "arm64" && runtime.GOOS == "darwin" &&
284
+ (numInts >= numOfIntegerRegisters() || numFloats >= numOfFloatRegisters) && v.Kind() != reflect.Struct { // hit the stack
285
+ fields := make([]reflect.StructField, len(args[i:]))
286
+
287
+ for j, val := range args[i:] {
288
+ if val.Kind() == reflect.String {
289
+ ptr := strings.CString(v.String())
290
+ keepAlive = append(keepAlive, ptr)
291
+ val = reflect.ValueOf(ptr)
292
+ args[i+j] = val
293
+ }
294
+ fields[j] = reflect.StructField{
295
+ Name: "X" + strconv.Itoa(j),
296
+ Type: val.Type(),
297
+ }
298
+ }
299
+ structType := reflect.StructOf(fields)
300
+ structInstance := reflect.New(structType).Elem()
301
+ for j, val := range args[i:] {
302
+ structInstance.Field(j).Set(val)
303
+ }
304
+ placeRegisters(structInstance, addFloat, addInt)
305
+ break
308
306
  }
307
+ keepAlive = addValue(v, keepAlive, addInt, addFloat, addStack, &numInts, &numFloats, &numStack)
309
308
  }
310
- if runtime.GOARCH == "arm64" || runtime.GOOS != "windows" {
309
+
310
+ syscall := thePool.Get().(*syscall15Args)
311
+ defer thePool.Put(syscall)
312
+
313
+ if runtime.GOARCH == "loong64" {
314
+ *syscall = syscall15Args{
315
+ cfn,
316
+ sysargs[0], sysargs[1], sysargs[2], sysargs[3], sysargs[4], sysargs[5],
317
+ sysargs[6], sysargs[7], sysargs[8], sysargs[9], sysargs[10], sysargs[11],
318
+ sysargs[12], sysargs[13], sysargs[14],
319
+ floats[0], floats[1], floats[2], floats[3], floats[4], floats[5], floats[6], floats[7],
320
+ 0,
321
+ }
322
+ runtime_cgocall(syscall15XABI0, unsafe.Pointer(syscall))
323
+ } else if runtime.GOARCH == "arm64" || runtime.GOOS != "windows" {
311
324
  // Use the normal arm64 calling convention even on Windows
312
- syscall = syscall15Args{
325
+ *syscall = syscall15Args{
313
326
  cfn,
314
327
  sysargs[0], sysargs[1], sysargs[2], sysargs[3], sysargs[4], sysargs[5],
315
328
  sysargs[6], sysargs[7], sysargs[8], sysargs[9], sysargs[10], sysargs[11],
316
329
  sysargs[12], sysargs[13], sysargs[14],
317
330
  floats[0], floats[1], floats[2], floats[3], floats[4], floats[5], floats[6], floats[7],
318
- syscall.arm64_r8,
331
+ arm64_r8,
319
332
  }
320
- runtime_cgocall(syscall15XABI0, unsafe.Pointer(&syscall))
333
+ runtime_cgocall(syscall15XABI0, unsafe.Pointer(syscall))
321
334
  } else {
335
+ *syscall = syscall15Args{}
322
336
  // This is a fallback for Windows amd64, 386, and arm. Note this may not support floats
323
337
  syscall.a1, syscall.a2, _ = syscall_syscall15X(cfn, sysargs[0], sysargs[1], sysargs[2], sysargs[3], sysargs[4],
324
338
  sysargs[5], sysargs[6], sysargs[7], sysargs[8], sysargs[9], sysargs[10], sysargs[11],
@@ -357,15 +371,54 @@ func RegisterFunc(fptr interface{}, cfn uintptr) {
357
371
  // On 32bit platforms syscall.r2 is the upper part of a 64bit return.
358
372
  v.SetFloat(math.Float64frombits(uint64(syscall.f1)))
359
373
  case reflect.Struct:
360
- v = getStruct(outType, syscall)
374
+ v = getStruct(outType, *syscall)
361
375
  default:
362
376
  panic("purego: unsupported return kind: " + outType.Kind().String())
363
377
  }
364
- return []reflect.Value{v}
378
+ if len(args) > 0 {
379
+ // reuse args slice instead of allocating one when possible
380
+ args[0] = v
381
+ return args[:1]
382
+ } else {
383
+ return []reflect.Value{v}
384
+ }
365
385
  })
366
386
  fn.Set(v)
367
387
  }
368
388
 
389
+ func addValue(v reflect.Value, keepAlive []any, addInt func(x uintptr), addFloat func(x uintptr), addStack func(x uintptr), numInts *int, numFloats *int, numStack *int) []any {
390
+ switch v.Kind() {
391
+ case reflect.String:
392
+ ptr := strings.CString(v.String())
393
+ keepAlive = append(keepAlive, ptr)
394
+ addInt(uintptr(unsafe.Pointer(ptr)))
395
+ case reflect.Uintptr, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
396
+ addInt(uintptr(v.Uint()))
397
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
398
+ addInt(uintptr(v.Int()))
399
+ case reflect.Ptr, reflect.UnsafePointer, reflect.Slice:
400
+ // There is no need to keepAlive this pointer separately because it is kept alive in the args variable
401
+ addInt(v.Pointer())
402
+ case reflect.Func:
403
+ addInt(NewCallback(v.Interface()))
404
+ case reflect.Bool:
405
+ if v.Bool() {
406
+ addInt(1)
407
+ } else {
408
+ addInt(0)
409
+ }
410
+ case reflect.Float32:
411
+ addFloat(uintptr(math.Float32bits(float32(v.Float()))))
412
+ case reflect.Float64:
413
+ addFloat(uintptr(math.Float64bits(v.Float())))
414
+ case reflect.Struct:
415
+ keepAlive = addStruct(v, numInts, numFloats, numStack, addInt, addFloat, addStack, keepAlive)
416
+ default:
417
+ panic("purego: unsupported kind: " + v.Kind().String())
418
+ }
419
+ return keepAlive
420
+ }
421
+
369
422
  // maxRegAllocStructSize is the biggest a struct can be while still fitting in registers.
370
423
  // if it is bigger than this than enough space must be allocated on the heap and then passed into
371
424
  // the function as the first parameter on amd64 or in R8 on arm64.
@@ -424,7 +477,7 @@ func roundUpTo8(val uintptr) uintptr {
424
477
 
425
478
  func numOfIntegerRegisters() int {
426
479
  switch runtime.GOARCH {
427
- case "arm64":
480
+ case "arm64", "loong64":
428
481
  return 8
429
482
  case "amd64":
430
483
  return 6
@@ -0,0 +1,6 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // SPDX-FileCopyrightText: 2025 The Ebitengine Authors
3
+
4
+ package purego
5
+
6
+ //go:generate go run wincallback.go
@@ -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
 
@@ -1,12 +1,12 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  // SPDX-FileCopyrightText: 2024 The Ebitengine Authors
3
3
 
4
- //go:build freebsd || linux
4
+ //go:build freebsd || linux || netbsd
5
5
 
6
6
  package cgo
7
7
 
8
8
  /*
9
- #cgo LDFLAGS: -ldl
9
+ #cgo !netbsd LDFLAGS: -ldl
10
10
 
11
11
  #include <dlfcn.h>
12
12
  #include <stdlib.h>
@@ -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 freebsd || (linux && !(arm64 || amd64))
4
+ //go:build freebsd || (linux && !(arm64 || amd64 || loong64)) || netbsd
5
5
 
6
6
  package cgo
7
7
 
@@ -9,7 +9,7 @@ package cgo
9
9
  // because Cgo and assembly files can't be in the same package.
10
10
 
11
11
  /*
12
- #cgo LDFLAGS: -ldl
12
+ #cgo !netbsd LDFLAGS: -ldl
13
13
 
14
14
  #include <stdint.h>
15
15
  #include <dlfcn.h>
@@ -0,0 +1,60 @@
1
+ // Copyright 2022 The Go Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style
3
+ // license that can be found in the LICENSE file.
4
+
5
+ // Macros for transitioning from the host ABI to Go ABI0.
6
+ //
7
+ // These macros save and restore the callee-saved registers
8
+ // from the stack, but they don't adjust stack pointer, so
9
+ // the user should prepare stack space in advance.
10
+ // SAVE_R22_TO_R31(offset) saves R22 ~ R31 to the stack space
11
+ // of ((offset)+0*8)(R3) ~ ((offset)+9*8)(R3).
12
+ //
13
+ // SAVE_F24_TO_F31(offset) saves F24 ~ F31 to the stack space
14
+ // of ((offset)+0*8)(R3) ~ ((offset)+7*8)(R3).
15
+ //
16
+ // Note: g is R22
17
+
18
+ #define SAVE_R22_TO_R31(offset) \
19
+ MOVV g, ((offset)+(0*8))(R3) \
20
+ MOVV R23, ((offset)+(1*8))(R3) \
21
+ MOVV R24, ((offset)+(2*8))(R3) \
22
+ MOVV R25, ((offset)+(3*8))(R3) \
23
+ MOVV R26, ((offset)+(4*8))(R3) \
24
+ MOVV R27, ((offset)+(5*8))(R3) \
25
+ MOVV R28, ((offset)+(6*8))(R3) \
26
+ MOVV R29, ((offset)+(7*8))(R3) \
27
+ MOVV R30, ((offset)+(8*8))(R3) \
28
+ MOVV R31, ((offset)+(9*8))(R3)
29
+
30
+ #define SAVE_F24_TO_F31(offset) \
31
+ MOVD F24, ((offset)+(0*8))(R3) \
32
+ MOVD F25, ((offset)+(1*8))(R3) \
33
+ MOVD F26, ((offset)+(2*8))(R3) \
34
+ MOVD F27, ((offset)+(3*8))(R3) \
35
+ MOVD F28, ((offset)+(4*8))(R3) \
36
+ MOVD F29, ((offset)+(5*8))(R3) \
37
+ MOVD F30, ((offset)+(6*8))(R3) \
38
+ MOVD F31, ((offset)+(7*8))(R3)
39
+
40
+ #define RESTORE_R22_TO_R31(offset) \
41
+ MOVV ((offset)+(0*8))(R3), g \
42
+ MOVV ((offset)+(1*8))(R3), R23 \
43
+ MOVV ((offset)+(2*8))(R3), R24 \
44
+ MOVV ((offset)+(3*8))(R3), R25 \
45
+ MOVV ((offset)+(4*8))(R3), R26 \
46
+ MOVV ((offset)+(5*8))(R3), R27 \
47
+ MOVV ((offset)+(6*8))(R3), R28 \
48
+ MOVV ((offset)+(7*8))(R3), R29 \
49
+ MOVV ((offset)+(8*8))(R3), R30 \
50
+ MOVV ((offset)+(9*8))(R3), R31
51
+
52
+ #define RESTORE_F24_TO_F31(offset) \
53
+ MOVD ((offset)+(0*8))(R3), F24 \
54
+ MOVD ((offset)+(1*8))(R3), F25 \
55
+ MOVD ((offset)+(2*8))(R3), F26 \
56
+ MOVD ((offset)+(3*8))(R3), F27 \
57
+ MOVD ((offset)+(4*8))(R3), F28 \
58
+ MOVD ((offset)+(5*8))(R3), F29 \
59
+ MOVD ((offset)+(6*8))(R3), F30 \
60
+ MOVD ((offset)+(7*8))(R3), F31
@@ -0,0 +1,40 @@
1
+ // Copyright 2022 The Go Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style
3
+ // license that can be found in the LICENSE file.
4
+
5
+ #include "textflag.h"
6
+ #include "abi_loong64.h"
7
+
8
+ // Called by C code generated by cmd/cgo.
9
+ // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr)
10
+ // Saves C callee-saved registers and calls cgocallback with three arguments.
11
+ // fn is the PC of a func(a unsafe.Pointer) function.
12
+ TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0
13
+ /*
14
+ * We still need to save all callee save register as before, and then
15
+ * push 3 args for fn (R4, R5, R7), skipping R6.
16
+ * Also note that at procedure entry in gc world, 8(R29) will be the
17
+ * first arg.
18
+ */
19
+
20
+ ADDV $(-23*8), R3
21
+ MOVV R4, (1*8)(R3) // fn unsafe.Pointer
22
+ MOVV R5, (2*8)(R3) // a unsafe.Pointer
23
+ MOVV R7, (3*8)(R3) // ctxt uintptr
24
+
25
+ SAVE_R22_TO_R31((4*8))
26
+ SAVE_F24_TO_F31((14*8))
27
+ MOVV R1, (22*8)(R3)
28
+
29
+ // Initialize Go ABI environment
30
+ JAL runtime·load_g(SB)
31
+
32
+ JAL runtime·cgocallback(SB)
33
+
34
+ RESTORE_R22_TO_R31((4*8))
35
+ RESTORE_F24_TO_F31((14*8))
36
+ MOVV (22*8)(R3), R1
37
+
38
+ ADDV $(23*8), R3
39
+
40
+ RET
@@ -2,7 +2,7 @@
2
2
  // Use of this source code is governed by a BSD-style
3
3
  // license that can be found in the LICENSE file.
4
4
 
5
- //go:build !cgo && (darwin || freebsd || linux)
5
+ //go:build !cgo && (darwin || freebsd || linux || netbsd)
6
6
 
7
7
  package fakecgo
8
8
 
@@ -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 && (darwin || freebsd || linux)
4
+ //go:build !cgo && (darwin || freebsd || linux || netbsd)
5
5
 
6
6
  // Package fakecgo implements the Cgo runtime (runtime/cgo) entirely in Go.
7
7
  // This allows code that calls into C to function properly when CGO_ENABLED=0.
@@ -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 && (darwin || freebsd || linux)
4
+ //go:build !cgo && (darwin || freebsd || linux || netbsd)
5
5
 
6
6
  package fakecgo
7
7