diff options
author | Dirk Herrmann <dirk@dirk-herrmanns-seiten.de> | 2000-03-24 08:55:14 +0000 |
---|---|---|
committer | Dirk Herrmann <dirk@dirk-herrmanns-seiten.de> | 2000-03-24 08:55:14 +0000 |
commit | 0cbaaf0b155ab10e85f8f9ec75fbecd2e7db0d2b (patch) | |
tree | dce84d16e79fbc69cb9b3010c5b6abfc3f38afb1 /libguile/pairs.h | |
parent | d87d36506d54b68d513f51b1f8fa19ab10a3926a (diff) | |
download | guile-0cbaaf0b155ab10e85f8f9ec75fbecd2e7db0d2b.tar.gz |
Added a set of low level macros for accessing cell entries.
Diffstat (limited to 'libguile/pairs.h')
-rw-r--r-- | libguile/pairs.h | 45 |
1 files changed, 33 insertions, 12 deletions
diff --git a/libguile/pairs.h b/libguile/pairs.h index 8c36a2804..b14532b0d 100644 --- a/libguile/pairs.h +++ b/libguile/pairs.h @@ -58,6 +58,39 @@ typedef struct scm_cell SCM cdr; } scm_cell; + +/* Low level cell data accessing macros: + */ + +#define SCM_CELL_WORD(x, n) (SCM_UNPACK (((SCM *) SCM2PTR (x))[n])) +#define SCM_CELL_WORD_0(x) SCM_CELL_WORD (x, 0) +#define SCM_CELL_WORD_1(x) SCM_CELL_WORD (x, 1) +#define SCM_CELL_WORD_2(x) SCM_CELL_WORD (x, 2) +#define SCM_CELL_WORD_3(x) SCM_CELL_WORD (x, 3) + +#define SCM_CELL_OBJECT(x, n) (((SCM *) SCM2PTR (x))[n]) +#define SCM_CELL_OBJECT_0(x) SCM_CELL_OBJECT (x, 0) +#define SCM_CELL_OBJECT_1(x) SCM_CELL_OBJECT (x, 1) +#define SCM_CELL_OBJECT_2(x) SCM_CELL_OBJECT (x, 2) +#define SCM_CELL_OBJECT_3(x) SCM_CELL_OBJECT (x, 3) + +#define SCM_SET_CELL_WORD(x, n, v) ((((SCM *) SCM2PTR (x))[n]) = SCM_PACK (v)) +#define SCM_SET_CELL_WORD_0(x, v) SCM_SET_CELL_WORD (x, 0, v) +#define SCM_SET_CELL_WORD_1(x, v) SCM_SET_CELL_WORD (x, 1, v) +#define SCM_SET_CELL_WORD_2(x, v) SCM_SET_CELL_WORD (x, 2, v) +#define SCM_SET_CELL_WORD_3(x, v) SCM_SET_CELL_WORD (x, 3, v) + +#define SCM_SET_CELL_OBJECT(x, n, v) ((((SCM *) SCM2PTR (x))[n]) = v) +#define SCM_SET_CELL_OBJECT_0(x, v) SCM_SET_CELL_OBJECT (x, 0, v) +#define SCM_SET_CELL_OBJECT_1(x, v) SCM_SET_CELL_OBJECT (x, 1, v) +#define SCM_SET_CELL_OBJECT_2(x, v) SCM_SET_CELL_OBJECT (x, 2, v) +#define SCM_SET_CELL_OBJECT_3(x, v) SCM_SET_CELL_OBJECT (x, 3, v) + + +#define SCM_CELL_TYPE(x) SCM_CELL_WORD_0 (x) +#define SCM_SET_CELL_TYPE(x, t) SCM_SET_CELL_WORD_0 (x, t) + + /* SCM_PTR_LT defines how to compare two SCM_CELLPTRs (which may not be in the * same scm_array). SCM_CELLPTR is a pointer to a cons cell which may be * compared or differenced. SCMPTR is used for stack bounds. @@ -155,20 +188,8 @@ typedef SCM huge *SCMPTR; /* Multi-cells */ -#define SCM_CELL_WORD(x, n) (((SCM *) (SCM2PTR (x)))[n]) -#define SCM_SET_CELL_WORD(x, n, v) (SCM_CELL_WORD (x, n) = (SCM) (v)) #define SCM_CELL_WORD_LOC(x, n) (&SCM_CELL_WORD (x, n)) -#define SCM_CELL_WORD0(x) SCM_CELL_WORD (x, 0) -#define SCM_CELL_WORD1(x) SCM_CELL_WORD (x, 1) -#define SCM_CELL_WORD2(x) SCM_CELL_WORD (x, 2) -#define SCM_CELL_WORD3(x) SCM_CELL_WORD (x, 3) - -#define SCM_SET_CELL_WORD0(x, v) SCM_SET_CELL_WORD(x, 0, v) -#define SCM_SET_CELL_WORD1(x, v) SCM_SET_CELL_WORD(x, 1, v) -#define SCM_SET_CELL_WORD2(x, v) SCM_SET_CELL_WORD(x, 2, v) -#define SCM_SET_CELL_WORD3(x, v) SCM_SET_CELL_WORD(x, 3, v) - /* the allocated thing: The car of newcells are set to scm_tc16_allocated to avoid the fragile state of newcells wrt the gc. If it stays as a freecell, any allocation afterwards could |