[systemd-commits] src/shared

Lennart Poettering lennart at kemper.freedesktop.org
Thu Jan 30 07:48:00 PST 2014


 src/shared/util.h |   12 ++++++++++++
 1 file changed, 12 insertions(+)

New commits:
commit ec417ccc276f245382e1dc3c7b0599a878160193
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 30 16:46:48 2014 +0100

    util: add u32ctz() call for determining ctz of uint32_t

diff --git a/src/shared/util.h b/src/shared/util.h
index 117855d..e4de472 100644
--- 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) {
+#if __SIZEOF_LONG_LONG__ == 8
         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) {



More information about the systemd-commits mailing list