Copy new macros from the DFS branch
authorproski <proski@0192ed92-7a03-0410-a25b-9323aeb14dbd>
Thu, 24 Jul 2008 02:05:54 +0000 (02:05 +0000)
committerproski <proski@0192ed92-7a03-0410-a25b-9323aeb14dbd>
Thu, 24 Jul 2008 02:05:54 +0000 (02:05 +0000)
git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@3823 0192ed92-7a03-0410-a25b-9323aeb14dbd

include/compat.h

index a94019b40ca89539e081994a165999532c3a2dd1..f8835ecbd9a35e387a66ae975f85933c0b220eb7 100644 (file)
 
 #define        howmany(x, y)   (((x)+((y)-1))/(y))
 
+/* roundup() and howmany() macros that works both with positive and negative
+ * values. */
+#define roundup_s(x,y) _roundup_s((signed)(x),(signed)(y))
+#define howmany_s(x,y) _howmany_s((signed)(x),(signed)(y))
+#define _roundup_s(x,y)        \
+       ((x) >= 0 ? (((x)+((y)-1))/(y))*(y) : ((x)/(y))*(y))
+#define        _howmany_s(x, y)        \
+       ((x) >= 0 ? (((x)+((y)-1))/(y)) : ((x)/(y)))
+
 /* Bit map related macros. */
 #define        setbit(a,i)     ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
 #define        clrbit(a,i)     ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))