From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Dirk Herrmann Newsgroups: gmane.lisp.guile.devel Subject: Re: The relationship between SCM and scm_t_bits. Date: Sat, 15 May 2004 18:42:30 +0200 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <40A64876.3090806@dirk-herrmanns-seiten.de> References: <40A6307C.9050809@dirk-herrmanns-seiten.de> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1084638102 32020 80.91.224.253 (15 May 2004 16:21:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 15 May 2004 16:21:42 +0000 (UTC) Cc: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat May 15 18:21:30 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BP1uj-000281-00 for ; Sat, 15 May 2004 18:21:29 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BP1qH-0008Vm-56 for guile-devel@m.gmane.org; Sat, 15 May 2004 12:16:53 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.34) id 1BP1pv-0008Uk-EL for guile-devel@gnu.org; Sat, 15 May 2004 12:16:31 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.34) id 1BP1pP-0008Op-5E for guile-devel@gnu.org; Sat, 15 May 2004 12:16:30 -0400 Original-Received: from [212.227.126.171] (helo=moutng.kundenserver.de) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BP1pO-0008Nc-CB for guile-devel@gnu.org; Sat, 15 May 2004 12:15:58 -0400 Original-Received: from [212.227.126.207] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1BP1pL-0002gr-00; Sat, 15 May 2004 18:15:55 +0200 Original-Received: from [80.131.48.15] (helo=dirk-herrmanns-seiten.de) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1BP1pK-0004Oj-00; Sat, 15 May 2004 18:15:55 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.2) Gecko/20040220 X-Accept-Language: de, en Original-To: Marius Vollmer In-Reply-To: <40A6307C.9050809@dirk-herrmanns-seiten.de> X-Enigmail-Version: 0.76.8.0 X-Enigmail-Supports: pgp-inline, pgp-mime X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:494e3e4d1bf8dc247959c49e6f1f4215 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:3720 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:3720 Dirk Herrmann wrote: > I have not yet given it a try, but I found the suggestion to use a > union quite appaling: > [some syntactically incorrect examples deleted :-)] However, I have now given it a try, and it seems to work quite nicely. I enclose a patch, which I would be glad to apply, if you, Marius, agree. I did not do it yet, though, in order to give everybody the chance to check whether it has any negative influence on performance. Best regards, Dirk Diff agains the latest CVS: Index: NEWS =================================================================== RCS file: /cvsroot/guile/guile/guile-core/NEWS,v retrieving revision 1.427 diff -u -b -r1.427 NEWS --- NEWS 6 May 2004 17:04:04 -0000 1.427 +++ NEWS 15 May 2004 16:02:26 -0000 @@ -584,16 +584,6 @@ * Changes to the C interface -** SCM_CELL_WORD_LOC has been deprecated. - -Use the new macro SCM_CELL_OBJECT_LOC instead, which return a pointer -to a SCM, as opposed to a pointer to a scm_t_bits. - -This was done to allow the correct use of pointers into the Scheme -heap. Previously, the heap words were of type scm_t_bits and local -variables and function arguments were of type SCM, making it -non-standards-conformant to have a pointer that can point to both. - ** New macros SCM_SMOB_DATA_2, SM_SMOB_DATA_3, etc. These macros should be used instead of SCM_CELL_WORD_2/3 to access the Index: libguile/ChangeLog =================================================================== RCS file: /cvsroot/guile/guile/guile-core/libguile/ChangeLog,v retrieving revision 1.2070 diff -u -b -r1.2070 ChangeLog --- libguile/ChangeLog 15 May 2004 15:50:24 -0000 1.2070 +++ libguile/ChangeLog 15 May 2004 16:02:26 -0000 @@ -1,5 +1,23 @@ 2004-05-15 Dirk Herrmann + * deprecated.h (SCM_CELL_WORD_LOC): Un-deprecated. + + * gc.h (scm_t_cell): Redefined to hold a union, since each cell + element either holds a scm_t_bits value or a SCM value. + + (SCM_GC_CARD_BVEC, SCM_GC_SET_CARD_BVEC, SCM_GC_GET_CARD_FLAGS, + SCM_GC_SET_CARD_FLAGS, SCM_GC_CELL_OBJECT, SCM_GC_CELL_WORD, + SCM_GC_SET_CELL_OBJECT, SCM_GC_SET_CELL_WORD): Modified to work + with the new scm_t_cell. + + (SCM_CELL_WORD_LOC): Un-deprecated. + + * numbers.h (SCM_I_BIG_MPZ): Use SCM_CELL_WORD_LOC instead of + SCM_CELL_OBJECT_LOC, since we are not dealing with scheme objects + here. + +2004-05-15 Dirk Herrmann + * numbers.h (SCM_SLOPPY_FRACTIONP): Removed. It was not used throughout guile, has not been part of an official release yet, and the concept of sloppy predicates has never been a good idea. Index: libguile/deprecated.h =================================================================== RCS file: /cvsroot/guile/guile/guile-core/libguile/deprecated.h,v retrieving revision 1.19 diff -u -b -r1.19 deprecated.h --- libguile/deprecated.h 6 May 2004 16:42:50 -0000 1.19 +++ libguile/deprecated.h 15 May 2004 16:02:26 -0000 @@ -300,11 +300,6 @@ #define SCM_VALIDATE_OPDIR(pos, port) SCM_MAKE_VALIDATE (pos, port, OPDIRP) -/* Deprecated because we can not safely cast a SCM* to a scm_t_bits* - */ - -#define SCM_CELL_WORD_LOC(x, n) ((scm_t_bits*)SCM_CELL_OBJECT_LOC((x),(n))) - void scm_i_init_deprecated (void); #endif Index: libguile/gc.h =================================================================== RCS file: /cvsroot/guile/guile/guile-core/libguile/gc.h,v retrieving revision 1.116 diff -u -b -r1.116 gc.h --- libguile/gc.h 6 May 2004 16:41:08 -0000 1.116 +++ libguile/gc.h 15 May 2004 16:02:26 -0000 @@ -36,8 +36,10 @@ typedef struct scm_t_cell { - SCM word_0; - SCM word_1; + union { + scm_t_bits word; + SCM object; + } elements[2]; } scm_t_cell; /* @@ -73,12 +75,14 @@ #define SCM_GC_CARD_N_CELLS 256 #define SCM_GC_SIZEOF_CARD SCM_GC_CARD_N_CELLS * sizeof (scm_t_cell) -#define SCM_GC_CARD_BVEC(card) ((scm_t_c_bvec_long *) ((card)->word_0)) +#define SCM_GC_CARD_BVEC(card) \ + ((scm_t_c_bvec_long *) ((card)->elements[0].word)) #define SCM_GC_SET_CARD_BVEC(card, bvec) \ - ((card)->word_0 = (SCM) (bvec)) -#define SCM_GC_GET_CARD_FLAGS(card) ((long) ((card)->word_1)) + ((card)->elements[0].word = (scm_t_bits) (bvec)) +#define SCM_GC_GET_CARD_FLAGS(card) \ + ((long) ((card)->elements[1].word)) #define SCM_GC_SET_CARD_FLAGS(card, flags) \ - ((card)->word_1 = (SCM) (flags)) + ((card)->elements[1].word = (flags)) #define SCM_GC_GET_CARD_FLAG(card, shift) \ (SCM_GC_GET_CARD_FLAGS (card) & (1L << (shift))) @@ -141,12 +145,13 @@ * in debug mode. In particular these macros will even work for free cells, * which should never be encountered by user code. */ -#define SCM_GC_CELL_OBJECT(x, n) (((SCM *)SCM2PTR (x)) [n]) -#define SCM_GC_CELL_WORD(x, n) (SCM_UNPACK (SCM_GC_CELL_OBJECT ((x), (n)))) +#define SCM_GC_CELL_WORD(x, n) (((SCM2PTR (x))->elements[n]).word) +#define SCM_GC_CELL_OBJECT(x, n) (((SCM2PTR (x))->elements[n]).object) -#define SCM_GC_SET_CELL_OBJECT(x, n, v) ((((SCM *)SCM2PTR (x)) [n]) = (v)) +#define SCM_GC_SET_CELL_OBJECT(x, n, v) \ + (((SCM2PTR (x))->elements[n]).object = (v)) #define SCM_GC_SET_CELL_WORD(x, n, v) \ - (SCM_GC_SET_CELL_OBJECT ((x), (n), SCM_PACK (v))) + (((SCM2PTR (x))->elements[n]).word = (v)) #define SCM_GC_CELL_TYPE(x) (SCM_GC_CELL_OBJECT ((x), 0)) @@ -214,6 +219,7 @@ (SCM_GC_SET_CELL_OBJECT ((x), 1, (v))) +#define SCM_CELL_WORD_LOC(x, n) (&SCM_CELL_WORD ((x), (n))) #define SCM_CELL_OBJECT_LOC(x, n) (&SCM_CELL_OBJECT ((x), (n))) #define SCM_CARLOC(x) (SCM_CELL_OBJECT_LOC ((x), 0)) #define SCM_CDRLOC(x) (SCM_CELL_OBJECT_LOC ((x), 1)) Index: libguile/numbers.h =================================================================== RCS file: /cvsroot/guile/guile/guile-core/libguile/numbers.h,v retrieving revision 1.82 diff -u -b -r1.82 numbers.h --- libguile/numbers.h 15 May 2004 15:50:24 -0000 1.82 +++ libguile/numbers.h 15 May 2004 16:02:26 -0000 @@ -144,7 +144,7 @@ #define SCM_COMPLEX_IMAG(x) (SCM_COMPLEX_MEM (x)->imag) /* Each bignum is just an mpz_t stored in a double cell starting at word 1. */ -#define SCM_I_BIG_MPZ(x) (*((mpz_t *) (SCM_CELL_OBJECT_LOC((x),1)))) +#define SCM_I_BIG_MPZ(x) (*((mpz_t *) (SCM_CELL_WORD_LOC ((x), 1)))) #define SCM_BIGP(x) (!SCM_IMP (x) && SCM_TYP16 (x) == scm_tc16_big) #define SCM_NUMBERP(x) (SCM_INUMP(x) || SCM_NUMP(x)) _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel