issue4029.c 791 B

123456789101112131415161718192021222324252627282930
  1. // Copyright 2015 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // +build !windows,!static
  5. // +build !darwin !internal_pie,!arm64
  6. #include <stdint.h>
  7. #include <dlfcn.h>
  8. // Write our own versions of dlopen/dlsym/dlclose so that we represent
  9. // the opaque handle as a Go uintptr rather than a Go pointer to avoid
  10. // garbage collector confusion. See issue 23663.
  11. uintptr_t dlopen4029(char* name, int flags) {
  12. return (uintptr_t)(dlopen(name, flags));
  13. }
  14. uintptr_t dlsym4029(uintptr_t handle, char* name) {
  15. return (uintptr_t)(dlsym((void*)(handle), name));
  16. }
  17. int dlclose4029(uintptr_t handle) {
  18. return dlclose((void*)(handle));
  19. }
  20. void call4029(void *arg) {
  21. void (*fn)(void) = arg;
  22. fn();
  23. }