diff options
author | Daniel Llorens <daniel.llorens@bluewin.ch> | 2014-09-19 14:48:22 +0200 |
---|---|---|
committer | Daniel Llorens <daniel.llorens@bluewin.ch> | 2014-09-30 11:35:08 +0200 |
commit | 65704b982dcc9758d5e5a5452832a43a1ec453d6 (patch) | |
tree | 77ada5ecfccc1323bd0dad928dc0a643829cea64 /libguile/arrays.h | |
parent | ea342aa6f7fd4a03dc0cc4bde8e6746c1daf083e (diff) | |
download | guile-65704b982dcc9758d5e5a5452832a43a1ec453d6.tar.gz |
Pack array dimensions in array object
* libguile/arrays.c (scm_i_make_array): redo object layout.
* libguile/arrays.h (SCM_I_ARRAY_V, SCM_ARRAY_BASE, SCM_I_ARRAY_DIMS):
to match new layout.
(SCM_I_ARRAY_SET_V, SCM_ARRAY_SET_BASE): new setters.
(SCM_I_ARRAY_MEM, scm_i_t_array): unused, remove.
(scm_i_shap2ra, scm_make_typed_array, scm_from_contiguous_typed_array,
scm_from_contiguous_array, scm_make_shared_array, scm_transpose_array,
scm_array_contents): fix uses of SCM_I_ARRAY_V, SCM_ARRAY_BASE as
lvalues.
* libguile/array-map.c (make1array, scm_ramapc): fix uses of
SCM_I_ARRAY_V, SCM_ARRAY_BASE as lvalues.
Diffstat (limited to 'libguile/arrays.h')
-rw-r--r-- | libguile/arrays.h | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/libguile/arrays.h b/libguile/arrays.h index 6045ab65d..5f4059792 100644 --- a/libguile/arrays.h +++ b/libguile/arrays.h @@ -54,23 +54,18 @@ SCM_API SCM scm_list_to_typed_array (SCM type, SCM ndim, SCM lst); /* internal. */ -typedef struct scm_i_t_array -{ - SCM v; /* the contents of the array, e.g., a vector or uniform vector. */ - unsigned long base; -} scm_i_t_array; - #define SCM_I_ARRAY_FLAG_CONTIGUOUS (1 << 0) #define SCM_I_ARRAYP(a) SCM_TYP16_PREDICATE (scm_tc7_array, a) #define SCM_I_ARRAY_NDIM(x) ((size_t) (SCM_CELL_WORD_0 (x)>>17)) #define SCM_I_ARRAY_CONTP(x) (SCM_CELL_WORD_0 (x) & (SCM_I_ARRAY_FLAG_CONTIGUOUS << 16)) -#define SCM_I_ARRAY_MEM(a) ((scm_i_t_array *) SCM_CELL_WORD_1 (a)) -#define SCM_I_ARRAY_V(a) (SCM_I_ARRAY_MEM (a)->v) -#define SCM_I_ARRAY_BASE(a) (SCM_I_ARRAY_MEM (a)->base) -#define SCM_I_ARRAY_DIMS(a) \ - ((scm_t_array_dim *)((char *) SCM_I_ARRAY_MEM (a) + sizeof (scm_i_t_array))) +#define SCM_I_ARRAY_V(a) SCM_CELL_OBJECT_1 (a) +#define SCM_I_ARRAY_BASE(a) ((size_t) SCM_CELL_WORD_2 (a)) +#define SCM_I_ARRAY_DIMS(a) ((scm_t_array_dim *) SCM_CELL_OBJECT_LOC (a, 3)) + +#define SCM_I_ARRAY_SET_V(a, v) SCM_SET_CELL_OBJECT_1(a, v) +#define SCM_I_ARRAY_SET_BASE(a, base) SCM_SET_CELL_WORD_2(a, base) SCM_INTERNAL SCM scm_i_make_array (int ndim); SCM_INTERNAL int scm_i_print_array (SCM array, SCM port, scm_print_state *pstate); |