Invent *cosmo_dltramp() function

This commit is contained in:
Justine Tunney 2024-01-05 09:11:51 -08:00
parent 0de6a08988
commit 44a463e4d2
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
2 changed files with 12 additions and 0 deletions

View file

@ -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

View file

@ -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.
*