Skip to content

Instantly share code, notes, and snippets.

@piscisaureus
Created October 21, 2011 18:41
Show Gist options
  • Save piscisaureus/1304600 to your computer and use it in GitHub Desktop.
Save piscisaureus/1304600 to your computer and use it in GitHub Desktop.
/* windows */
typedef HMODULE uv_lib_t;
#define UV_CALL FAR WINAPI
/* unix */
typedef void* uv_lib_t;
#define UV_CALL
/* returns -1 on error */
/* filename in utf-8 */
int uv_dlopen(const char* filename, uv_lib_t* library);
int uv_dlclose(uv_lib_t library);
/* retrieve a function pointer */
typedef void (UV_CALL *uv_func_t)();
uv_func_t uv_dlsym(uv_lib_t library, const char* name);
/* example */
typedef int (UV_CALL *module_init_t)(uv_loop_t* loop);
uv_lib_t module;
if (dlopen("foo.node", &module) != 0) {
assert(0 && "omg it failed");
}
module_init_t init_func = (module_init_t) uv_dlsym(module, "init");
assert(init_func != NULL);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment