summaryrefslogtreecommitdiff
path: root/git-compat-util.h
diff options
context:
space:
mode:
authorPierre Habouzit <madcoder@debian.org>2007-11-07 10:20:27 (GMT)
committerJunio C Hamano <gitster@pobox.com>2007-11-12 00:54:15 (GMT)
commitdb7244bd5be12e389badb9cec621dbbcfa11f59a (patch)
treee9934986eaa77ec543e1809ac35e97c28dc131cd /git-compat-util.h
parent40e2524da9f9fb2806a66a694b9aee722ea3ef0a (diff)
downloadgit-db7244bd5be12e389badb9cec621dbbcfa11f59a.zip
git-db7244bd5be12e389badb9cec621dbbcfa11f59a.tar.gz
git-db7244bd5be12e389badb9cec621dbbcfa11f59a.tar.bz2
parse-options new features.
options flags: ~~~~~~~~~~~~~ PARSE_OPT_NONEG allow the caller to disallow the negated option to exists. option types: ~~~~~~~~~~~~ OPTION_BIT: ORs (or NANDs) a mask. OPTION_SET_INT: force the value to be set to this integer. OPTION_SET_PTR: force the value to be set to this pointer. helper: ~~~~~~ HAS_MULTI_BITS (in git-compat-util.h) is a bit-hack to check if an unsigned integer has more than one bit set, useful to check if conflicting options have been used. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-compat-util.h')
-rw-r--r--git-compat-util.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/git-compat-util.h b/git-compat-util.h
index 7b29d1b..f86b19f 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -20,6 +20,7 @@
#endif
#define MSB(x, bits) ((x) & TYPEOF(x)(~0ULL << (sizeof(x) * 8 - (bits))))
+#define HAS_MULTI_BITS(i) ((i) & ((i) - 1)) /* checks if an integer has more than 1 bit set */
/* Approximation of the length of the decimal representation of this type. */
#define decimal_length(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1)