-
Notifications
You must be signed in to change notification settings - Fork 102
Expand file tree
/
Copy pathsyscall_stackargs.go
More file actions
42 lines (37 loc) · 1.46 KB
/
syscall_stackargs.go
File metadata and controls
42 lines (37 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2026 The Ebitengine Authors
//go:build ppc64le || s390x
package purego
import "unsafe"
// callbackArgs is the argument block passed from the assembly trampoline
// to callbackWrap when C code calls a Go callback registered with NewCallback.
// The assembly fills in the fields before calling callbackWrap, which uses
// them to determine which Go function to invoke and where to read its
// arguments from, and writes the return value back into result.
//
// callbackArgs is only used on Unix. On Windows, callbacks are handled by
// the runtime's own callback mechanism, so this type is compiled but unused,
// serving only as a stub to satisfy cross-platform compilation.
type callbackArgs struct {
index uintptr
// args points to the argument block.
//
// The structure of the arguments goes
// float registers followed by the
// integer registers followed by the stack.
//
// This variable is treated as a contiguous
// block of memory containing all of the arguments
// for this callback.
args unsafe.Pointer
// Below are out-args from callbackWrap
result [1]uintptr
// stackArgs points to stack-passed arguments for architectures where
// they can't be made contiguous with register args (e.g., ppc64le).
// On other architectures, this is nil and stack args are read from
// the end of the args block.
stackArgs unsafe.Pointer
}
func (c *callbackArgs) stackFrame() unsafe.Pointer {
return c.stackArgs
}