diff --git a/libc/dlopen/dlfcn.h b/libc/dlopen/dlfcn.h index c50dcc891..2514d908d 100644 --- a/libc/dlopen/dlfcn.h +++ b/libc/dlopen/dlfcn.h @@ -20,6 +20,7 @@ int dlclose(void *); char *cosmo_dlerror(void); void *cosmo_dlopen(const char *, int); void *cosmo_dlsym(void *, const char *); +void *cosmo_dltramp(void *); int cosmo_dlclose(void *); #endif diff --git a/libc/dlopen/dlopen.c b/libc/dlopen/dlopen.c index 7d36feac5..1a0bdf143 100644 --- a/libc/dlopen/dlopen.c +++ b/libc/dlopen/dlopen.c @@ -843,6 +843,17 @@ void *cosmo_dlsym(void *handle, const char *name) { return func; } +/** + * Trampolines foreign function pointer so it can be called safely. + */ +void *cosmo_dltramp(void *foreign_func) { + if (!IsWindows()) { + return foreign_thunk_sysv(foreign_func); + } else { + return foreign_thunk_nt(foreign_func); + } +} + /** * Closes dynamic shared object. *