add .gitignore
[tedtools.git] / tools.h
diff --git a/tools.h b/tools.h
index 473e21b..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);
@@ -44,9 +46,13 @@ 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_t), (LEN))
 #define INTALIGN(LEN)                   TYPEALIGN(sizeof(int32_t), (LEN))