Bundle attached. Reasons in the changelog; any idea of how to deal with
the returning-a-scm case?
--
http://wingolog.org/
# Bazaar revision bundle v0.8
#
# message:
# 2006-12-17 Andy Wingo <[EMAIL PROTECTED]>
#
# * guile/g-wrap/guile-compatibility.c (scm_without_guile):
# * guile/g-wrap/guile-compatibility.h: Support scm_without_guile on
# guile 1.6.
#
# * guile/g-wrap/guile-runtime.c (dynproc_smob_apply)
# (ffi_call_without_guile): Wrap the ffi_call in scm_without_guile,
# which allows guile to GC without the participation of this thread,
# and allows other threads to register themselves with guile.
# Procedures with SCM arguments should still be fine as long as they
# are just examining their arguments; I'm not sure how to deal with
# procedures that allocate new SCM objects, for example as their
# return values. That part needs more thought, and thus makes this a
# somewhat experimental patch :)
#
# committer: Andy Wingo <[EMAIL PROTECTED]>
# date: Sun 2006-12-17 18:17:25.944999933 +0100
=== modified file ChangeLog
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,19 @@
+2006-12-17 Andy Wingo <[EMAIL PROTECTED]>
+
+ * guile/g-wrap/guile-compatibility.c (scm_without_guile):
+ * guile/g-wrap/guile-compatibility.h: Support scm_without_guile on
+ guile 1.6.
+
+ * guile/g-wrap/guile-runtime.c (dynproc_smob_apply)
+ (ffi_call_without_guile): Wrap the ffi_call in scm_without_guile,
+ which allows guile to GC without the participation of this thread,
+ and allows other threads to register themselves with guile.
+ Procedures with SCM arguments should still be fine as long as they
+ are just examining their arguments; I'm not sure how to deal with
+ procedures that allocate new SCM objects, for example as their
+ return values. That part needs more thought, and thus makes this a
+ somewhat experimental patch :)
+
2006-12-15 Andy Wingo <[EMAIL PROTECTED]>
* Makefile.am (DIST_SUBDIRS): libffi needs to be in a
=== modified file guile/g-wrap/guile-compatibility.c
--- guile/g-wrap/guile-compatibility.c
+++ guile/g-wrap/guile-compatibility.c
@@ -86,4 +86,10 @@
return len;
}
+void *
+scm_without_guile (void*(*func)(void*), void *data)
+{
+ return func(data);
+}
+
#endif
=== modified file guile/g-wrap/guile-compatibility.h
--- guile/g-wrap/guile-compatibility.h
+++ guile/g-wrap/guile-compatibility.h
@@ -119,6 +119,9 @@
#define SCM_SIMPLE_VECTOR_SET(v, idx, val) (SCM_VELTS (v)[(idx)] = (val))
#define SCM_SIMPLE_VECTOR_REF(v, idx) (SCM_VELTS (v)[(idx)])
+/* Threads. */
+void *scm_without_guile (void*(*func)(void*), void *data);
+
#else /* SCM_VERSION_17X */
=== modified file guile/g-wrap/guile-runtime.c
--- guile/g-wrap/guile-runtime.c
+++ guile/g-wrap/guile-runtime.c
@@ -569,6 +569,21 @@
}
#undef FUNC_NAME
+typedef struct {
+ GWFunctionInfo *fi;
+ void **values;
+ void *rvalue;
+} ffi_guile_call_info;
+
+typedef void* (*guile_without_func)(void*);
+
+static void*
+ffi_call_without_guile (const ffi_guile_call_info *info)
+{
+ ffi_call (&info->fi->cif, info->fi->proc, info->rvalue, info->values);
+ return NULL;
+}
+
static SCM
dynproc_smob_apply (SCM smob, SCM arg_list)
{
@@ -580,17 +595,20 @@
unsigned offset;
void *data;
GWError error;
+ ffi_guile_call_info call_info = { fi, NULL, NULL };
/* TODO: Most of this should be factored out into the core; but how
* to deal with the arg list? */
data = alloca (fi->data_area_size);
values = (void **) data;
+ call_info.values = values;
error.status = GW_ERR_NONE;
offset = fi->n_req_args * sizeof (void *);
rvalue = (void *) ((unsigned char *) data + offset);
+ call_info.rvalue = rvalue;
offset += (fi->ret_type->type->size > sizeof(ffi_arg)
? fi->ret_type->type->size : sizeof(ffi_arg));
{
@@ -614,7 +632,7 @@
}
}
- ffi_call (&fi->cif, fi->proc, rvalue, values);
+ scm_without_guile ((guile_without_func)ffi_call_without_guile, &call_info);
rvalue = GW_RVALUE_PTR (rvalue, fi->ret_type);
fi->ret_type->wrap_value (&result, ARENA, &fi->ret_typespec, rvalue, &error);
# revision id: [EMAIL PROTECTED]
# sha1: 0e38e8c55db1f6a0ac11e0ea54d7a55493da589b
# inventory sha1: 0b35206f2fdab6fe94f18518538d9723ae55a685
# parent ids:
# [EMAIL PROTECTED]
# base id: [EMAIL PROTECTED]
# properties:
# branch-nick: mainline
_______________________________________________
g-wrap-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/g-wrap-dev