7 #if defined(__WATCOMC__) || defined(_WIN32) || defined(__DJGPP__)
14 #define PACKED __attribute__((packed))
20 /* Non-failing versions of malloc/calloc/realloc. They never return 0, they call
21 * demo_abort on failure. Use the macros, don't call the *_impl functions.
23 #define malloc_nf(sz) malloc_nf_impl(sz, __FILE__, __LINE__)
24 void *malloc_nf_impl(size_t sz, const char *file, int line);
25 #define calloc_nf(n, sz) calloc_nf_impl(n, sz, __FILE__, __LINE__)
26 void *calloc_nf_impl(size_t num, size_t sz, const char *file, int line);
27 #define realloc_nf(p, sz) realloc_nf_impl(p, sz, __FILE__, __LINE__)
28 void *realloc_nf_impl(void *p, size_t sz, const char *file, int line);
29 #define strdup_nf(s) strdup_nf_impl(s, __FILE__, __LINE__)
30 char *strdup_nf_impl(const char *s, const char *file, int line);
32 int match_prefix(const char *str, const char *prefix);
35 #if (__STDC_VERSION__ >= 199901) || defined(__GNUC__)
38 #define INLINE __inline
42 #if defined(__i386__) || defined(__386__) || defined(MSDOS)
44 /* fast conversion of double -> 32bit int
46 * - http://chrishecker.com/images/f/fb/Gdmfp.pdf
47 * - http://stereopsis.com/FPU.html#convert
49 static INLINE int32_t cround64(double val)
51 val += 6755399441055744.0;
52 return *(int32_t*)&val;
55 #define cround64(x) ((int32_t)(x))