[前][次][番号順一覧][スレッド一覧]

ruby-changes:13366

From: nobu <ko1@a...>
Date: Mon, 28 Sep 2009 22:46:33 +0900 (JST)
Subject: [ruby-changes:13366] Ruby:r25135 (trunk): * dln.c (dln_{exit,loaderror,memerror,notimplement}): renamed as

nobu	2009-09-28 22:46:18 +0900 (Mon, 28 Sep 2009)

  New Revision: 25135

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25135

  Log:
    * dln.c (dln_{exit,loaderror,memerror,notimplement}): renamed as
      independent names.

  Modified files:
    trunk/ChangeLog
    trunk/dln.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 25134)
+++ ChangeLog	(revision 25135)
@@ -1,5 +1,8 @@
-Mon Sep 28 22:33:11 2009  Nobuyoshi Nakada  <nobu@r...>
+Mon Sep 28 22:46:16 2009  Nobuyoshi Nakada  <nobu@r...>
 
+	* dln.c (dln_{exit,loaderror,memerror,notimplement}): renamed as
+	  independent names.
+
 	* dln.c (aix_loaderror): needs format string.
 
 Mon Sep 28 19:36:20 2009  NAKAMURA Usaku  <usa@r...>
Index: dln.c
===================================================================
--- dln.c	(revision 25134)
+++ dln.c	(revision 25135)
@@ -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 @@
 # 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 @@
     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 @@
     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 @@
 	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 @@
 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 @@
     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 @@
     }
 
     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 @@
 	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 @@
 	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 @@
 	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 @@
       /* 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 @@
 
       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 @@
 #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 */

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]