6 /* Misc. definitions. */
8 /* Use make -Dfloating_t=double in large configurations with counts > 1M,
9 * where 24 bits of floating_t mantissa become insufficient. */
11 # define floating_t float
14 #define likely(x) __builtin_expect(!!(x), 1)
15 #define unlikely(x) __builtin_expect((x), 0)
18 checked_malloc(size_t size
, char *filename
, unsigned int line
, const char *func
)
20 void *p
= malloc(size
);
22 fprintf(stderr
, "%s:%u: %s: OUT OF MEMORY malloc(%zu)\n",
23 filename
, line
, func
, size
);
30 checked_calloc(size_t nmemb
, size_t size
, char *filename
, unsigned int line
, const char *func
)
32 void *p
= calloc(nmemb
, size
);
34 fprintf(stderr
, "%s:%u: %s: OUT OF MEMORY calloc(%zu, %zu)\n",
35 filename
, line
, func
, nmemb
, size
);
41 #define malloc2(size) checked_malloc((size), __FILE__, __LINE__, __func__)
42 #define calloc2(nmemb, size) checked_calloc((nmemb), (size), __FILE__, __LINE__, __func__)