mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-04 22:40:25 +02:00
* Allow to activate strict compile time type checking by defining
the macro SCM_STRICT_TYPING. * Defined SCM_EQ_P as a macro equivalent for eq?.
This commit is contained in:
parent
96f6f4aebf
commit
8d3356e761
2 changed files with 47 additions and 13 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2000-03-25 Dirk Herrmann <D.Herrmann@tu-bs.de>
|
||||||
|
|
||||||
|
* tags.h (SCM_STRICT_TYPING): New macro that, if defined,
|
||||||
|
activates strict compile time type checking for variables of
|
||||||
|
type SCM.
|
||||||
|
(SCM, SCM_PACK, SCM_UNPACK): Define according to whether
|
||||||
|
SCM_STRICT_TYPING or SCM_VOIDP_TEST are defined.
|
||||||
|
(SCM_EQ_P): Defined as a macro equivalent for eq?.
|
||||||
|
|
||||||
2000-03-25 Dirk Herrmann <D.Herrmann@tu-bs.de>
|
2000-03-25 Dirk Herrmann <D.Herrmann@tu-bs.de>
|
||||||
|
|
||||||
* tags.h (SCM_POINTERS_MUNGED): Removed.
|
* tags.h (SCM_POINTERS_MUNGED): Removed.
|
||||||
|
|
|
@ -54,25 +54,50 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* #define SCM_STRICT_TYPING */
|
||||||
|
/* #define SCM_VOIDP_TEST */
|
||||||
|
|
||||||
/* In the beginning was the Word:
|
/* In the beginning was the Word:
|
||||||
*/
|
*/
|
||||||
typedef long scm_bits_t;
|
typedef long scm_bits_t;
|
||||||
/*
|
|
||||||
But as external interface, we use void*, which will be checked more strictly for
|
/* But as external interface, we use SCM, which may, according to the desired
|
||||||
dubious conversions.
|
* level of type checking, be defined in several ways:
|
||||||
*/
|
*/
|
||||||
/* #define SCM_VOIDP_TEST */
|
#if defined (SCM_STRICT_TYPING)
|
||||||
#ifndef SCM_VOIDP_TEST
|
/* Use this for _compile time_ type checking only, since the compiled result
|
||||||
typedef scm_bits_t SCM;
|
* will be quite inefficient. The right way to make use of this mode is to do
|
||||||
#define SCM_UNPACK(x) (x)
|
* a 'make clean' of your project, 'make all CFLAGS=-DSCM_STRICT_TYPING', fix
|
||||||
#define SCM_PACK(x) (x)
|
* your errors, and then do 'make clean; make all'.
|
||||||
|
*/
|
||||||
|
typedef union { struct { scm_bits_t n; } n; } SCM;
|
||||||
|
static SCM scm_pack(scm_bits_t b) { SCM s; s.n.n = b; return s; }
|
||||||
|
#define SCM_UNPACK(x) ((x).n.n)
|
||||||
|
#define SCM_PACK(x) (scm_pack (x))
|
||||||
|
#elif defined (SCM_VOIDP_TEST)
|
||||||
|
/* This is the default, which provides an intermediate level of compile time
|
||||||
|
* type checking while still resulting in very efficient code.
|
||||||
|
*/
|
||||||
|
typedef void * SCM;
|
||||||
|
#define SCM_UNPACK(x) ((scm_bits_t) (x))
|
||||||
|
#define SCM_PACK(x) ((SCM) (x))
|
||||||
#else
|
#else
|
||||||
typedef void * SCM;
|
/* This should be used as a fall back solution for machines on which casting
|
||||||
#define SCM_UNPACK(x) ((scm_bits_t) (x))
|
* to a pointer may lead to loss of bit information, e. g. in the three least
|
||||||
#define SCM_PACK(x) ((SCM) (x))
|
* significant bits.
|
||||||
|
*/
|
||||||
|
typedef scm_bits_t SCM;
|
||||||
|
#define SCM_UNPACK(x) (x)
|
||||||
|
#define SCM_PACK(x) (x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* SCM values can not be compared by using the operator ==. Use the following
|
||||||
|
* macro instead, which is the equivalent of the scheme predicate 'eq?'.
|
||||||
|
*/
|
||||||
|
#define SCM_EQ_P(x, y) (SCM_UNPACK (x) == SCM_UNPACK (y))
|
||||||
|
|
||||||
|
|
||||||
/* SCM_UNPACK_CAR is a convenience for treating the CAR of X as a word */
|
/* SCM_UNPACK_CAR is a convenience for treating the CAR of X as a word */
|
||||||
#define SCM_UNPACK_CAR(x) SCM_UNPACK (SCM_CAR (x))
|
#define SCM_UNPACK_CAR(x) SCM_UNPACK (SCM_CAR (x))
|
||||||
|
|
||||||
|
@ -81,8 +106,8 @@ typedef void * SCM;
|
||||||
* rather than each byte, the 3 most significant bits encode the byte
|
* rather than each byte, the 3 most significant bits encode the byte
|
||||||
* within the word. The following macros deal with this by storing the
|
* within the word. The following macros deal with this by storing the
|
||||||
* native Cray pointers like the ones that looks like scm expects. This
|
* native Cray pointers like the ones that looks like scm expects. This
|
||||||
* is done for any pointers that might appear in the car of a scm_cell, pointers
|
* is done for any pointers that might appear in the car of a scm_cell,
|
||||||
* to scm_vector elts, functions, &c are not munged.
|
* pointers to scm_vector elts, functions, &c are not munged.
|
||||||
*/
|
*/
|
||||||
#ifdef _UNICOS
|
#ifdef _UNICOS
|
||||||
# define SCM2PTR(x) ((void *) (SCM_UNPACK (x) >> 3))
|
# define SCM2PTR(x) ((void *) (SCM_UNPACK (x) >> 3))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue