diff options
author | Mikael Djurfeldt <djurfeldt@nada.kth.se> | 1996-10-20 03:29:01 +0000 |
---|---|---|
committer | Mikael Djurfeldt <djurfeldt@nada.kth.se> | 1996-10-20 03:29:01 +0000 |
commit | 24e68a57b9cf7bb8f0d0881911a5e233a2bc6616 (patch) | |
tree | 4fb78951446a6c866372654414080a91802816b1 /libguile/pairs.h | |
parent | 898a256f9156643b4ceb275776372ee4380b8df1 (diff) | |
download | guile-24e68a57b9cf7bb8f0d0881911a5e233a2bc6616.tar.gz |
* pairs.h, eval.c, eval.h, feature.c, gc.c, list.c, load.c,
ramap.c, symbols.c: Added new selectors SCM_CARLOC and SCM_CDRLOC
for obtaining the address of a car or cdr field. Motivation:
&SCM_CXR make assumptions about the internal structure of the
SCM_CXR selectors.
* pairs.h, eval.c, gc.c, init.c, ioext.c, ports.c, ports.h,
srcprop.h, tags.h, throw.c, unif.c: Added new selectors
SCM_SETAND_CAR, SCM_SETAND_CDR, SCM_SETOR_CAR and SCM_SETOR_CDR.
Motivation: Safer use. Some other macros are defined in terms of
these operations. If these are defined using the SCM_SETCXR
(<e1>, SCM_CXR (<e1>) <op> <e2>) pattern a complex <e1> will lead
to inefficiency and an <e1> with side-effects could potentially
break. Also, these particular operations are heavily utilized in
the garbage collector. In unoptimized code there will be a
measurable speedup.
* alist.c, arbiters.c, continuations.c, debug.c, debug.h, eval.c,
eval.h, feature.c, filesys.c, fports.c, gc.c, gsubr.c, init.c,
ioext.c, kw.c, list.c, load.c, mallocs.c, numbers.c, numbers.h,
pairs.c, pairs.h, ports.c, ports.h, posix.c, procprop.c, procs.c,
procs.h, ramap.c, read.c, root.c, srcprop.c, srcprop.h,
strports.c, symbols.c, tags.h, throw.c, unif.c, variable.c,
vports.c: Cleaned up use of pairs: Don't make any special
assumptions about the internal structure of selectors and
mutators: SCM_CXR (<e1>) = <e2> --> SCM_SETCXR (<e1>, <e2>),
SCM_CXR (<e1>) &= <e2> --> SCM_SETAND_CXR (<e1>, <e2>) etc.
(Among other things, this change makes it easier to build Guile
with certain compilers which have problems with casted lvalues.)
Diffstat (limited to 'libguile/pairs.h')
-rw-r--r-- | libguile/pairs.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libguile/pairs.h b/libguile/pairs.h index 9cbca3541..4b7af0b26 100644 --- a/libguile/pairs.h +++ b/libguile/pairs.h @@ -101,8 +101,16 @@ typedef SCM huge *SCMPTR; #define SCM_CAR(x) (((scm_cell *)(SCM2PTR(x)))->car) #define SCM_CDR(x) (((scm_cell *)(SCM2PTR(x)))->cdr) #define SCM_GCCDR(x) (~1L & SCM_CDR(x)) -#define SCM_SETCDR(x, v) SCM_CDR(x) = (SCM)(v) -#define SCM_SETCAR(x, v) SCM_CAR(x) = (SCM)(v) +#define SCM_SETCAR(x, v) (SCM_CAR(x) = (SCM)(v)) +#define SCM_SETCDR(x, v) (SCM_CDR(x) = (SCM)(v)) + +#define SCM_CARLOC(x) (&SCM_CAR (x)) +#define SCM_CDRLOC(x) (&SCM_CDR (x)) + +#define SCM_SETAND_CAR(x, y) (SCM_CAR (x) &= (y)) +#define SCM_SETAND_CDR(x, y) (SCM_CDR (x) &= (y)) +#define SCM_SETOR_CAR(x, y) (SCM_CAR (x) |= (y)) +#define SCM_SETOR_CDR(x, y) (SCM_CDR (x) |= (y)) #define SCM_CAAR(OBJ) SCM_CAR (SCM_CAR (OBJ)) #define SCM_CDAR(OBJ) SCM_CDR (SCM_CAR (OBJ)) |