* 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
This commit is contained in:
parent
b957eb25ff
commit
fc831f638a
@ -1,4 +1,7 @@
|
|||||||
Mon Sep 28 22:33:11 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Mon Sep 28 22:46:16 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* dln.c (dln_{exit,loaderror,memerror,notimplement}): renamed as
|
||||||
|
independent names.
|
||||||
|
|
||||||
* dln.c (aix_loaderror): needs format string.
|
* dln.c (aix_loaderror): needs format string.
|
||||||
|
|
||||||
|
58
dln.c
58
dln.c
@ -9,7 +9,18 @@
|
|||||||
|
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
|
#ifdef RUBY_EXPORT
|
||||||
#include "ruby/ruby.h"
|
#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"
|
#include "dln.h"
|
||||||
|
|
||||||
#ifdef HAVE_STDLIB_H
|
#ifdef HAVE_STDLIB_H
|
||||||
@ -77,6 +88,18 @@ char *getenv();
|
|||||||
# include <image.h>
|
# include <image.h>
|
||||||
#endif
|
#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
|
#ifndef NO_DLN_LOAD
|
||||||
|
|
||||||
#if defined(HAVE_DLOPEN) && !defined(USE_DLN_A_OUT) && !defined(_AIX) && !defined(MACOSX_DYLD) && !defined(_UNICOSMP)
|
#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);\
|
char *tmp = ALLOCA_N(char, len+1);\
|
||||||
if (!tmp) {\
|
if (!tmp) {\
|
||||||
free(*buf);\
|
free(*buf);\
|
||||||
rb_memerror();\
|
dln_memerror();\
|
||||||
}\
|
}\
|
||||||
strlcpy(tmp, *buf, len + 1);\
|
strlcpy(tmp, *buf, len + 1);\
|
||||||
free(*buf);\
|
free(*buf);\
|
||||||
@ -451,7 +474,7 @@ dln_undefined(void)
|
|||||||
if (undef_tbl->num_entries > 0) {
|
if (undef_tbl->num_entries > 0) {
|
||||||
fprintf(stderr, "dln: Calling undefined function\n");
|
fprintf(stderr, "dln: Calling undefined function\n");
|
||||||
dln_print_undef();
|
dln_print_undef();
|
||||||
rb_exit(1);
|
dln_exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1190,8 +1213,7 @@ aix_loaderror(const char *pathname)
|
|||||||
ERRBUF_APPEND("\n");
|
ERRBUF_APPEND("\n");
|
||||||
}
|
}
|
||||||
errbuf[strlen(errbuf)-1] = '\0'; /* trim off last newline */
|
errbuf[strlen(errbuf)-1] = '\0'; /* trim off last newline */
|
||||||
rb_loaderror("%s", errbuf);
|
dln_loaderror("%s", errbuf);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1201,7 +1223,7 @@ void*
|
|||||||
dln_load(const char *file)
|
dln_load(const char *file)
|
||||||
{
|
{
|
||||||
#ifdef NO_DLN_LOAD
|
#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
|
#else
|
||||||
|
|
||||||
#if !defined(_AIX) && !defined(NeXT)
|
#if !defined(_AIX) && !defined(NeXT)
|
||||||
@ -1215,7 +1237,7 @@ dln_load(const char *file)
|
|||||||
void (*init_fct)();
|
void (*init_fct)();
|
||||||
char *buf;
|
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 */
|
/* Load the file as an object one */
|
||||||
init_funcname(&buf, file);
|
init_funcname(&buf, file);
|
||||||
@ -1229,7 +1251,7 @@ dln_load(const char *file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((init_fct = (void(*)())GetProcAddress(handle, buf)) == NULL) {
|
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 */
|
/* Call the init code */
|
||||||
@ -1299,14 +1321,14 @@ dln_load(const char *file)
|
|||||||
lib = shl_load(file, flags, 0);
|
lib = shl_load(file, flags, 0);
|
||||||
if (lib == NULL) {
|
if (lib == NULL) {
|
||||||
extern int errno;
|
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);
|
shl_findsym(&lib, buf, TYPE_PROCEDURE, (void*)&init_fct);
|
||||||
if (init_fct == NULL) {
|
if (init_fct == NULL) {
|
||||||
shl_findsym(&lib, buf, TYPE_UNDEFINED, (void*)&init_fct);
|
shl_findsym(&lib, buf, TYPE_UNDEFINED, (void*)&init_fct);
|
||||||
if (init_fct == NULL) {
|
if (init_fct == NULL) {
|
||||||
errno = ENOSYM;
|
errno = ENOSYM;
|
||||||
rb_loaderror("%s - %s", strerror(ENOSYM), file);
|
dln_loaderror("%s - %s", strerror(ENOSYM), file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(*init_fct)();
|
(*init_fct)();
|
||||||
@ -1359,14 +1381,14 @@ dln_load(const char *file)
|
|||||||
if(rld_load(s, NULL, object_files, NULL) == 0) {
|
if(rld_load(s, NULL, object_files, NULL) == 0) {
|
||||||
NXFlush(s);
|
NXFlush(s);
|
||||||
NXClose(s);
|
NXClose(s);
|
||||||
rb_loaderror("Failed to load %.200s", file);
|
dln_loaderror("Failed to load %.200s", file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* lookup the initial function */
|
/* lookup the initial function */
|
||||||
if(rld_lookup(s, buf, &init_address) == 0) {
|
if(rld_lookup(s, buf, &init_address) == 0) {
|
||||||
NXFlush(s);
|
NXFlush(s);
|
||||||
NXClose(s);
|
NXClose(s);
|
||||||
rb_loaderror("Failed to lookup Init function %.200s", file);
|
dln_loaderror("Failed to lookup Init function %.200s", file);
|
||||||
}
|
}
|
||||||
|
|
||||||
NXFlush(s);
|
NXFlush(s);
|
||||||
@ -1391,14 +1413,14 @@ dln_load(const char *file)
|
|||||||
dyld_result = NSCreateObjectFileImageFromFile(file, &obj_file);
|
dyld_result = NSCreateObjectFileImageFromFile(file, &obj_file);
|
||||||
|
|
||||||
if (dyld_result != NSObjectFileImageSuccess) {
|
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);
|
NSLinkModule(obj_file, file, NSLINKMODULE_OPTION_BINDNOW);
|
||||||
|
|
||||||
/* lookup the initial function */
|
/* lookup the initial function */
|
||||||
if(!NSIsSymbolNameDefined(buf)) {
|
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 = NSAddressOfSymbol(NSLookupAndBindSymbol(buf));
|
||||||
(*init_fct)();
|
(*init_fct)();
|
||||||
@ -1418,7 +1440,7 @@ dln_load(const char *file)
|
|||||||
/* load extention module */
|
/* load extention module */
|
||||||
img_id = load_add_on(file);
|
img_id = load_add_on(file);
|
||||||
if (img_id <= 0) {
|
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);
|
file, img_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1442,12 +1464,12 @@ dln_load(const char *file)
|
|||||||
|
|
||||||
if ((B_BAD_IMAGE_ID == err_stat) || (B_BAD_INDEX == err_stat)) {
|
if ((B_BAD_IMAGE_ID == err_stat) || (B_BAD_INDEX == err_stat)) {
|
||||||
unload_add_on(img_id);
|
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) {
|
else if (B_NO_ERROR != err_stat) {
|
||||||
char errmsg[] = "Internal of BeOS version. %.200s (symbol_name = %s)";
|
char errmsg[] = "Internal of BeOS version. %.200s (symbol_name = %s)";
|
||||||
unload_add_on(img_id);
|
unload_add_on(img_id);
|
||||||
rb_loaderror(errmsg, strerror(err_stat), buf);
|
dln_loaderror(errmsg, strerror(err_stat), buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* call module initialize function. */
|
/* call module initialize function. */
|
||||||
@ -1457,14 +1479,14 @@ dln_load(const char *file)
|
|||||||
#endif /* __BEOS__*/
|
#endif /* __BEOS__*/
|
||||||
|
|
||||||
#ifndef DLN_DEFINED
|
#ifndef DLN_DEFINED
|
||||||
rb_notimplement();
|
dln_notimplement();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* USE_DLN_A_OUT */
|
#endif /* USE_DLN_A_OUT */
|
||||||
#endif
|
#endif
|
||||||
#if !defined(_AIX) && !defined(NeXT)
|
#if !defined(_AIX) && !defined(NeXT)
|
||||||
failed:
|
failed:
|
||||||
rb_loaderror("%s - %s", error, file);
|
dln_loaderror("%s - %s", error, file);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* NO_DLN_LOAD */
|
#endif /* NO_DLN_LOAD */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user