Debian Codegraph @

syscall_notstackargs.go

raw
1 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2026 The Ebitengine Authors
3
4 //go:build !(ppc64le || s390x)
5
6 package purego
7
8 import "unsafe"
9
10 // callbackArgs is the argument block passed from the assembly trampoline
11 // to callbackWrap when C code calls a Go callback registered with NewCallback.
12 // The assembly fills in the fields before calling callbackWrap, which uses
13 // them to determine which Go function to invoke and where to read its
14 // arguments from, and writes the return value back into result.
15 //
16 // callbackArgs is only used on Unix. On Windows, callbacks are handled by
17 // the runtime's own callback mechanism, so this type is compiled but unused,
18 // serving only as a stub to satisfy cross-platform compilation.
19 type callbackArgs struct {
20 index uintptr
21 // args points to the argument block.
22 //
23 // The structure of the arguments goes
24 // float registers followed by the
25 // integer registers followed by the stack.
26 //
27 // This variable is treated as a contiguous
28 // block of memory containing all of the arguments
29 // for this callback.
30 args unsafe.Pointer
31 // Below are out-args from callbackWrap
32 result [4]uintptr
33 }
34
35 func (c *callbackArgs) stackFrame() unsafe.Pointer {
36 return nil
37 }
38
39 func (c *callbackArgs) intFrame() unsafe.Pointer {
40 return nil
41 }
42
43 func (c *callbackArgs) setInt64Result(result int64) {
44 c.result[0] = uintptr(result)
45 if unsafe.Sizeof(uintptr(0)) == 4 {
46 c.result[1] = uintptr(result >> 32)
47 }
48 }
49
50 func (c *callbackArgs) setUint64Result(result uint64) {
51 c.result[0] = uintptr(result)
52 if unsafe.Sizeof(uintptr(0)) == 4 {
53 c.result[1] = uintptr(result >> 32)
54 }
55 }