chiark / gitweb /
timedated: use builtins for integer log and exp
[elogind.git] / src / shared / util.h
index e99f8d1123641da0ae4f0e8f4a85d55aad463ffd..7752b1e3dff660e265015ecda90b2ce8c39a65a1 100644 (file)
@@ -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;
 }
@@ -914,3 +920,5 @@ const char *personality_to_string(unsigned long);
 uint64_t physical_memory(void);
 
 char* mount_test_option(const char *haystack, const char *needle);
+
+void hexdump(FILE *f, const void *p, size_t s);