6 /* Misc. definitions. */
8 /* Use make DOUBLE=1 in large configurations with counts > 1M
9 * where 24 bits of floating_t mantissa become insufficient. */
11 # define floating_t double
12 # define PRIfloating "%lf"
14 # define floating_t float
15 # define PRIfloating "%f"
18 #define likely(x) __builtin_expect(!!(x), 1)
19 #define unlikely(x) __builtin_expect((x), 0)
22 checked_malloc(size_t size
, char *filename
, unsigned int line
, const char *func
)
24 void *p
= malloc(size
);
26 fprintf(stderr
, "%s:%u: %s: OUT OF MEMORY malloc(%zu)\n",
27 filename
, line
, func
, size
);
34 checked_calloc(size_t nmemb
, size_t size
, char *filename
, unsigned int line
, const char *func
)
36 void *p
= calloc(nmemb
, size
);
38 fprintf(stderr
, "%s:%u: %s: OUT OF MEMORY calloc(%zu, %zu)\n",
39 filename
, line
, func
, nmemb
, size
);
45 #define malloc2(size) checked_malloc((size), __FILE__, __LINE__, __func__)
46 #define calloc2(nmemb, size) checked_calloc((nmemb), (size), __FILE__, __LINE__, __func__)