dlfcn_android.go 886 B

12345678910111213141516171819202122232425262728293031323334
  1. // SPDX-License-Identifier: Apache-2.0
  2. // SPDX-FileCopyrightText: 2024 The Ebitengine Authors
  3. package purego
  4. import "github.com/ebitengine/purego/internal/cgo"
  5. // Source for constants: https://android.googlesource.com/platform/bionic/+/refs/heads/main/libc/include/dlfcn.h
  6. const (
  7. is64bit = 1 << (^uintptr(0) >> 63) / 2
  8. is32bit = 1 - is64bit
  9. RTLD_DEFAULT = is32bit * 0xffffffff
  10. RTLD_LAZY = 0x00000001
  11. RTLD_NOW = is64bit * 0x00000002
  12. RTLD_LOCAL = 0x00000000
  13. RTLD_GLOBAL = is64bit*0x00100 | is32bit*0x00000002
  14. )
  15. func Dlopen(path string, mode int) (uintptr, error) {
  16. return cgo.Dlopen(path, mode)
  17. }
  18. func Dlsym(handle uintptr, name string) (uintptr, error) {
  19. return cgo.Dlsym(handle, name)
  20. }
  21. func Dlclose(handle uintptr) error {
  22. return cgo.Dlclose(handle)
  23. }
  24. func loadSymbol(handle uintptr, name string) (uintptr, error) {
  25. return Dlsym(handle, name)
  26. }