Michael FIG wrote:
Great!
I took your patch and added some minor improvements (attached):
* Use ../idc, so that libjolt will build with the newly-compiled idc
instead of the installed one.
* Implement and use the 'idc -C CPPFLAGS' option to get the path to
the include directory instead of hardcoding it.
* Declare _local_init to be the right type instead of casting it.
Thanks for getting this working again,
Muchly thanks MIchael, this works great !
I've made a small modification to your patch which:
* escapes the opening '(' on the awk expression
Patch tested against a clean revision 362 tree.
- antoine
diff -r 80d0db8bd40d function/examples/libjolt/Makefile
--- a/function/examples/libjolt/Makefile Thu Nov 22 18:42:15 2007 -0600
+++ b/function/examples/libjolt/Makefile Thu Nov 22 19:29:19 2007 -0600
@@ -1,4 +1,4 @@ IDC = idc -k # -O
-IDC = idc -k # -O
+IDC = ../idc -k # -O
OBJECTS = ../../objects
MPINT = ../../objects/mpint
JOLT = ../../jolt-burg
@@ -11,6 +11,7 @@ OBJEXT_SO = .so
LDFLAGS = $(shell $(IDC) -C LDFLAGS)
LDLIBS = $(shell $(IDC) -C LDLIBS)
+CPPFLAGS = $(shell $(IDC) -C CPPFLAGS)
JOLT_OBJ_FILES = $(filter-out $(JOLT)/readline.o, $(wildcard $(JOLT)/*.o))
JOLT_BOOT_FILES = boot.k quasiquote.k syntax.k number.k object.k
@@ -50,7 +51,7 @@ test : jest$(OBJEXT) .FORCE
#
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, "\""}' | \
@@ -61,8 +62,8 @@ libjolt.o : boot.h
libjolt.o : boot.h
libjolt.a : libjolt.o
- ld -r libjolt.o $(OBJECTS)/*.o $(MPINT)/*.o $(JOLT_OBJ_FILES) $(OBJ)/gc.a \
- $(OBJ)/libid.o -o [EMAIL PROTECTED]
+ ld -r libjolt.o $(OBJECTS)/*.o $(MPINT)/*.o $(JOLT_OBJ_FILES) \
+ $(OBJ)/libid.o $(OBJ)/gc.a -o [EMAIL PROTECTED]
ar rsc [EMAIL PROTECTED] [EMAIL PROTECTED]
rm [EMAIL PROTECTED]
mv [EMAIL PROTECTED] $@
@@ -73,11 +74,11 @@ install: libjolt.a
cp jolt.h /usr/include
test-libjolt : libjolt.a .FORCE
- gcc -o $@ [EMAIL PROTECTED] $(LDFLAGS) libjolt.a $(LDLIBS)
+ gcc $(CPPFLAGS) -o $@ [EMAIL PROTECTED] $(LDFLAGS) libjolt.a $(LDLIBS)
./$@
jest : jest.c libjolt.a jolt.h
- gcc -o $@ [EMAIL PROTECTED] $(LDFLAGS) libjolt.a $(LDLIBS)
+ gcc $(CPPFLAGS) -o $@ [EMAIL PROTECTED] $(LDFLAGS) libjolt.a $(LDLIBS)
tidy : .FORCE
-rm -f *.o *.d *~ .gdb* *.stackdump *.o.c boot.h
diff -r 80d0db8bd40d function/examples/libjolt/jolt.h
--- a/function/examples/libjolt/jolt.h Thu Nov 22 18:42:15 2007 -0600
+++ b/function/examples/libjolt/jolt.h Thu Nov 22 19:29:19 2007 -0600
@@ -50,67 +50,51 @@ typedef struct t__object *oop;
typedef oop (*_imp_t)(oop _thunk, oop receiver, ...);
-struct __closure
-{
- _imp_t method;
- oop data;
-};
-
-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;
+#include <id/id.h>
+static struct __libid *_libid= 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;
+ struct __libid *(*_local_init)(int *, char ***, char ***)=
+ dlsym(global, "_libid_init");
if (!_local_init) { fprintf(stderr, "id runtime not found\n"); abort(); }
- ((void (*)(int *, char ***, char ***))_local_init)(argcp, argvp, envpp);
- entry= __id__init__();
+
+ libid = _local_init(argcp, argvp, envpp);
+ entry= __id__init__(libid);
dlclose(global);
+
return entry;
}
diff -r 80d0db8bd40d function/objects/sigalrm.h
--- a/function/objects/sigalrm.h Thu Nov 22 18:42:15 2007 -0600
+++ b/function/objects/sigalrm.h Thu Nov 22 19:29:19 2007 -0600
@@ -1,3 +1,5 @@ static oop sigalrmReceiver= 0;
+#include <signal.h>
+
static oop sigalrmReceiver= 0;
static oop sigalrmSelector= 0;
diff -r 80d0db8bd40d object/idc/idc.in
--- a/object/idc/idc.in Thu Nov 22 18:42:15 2007 -0600
+++ b/object/idc/idc.in Thu Nov 22 19:29:19 2007 -0600
@@ -131,6 +131,8 @@ while [ $# -gt 0 ]; do
shift;
done
+CPPFLAGS="-I$prefix/include"
+
case "$config" in
"arch") echo "@SYSARCH@"; exit;;
"os") echo "@SYSOS@"; exit;;
@@ -144,6 +146,7 @@ case "$config" in
"CCFLAGS") echo "@CCFLAGS@"; exit;;
"CCFLAGS_O") echo "@CCFLAGS_O@"; exit;;
"CCFLAGS_SO") echo "@CCFLAGS_SO@"; exit;;
+ "CPPFLAGS") echo "$CPPFLAGS"; exit;;
"LDFLAGS") echo "@LDFLAGS@"; exit;;
"LDFLAGS_O") echo "@LDFLAGS_O@"; exit;;
"LDFLAGS_SO") echo "@LDFLAGS_SO@"; exit;;
@@ -240,9 +243,9 @@ if [ ! -z "$infile" ]; then
if [ ! -z "$infile" ]; then
$verbose
$run ${prefix}idc1 -I$prefix $idopts $idflags $infile -o $ccfile &&
- $run $cc -I$prefix/include $ccflags $ccopts $ccfile -o $outfile $ldflags $ldobjs $idlibs $ldlibs &&
+ $run $cc $CPPFLAGS $ccflags $ccopts $ccfile -o $outfile $ldflags $ldobjs $idlibs $ldlibs &&
$run $cckill $ccfile
else
$verbose
- $run $cc -I$prefix/include $ccflags $ccopts -o $outfile $ldflags $ldobjs $idlibs $ldlibs
-fi
+ $run $cc $CPPFLAGS $ccflags $ccopts -o $outfile $ldflags $ldobjs $idlibs $ldlibs
+fi
_______________________________________________
fonc mailing list
[email protected]
http://vpri.org/mailman/listinfo/fonc