1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-25 06:03:40 +03:00

basic/util: rename u64log2 to log2u64

u64log2 was strangely named. We even have log2i and log2u right below
in that file.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-11-26 11:40:17 +01:00
parent e6f48be8d4
commit 58c34be864
5 changed files with 12 additions and 12 deletions

View File

@ -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;

View File

@ -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

View File

@ -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)

View File

@ -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]++;

View File

@ -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) {