]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/lib.h
changed OFFSETOF again
[libucw.git] / ucw / lib.h
index c473343ce5338af7466ca703c81ad63b091db098..99b848e348c4d1cd0ce3aa1cab85d2f20d3bf9ee 100644 (file)
--- a/ucw/lib.h
+++ b/ucw/lib.h
@@ -20,7 +20,7 @@
 
 #define CHECK_PTR_TYPE(x, type) ((x)-(type)(x) + (type)(x))
 #define PTR_TO(s, i) &((s*)0)->i
-#define OFFSETOF(s, i) ((unsigned int) PTR_TO(s, i))
+#define OFFSETOF(s, i) ((unsigned int) (uintptr_t) PTR_TO(s, i))
 #define SKIP_BACK(s, i, p) ((s *)((char *)p - OFFSETOF(s, i)))
 #define ALIGN_TO(s, a) (((s)+a-1)&~(a-1))
 #define ALIGN_PTR(p, s) ((uintptr_t)(p) % (s) ? (typeof(p))((uintptr_t)(p) + (s) - (uintptr_t)(p) % (s)) : (p))
@@ -43,7 +43,8 @@
 #define COMPARE_LT(x,y) do { if ((x)<(y)) return 1; if ((x)>(y)) return 0; } while(0)
 #define COMPARE_GT(x,y) COMPARE_LT(y,x)
 
-#define        ROL(x, bits) (((x) << (bits)) | ((x) >> (sizeof(uns)*8 - (bits))))      /* Bitwise rotation of an uns to the left */
+#define        ROL(x, bits) (((x) << (bits)) | ((uns)(x) >> (sizeof(uns)*8 - (bits)))) /* Bitwise rotation of an uns to the left */
+#define        ROR(x, bits) (((uns)(x) >> (bits)) | ((x) << (sizeof(uns)*8 - (bits))))
 
 /* GCC Extensions */
 
@@ -154,7 +155,7 @@ timestamp_t get_timestamp(void);
 
 void init_timer(timestamp_t *timer);
 uns get_timer(timestamp_t *timer);
-uns switch_timer(timestamp_t *old, timestamp_t *new);
+uns switch_timer(timestamp_t *oldt, timestamp_t *newt);
 
 /* random.c */
 
@@ -207,7 +208,7 @@ typedef int (*ucw_sighandler_t)(int);       // gets signum, returns nonzero if abort()
 
 void handle_signal(int signum);
 void unhandle_signal(int signum);
-ucw_sighandler_t set_signal_handler(int signum, ucw_sighandler_t new);
+ucw_sighandler_t set_signal_handler(int signum, ucw_sighandler_t newh);
 
 /* bigalloc.c */