Remove linkname on playground (#250)
Currently the playground just crashes with a nasty error. This makes it so the error message is nice. It also removes linkname usages which is also good. Updates #247
- commit
- 88cc57927e42f1fbd59f6523fe0eafb572985f57
- author
- TotallyGamerJet · · 2024-05-22 16:35 UTC
- committer
- GitHub · · 2024-05-22 16:35 UTC
- parent
- 6cd1224
- signature
- GPG Unverified
B5690EEEBB952194The key is unknown
3 files · +18 -14
M dlfcn.go +1 -1
| @@ -1,7 +1,7 @@ | |||
| 1 | 1 | // SPDX-License-Identifier: Apache-2.0 | |
| 2 | 2 | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | |
| 3 | 3 | ||
| 4 | - | //go:build darwin || freebsd || linux | |
| 4 | + | //go:build (darwin || freebsd || linux) && !faketime | |
| 5 | 5 | ||
| 6 | 6 | package purego | |
| 7 | 7 | ||
| @@ -1,7 +1,7 @@ | |||||
| 1 | // SPDX-License-Identifier: Apache-2.0 | 1 | // SPDX-License-Identifier: Apache-2.0 | ||
| 2 | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | 2 | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | ||
| 3 | 3 | ||||
| 4 | - | //go:build darwin || freebsd || linux | 4 | + | //go:build (darwin || freebsd || linux) && !faketime |
| 5 | 5 | ||||
| 6 | package purego | 6 | package purego | ||
| 7 | 7 | ||||
M dlfcn_playground.go +16 -12
| @@ -5,16 +5,20 @@ | |||
| 5 | 5 | ||
| 6 | 6 | package purego | |
| 7 | 7 | ||
| 8 | - | import _ "unsafe" | |
| 8 | + | import "errors" | |
| 9 | 9 | ||
| 10 | - | // The playground doesn't support dynamic linking so just stub out the addresses | |
| 11 | - | var ( | |
| 12 | - | //go:linkname purego_dlopen purego_dlopen | |
| 13 | - | purego_dlopen uintptr | |
| 14 | - | //go:linkname purego_dlsym purego_dlsym | |
| 15 | - | purego_dlsym uintptr | |
| 16 | - | //go:linkname purego_dlerror purego_dlerror | |
| 17 | - | purego_dlerror uintptr | |
| 18 | - | //go:linkname purego_dlclose purego_dlclose | |
| 19 | - | purego_dlclose uintptr | |
| 20 | - | ) | |
| 10 | + | func Dlopen(path string, mode int) (uintptr, error) { | |
| 11 | + | return 0, errors.New("Dlopen is not supported in the playground") | |
| 12 | + | } | |
| 13 | + | ||
| 14 | + | func Dlsym(handle uintptr, name string) (uintptr, error) { | |
| 15 | + | return 0, errors.New("Dlsym is not supported in the playground") | |
| 16 | + | } | |
| 17 | + | ||
| 18 | + | func Dlclose(handle uintptr) error { | |
| 19 | + | return errors.New("Dlclose is not supported in the playground") | |
| 20 | + | } | |
| 21 | + | ||
| 22 | + | func loadSymbol(handle uintptr, name string) (uintptr, error) { | |
| 23 | + | return Dlsym(handle, name) | |
| 24 | + | } | |
| @@ -5,16 +5,20 @@ | |||||
| 5 | 5 | ||||
| 6 | package purego | 6 | package purego | ||
| 7 | 7 | ||||
| 8 | - | import _ "unsafe" | 8 | + | import "errors" |
| 9 | 9 | ||||
| 10 | - | // The playground doesn't support dynamic linking so just stub out the addresses | 10 | + | func Dlopen(path string, mode int) (uintptr, error) { |
| 11 | - | var ( | 11 | + | return 0, errors.New("Dlopen is not supported in the playground") |
| 12 | - | //go:linkname purego_dlopen purego_dlopen | 12 | + | } |
| 13 | - | purego_dlopen uintptr | 13 | + | |
| 14 | - | //go:linkname purego_dlsym purego_dlsym | 14 | + | func Dlsym(handle uintptr, name string) (uintptr, error) { |
| 15 | - | purego_dlsym uintptr | 15 | + | return 0, errors.New("Dlsym is not supported in the playground") |
| 16 | - | //go:linkname purego_dlerror purego_dlerror | 16 | + | } |
| 17 | - | purego_dlerror uintptr | 17 | + | |
| 18 | - | //go:linkname purego_dlclose purego_dlclose | 18 | + | func Dlclose(handle uintptr) error { |
| 19 | - | purego_dlclose uintptr | 19 | + | return errors.New("Dlclose is not supported in the playground") |
| 20 | - | ) | 20 | + | } |
| 21 | + | ||||
| 22 | + | func loadSymbol(handle uintptr, name string) (uintptr, error) { | |||
| 23 | + | return Dlsym(handle, name) | |||
| 24 | + | } | |||
M dlfcn_stubs.s +1 -1
| @@ -1,7 +1,7 @@ | |||
| 1 | 1 | // SPDX-License-Identifier: Apache-2.0 | |
| 2 | 2 | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | |
| 3 | 3 | ||
| 4 | - | //go:build darwin || !cgo && (freebsd || linux) | |
| 4 | + | //go:build darwin || !cgo && (freebsd || linux) && !faketime | |
| 5 | 5 | ||
| 6 | 6 | #include "textflag.h" | |
| 7 | 7 | ||
| @@ -1,7 +1,7 @@ | |||||
| 1 | // SPDX-License-Identifier: Apache-2.0 | 1 | // SPDX-License-Identifier: Apache-2.0 | ||
| 2 | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | 2 | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | ||
| 3 | 3 | ||||
| 4 | - | //go:build darwin || !cgo && (freebsd || linux) | 4 | + | //go:build darwin || !cgo && (freebsd || linux) && !faketime |
| 5 | 5 | ||||
| 6 | #include "textflag.h" | 6 | #include "textflag.h" | ||
| 7 | 7 | ||||