Move dlfcn.h constants under platform specific file (#53)
1. moves the constants under dlfcn_darwin.go since the value is platform specific 2. remove RTLD_DEFAULT which is specific to darwin 3. adds RTLD_LAZY, RTLD_NOW, RTLD_LOCAL to complete the unix specification Closes #53
- commit
- d863f555d77d42e65a6856606b253faf67301230
- author
- TotallyGamerJet · · 2022-10-23 18:21 UTC
- committer
- GitHub · · 2022-10-23 18:21 UTC
- parent
- d67702f
- signature
- GPG Unverified
4AEE18F83AFDEB23The key is unknown
2 files · +9 -4
M dlfcn.go +0 -4
| @@ -10,10 +10,6 @@ import ( | |||
| 10 | 10 | "unsafe" | |
| 11 | 11 | ) | |
| 12 | 12 | ||
| 13 | - | const RTLD_GLOBAL = 0x8 | |
| 14 | - | ||
| 15 | - | const RTLD_DEFAULT = ^uintptr(1) | |
| 16 | - | ||
| 17 | 13 | var ( | |
| 18 | 14 | fnDlopen func(path string, mode int) uintptr | |
| 19 | 15 | fnDlsym func(handle uintptr, name string) uintptr | |
| @@ -10,10 +10,6 @@ import ( | |||||
| 10 | "unsafe" | 10 | "unsafe" | ||
| 11 | ) | 11 | ) | ||
| 12 | 12 | ||||
| 13 | - | const RTLD_GLOBAL = 0x8 | |||
| 14 | - | ||||
| 15 | - | const RTLD_DEFAULT = ^uintptr(1) | |||
| 16 | - | ||||
| 17 | var ( | 13 | var ( | ||
| 18 | fnDlopen func(path string, mode int) uintptr | 14 | fnDlopen func(path string, mode int) uintptr | ||
| 19 | fnDlsym func(handle uintptr, name string) uintptr | 15 | fnDlsym func(handle uintptr, name string) uintptr | ||
M dlfcn_darwin.go +9 -0
| @@ -3,6 +3,15 @@ | |||
| 3 | 3 | ||
| 4 | 4 | package purego | |
| 5 | 5 | ||
| 6 | + | // Source for constants: https://opensource.apple.com/source/dyld/dyld-360.14/include/dlfcn.h.auto.html | |
| 7 | + | ||
| 8 | + | const ( | |
| 9 | + | RTLD_LAZY = 0x1 // Relocations are performed at an implementation-dependent time. | |
| 10 | + | RTLD_NOW = 0x2 // Relocations are performed when the object is loaded. | |
| 11 | + | RTLD_LOCAL = 0x4 // All symbols are not made available for relocation processing by other modules. | |
| 12 | + | RTLD_GLOBAL = 0x8 // All symbols are available for relocation processing of other modules. | |
| 13 | + | ) | |
| 14 | + | ||
| 6 | 15 | //go:cgo_import_dynamic purego_dlopen dlopen "/usr/lib/libSystem.B.dylib" | |
| 7 | 16 | //go:cgo_import_dynamic purego_dlsym dlsym "/usr/lib/libSystem.B.dylib" | |
| 8 | 17 | //go:cgo_import_dynamic purego_dlerror dlerror "/usr/lib/libSystem.B.dylib" | |
| @@ -3,6 +3,15 @@ | |||||
| 3 | 3 | ||||
| 4 | package purego | 4 | package purego | ||
| 5 | 5 | ||||
| 6 | + | // Source for constants: https://opensource.apple.com/source/dyld/dyld-360.14/include/dlfcn.h.auto.html | |||
| 7 | + | ||||
| 8 | + | const ( | |||
| 9 | + | RTLD_LAZY = 0x1 // Relocations are performed at an implementation-dependent time. | |||
| 10 | + | RTLD_NOW = 0x2 // Relocations are performed when the object is loaded. | |||
| 11 | + | RTLD_LOCAL = 0x4 // All symbols are not made available for relocation processing by other modules. | |||
| 12 | + | RTLD_GLOBAL = 0x8 // All symbols are available for relocation processing of other modules. | |||
| 13 | + | ) | |||
| 14 | + | ||||
| 6 | //go:cgo_import_dynamic purego_dlopen dlopen "/usr/lib/libSystem.B.dylib" | 15 | //go:cgo_import_dynamic purego_dlopen dlopen "/usr/lib/libSystem.B.dylib" | ||
| 7 | //go:cgo_import_dynamic purego_dlsym dlsym "/usr/lib/libSystem.B.dylib" | 16 | //go:cgo_import_dynamic purego_dlsym dlsym "/usr/lib/libSystem.B.dylib" | ||
| 8 | //go:cgo_import_dynamic purego_dlerror dlerror "/usr/lib/libSystem.B.dylib" | 17 | //go:cgo_import_dynamic purego_dlerror dlerror "/usr/lib/libSystem.B.dylib" | ||