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 5 //go:build !windows && !static && !(darwin && internal) 6 7 #include <stdint.h> 8 #include <dlfcn.h> 9 10 // Write our own versions of dlopen/dlsym/dlclose so that we represent 11 // the opaque handle as a Go uintptr rather than a Go pointer to avoid 12 // garbage collector confusion. See issue 23663. 13 dlopen4029(char * name,int flags)14uintptr_t dlopen4029(char* name, int flags) { 15 return (uintptr_t)(dlopen(name, flags)); 16 } 17 dlsym4029(uintptr_t handle,char * name)18uintptr_t dlsym4029(uintptr_t handle, char* name) { 19 return (uintptr_t)(dlsym((void*)(handle), name)); 20 } 21 dlclose4029(uintptr_t handle)22int dlclose4029(uintptr_t handle) { 23 return dlclose((void*)(handle)); 24 } 25 call4029(void * arg)26void call4029(void *arg) { 27 void (*fn)(void) = arg; 28 fn(); 29 } 30