git://git.onelab.eu
/
sliver-openvswitch.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
util: Make raw_ctz() accept 64-bit integers.
[sliver-openvswitch.git]
/
lib
/
util.c
diff --git
a/lib/util.c
b/lib/util.c
index
9b79c25
..
19abada
100644
(file)
--- a/
lib/util.c
+++ b/
lib/util.c
@@
-889,16
+889,14
@@
log_2_ceil(uint32_t n)
}
/* Returns the number of trailing 0-bits in 'n'. Undefined if 'n' == 0. */
}
/* Returns the number of trailing 0-bits in 'n'. Undefined if 'n' == 0. */
-#if !defined(UINT_MAX) || !defined(UINT32_MAX)
-#error "Someone screwed up the #includes."
-#elif __GNUC__ >= 4 && UINT_MAX == UINT32_MAX
+#if __GNUC__ >= 4
/* Defined inline in util.h. */
#else
int
/* Defined inline in util.h. */
#else
int
-raw_ctz(uint
32
_t n)
+raw_ctz(uint
64
_t n)
{
{
- u
nsigned in
t k;
- int count =
31
;
+ u
int64_
t k;
+ int count =
63
;
#define CTZ_STEP(X) \
k = n << (X); \
#define CTZ_STEP(X) \
k = n << (X); \
@@
-906,6
+904,7
@@
raw_ctz(uint32_t n)
count -= X; \
n = k; \
}
count -= X; \
n = k; \
}
+ CTZ_STEP(32);
CTZ_STEP(16);
CTZ_STEP(8);
CTZ_STEP(4);
CTZ_STEP(16);
CTZ_STEP(8);
CTZ_STEP(4);