type cgoCallers … type argset … // wrapper for syscall package to call cgocall for libc (cgo) calls. // //go:linkname syscall_cgocaller syscall.cgocaller //go:nosplit //go:uintptrescapes func syscall_cgocaller(fn unsafe.Pointer, args ...uintptr) uintptr { … } var ncgocall … // Call from Go to C. // // This must be nosplit because it's used for syscalls on some // platforms. Syscalls may have untyped arguments on the stack, so // it's not safe to grow or scan the stack. // // cgocall should be an internal detail, // but widely used packages access it using linkname. // Notable members of the hall of shame include: // - github.com/ebitengine/purego // // Do not remove or change the type signature. // See go.dev/issue/67401. // //go:linkname cgocall //go:nosplit func cgocall(fn, arg unsafe.Pointer) int32 { … } // Set or reset the system stack bounds for a callback on sp. // // Must be nosplit because it is called by needm prior to fully initializing // the M. // //go:nosplit func callbackUpdateSystemStack(mp *m, sp uintptr, signal bool) { … } // Call from C back to Go. fn must point to an ABIInternal Go entry-point. // //go:nosplit func cgocallbackg(fn, frame unsafe.Pointer, ctxt uintptr) { … } func cgocallbackg1(fn, frame unsafe.Pointer, ctxt uintptr) { … } func unwindm(restore *bool) { … } // called from assembly. func badcgocallback() { … } // called from (incomplete) assembly. func cgounimpl() { … } var racecgosync … // cgoCheckPointer checks if the argument contains a Go pointer that // points to an unpinned Go pointer, and panics if it does. func cgoCheckPointer(ptr any, arg any) { … } const cgoCheckPointerFail … const cgoResultFail … // cgoCheckArg is the real work of cgoCheckPointer. The argument p // is either a pointer to the value (of type t), or the value itself, // depending on indir. The top parameter is whether we are at the top // level, where Go pointers are allowed. Go pointers to pinned objects are // allowed as long as they don't reference other unpinned pointers. func cgoCheckArg(t *_type, p unsafe.Pointer, indir, top bool, msg string) { … } // cgoCheckUnknownPointer is called for an arbitrary pointer into Go // memory. It checks whether that Go memory contains any other // pointer into unpinned Go memory. If it does, we panic. // The return values are unused but useful to see in panic tracebacks. func cgoCheckUnknownPointer(p unsafe.Pointer, msg string) (base, i uintptr) { … } // cgoIsGoPointer reports whether the pointer is a Go pointer--a // pointer to Go memory. We only care about Go memory that might // contain pointers. // //go:nosplit //go:nowritebarrierrec func cgoIsGoPointer(p unsafe.Pointer) bool { … } // cgoInRange reports whether p is between start and end. // //go:nosplit //go:nowritebarrierrec func cgoInRange(p unsafe.Pointer, start, end uintptr) bool { … } // cgoCheckResult is called to check the result parameter of an // exported Go function. It panics if the result is or contains any // other pointer into unpinned Go memory. func cgoCheckResult(val any) { … }