#define offsetof(type, field) ((int) &((type *)0)->field)
#endif /* offsetof */
+#ifndef lengthof
+#define lengthof(array) (sizeof (array) / sizeof ((array)[0]))
+#endif
+
#ifndef TYPEALIGN
#define TYPEALIGN(ALIGNVAL,LEN) \
- (((long) (LEN) + ((ALIGNVAL) - 1)) & ~((long) ((ALIGNVAL) - 1)))
+ (((uintptr_t) (LEN) + ((ALIGNVAL) - 1)) & ~((uintptr_t) ((ALIGNVAL) - 1)))
#define SHORTALIGN(LEN) TYPEALIGN(sizeof(int16_t), (LEN))
#define INTALIGN(LEN) TYPEALIGN(sizeof(int32_t), (LEN))