X-Git-Url: https://www.kengrimes.com/gitweb/?p=henge%2Fapc.git;a=blobdiff_plain;f=src%2Fhenge.h;fp=src%2Fhenge.h;h=4f617339d07bf97d0b28b83b6a5871bbbfe67a83;hp=0000000000000000000000000000000000000000;hb=f2a688cfd74095b79151a34e5316910c053e1391;hpb=92a90286c61461f1de3d199d887fcb1951dca835 diff --git a/src/henge.h b/src/henge.h new file mode 100644 index 0000000..4f61733 --- /dev/null +++ b/src/henge.h @@ -0,0 +1,42 @@ +/*!@file + \brief HENGE Memory Definition in common with STON Asset Packages + \details C Aligned memory structures used to define datatypes in the STON + Asset Package format, used for reading asset packages as runtime + memory. + \author Ken Grimes + \date Feb 2017 + ----------------------------------------------------------------------------*/ +#ifndef _HENGE_H_ +#define _HENGE_H_ + +/* Henge Generic Hashtable + + Hashtables are stored as dynamically sized two dimensional arrays, whose + columns are provided, and whose rows, and sizes, are derived. + + ht_size = header.ht_columns << header.ht_2pow; + ht_rows = 0x1 << header.ht_2pow; + + All generic hashtables in henge must have a power-of-two number of rows. An + ht_columns value that is also a power-of-two will result in a power-of-two + sized memory imprint for the structure, making it easy to page align. + + Elements in the columns may be of any arbitrary size. + + typedef uint32_t my_ht_type; + ht_bytes = ht_size * sizeof(my_ht_type); +*/ +struct hng_ht_header_t +{ uint16_t ht_columns; + uint8_t ht_2pow, ht_flags; +}; + +#define hng_ht_size(_HEADER) ((_HEADER)->ht_columns << (_HEADER)->ht_2pow) +#define hng_ht_rows(_HEADER) (0x1 << (_HEADER)->ht_2pow) +#define hng_ht_cols(_HEADER) (_HEADER->ht_columns) +#define hng_ht_start(_HEADER) (_HEADER + sizeof(*_HEADER)) +#define hng_ht_array(_HEADER,_UNIT) ((_UNIT*)hng_ht_start(_HEADER)) +#define hng_ht_bytes(_HEADER,_UNIT) (hng_ht_size(_HEADER) * sizeof(_UNIT)) +#define hng_ht_2bytes(_HEADER,_UNIT2POW) (hng_ht_size(_HEADER) << _UNIT2POW) + +#endif //_HENGE_H_