X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-compat-util.h;h=9f941e42b16d927f738b4911b41344dd2f3ed0da;hb=6d71c1dca4396de545a6c9667b3dcf0c03e42b30;hp=919b7f1ade9cab3c4ba907f9506e3cb518fb9e7f;hpb=cec3f989dab861761ad83e264c3cd8a754e4ace5;p=git.git diff --git a/git-compat-util.h b/git-compat-util.h index 919b7f1ad..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 @@ -175,6 +179,7 @@ extern char *gitbasename(char *); /* General helper functions */ extern void usage(const char *err) NORETURN; extern void die(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2))); +extern void die_errno(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2))); extern int error(const char *err, ...) __attribute__((format (printf, 1, 2))); extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)));