diff --git a/bootstrap.conf b/bootstrap.conf index 126e1e80a..43924c5b1 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -64,7 +64,6 @@ gnulib_modules=" config-h configmake copy-file-range - count-leading-zeros crypto/md5 crypto/sha1 crypto/sha256 @@ -247,6 +246,7 @@ gnulib_modules=" stat-size stat-time stdbool + stdc_leading_zeros stdckdint stdlib-safer stpcpy diff --git a/gl/lib/randperm.c b/gl/lib/randperm.c index 9903966e4..50328cd9a 100644 --- a/gl/lib/randperm.c +++ b/gl/lib/randperm.c @@ -22,28 +22,14 @@ #include "randperm.h" #include +#include #include #include #include "attribute.h" -#include "count-leading-zeros.h" #include "hash.h" #include "xalloc.h" -/* Return the floor of the log base 2 of N. If N is zero, return -1. */ - -ATTRIBUTE_CONST static int -floor_lg (size_t n) -{ - static_assert (SIZE_WIDTH <= ULLONG_WIDTH); - return (n == 0 ? -1 - : SIZE_WIDTH <= UINT_WIDTH - ? UINT_WIDTH - 1 - count_leading_zeros (n) - : SIZE_WIDTH <= ULONG_WIDTH - ? ULONG_WIDTH - 1 - count_leading_zeros_l (n) - : ULLONG_WIDTH - 1 - count_leading_zeros_ll (n)); -} - /* Return an upper bound on the number of random bytes needed to generate the first H elements of a random permutation of N elements. H must not exceed N. */ @@ -53,7 +39,7 @@ randperm_bound (size_t h, size_t n) { /* Upper bound on number of bits needed to generate the first number of the permutation. */ - uintmax_t lg_n = floor_lg (n) + 1; + uintmax_t lg_n = stdc_bit_width (n) + 1; /* Upper bound on number of bits needed to generated the first H elements. */ uintmax_t ar = lg_n * h; diff --git a/gl/modules/randperm b/gl/modules/randperm index 5bb5faefc..ae54bf7ab 100644 --- a/gl/modules/randperm +++ b/gl/modules/randperm @@ -7,8 +7,8 @@ lib/randperm.h Depends-on: assert-h -count-leading-zeros randint +stdc_bit_width stdint xalloc hash diff --git a/src/ioblksize.h b/src/ioblksize.h index dcf94fc60..d6aabebeb 100644 --- a/src/ioblksize.h +++ b/src/ioblksize.h @@ -17,7 +17,7 @@ /* Include this file _after_ system headers if possible. */ /* sys/stat.h and minmax.h will already have been included by system.h. */ -#include "count-leading-zeros.h" +#include #include "stat-size.h" @@ -94,7 +94,7 @@ io_blksize (struct stat const *st) power of two when the reported blocksize is not a power of two. */ if (S_ISREG (st->st_mode) && blocksize & (blocksize - 1)) { - int leading_zeros = count_leading_zeros_ll (blocksize); + int leading_zeros = stdc_leading_zeros_ull (blocksize); if (IDX_MAX < ULLONG_MAX || leading_zeros) { unsigned long long power = 1ull << (ULLONG_WIDTH - leading_zeros);