Debian Codegraph @

internal/fakecgo/threadentry_noasm.go

raw
1 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2026 The Ebitengine Authors
3
4 //go:build !cgo && !amd64 && (darwin || freebsd || linux || netbsd)
5
6 package fakecgo
7
8 import "unsafe"
9
10 // callThreadEntryFn calls fn (runtime.mstart). On architectures without the
11 // amd64 frame-pointer epilogue issue this is a plain indirect call. It must be
12 // nosplit and norace like the threadentry callers so it neither inserts a
13 // morestack preamble nor runs race instrumentation during the fragile
14 // thread-bootstrap window.
15 //
16 //go:nosplit
17 //go:norace
18 func callThreadEntryFn(fn uintptr) {
19 // fn is the code pointer. Build a func value whose first word is fn by
20 // pointing the closure at &fn, then call it (same trick fakecgo has always
21 // used to call a raw PC from Go).
22 fnPtr := uintptr(unsafe.Pointer(&fn))
23 (*(*func())(unsafe.Pointer(&fnPtr)))()
24 }