diff options
author | Sverker Eriksson <[email protected]> | 2012-11-28 12:26:30 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2012-11-28 12:27:36 +0100 |
commit | 0ba0ffb914fa423ef34faa233f5bd92e9fa753ab (patch) | |
tree | 20609b83b125c179ab98e2ee0c4b549baae9c2f1 /erts/emulator/beam/erl_nif.c | |
parent | 4789aa5ab21e86e59fb0098938729d7cd46f385f (diff) | |
parent | b7b4abaeac8e559a3a4f587d46dc0014332b517e (diff) | |
download | otp-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.c | 38 |
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 ** ***************************************************************************/ |