35 lines
710 B
C++
35 lines
710 B
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <cstring>
|
|
#include <immintrin.h>
|
|
|
|
#define DISALLOW_EVIL_CONSTRUCTORS(TypeName) \
|
|
TypeName(const TypeName &) = delete; \
|
|
void operator=(const TypeName &) = delete
|
|
|
|
#define UNUSED __attribute__((unused))
|
|
|
|
constexpr static unsigned long S2NS = 1000000000UL;
|
|
constexpr static unsigned long S2US = 1000000UL;
|
|
constexpr static unsigned long MS2NS = 1000000UL;
|
|
|
|
constexpr static int NEXT_CPU_NULL = -1;
|
|
|
|
static inline int
|
|
cmask_get_next_cpu(uint64_t *mask)
|
|
{
|
|
int ffs = ffsll(*mask);
|
|
*mask &= ~(1ul << (ffs - 1));
|
|
return ffs - 1;
|
|
}
|
|
|
|
static inline int
|
|
cmask_get_num_cpus(const uint64_t mask)
|
|
{
|
|
return _mm_popcnt_u64(mask);
|
|
}
|
|
|
|
#define ATTR_UNUSED __attribute__((unused))
|
|
|