// 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 { _ hostLayout 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 }