24#define CACHE_LINE_DEFAULT      128 
   25#define CORES_DEFAULT           1 
   27#include <freeradius-devel/util/hw.h> 
   28#include <freeradius-devel/util/syserror.h> 
   29#include <freeradius-devel/util/strerror.h> 
   31#if defined(__APPLE__) || defined(__FreeBSD__) 
   32#include <sys/sysctl.h> 
   36        size_t cache_line_size_len      = 
sizeof(cache_line_size);
 
   38        sysctlbyname(
"hw.cachelinesize", &cache_line_size, &cache_line_size_len, 0, 0);
 
   40        return cache_line_size;
 
   46        size_t num_cores_len            = 
sizeof(num_cores);
 
   48        sysctlbyname(
"hw.physicalcpu", &num_cores, &num_cores_len, 0, 0);
 
   53#elif defined(__linux__) 
   61        file = fopen(
"/sys/devices/system/cpu/cpu0/cache/index0/coherency_cache_line_size", 
"r");
 
   63                if (fscanf(
file, 
"%d", &cache_line_size) != 1) {
 
   69        return cache_line_size;
 
   79        for (lcores = 0;;lcores++) {
 
   82                snprintf(path, 
sizeof(path), 
"/sys/devices/system/cpu/cpu%u/topology/thread_siblings_list", lcores);
 
   84                cpu = fopen(path, 
"r");
 
   87                while (fscanf(cpu, 
"%[0-9]", 
buff)) {
 
   89                        if (fgetc(cpu) != 
',') 
break;
 
  101        if (
unlikely((tsibs == 0) || (lcores == 0) || (lcores > tsibs))) {
 
  106#ifdef STATIC_ANALYZER 
  110        if ((tsibs / lcores) == 0) 
return 0;
 
  113        return lcores / (tsibs / lcores);
 
size_t fr_hw_cache_line_size(void)
#define CACHE_LINE_DEFAULT
uint32_t fr_hw_num_cores_active(void)
static char buff[sizeof("18446744073709551615")+3]
PUBLIC int snprintf(char *string, size_t length, char *format, va_alist)
char const * fr_syserror(int num)
Guaranteed to be thread-safe version of strerror.
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.