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