diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-09-28 13:46:18 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-09-28 13:46:18 +0000 |
commit | fc831f638a3da7c0e6785197e7c35f8d30c2f128 (patch) | |
tree | d47894896f5e07b07d0a05548d8c5106ab921e3c /dln.c | |
parent | b957eb25ff289133d278519dd4182510d1de14c1 (diff) |
* dln.c (dln_{exit,loaderror,memerror,notimplement}): renamed as
independent names.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25135 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dln.c')
-rw-r--r-- | dln.c | 58 |
1 files changed, 40 insertions, 18 deletions
@@ -9,7 +9,18 @@ **********************************************************************/ +#ifdef RUBY_EXPORT #include "ruby/ruby.h" +#define dln_notimplement rb_notimplement +#define dln_memerror rb_memerror +#define dln_exit rb_exit +#define dln_loaderror rb_loaderror +#else +#define dln_notimplement --->>> dln not implemented <<<--- +#define dln_memerror abort +#define dln_exit exit +static void dln_loaderror(const char *format, ...); +#endif #include "dln.h" #ifdef HAVE_STDLIB_H @@ -77,6 +88,18 @@ char *getenv(); # include <image.h> #endif +#ifndef dln_loaderror +static void +dln_loaderror(const char *format, ...) +{ + va_list ap; + va_start(ap, format); + vfprintf(stderr, format, ap); + va_end(ap); + abort(); +} +#endif + #ifndef NO_DLN_LOAD #if defined(HAVE_DLOPEN) && !defined(USE_DLN_A_OUT) && !defined(_AIX) && !defined(MACOSX_DYLD) && !defined(_UNICOSMP) @@ -119,7 +142,7 @@ init_funcname_len(char **buf, const char *file) char *tmp = ALLOCA_N(char, len+1);\ if (!tmp) {\ free(*buf);\ - rb_memerror();\ + dln_memerror();\ }\ strlcpy(tmp, *buf, len + 1);\ free(*buf);\ @@ -451,7 +474,7 @@ dln_undefined(void) if (undef_tbl->num_entries > 0) { fprintf(stderr, "dln: Calling undefined function\n"); dln_print_undef(); - rb_exit(1); + dln_exit(1); } } @@ -1190,8 +1213,7 @@ aix_loaderror(const char *pathname) ERRBUF_APPEND("\n"); } errbuf[strlen(errbuf)-1] = '\0'; /* trim off last newline */ - rb_loaderror("%s", errbuf); - return; + dln_loaderror("%s", errbuf); } #endif @@ -1201,7 +1223,7 @@ void* dln_load(const char *file) { #ifdef NO_DLN_LOAD - rb_raise(rb_eLoadError, "this executable file can't load extension libraries"); + dln_loaderror("this executable file can't load extension libraries"); #else #if !defined(_AIX) && !defined(NeXT) @@ -1215,7 +1237,7 @@ dln_load(const char *file) void (*init_fct)(); char *buf; - if (strlen(file) >= MAXPATHLEN) rb_loaderror("filename too long"); + if (strlen(file) >= MAXPATHLEN) dln_loaderror("filename too long"); /* Load the file as an object one */ init_funcname(&buf, file); @@ -1229,7 +1251,7 @@ dln_load(const char *file) } if ((init_fct = (void(*)())GetProcAddress(handle, buf)) == NULL) { - rb_loaderror("%s - %s\n%s", dln_strerror(), buf, file); + dln_loaderror("%s - %s\n%s", dln_strerror(), buf, file); } /* Call the init code */ @@ -1299,14 +1321,14 @@ dln_load(const char *file) lib = shl_load(file, flags, 0); if (lib == NULL) { extern int errno; - rb_loaderror("%s - %s", strerror(errno), file); + dln_loaderror("%s - %s", strerror(errno), file); } shl_findsym(&lib, buf, TYPE_PROCEDURE, (void*)&init_fct); if (init_fct == NULL) { shl_findsym(&lib, buf, TYPE_UNDEFINED, (void*)&init_fct); if (init_fct == NULL) { errno = ENOSYM; - rb_loaderror("%s - %s", strerror(ENOSYM), file); + dln_loaderror("%s - %s", strerror(ENOSYM), file); } } (*init_fct)(); @@ -1359,14 +1381,14 @@ dln_load(const char *file) if(rld_load(s, NULL, object_files, NULL) == 0) { NXFlush(s); NXClose(s); - rb_loaderror("Failed to load %.200s", file); + dln_loaderror("Failed to load %.200s", file); } /* lookup the initial function */ if(rld_lookup(s, buf, &init_address) == 0) { NXFlush(s); NXClose(s); - rb_loaderror("Failed to lookup Init function %.200s", file); + dln_loaderror("Failed to lookup Init function %.200s", file); } NXFlush(s); @@ -1391,14 +1413,14 @@ dln_load(const char *file) dyld_result = NSCreateObjectFileImageFromFile(file, &obj_file); if (dyld_result != NSObjectFileImageSuccess) { - rb_loaderror("Failed to load %.200s", file); + dln_loaderror("Failed to load %.200s", file); } NSLinkModule(obj_file, file, NSLINKMODULE_OPTION_BINDNOW); /* lookup the initial function */ if(!NSIsSymbolNameDefined(buf)) { - rb_loaderror("Failed to lookup Init function %.200s",file); + dln_loaderror("Failed to lookup Init function %.200s",file); } init_fct = NSAddressOfSymbol(NSLookupAndBindSymbol(buf)); (*init_fct)(); @@ -1418,7 +1440,7 @@ dln_load(const char *file) /* load extention module */ img_id = load_add_on(file); if (img_id <= 0) { - rb_loaderror("Failed to load add_on %.200s error_code=%x", + dln_loaderror("Failed to load add_on %.200s error_code=%x", file, img_id); } @@ -1442,12 +1464,12 @@ dln_load(const char *file) if ((B_BAD_IMAGE_ID == err_stat) || (B_BAD_INDEX == err_stat)) { unload_add_on(img_id); - rb_loaderror("Failed to lookup Init function %.200s", file); + dln_loaderror("Failed to lookup Init function %.200s", file); } else if (B_NO_ERROR != err_stat) { char errmsg[] = "Internal of BeOS version. %.200s (symbol_name = %s)"; unload_add_on(img_id); - rb_loaderror(errmsg, strerror(err_stat), buf); + dln_loaderror(errmsg, strerror(err_stat), buf); } /* call module initialize function. */ @@ -1457,14 +1479,14 @@ dln_load(const char *file) #endif /* __BEOS__*/ #ifndef DLN_DEFINED - rb_notimplement(); + dln_notimplement(); #endif #endif /* USE_DLN_A_OUT */ #endif #if !defined(_AIX) && !defined(NeXT) failed: - rb_loaderror("%s - %s", error, file); + dln_loaderror("%s - %s", error, file); #endif #endif /* NO_DLN_LOAD */ |