[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Passing C pointers through guile

From: Ludovic Courtès
Subject: Re: Passing C pointers through guile
Date: Wed, 09 Jul 2008 22:43:34 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)


"Kjetil S. Matheussen" <address@hidden> writes:

> Ludovic Court?s:

>>You have to make sure you are on the `branch_release-1-8', and then
>>"autoreconf -vfi" should suffice to produce everything.  Autoconf 2.61,
>>Automake 1.10 and Libtool 1.5.26 is all you need.
> Thanks. It would be nice if that information was in the source 
> too...

Well, `' has an `AC_PREREQ' call, 1.10(.1) is the latest
Automake, and 1.5.26 is the latest Libtool of the 1.x series, it's
easy.  :-)

>> I think this type shouldn't be optional, because there will always be a
>> pointer-sized integer type (whereas there could be platform without
>> 64-bit integers).
> But isn't the only way to make sure that an integer size
> is big enough to hold a pointer, to use uintptr_t from
> stdint.h ?

No.  `configure' checks the size of a number of (integer) types.  The
idea here would be to have a check for `void *' (if there isn't one
already); then in `numbers.h', you'd add something along the lines of:

  #if SCM_SIZEOF_VOID_P == 4
  #define scm_to_uintptr scm_to_uint32
  #elif SCM_SIZEOF_VOID_P == 8
  #define scm_to_uintptr scm_to_uint64
  #error "strange `void *'"

IOW, don't rely on <stdint.h> or <inttypes.h>.

> That's true. But at least my experience is that using guardians
> is cleaner than smurf's.

Smurf?  Smurf's what?

> For example, I think the use of guardians for 
> faust objects in
> is very simple, it's just one line: "(add-finalizer (-> faust 
> get-c-object) cleanup-faust-object)".

Yes, guardians are easy to use.

> Also, various types of non-gc pointers are stored in integers in
> all of the rt-*.scm files in
> and many others (xg.c, etc.). It would be horribly idiotic
> to write smurf's for all of those, or at least a common smurf, when a 
> single integer is enough.

Do you mean "SMOB" instead of "smurf"?  :-)

If so, the deallocation routine that's called from the guardian (which
is necessarily written in C) is roughly the same as the one you'd pass
to `scm_set_smob_free ()'.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]