From 9b7de260d91aee53cdd8f4975b7614e25a1951a6 Mon Sep 17 00:00:00 2001 From: Andrey Kolkov Date: Mon, 20 Jul 2026 21:33:20 +0300 Subject: [PATCH] refactor: rename purego_ -> goffi_ in internal/fakecgo Rename all dynamic import symbols from purego_ prefix to goffi_ to reflect project identity. The fakecgo package was originally a snapshot of ebitengine/purego's internal/fakecgo (~2024). The purego_ naming was inherited but is inconsistent with the rest of the codebase (internal/dl and internal/syscall use goffi_ prefix). Add GoGPU copyright alongside original Ebitengine Authors attribution as required by Apache-2.0 license. --- LICENSE | 2 +- NOTICE | 13 +++++++++ ffi/struct_e2e_test.go | 2 +- ffi/struct_return_e2e_amd64_test.go | 2 +- ffi/variadic_e2e_test.go | 2 +- internal/arch/arm64/fakecgo_test.go | 2 +- internal/dl/cgo.go | 2 +- internal/fakecgo/doc.go | 15 +++++----- internal/fakecgo/gen.go | 8 ++++-- internal/fakecgo/go_libinit.go | 1 + internal/fakecgo/go_setenv.go | 1 + internal/fakecgo/go_util.go | 1 + internal/fakecgo/libcgo.go | 1 + internal/fakecgo/libcgo_darwin.go | 1 + internal/fakecgo/libcgo_freebsd.go | 1 + internal/fakecgo/libcgo_linux.go | 1 + internal/fakecgo/libcgo_netbsd.go | 1 + internal/fakecgo/symbols.go | 1 + internal/fakecgo/symbols_darwin.go | 43 ++++++++++++++-------------- internal/fakecgo/symbols_freebsd.go | 43 ++++++++++++++-------------- internal/fakecgo/symbols_linux.go | 43 ++++++++++++++-------------- internal/fakecgo/symbols_netbsd.go | 43 ++++++++++++++-------------- internal/fakecgo/trampolines_amd64.s | 1 + internal/fakecgo/trampolines_arm64.s | 1 + internal/fakecgo/trampolines_stubs.s | 43 ++++++++++++++-------------- internal/syscall/cgo.go | 2 +- 26 files changed, 155 insertions(+), 121 deletions(-) create mode 100644 NOTICE diff --git a/LICENSE b/LICENSE index 17a44f0..8b0cfe0 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2025 go-webgpu contributors +Copyright (c) 2025-2026 Andrey Kolkov and GoGPU Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..62996b8 --- /dev/null +++ b/NOTICE @@ -0,0 +1,13 @@ +goffi +Copyright 2025-2026 Andrey Kolkov and GoGPU Contributors + +This project is licensed under the MIT License (see LICENSE). + +Portions of this software (internal/fakecgo/) are derived from +ebitengine/purego (https://github.com/ebitengine/purego), licensed +under the Apache License, Version 2.0. Original copyright: + + Copyright 2022 The Ebitengine Authors + +The Apache-2.0 licensed files retain their original SPDX headers +with dual copyright attribution. diff --git a/ffi/struct_e2e_test.go b/ffi/struct_e2e_test.go index 7dfa452..a80d240 100644 --- a/ffi/struct_e2e_test.go +++ b/ffi/struct_e2e_test.go @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2026 The Goffi Authors +// SPDX-FileCopyrightText: 2026 Andrey Kolkov and GoGPU Contributors //go:build (linux || darwin || freebsd || windows) && (amd64 || arm64) diff --git a/ffi/struct_return_e2e_amd64_test.go b/ffi/struct_return_e2e_amd64_test.go index a3fb0ca..497b021 100644 --- a/ffi/struct_return_e2e_amd64_test.go +++ b/ffi/struct_return_e2e_amd64_test.go @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2026 The Goffi Authors +// SPDX-FileCopyrightText: 2026 Andrey Kolkov and GoGPU Contributors //go:build (linux || darwin || freebsd || windows) && amd64 diff --git a/ffi/variadic_e2e_test.go b/ffi/variadic_e2e_test.go index c1540f4..e1ac72d 100644 --- a/ffi/variadic_e2e_test.go +++ b/ffi/variadic_e2e_test.go @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2026 The Goffi Authors +// SPDX-FileCopyrightText: 2026 Andrey Kolkov and GoGPU Contributors //go:build (linux || darwin || freebsd || windows) && (amd64 || arm64) diff --git a/internal/arch/arm64/fakecgo_test.go b/internal/arch/arm64/fakecgo_test.go index 8a4f59f..bf6d2c2 100644 --- a/internal/arch/arm64/fakecgo_test.go +++ b/internal/arch/arm64/fakecgo_test.go @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2026 The Goffi Authors +// SPDX-FileCopyrightText: 2026 Andrey Kolkov and GoGPU Contributors //go:build arm64 && !cgo diff --git a/internal/dl/cgo.go b/internal/dl/cgo.go index 802a288..5245f96 100644 --- a/internal/dl/cgo.go +++ b/internal/dl/cgo.go @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors -// SPDX-FileCopyrightText: 2026 The Goffi Authors +// SPDX-FileCopyrightText: 2026 Andrey Kolkov and GoGPU Contributors //go:build cgo && (darwin || freebsd || linux || netbsd) diff --git a/internal/fakecgo/doc.go b/internal/fakecgo/doc.go index f93921e..968df4f 100644 --- a/internal/fakecgo/doc.go +++ b/internal/fakecgo/doc.go @@ -1,5 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors +// SPDX-FileCopyrightText: 2025-2026 Andrey Kolkov and GoGPU Contributors //go:build !cgo && (darwin || freebsd || linux || netbsd) @@ -15,17 +16,17 @@ // // # Support // -// Currently, fakecgo only supports macOS on amd64 & arm64. It also cannot -// be used with -buildmode=c-archive because that requires special initialization -// that fakecgo does not implement at the moment. +// Currently, fakecgo supports Linux, macOS, FreeBSD, and NetBSD on amd64 & arm64. +// It cannot be used with -buildmode=c-archive because that requires special +// initialization that fakecgo does not implement at the moment. // // # Usage // -// Using fakecgo is easy just import _ "github.com/go-webgpu/goffi/internal/fakecgo" and then +// Using fakecgo is easy: just import _ "github.com/go-webgpu/goffi/internal/fakecgo" and then // set the environment variable CGO_ENABLED=0. -// The recommended usage for fakecgo is to prefer using runtime/cgo if possible -// but if cross-compiling or fast build times are important fakecgo is available. -// Purego will pick which ever Cgo runtime is available and prefer the one that +// The recommended usage is to prefer runtime/cgo if possible, but if +// cross-compiling or fast build times are important, fakecgo is available. +// goffi will pick whichever Cgo runtime is available and prefer the one that // comes with Go (runtime/cgo). package fakecgo diff --git a/internal/fakecgo/gen.go b/internal/fakecgo/gen.go index 8ceaa23..5407e79 100644 --- a/internal/fakecgo/gen.go +++ b/internal/fakecgo/gen.go @@ -1,5 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors +// SPDX-FileCopyrightText: 2025-2026 Andrey Kolkov and GoGPU Contributors //go:build ignore @@ -19,6 +20,7 @@ const templateSymbols = `// Code generated by 'go generate' with gen.go. DO NOT // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors +// SPDX-FileCopyrightText: 2025-2026 Andrey Kolkov and GoGPU Contributors //go:build !cgo && (darwin || freebsd || linux || netbsd) @@ -86,6 +88,7 @@ const templateTrampolinesStubs = `// Code generated by 'go generate' with gen.go // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors +// SPDX-FileCopyrightText: 2025-2026 Andrey Kolkov and GoGPU Contributors //go:build !cgo && (darwin || freebsd || linux || netbsd) @@ -94,7 +97,7 @@ const templateTrampolinesStubs = `// Code generated by 'go generate' with gen.go // these stubs are here because it is not possible to go:linkname directly the C functions on darwin arm64 {{ range . }} TEXT _{{.Name}}(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_{{.Name}}(SB) + JMP goffi_{{.Name}}(SB) RET {{ end -}} ` @@ -103,6 +106,7 @@ const templateSymbolsGoos = `// Code generated by 'go generate' with gen.go. DO // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors +// SPDX-FileCopyrightText: 2025-2026 Andrey Kolkov and GoGPU Contributors //go:build !cgo @@ -110,7 +114,7 @@ package fakecgo {{- range $location := . }} {{- range .Symbols }} -//go:cgo_import_dynamic purego_{{ .Name }} {{ .Name }} "{{ $location.SharedObject }}" +//go:cgo_import_dynamic goffi_{{ .Name }} {{ .Name }} "{{ $location.SharedObject }}" {{- end }} {{- end }} ` diff --git a/internal/fakecgo/go_libinit.go b/internal/fakecgo/go_libinit.go index 0c46306..b2f7325 100644 --- a/internal/fakecgo/go_libinit.go +++ b/internal/fakecgo/go_libinit.go @@ -1,5 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors +// SPDX-FileCopyrightText: 2025-2026 Andrey Kolkov and GoGPU Contributors //go:build !cgo && (darwin || freebsd || linux || netbsd) diff --git a/internal/fakecgo/go_setenv.go b/internal/fakecgo/go_setenv.go index dfc6629..0c4bf83 100644 --- a/internal/fakecgo/go_setenv.go +++ b/internal/fakecgo/go_setenv.go @@ -1,5 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors +// SPDX-FileCopyrightText: 2025-2026 Andrey Kolkov and GoGPU Contributors //go:build !cgo && (darwin || freebsd || linux || netbsd) diff --git a/internal/fakecgo/go_util.go b/internal/fakecgo/go_util.go index 771cb52..4d52cb5 100644 --- a/internal/fakecgo/go_util.go +++ b/internal/fakecgo/go_util.go @@ -1,5 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors +// SPDX-FileCopyrightText: 2025-2026 Andrey Kolkov and GoGPU Contributors //go:build !cgo && (darwin || freebsd || linux || netbsd) diff --git a/internal/fakecgo/libcgo.go b/internal/fakecgo/libcgo.go index d1c842e..f50e835 100644 --- a/internal/fakecgo/libcgo.go +++ b/internal/fakecgo/libcgo.go @@ -1,5 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors +// SPDX-FileCopyrightText: 2025-2026 Andrey Kolkov and GoGPU Contributors //go:build !cgo && (darwin || freebsd || linux || netbsd) diff --git a/internal/fakecgo/libcgo_darwin.go b/internal/fakecgo/libcgo_darwin.go index ecdcb2e..35785fd 100644 --- a/internal/fakecgo/libcgo_darwin.go +++ b/internal/fakecgo/libcgo_darwin.go @@ -1,5 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors +// SPDX-FileCopyrightText: 2025-2026 Andrey Kolkov and GoGPU Contributors //go:build !cgo diff --git a/internal/fakecgo/libcgo_freebsd.go b/internal/fakecgo/libcgo_freebsd.go index 4bfb70c..990f712 100644 --- a/internal/fakecgo/libcgo_freebsd.go +++ b/internal/fakecgo/libcgo_freebsd.go @@ -1,5 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors +// SPDX-FileCopyrightText: 2025-2026 Andrey Kolkov and GoGPU Contributors //go:build !cgo diff --git a/internal/fakecgo/libcgo_linux.go b/internal/fakecgo/libcgo_linux.go index b08a44a..78cd999 100644 --- a/internal/fakecgo/libcgo_linux.go +++ b/internal/fakecgo/libcgo_linux.go @@ -1,5 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors +// SPDX-FileCopyrightText: 2025-2026 Andrey Kolkov and GoGPU Contributors //go:build !cgo diff --git a/internal/fakecgo/libcgo_netbsd.go b/internal/fakecgo/libcgo_netbsd.go index 650f695..bc25eb0 100644 --- a/internal/fakecgo/libcgo_netbsd.go +++ b/internal/fakecgo/libcgo_netbsd.go @@ -1,5 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2025 The Ebitengine Authors +// SPDX-FileCopyrightText: 2025-2026 Andrey Kolkov and GoGPU Contributors //go:build !cgo diff --git a/internal/fakecgo/symbols.go b/internal/fakecgo/symbols.go index 135f6d2..cb7668a 100644 --- a/internal/fakecgo/symbols.go +++ b/internal/fakecgo/symbols.go @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors +// SPDX-FileCopyrightText: 2025-2026 Andrey Kolkov and GoGPU Contributors //go:build !cgo && (darwin || freebsd || linux || netbsd) diff --git a/internal/fakecgo/symbols_darwin.go b/internal/fakecgo/symbols_darwin.go index 8c4489f..812feda 100644 --- a/internal/fakecgo/symbols_darwin.go +++ b/internal/fakecgo/symbols_darwin.go @@ -2,29 +2,30 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors +// SPDX-FileCopyrightText: 2025-2026 Andrey Kolkov and GoGPU Contributors //go:build !cgo package fakecgo -//go:cgo_import_dynamic purego_malloc malloc "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_free free "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_setenv setenv "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_unsetenv unsetenv "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_sigfillset sigfillset "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_nanosleep nanosleep "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_abort abort "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_sigaltstack sigaltstack "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_create pthread_create "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_detach pthread_detach "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_sigmask pthread_sigmask "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_self pthread_self "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_get_stacksize_np pthread_get_stacksize_np "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_attr_getstacksize pthread_attr_getstacksize "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_attr_setstacksize pthread_attr_setstacksize "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_attr_destroy pthread_attr_destroy "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_mutex_lock pthread_mutex_lock "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_mutex_unlock pthread_mutex_unlock "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_cond_broadcast pthread_cond_broadcast "/usr/lib/libSystem.B.dylib" -//go:cgo_import_dynamic purego_pthread_setspecific pthread_setspecific "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic goffi_malloc malloc "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic goffi_free free "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic goffi_setenv setenv "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic goffi_unsetenv unsetenv "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic goffi_sigfillset sigfillset "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic goffi_nanosleep nanosleep "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic goffi_abort abort "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic goffi_sigaltstack sigaltstack "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic goffi_pthread_attr_init pthread_attr_init "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic goffi_pthread_create pthread_create "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic goffi_pthread_detach pthread_detach "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic goffi_pthread_sigmask pthread_sigmask "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic goffi_pthread_self pthread_self "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic goffi_pthread_get_stacksize_np pthread_get_stacksize_np "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic goffi_pthread_attr_getstacksize pthread_attr_getstacksize "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic goffi_pthread_attr_setstacksize pthread_attr_setstacksize "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic goffi_pthread_attr_destroy pthread_attr_destroy "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic goffi_pthread_mutex_lock pthread_mutex_lock "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic goffi_pthread_mutex_unlock pthread_mutex_unlock "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic goffi_pthread_cond_broadcast pthread_cond_broadcast "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic goffi_pthread_setspecific pthread_setspecific "/usr/lib/libSystem.B.dylib" diff --git a/internal/fakecgo/symbols_freebsd.go b/internal/fakecgo/symbols_freebsd.go index bbe1bd5..c6495b5 100644 --- a/internal/fakecgo/symbols_freebsd.go +++ b/internal/fakecgo/symbols_freebsd.go @@ -2,29 +2,30 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors +// SPDX-FileCopyrightText: 2025-2026 Andrey Kolkov and GoGPU Contributors //go:build !cgo package fakecgo -//go:cgo_import_dynamic purego_malloc malloc "libc.so.7" -//go:cgo_import_dynamic purego_free free "libc.so.7" -//go:cgo_import_dynamic purego_setenv setenv "libc.so.7" -//go:cgo_import_dynamic purego_unsetenv unsetenv "libc.so.7" -//go:cgo_import_dynamic purego_sigfillset sigfillset "libc.so.7" -//go:cgo_import_dynamic purego_nanosleep nanosleep "libc.so.7" -//go:cgo_import_dynamic purego_abort abort "libc.so.7" -//go:cgo_import_dynamic purego_sigaltstack sigaltstack "libc.so.7" -//go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "libpthread.so" -//go:cgo_import_dynamic purego_pthread_create pthread_create "libpthread.so" -//go:cgo_import_dynamic purego_pthread_detach pthread_detach "libpthread.so" -//go:cgo_import_dynamic purego_pthread_sigmask pthread_sigmask "libpthread.so" -//go:cgo_import_dynamic purego_pthread_self pthread_self "libpthread.so" -//go:cgo_import_dynamic purego_pthread_get_stacksize_np pthread_get_stacksize_np "libpthread.so" -//go:cgo_import_dynamic purego_pthread_attr_getstacksize pthread_attr_getstacksize "libpthread.so" -//go:cgo_import_dynamic purego_pthread_attr_setstacksize pthread_attr_setstacksize "libpthread.so" -//go:cgo_import_dynamic purego_pthread_attr_destroy pthread_attr_destroy "libpthread.so" -//go:cgo_import_dynamic purego_pthread_mutex_lock pthread_mutex_lock "libpthread.so" -//go:cgo_import_dynamic purego_pthread_mutex_unlock pthread_mutex_unlock "libpthread.so" -//go:cgo_import_dynamic purego_pthread_cond_broadcast pthread_cond_broadcast "libpthread.so" -//go:cgo_import_dynamic purego_pthread_setspecific pthread_setspecific "libpthread.so" +//go:cgo_import_dynamic goffi_malloc malloc "libc.so.7" +//go:cgo_import_dynamic goffi_free free "libc.so.7" +//go:cgo_import_dynamic goffi_setenv setenv "libc.so.7" +//go:cgo_import_dynamic goffi_unsetenv unsetenv "libc.so.7" +//go:cgo_import_dynamic goffi_sigfillset sigfillset "libc.so.7" +//go:cgo_import_dynamic goffi_nanosleep nanosleep "libc.so.7" +//go:cgo_import_dynamic goffi_abort abort "libc.so.7" +//go:cgo_import_dynamic goffi_sigaltstack sigaltstack "libc.so.7" +//go:cgo_import_dynamic goffi_pthread_attr_init pthread_attr_init "libpthread.so" +//go:cgo_import_dynamic goffi_pthread_create pthread_create "libpthread.so" +//go:cgo_import_dynamic goffi_pthread_detach pthread_detach "libpthread.so" +//go:cgo_import_dynamic goffi_pthread_sigmask pthread_sigmask "libpthread.so" +//go:cgo_import_dynamic goffi_pthread_self pthread_self "libpthread.so" +//go:cgo_import_dynamic goffi_pthread_get_stacksize_np pthread_get_stacksize_np "libpthread.so" +//go:cgo_import_dynamic goffi_pthread_attr_getstacksize pthread_attr_getstacksize "libpthread.so" +//go:cgo_import_dynamic goffi_pthread_attr_setstacksize pthread_attr_setstacksize "libpthread.so" +//go:cgo_import_dynamic goffi_pthread_attr_destroy pthread_attr_destroy "libpthread.so" +//go:cgo_import_dynamic goffi_pthread_mutex_lock pthread_mutex_lock "libpthread.so" +//go:cgo_import_dynamic goffi_pthread_mutex_unlock pthread_mutex_unlock "libpthread.so" +//go:cgo_import_dynamic goffi_pthread_cond_broadcast pthread_cond_broadcast "libpthread.so" +//go:cgo_import_dynamic goffi_pthread_setspecific pthread_setspecific "libpthread.so" diff --git a/internal/fakecgo/symbols_linux.go b/internal/fakecgo/symbols_linux.go index 2165265..5d35a76 100644 --- a/internal/fakecgo/symbols_linux.go +++ b/internal/fakecgo/symbols_linux.go @@ -2,29 +2,30 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors +// SPDX-FileCopyrightText: 2025-2026 Andrey Kolkov and GoGPU Contributors //go:build !cgo package fakecgo -//go:cgo_import_dynamic purego_malloc malloc "libc.so.6" -//go:cgo_import_dynamic purego_free free "libc.so.6" -//go:cgo_import_dynamic purego_setenv setenv "libc.so.6" -//go:cgo_import_dynamic purego_unsetenv unsetenv "libc.so.6" -//go:cgo_import_dynamic purego_sigfillset sigfillset "libc.so.6" -//go:cgo_import_dynamic purego_nanosleep nanosleep "libc.so.6" -//go:cgo_import_dynamic purego_abort abort "libc.so.6" -//go:cgo_import_dynamic purego_sigaltstack sigaltstack "libc.so.6" -//go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "libpthread.so.0" -//go:cgo_import_dynamic purego_pthread_create pthread_create "libpthread.so.0" -//go:cgo_import_dynamic purego_pthread_detach pthread_detach "libpthread.so.0" -//go:cgo_import_dynamic purego_pthread_sigmask pthread_sigmask "libpthread.so.0" -//go:cgo_import_dynamic purego_pthread_self pthread_self "libpthread.so.0" -//go:cgo_import_dynamic purego_pthread_get_stacksize_np pthread_get_stacksize_np "libpthread.so.0" -//go:cgo_import_dynamic purego_pthread_attr_getstacksize pthread_attr_getstacksize "libpthread.so.0" -//go:cgo_import_dynamic purego_pthread_attr_setstacksize pthread_attr_setstacksize "libpthread.so.0" -//go:cgo_import_dynamic purego_pthread_attr_destroy pthread_attr_destroy "libpthread.so.0" -//go:cgo_import_dynamic purego_pthread_mutex_lock pthread_mutex_lock "libpthread.so.0" -//go:cgo_import_dynamic purego_pthread_mutex_unlock pthread_mutex_unlock "libpthread.so.0" -//go:cgo_import_dynamic purego_pthread_cond_broadcast pthread_cond_broadcast "libpthread.so.0" -//go:cgo_import_dynamic purego_pthread_setspecific pthread_setspecific "libpthread.so.0" +//go:cgo_import_dynamic goffi_malloc malloc "libc.so.6" +//go:cgo_import_dynamic goffi_free free "libc.so.6" +//go:cgo_import_dynamic goffi_setenv setenv "libc.so.6" +//go:cgo_import_dynamic goffi_unsetenv unsetenv "libc.so.6" +//go:cgo_import_dynamic goffi_sigfillset sigfillset "libc.so.6" +//go:cgo_import_dynamic goffi_nanosleep nanosleep "libc.so.6" +//go:cgo_import_dynamic goffi_abort abort "libc.so.6" +//go:cgo_import_dynamic goffi_sigaltstack sigaltstack "libc.so.6" +//go:cgo_import_dynamic goffi_pthread_attr_init pthread_attr_init "libpthread.so.0" +//go:cgo_import_dynamic goffi_pthread_create pthread_create "libpthread.so.0" +//go:cgo_import_dynamic goffi_pthread_detach pthread_detach "libpthread.so.0" +//go:cgo_import_dynamic goffi_pthread_sigmask pthread_sigmask "libpthread.so.0" +//go:cgo_import_dynamic goffi_pthread_self pthread_self "libpthread.so.0" +//go:cgo_import_dynamic goffi_pthread_get_stacksize_np pthread_get_stacksize_np "libpthread.so.0" +//go:cgo_import_dynamic goffi_pthread_attr_getstacksize pthread_attr_getstacksize "libpthread.so.0" +//go:cgo_import_dynamic goffi_pthread_attr_setstacksize pthread_attr_setstacksize "libpthread.so.0" +//go:cgo_import_dynamic goffi_pthread_attr_destroy pthread_attr_destroy "libpthread.so.0" +//go:cgo_import_dynamic goffi_pthread_mutex_lock pthread_mutex_lock "libpthread.so.0" +//go:cgo_import_dynamic goffi_pthread_mutex_unlock pthread_mutex_unlock "libpthread.so.0" +//go:cgo_import_dynamic goffi_pthread_cond_broadcast pthread_cond_broadcast "libpthread.so.0" +//go:cgo_import_dynamic goffi_pthread_setspecific pthread_setspecific "libpthread.so.0" diff --git a/internal/fakecgo/symbols_netbsd.go b/internal/fakecgo/symbols_netbsd.go index 7c92bb0..4d42854 100644 --- a/internal/fakecgo/symbols_netbsd.go +++ b/internal/fakecgo/symbols_netbsd.go @@ -2,29 +2,30 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors +// SPDX-FileCopyrightText: 2025-2026 Andrey Kolkov and GoGPU Contributors //go:build !cgo package fakecgo -//go:cgo_import_dynamic purego_malloc malloc "libc.so" -//go:cgo_import_dynamic purego_free free "libc.so" -//go:cgo_import_dynamic purego_setenv setenv "libc.so" -//go:cgo_import_dynamic purego_unsetenv unsetenv "libc.so" -//go:cgo_import_dynamic purego_sigfillset sigfillset "libc.so" -//go:cgo_import_dynamic purego_nanosleep nanosleep "libc.so" -//go:cgo_import_dynamic purego_abort abort "libc.so" -//go:cgo_import_dynamic purego_sigaltstack sigaltstack "libc.so" -//go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "libpthread.so" -//go:cgo_import_dynamic purego_pthread_create pthread_create "libpthread.so" -//go:cgo_import_dynamic purego_pthread_detach pthread_detach "libpthread.so" -//go:cgo_import_dynamic purego_pthread_sigmask pthread_sigmask "libpthread.so" -//go:cgo_import_dynamic purego_pthread_self pthread_self "libpthread.so" -//go:cgo_import_dynamic purego_pthread_get_stacksize_np pthread_get_stacksize_np "libpthread.so" -//go:cgo_import_dynamic purego_pthread_attr_getstacksize pthread_attr_getstacksize "libpthread.so" -//go:cgo_import_dynamic purego_pthread_attr_setstacksize pthread_attr_setstacksize "libpthread.so" -//go:cgo_import_dynamic purego_pthread_attr_destroy pthread_attr_destroy "libpthread.so" -//go:cgo_import_dynamic purego_pthread_mutex_lock pthread_mutex_lock "libpthread.so" -//go:cgo_import_dynamic purego_pthread_mutex_unlock pthread_mutex_unlock "libpthread.so" -//go:cgo_import_dynamic purego_pthread_cond_broadcast pthread_cond_broadcast "libpthread.so" -//go:cgo_import_dynamic purego_pthread_setspecific pthread_setspecific "libpthread.so" +//go:cgo_import_dynamic goffi_malloc malloc "libc.so" +//go:cgo_import_dynamic goffi_free free "libc.so" +//go:cgo_import_dynamic goffi_setenv setenv "libc.so" +//go:cgo_import_dynamic goffi_unsetenv unsetenv "libc.so" +//go:cgo_import_dynamic goffi_sigfillset sigfillset "libc.so" +//go:cgo_import_dynamic goffi_nanosleep nanosleep "libc.so" +//go:cgo_import_dynamic goffi_abort abort "libc.so" +//go:cgo_import_dynamic goffi_sigaltstack sigaltstack "libc.so" +//go:cgo_import_dynamic goffi_pthread_attr_init pthread_attr_init "libpthread.so" +//go:cgo_import_dynamic goffi_pthread_create pthread_create "libpthread.so" +//go:cgo_import_dynamic goffi_pthread_detach pthread_detach "libpthread.so" +//go:cgo_import_dynamic goffi_pthread_sigmask pthread_sigmask "libpthread.so" +//go:cgo_import_dynamic goffi_pthread_self pthread_self "libpthread.so" +//go:cgo_import_dynamic goffi_pthread_get_stacksize_np pthread_get_stacksize_np "libpthread.so" +//go:cgo_import_dynamic goffi_pthread_attr_getstacksize pthread_attr_getstacksize "libpthread.so" +//go:cgo_import_dynamic goffi_pthread_attr_setstacksize pthread_attr_setstacksize "libpthread.so" +//go:cgo_import_dynamic goffi_pthread_attr_destroy pthread_attr_destroy "libpthread.so" +//go:cgo_import_dynamic goffi_pthread_mutex_lock pthread_mutex_lock "libpthread.so" +//go:cgo_import_dynamic goffi_pthread_mutex_unlock pthread_mutex_unlock "libpthread.so" +//go:cgo_import_dynamic goffi_pthread_cond_broadcast pthread_cond_broadcast "libpthread.so" +//go:cgo_import_dynamic goffi_pthread_setspecific pthread_setspecific "libpthread.so" diff --git a/internal/fakecgo/trampolines_amd64.s b/internal/fakecgo/trampolines_amd64.s index e4e4c75..13aa365 100644 --- a/internal/fakecgo/trampolines_amd64.s +++ b/internal/fakecgo/trampolines_amd64.s @@ -1,5 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors +// SPDX-FileCopyrightText: 2025-2026 Andrey Kolkov and GoGPU Contributors //go:build !cgo && (darwin || linux || freebsd) diff --git a/internal/fakecgo/trampolines_arm64.s b/internal/fakecgo/trampolines_arm64.s index dceb1ca..b938006 100644 --- a/internal/fakecgo/trampolines_arm64.s +++ b/internal/fakecgo/trampolines_arm64.s @@ -1,5 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors +// SPDX-FileCopyrightText: 2025-2026 Andrey Kolkov and GoGPU Contributors //go:build !cgo && (darwin || freebsd || linux) diff --git a/internal/fakecgo/trampolines_stubs.s b/internal/fakecgo/trampolines_stubs.s index c93d783..4bbeb89 100644 --- a/internal/fakecgo/trampolines_stubs.s +++ b/internal/fakecgo/trampolines_stubs.s @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors +// SPDX-FileCopyrightText: 2025-2026 Andrey Kolkov and GoGPU Contributors //go:build !cgo && (darwin || freebsd || linux || netbsd) @@ -10,85 +11,85 @@ // these stubs are here because it is not possible to go:linkname directly the C functions on darwin arm64 TEXT _malloc(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_malloc(SB) + JMP goffi_malloc(SB) RET TEXT _free(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_free(SB) + JMP goffi_free(SB) RET TEXT _setenv(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_setenv(SB) + JMP goffi_setenv(SB) RET TEXT _unsetenv(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_unsetenv(SB) + JMP goffi_unsetenv(SB) RET TEXT _sigfillset(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_sigfillset(SB) + JMP goffi_sigfillset(SB) RET TEXT _nanosleep(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_nanosleep(SB) + JMP goffi_nanosleep(SB) RET TEXT _abort(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_abort(SB) + JMP goffi_abort(SB) RET TEXT _sigaltstack(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_sigaltstack(SB) + JMP goffi_sigaltstack(SB) RET TEXT _pthread_attr_init(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_attr_init(SB) + JMP goffi_pthread_attr_init(SB) RET TEXT _pthread_create(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_create(SB) + JMP goffi_pthread_create(SB) RET TEXT _pthread_detach(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_detach(SB) + JMP goffi_pthread_detach(SB) RET TEXT _pthread_sigmask(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_sigmask(SB) + JMP goffi_pthread_sigmask(SB) RET TEXT _pthread_self(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_self(SB) + JMP goffi_pthread_self(SB) RET TEXT _pthread_get_stacksize_np(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_get_stacksize_np(SB) + JMP goffi_pthread_get_stacksize_np(SB) RET TEXT _pthread_attr_getstacksize(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_attr_getstacksize(SB) + JMP goffi_pthread_attr_getstacksize(SB) RET TEXT _pthread_attr_setstacksize(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_attr_setstacksize(SB) + JMP goffi_pthread_attr_setstacksize(SB) RET TEXT _pthread_attr_destroy(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_attr_destroy(SB) + JMP goffi_pthread_attr_destroy(SB) RET TEXT _pthread_mutex_lock(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_mutex_lock(SB) + JMP goffi_pthread_mutex_lock(SB) RET TEXT _pthread_mutex_unlock(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_mutex_unlock(SB) + JMP goffi_pthread_mutex_unlock(SB) RET TEXT _pthread_cond_broadcast(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_cond_broadcast(SB) + JMP goffi_pthread_cond_broadcast(SB) RET TEXT _pthread_setspecific(SB), NOSPLIT|NOFRAME, $0-0 - JMP purego_pthread_setspecific(SB) + JMP goffi_pthread_setspecific(SB) RET diff --git a/internal/syscall/cgo.go b/internal/syscall/cgo.go index 23e5057..4d0b95f 100644 --- a/internal/syscall/cgo.go +++ b/internal/syscall/cgo.go @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2026 The Goffi Authors +// SPDX-FileCopyrightText: 2026 Andrey Kolkov and GoGPU Contributors //go:build cgo && (linux || darwin || freebsd)