diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-03-14 21:43:56 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-03-14 21:44:20 -0400 |
commit | 8fe90522fb74dd84ff791a7546fee70047672396 (patch) | |
tree | 431a098266bd3ea245a0f019678667a06cc094b0 /src/shared/util.h | |
parent | 40b71e89bae4e51768db4dc50ec64c1e9c96eec4 (diff) |
timedated: use builtins for integer log and exp
Diffstat (limited to 'src/shared/util.h')
-rw-r--r-- | src/shared/util.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/shared/util.h b/src/shared/util.h index c596d795d3..7752b1e3df 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -782,6 +782,12 @@ static inline unsigned u32ctz(uint32_t n) { #endif } +static inline int log2i(int x) { + assert(x > 0); + + return __SIZEOF_INT__ * 8 - __builtin_clz(x) - 1; +} + static inline bool logind_running(void) { return access("/run/systemd/seats/", F_OK) >= 0; } |