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