chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
timedated: use builtins for integer log and exp
[elogind.git]
/
src
/
shared
/
util.h
diff --git
a/src/shared/util.h
b/src/shared/util.h
index c596d795d3666d14e92741fb6c5bc32d484c1ffa..7752b1e3dff660e265015ecda90b2ce8c39a65a1 100644
(file)
--- 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;
}