git-repack --max-pack-size: write_{object,one}() respect pack limit
[gitweb.git] / git-compat-util.h
index 7ed8b88b1f3cef2562693bbf6d68e2e4cef9465b..6bd8987b2774774fbbd3747a2b571b66ad78727b 100644 (file)
 
 #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
 
+#ifdef __GNUC__
+#define TYPEOF(x) (__typeof__(x))
+#else
+#define TYPEOF(x)
+#endif
+
+#define MSB(x, bits) ((x) & TYPEOF(x)(~0ULL << (sizeof(x) * 8 - (bits))))
+
 /* Approximation of the length of the decimal representation of this type. */
 #define decimal_length(x)      ((int)(sizeof(x) * 2.56 + 0.5) + 1)