added a few useful macros
This commit is contained in:
parent
73231a29d7
commit
d7cb283e44
@ -628,6 +628,15 @@ typedef struct moo_t moo_t;
|
|||||||
#define MOO_TYPE_MIN(type) \
|
#define MOO_TYPE_MIN(type) \
|
||||||
((MOO_TYPE_IS_SIGNED(type)? MOO_TYPE_SIGNED_MIN(type): MOO_TYPE_UNSIGNED_MIN(type)))
|
((MOO_TYPE_IS_SIGNED(type)? MOO_TYPE_SIGNED_MIN(type): MOO_TYPE_UNSIGNED_MIN(type)))
|
||||||
|
|
||||||
|
/* round up a positive integer x to the nearst multiple of y */
|
||||||
|
#define MOO_ALIGN(x,y) ((((x) + (y) - 1) / (y)) * (y))
|
||||||
|
|
||||||
|
/* round up a positive integer x to the nearst multiple of y where
|
||||||
|
* y must be a multiple of a power of 2*/
|
||||||
|
#define MOO_ALIGN_POW2(x,y) ((((x) + (y) - 1)) & ~((y) - 1))
|
||||||
|
|
||||||
|
#define MOO_IS_UNALIGNED_POW2(x,y) ((x) & ((y) - 1))
|
||||||
|
#define MOO_IS_ALIGNED_POW2(x,y) (!MOO_IS_UNALIGNED_POW2(x,y))
|
||||||
|
|
||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
* COMPILER FEATURE TEST MACROS
|
* COMPILER FEATURE TEST MACROS
|
||||||
|
@ -102,8 +102,6 @@
|
|||||||
# define MOO_MEMCMP(dst,src,size) memcmp(dst,src,size)
|
# define MOO_MEMCMP(dst,src,size) memcmp(dst,src,size)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MOO_ALIGN(x,y) ((((x) + (y) - 1) / (y)) * (y))
|
|
||||||
|
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
/* CLASS SPEC ENCODING */
|
/* CLASS SPEC ENCODING */
|
||||||
@ -113,7 +111,7 @@
|
|||||||
* The spec field of a class object encodes the number of the fixed part
|
* The spec field of a class object encodes the number of the fixed part
|
||||||
* and the type of the indexed part. The fixed part is the number of
|
* and the type of the indexed part. The fixed part is the number of
|
||||||
* named instance variables. If the spec of a class is indexed, the object
|
* named instance variables. If the spec of a class is indexed, the object
|
||||||
* of the class can be i nstantiated with the size of the indexed part.
|
* of the class can be instantiated with the size of the indexed part.
|
||||||
*
|
*
|
||||||
* For example, on a platform where sizeof(moo_oow_t) is 4,
|
* For example, on a platform where sizeof(moo_oow_t) is 4,
|
||||||
* the layout of the spec field of a class as an OOP value looks like this:
|
* the layout of the spec field of a class as an OOP value looks like this:
|
||||||
|
Loading…
Reference in New Issue
Block a user