util.h 439 B

1234567891011121314151617181920
  1. /* See LICENSE file for copyright and license details. */
  2. #ifndef MAX
  3. #define MAX(A, B) ((A) > (B) ? (A) : (B))
  4. #endif
  5. #ifndef MIN
  6. #define MIN(A, B) ((A) < (B) ? (A) : (B))
  7. #endif
  8. #define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B))
  9. #ifdef _DEBUG
  10. #define DEBUG(...) fprintf(stderr, __VA_ARGS__)
  11. #else
  12. #define DEBUG(...)
  13. #endif
  14. void die(const char *fmt, ...);
  15. void *ecalloc(size_t nmemb, size_t size);