X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-compat-util.h;h=9f941e42b16d927f738b4911b41344dd2f3ed0da;hb=f1f523eae99020d58ad6e7a1ef8187569e15c270;hp=9609eaa77f1dad589700bda222e0a81ad4f4d1ee;hpb=ce4f404c6f059abb4988f4549c6e46a3ba0d56ec;p=git.git diff --git a/git-compat-util.h b/git-compat-util.h index 9609eaa77..9f941e42b 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -26,6 +26,7 @@ #endif #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) +#define bitsizeof(x) (CHAR_BIT * sizeof(x)) #ifdef __GNUC__ #define TYPEOF(x) (__typeof__(x)) @@ -33,9 +34,11 @@ #define TYPEOF(x) #endif -#define MSB(x, bits) ((x) & TYPEOF(x)(~0ULL << (sizeof(x) * 8 - (bits)))) +#define MSB(x, bits) ((x) & TYPEOF(x)(~0ULL << (bitsizeof(x) - (bits)))) #define HAS_MULTI_BITS(i) ((i) & ((i) - 1)) /* checks if an integer has more than 1 bit set */ +#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) + /* Approximation of the length of the decimal representation of this type. */ #define decimal_length(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1) @@ -52,7 +55,7 @@ # else # define _XOPEN_SOURCE 500 # endif -#elif !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__USLC__) && !defined(_M_UNIX) +#elif !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__USLC__) && !defined(_M_UNIX) && !defined(sgi) #define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */ #ifndef __sun__ #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */ @@ -62,6 +65,7 @@ #define _GNU_SOURCE 1 #define _BSD_SOURCE 1 #define _NETBSD_SOURCE 1 +#define _SGI_SOURCE 1 #include #include