purego: clean up files for callbackArgs definitions (#435)
- commit
- 81d8c41541b87236c0cdd602d09f073d3969f6d2
- author
- Hajime Hoshi · · 2026-03-08 12:50 UTC
- committer
- GitHub · · 2026-03-08 12:50 UTC
- parent
- 90bb24e
- signature
- GPG Unverified
B5690EEEBB952194The key is unknown
4 files · +48 -30
A syscall_notstackargs.go +37 -0
| @@ -0,0 +1,37 @@ | |||
| 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 uintptr | |
| 33 | + | } | |
| 34 | + | ||
| 35 | + | func (c *callbackArgs) stackFrame() unsafe.Pointer { | |
| 36 | + | return nil | |
| 37 | + | } | |
| @@ -0,0 +1,37 @@ | |||||
| 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 uintptr | |||
| 33 | + | } | |||
| 34 | + | ||||
| 35 | + | func (c *callbackArgs) stackFrame() unsafe.Pointer { | |||
| 36 | + | return nil | |||
| 37 | + | } | |||
R syscall_sysv_stackargs.go → syscall_stackargs.go +11 -2 renamed, 55% similar
| @@ -1,12 +1,21 @@ | |||
| 1 | 1 | // SPDX-License-Identifier: Apache-2.0 | |
| 2 | 2 | // SPDX-FileCopyrightText: 2026 The Ebitengine Authors | |
| 3 | 3 | ||
| 4 | - | //go:build linux && (ppc64le || s390x) | |
| 4 | + | //go:build ppc64le || s390x | |
| 5 | 5 | ||
| 6 | 6 | package purego | |
| 7 | 7 | ||
| 8 | 8 | import "unsafe" | |
| 9 | 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. | |
| 10 | 19 | type callbackArgs struct { | |
| 11 | 20 | index uintptr | |
| 12 | 21 | // args points to the argument block. | |
| @@ -15,7 +24,7 @@ type callbackArgs struct { | |||
| 15 | 24 | // float registers followed by the | |
| 16 | 25 | // integer registers followed by the stack. | |
| 17 | 26 | // | |
| 18 | - | // This variable is treated as a continuous | |
| 27 | + | // This variable is treated as a contiguous | |
| 19 | 28 | // block of memory containing all of the arguments | |
| 20 | 29 | // for this callback. | |
| 21 | 30 | args unsafe.Pointer | |
| @@ -1,12 +1,21 @@ | |||||
| 1 | // SPDX-License-Identifier: Apache-2.0 | 1 | // SPDX-License-Identifier: Apache-2.0 | ||
| 2 | // SPDX-FileCopyrightText: 2026 The Ebitengine Authors | 2 | // SPDX-FileCopyrightText: 2026 The Ebitengine Authors | ||
| 3 | 3 | ||||
| 4 | - | //go:build linux && (ppc64le || s390x) | 4 | + | //go:build ppc64le || s390x |
| 5 | 5 | ||||
| 6 | package purego | 6 | package purego | ||
| 7 | 7 | ||||
| 8 | import "unsafe" | 8 | import "unsafe" | ||
| 9 | 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. | |||
| 10 | type callbackArgs struct { | 19 | type callbackArgs struct { | ||
| 11 | index uintptr | 20 | index uintptr | ||
| 12 | // args points to the argument block. | 21 | // args points to the argument block. | ||
| @@ -15,7 +24,7 @@ type callbackArgs struct { | |||||
| 15 | // float registers followed by the | 24 | // float registers followed by the | ||
| 16 | // integer registers followed by the stack. | 25 | // integer registers followed by the stack. | ||
| 17 | // | 26 | // | ||
| 18 | - | // This variable is treated as a continuous | 27 | + | // This variable is treated as a contiguous |
| 19 | // block of memory containing all of the arguments | 28 | // block of memory containing all of the arguments | ||
| 20 | // for this callback. | 29 | // for this callback. | ||
| 21 | args unsafe.Pointer | 30 | args unsafe.Pointer | ||
D syscall_sysv_others.go +0 -28
| @@ -1,28 +0,0 @@ | |||
| 1 | - | // SPDX-License-Identifier: Apache-2.0 | |
| 2 | - | // SPDX-FileCopyrightText: 2026 The Ebitengine Authors | |
| 3 | - | ||
| 4 | - | //go:build darwin || freebsd || (linux && (386 || amd64 || arm || arm64 || loong64 || riscv64)) || netbsd | |
| 5 | - | ||
| 6 | - | package purego | |
| 7 | - | ||
| 8 | - | import "unsafe" | |
| 9 | - | ||
| 10 | - | type callbackArgs struct { | |
| 11 | - | index uintptr | |
| 12 | - | // args points to the argument block. | |
| 13 | - | // | |
| 14 | - | // The structure of the arguments goes | |
| 15 | - | // float registers followed by the | |
| 16 | - | // integer registers followed by the stack. | |
| 17 | - | // | |
| 18 | - | // This variable is treated as a continuous | |
| 19 | - | // block of memory containing all of the arguments | |
| 20 | - | // for this callback. | |
| 21 | - | args unsafe.Pointer | |
| 22 | - | // Below are out-args from callbackWrap | |
| 23 | - | result uintptr | |
| 24 | - | } | |
| 25 | - | ||
| 26 | - | func (c *callbackArgs) stackFrame() unsafe.Pointer { | |
| 27 | - | return nil | |
| 28 | - | } | |
| @@ -1,28 +0,0 @@ | |||||
| 1 | - | // SPDX-License-Identifier: Apache-2.0 | |||
| 2 | - | // SPDX-FileCopyrightText: 2026 The Ebitengine Authors | |||
| 3 | - | ||||
| 4 | - | //go:build darwin || freebsd || (linux && (386 || amd64 || arm || arm64 || loong64 || riscv64)) || netbsd | |||
| 5 | - | ||||
| 6 | - | package purego | |||
| 7 | - | ||||
| 8 | - | import "unsafe" | |||
| 9 | - | ||||
| 10 | - | type callbackArgs struct { | |||
| 11 | - | index uintptr | |||
| 12 | - | // args points to the argument block. | |||
| 13 | - | // | |||
| 14 | - | // The structure of the arguments goes | |||
| 15 | - | // float registers followed by the | |||
| 16 | - | // integer registers followed by the stack. | |||
| 17 | - | // | |||
| 18 | - | // This variable is treated as a continuous | |||
| 19 | - | // block of memory containing all of the arguments | |||
| 20 | - | // for this callback. | |||
| 21 | - | args unsafe.Pointer | |||
| 22 | - | // Below are out-args from callbackWrap | |||
| 23 | - | result uintptr | |||
| 24 | - | } | |||
| 25 | - | ||||
| 26 | - | func (c *callbackArgs) stackFrame() unsafe.Pointer { | |||
| 27 | - | return nil | |||
| 28 | - | } | |||
R syscall_sysv.go → syscall_unix.go +0 -0 renamed, 100% similar
renamed, 100% similar