Ian Piumarta wrote:
On Nov 10, 2007, at 6:17 AM, Antoine van Gelder wrote:
object= *(oop *)dlsym(global, "_libid_object");

It's not finding the symbol _libid_object so returning 0 and segfaulting during the cast.

Ah, now I remember. _libid_object (and all the similar globals) went away (to eliminate any dependency on dlsym() during initialisation) and were replaced by a single structure called _libid (described in id.h). All the same stuff is there; you just have to replace _libid_object with _libid->object etc.

Patch attached which switches libjolt to use _libid->* style calls as well as a Makefile fix for the awk script which was causing Michael's syntax errors.

Thanks for the help everyone!

- antoine
Index: function/examples/libjolt/Makefile
===================================================================
--- function/examples/libjolt/Makefile	(revision 362)
+++ function/examples/libjolt/Makefile	(working copy)
@@ -3,7 +3,8 @@
 MPINT		= ../../objects/mpint
 JOLT		= ../../jolt-burg
 OBJ		= ../../../object/stage2
-IDFLAGS		= -g -I../../objects -I$(JOLT)
+IDFLAGS	= -g -I../../objects -I$(JOLT) 
+JESTFLAGS	= -g -I../../../object
 
 OBJEXT          = 
 OBJEXT_O        = .o
@@ -50,7 +51,7 @@
 #
 boot.h : $(JOLT_BOOT_FILES)
 	cat $(JOLT_BOOT_FILES) | \
-		awk 'BEGIN {RS = "\(define herald.*contents\]\)\)\)\)"} {print $$0}' | \
+		awk 'BEGIN {RS = "\\(define herald.*contents\\]\\)\\)\\)\\)"} {print $$0}' | \
 		grep -Ev '^(;|$$)' | \
 		sed -e 's/";/"/g' -e 's/;.*$$//' -e 's/\\/\\\\/g' -e 's/"/\\"/g' | \
 		awk '{print "\"", $$0, "\""}' | \
@@ -73,11 +74,11 @@
 	cp jolt.h /usr/include
 
 test-libjolt : libjolt.a .FORCE
-	gcc -o $@ [EMAIL PROTECTED] $(LDFLAGS) libjolt.a $(LDLIBS)
+	gcc -o $@ [EMAIL PROTECTED] $(JESTFLAGS) $(LDFLAGS) libjolt.a $(LDLIBS)  $(OBJ)/gc.a
 	./$@
 
 jest : jest.c libjolt.a jolt.h
-	gcc -o $@ [EMAIL PROTECTED]  $(LDFLAGS) libjolt.a $(LDLIBS)
+	gcc -o $@ [EMAIL PROTECTED] $(JESTFLAGS) $(LDFLAGS) libjolt.a $(LDLIBS)  $(OBJ)/gc.a 
 
 tidy : .FORCE
 	-rm -f *.o *.d *~ .gdb* *.stackdump *.o.c boot.h
Index: function/examples/libjolt/jolt.h
===================================================================
--- function/examples/libjolt/jolt.h	(revision 362)
+++ function/examples/libjolt/jolt.h	(working copy)
@@ -50,67 +50,50 @@
 
 typedef oop (*_imp_t)(oop _thunk, oop receiver, ...);
 
-struct __closure
-{
-  _imp_t method;
-  oop	 data;
-};
+#include <id/id.h>
+static struct __libid *_libid= 0;
 
-static oop  		  (*_local_intern  )(const char *string)= 0;
-static oop  		  (*_local_import  )(const char *name)= 0;
-static struct __closure  *(*_local_bind    )(oop selector, oop receiver)= 0;
-static oop  		    _local_object= 0;
-
 #define _send(MSG, RCV, ARG...) ({					\
   register oop _r= (RCV);						\
-  struct __closure *_c= (struct __closure *)_local_bind((MSG), _r);	\
+  struct __closure *_c= (struct __closure *)_libid->bind((MSG), _r);	\
   (_c->method)((oop)_c, _r, _r, ##ARG);					\
 })
 
 #define _super(TYP, MSG, RCV, ARG...) ({				\
   register oop _r= (RCV);						\
-  struct __closure *_c= (struct __closure *)_local_bind((MSG), (TYP));	\
+  struct __closure *_c= (struct __closure *)_libid->bind((MSG), (TYP));	\
   (_c->method)((oop)_c, _r, _r, ##ARG);					\
 })
 
-static oop s__5fimport_= 0;
-static oop s_initialise= 0;
-static oop s_size_5f_value_5f_= 0;
-
-static oop v_String= 0;
-static oop v_Jolt= 0;
-
 extern oop __id__init__libjolt(void);
 static void *__libjolt_ref= __id__init__libjolt;
 
-oop __id__init__(void)
+oop __id__init__(struct __libid *__libid)
 {
-  if (_local_object) return;
-  { 
-    dlhandle_t global= dlopen(0, RTLD_LAZY);
-    _local_object= *(oop *)dlsym(global, "_libid_object");
-    _local_intern= dlsym(global, "_libid_intern");
-    _local_import= dlsym(global, "_libid_import");
-    _local_bind= dlsym(global, "_libid_bind");
-    dlclose(global);
-  }
-  s__5fimport_		= _local_intern("_import:");
-  s_initialise		= _local_intern("initialise");
-  s_size_5f_value_5f_	= _local_intern("size_:value_:");
-  _send(s__5fimport_, _local_object, "libjolt", "__id__init__libjolt");
-  v_String= _local_import("String");
-  v_Jolt= _local_import("Jolt");
-  return _send(s_initialise, v_Jolt);
+  if (_libid) return;
+  if (!(_libid= __libid)) { fprintf(stderr, "init _libid %p\n", __libid);  abort(); }
+
+  _send(_libid->intern("_import:"), 
+        _libid->_object, 
+        "libjolt", 
+        "__id__init__libjolt");
+
+  return _send(_libid->intern("initialise"), 
+               _libid->import("Jolt"));
 }
 
 oop libjolt_init(int *argcp, char ***argvp, char ***envpp)
 {
+  struct __libid* libid;
+  oop entry= 0;
+
   dlhandle_t global= dlopen(0, RTLD_LAZY);
   void *_local_init= dlsym(global, "_libid_init");
-  oop entry= 0;
   if (!_local_init) { fprintf(stderr, "id runtime not found\n");  abort(); }
-  ((void (*)(int *, char ***, char ***))_local_init)(argcp, argvp, envpp);
-  entry= __id__init__();
+  
+  libid = ((struct __libid *(*)(int *, char ***, char ***))_local_init)(argcp, argvp, envpp);
+  entry= __id__init__(libid);
   dlclose(global);
+  
   return entry;
 }
_______________________________________________
fonc mailing list
[email protected]
http://vpri.org/mailman/listinfo/fonc

Reply via email to