Add a function for retrieving the array element size in bytes.

This information is necessary for various alignment needs and
other low-level memory manipulation. For bit it returns a ratio.
This commit is contained in:
Alexander Gavrilov 2010-08-14 18:08:12 +04:00 committed by Juan Jose Garcia Ripoll
parent 7c7a40e4bd
commit 8ed8a8e807
4 changed files with 14 additions and 0 deletions

View file

@ -671,6 +671,15 @@ ecl_elttype_to_symbol(cl_elttype aet)
return ecl_aet_name[aet];
}
cl_object
si_array_element_type_byte_size(cl_object type) {
cl_elttype aet = ecl_symbol_to_elttype(type);
cl_object size = MAKE_FIXNUM(ecl_aet_size[aet]);
if (aet == aet_bit)
size = ecl_make_ratio(MAKE_FIXNUM(1),MAKE_FIXNUM(CHAR_BIT));
@(return size ecl_elttype_to_symbol(aet))
}
static void *
address_inc(void *address, cl_fixnum inc, cl_elttype elt_type)
{

View file

@ -1928,6 +1928,8 @@ cl_symbols[] = {
{SYS_ "SERIALIZE", SI_ORDINARY, si_serialize, 1, OBJNULL},
{SYS_ "DESERIALIZE", SI_ORDINARY, si_deserialize, 1, OBJNULL},
{EXT_ "ARRAY-ELEMENT-TYPE-BYTE-SIZE", EXT_ORDINARY, si_array_element_type_byte_size, 1, OBJNULL},
#ifdef ECL_SSE2
{EXT_ "SSE-PACK", EXT_ORDINARY, NULL, -1, OBJNULL},
{EXT_ "SSE-PACK-P", EXT_ORDINARY, si_sse_pack_p, 1, OBJNULL},

View file

@ -1928,6 +1928,8 @@ cl_symbols[] = {
{SYS_ "SERIALIZE","si_serialize"},
{SYS_ "DESERIALIZE","si_deserialize"},
{EXT_ "ARRAY-ELEMENT-TYPE-BYTE-SIZE","si_array_element_type_byte_size"},
#ifdef ECL_SSE2
{EXT_ "SSE-PACK",NULL},
{EXT_ "SSE-PACK-P","si_sse_pack_p"},

View file

@ -335,6 +335,7 @@ extern ECL_API cl_object cl_array_total_size(cl_object a);
extern ECL_API cl_object cl_adjustable_array_p(cl_object a);
extern ECL_API cl_object cl_array_displacement(cl_object a);
extern ECL_API cl_object si_array_raw_data(cl_object array);
extern ECL_API cl_object si_array_element_type_byte_size(cl_object type);
extern ECL_API cl_object cl_svref(cl_object x, cl_object index);
extern ECL_API cl_object si_svset(cl_object x, cl_object index, cl_object v);
extern ECL_API cl_object cl_array_has_fill_pointer_p(cl_object a);