#include <sys/time.h>
u_int32_t strtox(char *src, char **end);
+u_int64_t strtox64(char *src, char **end);
#define atox(x) strtox((x),NULL)
char* xtostr(u_int32_t x);
+char* x64tostr(u_int64_t x);
double timediff(struct timeval *begin, struct timeval *end);
double elapsedtime(struct timeval *begin);
#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), (LEN))
-#define INTALIGN(LEN) TYPEALIGN(sizeof(int32), (LEN))
-#define MAXALIGN(LEN) TYPEALIGN(sizeof(int64), (LEN))
+#define SHORTALIGN(LEN) TYPEALIGN(sizeof(int16_t), (LEN))
+#define INTALIGN(LEN) TYPEALIGN(sizeof(int32_t), (LEN))
+#define MAXALIGN(LEN) TYPEALIGN(sizeof(int64_t), (LEN))
#define PTRALIGN(LEN) TYPEALIGN(sizeof(void*), (LEN))
#endif