void* dln_load(const char *file) { rb_loaderror("this executable file can't load extension libraries"); UNREACHABLE; }
/* * call-seq: * require_relative(string) -> true or false * * Ruby tries to load the library named _string_ relative to the requiring * file's path. If the file's path cannot be determined a LoadError is raised. * If a file is loaded +true+ is returned and false otherwise. */ VALUE rb_f_require_relative(VALUE obj, VALUE fname) { VALUE base = rb_current_realfilepath(); if (NIL_P(base)) { rb_loaderror("cannot infer basepath"); } base = rb_file_dirname(base); return rb_require_safe(rb_file_absolute_path(fname, base), rb_safe_level()); }
void* dln_load(const char *file, bool call_init) { if (ruby_is_miniruby) { rb_raise(rb_eLoadError, "miniruby can't load C extension bundles due to technical problems"); } const char *error = 0; #define DLN_ERROR() (error = dln_strerror(), strcpy(ALLOCA_N(char, strlen(error) + 1), error)) char *buf; /* Load the file as an object one */ init_funcname(&buf, file); { void *handle; /* Load file */ __mrep__ = NULL; if ((handle = (void*)dlopen(file, RTLD_LAZY|RTLD_GLOBAL)) == NULL) { error = dln_strerror(); goto failed; } if (call_init) { void (*init_fct)(); init_fct = (void(*)())dlsym(handle, buf); if (init_fct == NULL) { error = DLN_ERROR(); dlclose(handle); goto failed; } /* Call the init code */ (*init_fct)(); } else { if (__mrep__ == NULL) { rb_raise(rb_eLoadError, "Can't load %s: entry point function not located (this can happen when you load twice the same .rbo file with a different case on a case-insensitive filesystem)", file); } ((IMP)__mrep__)((id)rb_vm_top_self(), 0); } return handle; } failed: rb_loaderror("%s - %s", error, file); return 0; /* dummy return */ }
static rb_encoding * must_encindex(int index) { rb_encoding *enc = rb_enc_from_index(index); if (!enc) { rb_raise(rb_eEncodingError, "encoding index out of bound: %d", index); } if (ENC_TO_ENCINDEX(enc) != (int)(index & ENC_INDEX_MASK)) { rb_raise(rb_eEncodingError, "wrong encoding index %d for %s (expected %d)", index, rb_enc_name(enc), ENC_TO_ENCINDEX(enc)); } if (enc_autoload_p(enc) && enc_autoload(enc) == -1) { rb_loaderror("failed to load encoding (%s)", rb_enc_name(enc)); } return enc; }
void* dln_load(const char *file) { const char *error = 0; #define DLN_ERROR() (error = dln_strerror(), strcpy(ALLOCA_N(char, strlen(error) + 1), error)) char *buf; /* Load the file as an object one */ init_funcname(&buf, file); { void *handle; void (*init_fct)(); /* Load file */ if ((handle = (void*)dlopen(file, RTLD_LAZY|RTLD_GLOBAL)) == NULL) { error = dln_strerror(); goto failed; } init_fct = (void(*)())dlsym(handle, buf); if (init_fct == NULL) { error = DLN_ERROR(); dlclose(handle); goto failed; } /* Call the init code */ (*init_fct)(); return handle; } failed: rb_loaderror("%s - %s", error, file); return 0; /* dummy return */ }
void rb_load_fail(const char *path) { rb_loaderror("%s -- %s", strerror(errno), path); }