chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
50add29
)
util: add u32ctz() call for determining ctz of uint32_t
author
Lennart Poettering
<lennart@poettering.net>
Thu, 30 Jan 2014 15:46:48 +0000
(16:46 +0100)
committer
Lennart Poettering
<lennart@poettering.net>
Thu, 30 Jan 2014 15:47:18 +0000
(16:47 +0100)
src/shared/util.h
patch
|
blob
|
history
diff --git
a/src/shared/util.h
b/src/shared/util.h
index 117855de819933fc173e6e9d9e7073ea00bb8501..e4de4728bdf3b66e69464c52a83ee3913a690e01 100644
(file)
--- a/
src/shared/util.h
+++ b/
src/shared/util.h
@@
-743,7
+743,19
@@
static inline void _reset_umask_(struct _umask_struct_ *s) {
_saved_umask_.quit = true)
static inline unsigned u64log2(uint64_t n) {
_saved_umask_.quit = true)
static inline unsigned u64log2(uint64_t n) {
+#if __SIZEOF_LONG_LONG__ == 8
return (n > 1) ? (unsigned) __builtin_clzll(n) ^ 63U : 0;
return (n > 1) ? (unsigned) __builtin_clzll(n) ^ 63U : 0;
+#else
+#error "Wut?"
+#endif
+}
+
+static inline unsigned u32ctz(uint32_t n) {
+#if __SIZEOF_INT__ == 4
+ return __builtin_ctz(n);
+#else
+#error "Wut?"
+#endif
}
static inline bool logind_running(void) {
}
static inline bool logind_running(void) {