1#ifndef LIBNAGIOS_NSUTILS_H_INCLUDED
2#define LIBNAGIOS_NSUTILS_H_INCLUDED
24#define alloc_nr(x) (((x)+16)*3/2)
31static inline int nsu_ispow2(
unsigned int x)
33 return x > 1 ? !(x & (x - 1)) : 0;
43static inline unsigned int rup2pof2(
unsigned int r)
64static inline unsigned int ranged_urand(
unsigned int low,
unsigned int high)
66 return low + (rand() * (1.0 / (RAND_MAX + 1.0)) * (high - low));
91extern const char *
mkstr(
const char *fmt, ...)
92 __attribute__((__format__(__printf__, 1, 2)));
100extern
int tv_delta_msec(const struct timeval *start, const struct timeval *stop);
109extern
float tv_delta_f(const struct timeval *start, const struct timeval *stop);
float tv_delta_f(const struct timeval *start, const struct timeval *stop)
Get timeval delta as seconds.
const char * mkstr(const char *fmt,...) __attribute__((__format__(__printf__
Create a short-lived string in stack-allocated memory The number and size of strings is limited (curr...
int online_cpus(void)
Wrapper for real_online_cpus(), returning 1 in case we can't detect any active cpus.
int real_online_cpus(void)
Get number of online cpus.
const char int tv_delta_msec(const struct timeval *start, const struct timeval *stop)
Calculate the millisecond delta between two timeval structs.