summaryrefslogtreecommitdiff
path: root/src/shared/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/util.h')
-rw-r--r--src/shared/util.h6
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;
}