areadlink
base64
bind
-bitrotate
byteswap
c-ctype
c-strcase
close
connect
configmake
-count-leading-zeros
-count-one-bits
dirname-lgpl
environ
execinfo
fcntl
fcntl-h
fdatasync
-ffs
-ffsl
fnmatch
fsync
getaddrinfo
#include <config.h>
-#include <strings.h>
#include <unistd.h>
#include "capabilities.h"
virBufferAddLit(buf, "<power_management>\n");
virBufferAdjustIndent(buf, 2);
while (pm) {
- int bit = ffs(pm) - 1;
+ int bit = __builtin_ffs(pm) - 1;
virBufferAsprintf(buf, "<%s/>\n",
virCapsHostPMTargetTypeToString(bit));
pm &= ~(1U << bit);
#include "virstoragefile.h"
#include "virfile.h"
#include "virbitmap.h"
-#include "count-one-bits.h"
#include "secret_conf.h"
#include "netdev_vport_profile_conf.h"
#include "netdev_bandwidth_conf.h"
#include "internal.h"
#include "virbitmap.h"
#include "virbuffer.h"
-#include "count-one-bits.h"
#include "datatypes.h"
#include "domain_conf.h"
#include "virlog.h"
#include <stdint.h>
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
#if STATIC_ANALYSIS
# undef NDEBUG /* Don't let a prior NDEBUG definition cause trouble. */
#include "c-strcase.h"
#include "ignore-value.h"
-#include "count-leading-zeros.h"
/* String equality tests, suggested by Jim Meyering. */
#define STREQ(a, b) (strcmp(a, b) == 0)
} while (0)
+/* Count leading zeros in an unsigned int.
+ *
+ * Wrapper needed as __builtin_clz is undefined if value is zero
+ */
+#define VIR_CLZ(value) \
+ (value ? __builtin_clz(value) : (8 * sizeof(unsigned)))
/* divide value by size, rounding up */
#define VIR_DIV_UP(value, size) (((value) + (size) - 1) / (size))
* for 0 or number more than 2^31 (for 32bit unsigned int). */
#define VIR_ROUND_UP_POWER_OF_TWO(value) \
((value) > 0 && (value) <= 1U << (sizeof(unsigned int) * 8 - 1) ? \
- 1U << (sizeof(unsigned int) * 8 - count_leading_zeros((value) - 1)) : 0)
+ 1U << (sizeof(unsigned int) * 8 - VIR_CLZ((value) - 1)) : 0)
/* Specific error values for use in forwarding programs such as
#include "virconf.h"
#include "viralloc.h"
#include "viruuid.h"
-#include "count-one-bits.h"
#include "xenxs_private.h"
#include "domain_conf.h"
#include "virstring.h"
#include "viralloc.h"
#include "virbuffer.h"
#include "c-ctype.h"
-#include "count-one-bits.h"
#include "virstring.h"
#include "virutil.h"
#include "virerror.h"
if (bits == 0)
return -1;
- return ffsl(bits) - 1 + nl * VIR_BITMAP_BITS_PER_UNIT;
+ return __builtin_ffsl(bits) - 1 + nl * VIR_BITMAP_BITS_PER_UNIT;
}
if (bits == 0)
return -1;
- return ffsl(bits) - 1 + nl * VIR_BITMAP_BITS_PER_UNIT;
+ return __builtin_ffsl(bits) - 1 + nl * VIR_BITMAP_BITS_PER_UNIT;
}
size_t ret = 0;
for (i = 0; i < bitmap->map_len; i++)
- ret += count_one_bits_l(bitmap->map[i]);
+ ret += __builtin_popcountl(bitmap->map[i]);
return ret;
}
virCgroupV2GetAnyController(virCgroupPtr group)
{
/* The least significant bit is position 1. */
- return ffs(group->unified.controllers) - 1;
+ return __builtin_ffs(group->unified.controllers) - 1;
}
#include <config.h>
#include "virhashcode.h"
-#include "bitrotate.h"
+
+static uint32_t rotl32(uint32_t x, int8_t r)
+{
+ return (x << r) | (x >> (32 - r));
+}
/* slower than original but handles platforms that do only aligned reads */
static inline uint32_t getblock(const uint8_t *p, int i)
#include "virhostcpupriv.h"
#include "physmem.h"
#include "virerror.h"
-#include "count-one-bits.h"
#include "intprops.h"
#include "virarch.h"
#include "virfile.h"
#include "virhostmem.h"
#include "physmem.h"
#include "virerror.h"
-#include "count-one-bits.h"
#include "virarch.h"
#include "virfile.h"
#include "virtypedparam.h"
#include <inttypes.h>
#include <math.h>
-#include <strings.h>
#include <time.h>
#include <fcntl.h>
#include <sys/stat.h>
#include "virrandom.h"
#include "virthread.h"
-#include "count-one-bits.h"
#include "virutil.h"
#include "virerror.h"
#include "virfile.h"
uint32_t virRandomInt(uint32_t max)
{
if ((max & (max - 1)) == 0)
- return virRandomBits(ffs(max) - 1);
+ return virRandomBits(__builtin_ffs(max) - 1);
double val = virRandom();
return val * max;
return NULL;
/* Grab least-significant set bit */
- i = ffsl(*opts_need_arg) - 1;
+ i = __builtin_ffsl(*opts_need_arg) - 1;
opt = &cmd->opts[i];
if (opt->type != VSH_OT_ARGV)
*opts_need_arg &= ~(1ULL << i);