add .gitignore
[tedtools.git] / tools.h
diff --git a/tools.h b/tools.h
index d70d14d..7a4ffe4 100644 (file)
--- a/tools.h
+++ b/tools.h
 #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);
+
+#ifndef offsetof
+#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)  \
+        (((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))
+#define MAXALIGN(LEN)                   TYPEALIGN(sizeof(int64_t), (LEN))
+#define PTRALIGN(LEN)                   TYPEALIGN(sizeof(void*), (LEN))
+#endif
+
 #endif