From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: Passing C pointers through guile Date: Wed, 09 Jul 2008 22:43:34 +0200 Message-ID: <87skuivle1.fsf@gnu.org> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1215636255 22633 80.91.229.12 (9 Jul 2008 20:44:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 9 Jul 2008 20:44:15 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Jul 09 22:45:02 2008 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KGgX4-0001dQ-PE for guile-devel@m.gmane.org; Wed, 09 Jul 2008 22:44:59 +0200 Original-Received: from localhost ([127.0.0.1]:53094 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KGgWC-00037T-K2 for guile-devel@m.gmane.org; Wed, 09 Jul 2008 16:44:04 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KGgW6-00036v-Dn for guile-devel@gnu.org; Wed, 09 Jul 2008 16:43:58 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KGgW4-00036b-SB for guile-devel@gnu.org; Wed, 09 Jul 2008 16:43:58 -0400 Original-Received: from [199.232.76.173] (port=34885 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KGgW4-00036Y-NJ for guile-devel@gnu.org; Wed, 09 Jul 2008 16:43:56 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:37600 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KGgW3-0005WN-UX for guile-devel@gnu.org; Wed, 09 Jul 2008 16:43:56 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1KGgVt-0000cB-R1 for guile-devel@gnu.org; Wed, 09 Jul 2008 20:43:45 +0000 Original-Received: from reverse-83.fdn.fr ([80.67.176.83]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 09 Jul 2008 20:43:45 +0000 Original-Received: from ludo by reverse-83.fdn.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 09 Jul 2008 20:43:45 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 67 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: reverse-83.fdn.fr X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 22 Messidor an 216 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 821D 815D 902A 7EAB 5CEE D120 7FBA 3D4F EB1F 5364 X-OS: i686-pc-linux-gnu User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) Cancel-Lock: sha1:qJ17/YklVbHk+jbowRwYAJhHZIc= X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:7363 Archived-At: Hey, "Kjetil S. Matheussen" 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, `configure.in' 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 [...] #else #error "strange `void *'" #endif IOW, don't rely on or . > 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 http://snd.cvs.sourceforge.net/snd/cvs-snd/rt-faust.scm > 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 http://snd.cvs.sourceforge.net/snd/cvs-snd/ > 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 ()'. Thanks, Ludovic.