aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_nif.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2012-11-28 12:26:30 +0100
committerSverker Eriksson <[email protected]>2012-11-28 12:27:36 +0100
commit0ba0ffb914fa423ef34faa233f5bd92e9fa753ab (patch)
tree20609b83b125c179ab98e2ee0c4b549baae9c2f1 /erts/emulator/beam/erl_nif.c
parent4789aa5ab21e86e59fb0098938729d7cd46f385f (diff)
parentb7b4abaeac8e559a3a4f587d46dc0014332b517e (diff)
downloadotp-0ba0ffb914fa423ef34faa233f5bd92e9fa753ab.tar.gz
otp-0ba0ffb914fa423ef34faa233f5bd92e9fa753ab.tar.bz2
otp-0ba0ffb914fa423ef34faa233f5bd92e9fa753ab.zip
Merge branch 'sverk/crypto-unloading'
* sverk/crypto-unloading: crypto: Link crypto_callback statically crypto: Add debug print macros crypto: Enable runtime upgrade of crypto crypto: Make unloading of crypto safer OTP-10596
Diffstat (limited to 'erts/emulator/beam/erl_nif.c')
-rw-r--r--erts/emulator/beam/erl_nif.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c
index 0dca588847..632d756481 100644
--- a/erts/emulator/beam/erl_nif.c
+++ b/erts/emulator/beam/erl_nif.c
@@ -1396,6 +1396,44 @@ size_t enif_sizeof_resource(void* obj)
return ERTS_MAGIC_BIN_DATA_SIZE(bin) - offsetof(ErlNifResource,data);
}
+
+void* enif_dlopen(const char* lib,
+ void (*err_handler)(void*,const char*), void* err_arg)
+{
+ ErtsSysDdllError errdesc = ERTS_SYS_DDLL_ERROR_INIT;
+ void* handle;
+ void* init_func;
+ if (erts_sys_ddll_open2(lib, &handle, &errdesc) == ERL_DE_NO_ERROR) {
+ if (erts_sys_ddll_load_nif_init(handle, &init_func, &errdesc) == ERL_DE_NO_ERROR) {
+ erts_sys_ddll_call_nif_init(init_func);
+ }
+ }
+ else {
+ if (err_handler != NULL) {
+ (*err_handler)(err_arg, errdesc.str);
+ }
+ handle = NULL;
+ }
+ erts_sys_ddll_free_error(&errdesc);
+ return handle;
+}
+
+void* enif_dlsym(void* handle, const char* symbol,
+ void (*err_handler)(void*,const char*), void* err_arg)
+{
+ ErtsSysDdllError errdesc = ERTS_SYS_DDLL_ERROR_INIT;
+ void* ret;
+ if (erts_sys_ddll_sym2(handle, symbol, &ret, &errdesc) != ERL_DE_NO_ERROR) {
+ if (err_handler != NULL) {
+ (*err_handler)(err_arg, errdesc.str);
+ }
+ erts_sys_ddll_free_error(&errdesc);
+ return NULL;
+ }
+ return ret;
+}
+
+
/***************************************************************************
** load_nif/2 **
***************************************************************************/