diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-01-30 16:46:48 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-01-30 16:47:18 +0100 |
commit | ec417ccc276f245382e1dc3c7b0599a878160193 (patch) | |
tree | 68927e83b77b0379e1f759859c25f4fc90548551 /src | |
parent | 50add2909c2e4b13a04d285b058b1c2270137656 (diff) |
util: add u32ctz() call for determining ctz of uint32_t
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/util.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/shared/util.h b/src/shared/util.h index 117855de81..e4de4728bd 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) { |