aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/beam/erl_nif.c20
-rwxr-xr-xerts/emulator/beam/global.h3
-rw-r--r--erts/emulator/beam/utils.c22
-rwxr-xr-xerts/emulator/utils/make_driver_tab18
4 files changed, 17 insertions, 46 deletions
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c
index 673012a9af..ee480fb661 100644
--- a/erts/emulator/beam/erl_nif.c
+++ b/erts/emulator/beam/erl_nif.c
@@ -1568,9 +1568,10 @@ BIF_RETTYPE load_nif_2(BIF_ALIST_2)
void* init_func = NULL;
ErlNifEntry* entry = NULL;
ErlNifEnv env;
- int len, i, err;
+ int i, err;
Module* mod;
Eterm mod_atom;
+ const Atom* mod_atomp;
Eterm f_atom;
BeamInstr* caller;
ErtsSysDdllError errdesc = ERTS_SYS_DDLL_ERROR_INIT;
@@ -1578,21 +1579,13 @@ BIF_RETTYPE load_nif_2(BIF_ALIST_2)
int veto;
struct erl_module_nif* lib = NULL;
int reload_warning = 0;
- char tmp_buf[255];
- len = list_length(BIF_ARG_1);
- if (len < 0) {
+ lib_name = erts_convert_filename_to_native(BIF_ARG_1, NULL, 0,
+ ERTS_ALC_T_TMP, 1, 0, NULL);
+ if (!lib_name) {
BIF_ERROR(BIF_P, BADARG);
}
- lib_name = (char *) erts_alloc(ERTS_ALC_T_TMP, len + 1);
-
- if (intlist_to_buf(BIF_ARG_1, lib_name, len) != len) {
- erts_free(ERTS_ALC_T_TMP, lib_name);
- BIF_ERROR(BIF_P, BADARG);
- }
- lib_name[len] = '\0';
-
if (!erts_try_seize_code_write_permission(BIF_P)) {
erts_free(ERTS_ALC_T_TMP, lib_name);
ERTS_BIF_YIELD2(bif_export[BIF_load_nif_2],
@@ -1615,7 +1608,8 @@ BIF_RETTYPE load_nif_2(BIF_ALIST_2)
mod=erts_get_module(mod_atom, erts_active_code_ix());
ASSERT(mod != NULL);
- init_func = erts_static_nif_get_nif_init(erts_basename(lib_name,tmp_buf));
+ mod_atomp = atom_tab(atom_val(mod_atom));
+ init_func = erts_static_nif_get_nif_init(mod_atomp->name, mod_atomp->len);
if (init_func != NULL)
handle = init_func;
diff --git a/erts/emulator/beam/global.h b/erts/emulator/beam/global.h
index e3a0487aeb..11e464b639 100755
--- a/erts/emulator/beam/global.h
+++ b/erts/emulator/beam/global.h
@@ -849,7 +849,7 @@ void erts_lcnt_enable_io_lock_count(int enable);
/* driver_tab.c */
typedef void *(*ErtsStaticNifInitFPtr)(void);
-ErtsStaticNifInitFPtr erts_static_nif_get_nif_init(const char *name);
+ErtsStaticNifInitFPtr erts_static_nif_get_nif_init(const char *name, int len);
int erts_is_static_nif(void *handle);
void erts_init_static_drivers(void);
@@ -858,7 +858,6 @@ void erl_drv_thr_init(void);
/* utils.c */
void erts_cleanup_offheap(ErlOffHeap *offheap);
-const char *erts_basename(const char* path, char* buff);
Uint64 erts_timestamp_millis(void);
diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c
index 6293286c75..43720084d1 100644
--- a/erts/emulator/beam/utils.c
+++ b/erts/emulator/beam/utils.c
@@ -4019,28 +4019,6 @@ erts_smp_ensure_later_interval_acqb(erts_interval_t *icp, Uint64 ic)
#endif
}
-const char *erts_basename(const char* path, char* buff) {
- /* This function is not compliant with bash basename. Edge cases like "//"
- and "/path//" do not work properly.
- */
- int i;
- int len = strlen(path);
- const char *basename = path;
- for (i = 0; path[i] != '\0'; i++) {
- if (path[i] == '/') {
- if (path[i+1] == '\0') {
- memcpy(buff,basename,len - (basename-path));
- buff[len - (basename-path)-1] = '\0';
- basename = buff;
- break;
- } else { basename = path+i;}
- }
- }
- if (basename == path)
- return path;
- return basename+1;
-}
-
/*
* A millisecond timestamp without time correction where there's no hrtime
* - for tracing on "long" things...
diff --git a/erts/emulator/utils/make_driver_tab b/erts/emulator/utils/make_driver_tab
index 0e6793d2af..5c68143d58 100755
--- a/erts/emulator/utils/make_driver_tab
+++ b/erts/emulator/utils/make_driver_tab
@@ -137,19 +137,19 @@ foreach (@nifs) {
print " {NULL,NULL}\n};\n";
print <<EOF;
-ErtsStaticNifInitFPtr erts_static_nif_get_nif_init(const char *name) {
- int i;
- for (i = 0; static_nif_tab[i].nif_name != NULL; i++)
- if (strcmp(name,static_nif_tab[i].nif_name) == 0)
- return static_nif_tab[i].nif_init;
+ErtsStaticNifInitFPtr erts_static_nif_get_nif_init(const char *name, int len) {
+ ErtsStaticNifEntry* p;
+ for (p = static_nif_tab; p->nif_name != NULL; p++)
+ if (strncmp(p->nif_name, name, len) == 0 && p->nif_name[len] == 0)
+ return p->nif_init;
return NULL;
}
int erts_is_static_nif(void *handle) {
- int i;
- for (i = 0; static_nif_tab[i].nif_name != NULL; i++)
- if (((void*)static_nif_tab[i].nif_init) == handle)
- return 1;
+ ErtsStaticNifEntry* p;
+ for (p = static_nif_tab; p->nif_name != NULL; p++)
+ if (((void*)p->nif_init) == handle)
+ return 1;
return 0;
}