summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-11-26 11:40:17 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-11-26 15:29:06 +0100
commit58c34be864fd47ebca7d1cc5acfb716a8731bc8c (patch)
treefdafbb0777459c500ba9ec40f2b031c3090ed358 /src
parente6f48be8d4432924028ca0d5ee5289626a2fd7bb (diff)
downloadsystemd-58c34be864fd47ebca7d1cc5acfb716a8731bc8c.tar.gz
basic/util: rename u64log2 to log2u64
u64log2 was strangely named. We even have log2i and log2u right below in that file.
Diffstat (limited to 'src')
-rw-r--r--src/basic/capability-util.c2
-rw-r--r--src/basic/util.h2
-rw-r--r--src/journal/journald-rate-limit.c2
-rw-r--r--src/libsystemd/sd-event/sd-event.c2
-rw-r--r--src/test/test-util.c16
5 files changed, 12 insertions, 12 deletions
diff --git a/src/basic/capability-util.c b/src/basic/capability-util.c
index b31a9cb211..fa74b5b9c6 100644
--- a/src/basic/capability-util.c
+++ b/src/basic/capability-util.c
@@ -336,7 +336,7 @@ int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilities) {
/* Now upgrade the permitted caps we still kept to effective caps */
if (keep_capabilities != 0) {
- cap_value_t bits[u64log2(keep_capabilities) + 1];
+ cap_value_t bits[log2u64(keep_capabilities) + 1];
_cleanup_cap_free_ cap_t d = NULL;
unsigned i, j = 0;
diff --git a/src/basic/util.h b/src/basic/util.h
index b6c51c036e..20bda9bbf3 100644
--- a/src/basic/util.h
+++ b/src/basic/util.h
@@ -22,7 +22,7 @@ void in_initrd_force(bool value);
int on_ac_power(void);
-static inline unsigned u64log2(uint64_t n) {
+static inline unsigned log2u64(uint64_t n) {
#if __SIZEOF_LONG_LONG__ == 8
return (n > 1) ? (unsigned) __builtin_clzll(n) ^ 63U : 0;
#else
diff --git a/src/journal/journald-rate-limit.c b/src/journal/journald-rate-limit.c
index f464b6e0d8..8accd7c7f5 100644
--- a/src/journal/journald-rate-limit.c
+++ b/src/journal/journald-rate-limit.c
@@ -162,7 +162,7 @@ static unsigned burst_modulate(unsigned burst, uint64_t available) {
/* Modulates the burst rate a bit with the amount of available
* disk space */
- k = u64log2(available);
+ k = log2u64(available);
/* 1MB */
if (k <= 20)
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index 8d21627b3f..3c916f2466 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -4218,7 +4218,7 @@ _public_ int sd_event_run(sd_event *e, uint64_t timeout) {
this_run = now(CLOCK_MONOTONIC);
- l = u64log2(this_run - e->last_run_usec);
+ l = log2u64(this_run - e->last_run_usec);
assert(l < ELEMENTSOF(e->delays));
e->delays[l]++;
diff --git a/src/test/test-util.c b/src/test/test-util.c
index 413469a26f..8e8ad05205 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -17,14 +17,14 @@
#include "tests.h"
#include "util.h"
-TEST(u64log2) {
- assert_se(u64log2(0) == 0);
- assert_se(u64log2(8) == 3);
- assert_se(u64log2(9) == 3);
- assert_se(u64log2(15) == 3);
- assert_se(u64log2(16) == 4);
- assert_se(u64log2(1024*1024) == 20);
- assert_se(u64log2(1024*1024+5) == 20);
+TEST(log2u64) {
+ assert_se(log2u64(0) == 0);
+ assert_se(log2u64(8) == 3);
+ assert_se(log2u64(9) == 3);
+ assert_se(log2u64(15) == 3);
+ assert_se(log2u64(16) == 4);
+ assert_se(log2u64(1024*1024) == 20);
+ assert_se(log2u64(1024*1024+5) == 20);
}
TEST(protect_errno) {