home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Assembler / dse-src3.dms / in.adf / Source / PeanoRoutines / peano_routines.lha / peano_routines.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-06  |  1.4 KB  |  44 lines

  1. /* Standard include file with lots of generally useful stuff */
  2. /* by Gary Oberbrunner */
  3.  
  4. #define min(x,y) ((x) < (y) ? (x) : (y))
  5. #define max(x,y) ((x) > (y) ? (x) : (y))
  6. #define clamp(x, mn, mx) (((x) <= (mn)) ? (mn) : (((x) >= (mx)) ? (mx) : (x)))
  7.  
  8. #define SECURITY
  9. #ifdef SECURITY
  10. #define ASSERT(exp) { if (!(exp)) { fprintf(stderr,\
  11.     "Assertion error: %s, line %d. Assertion exp failed.\n",\
  12.     __FILE__, __LINE__);\
  13.     exit(69); } }
  14. #else
  15. #define ASSERT(exp)
  16. #endif
  17.  
  18. #define dbug0(str) \
  19.     if (debug) fprintf(stderr, str);
  20. #define dbug1(str, arg1) \
  21.     if (debug) fprintf(stderr, str, arg1);
  22. #define dbug2(str, arg1, arg2) \
  23.     if (debug) fprintf(stderr, str, arg1, arg2);
  24. #define dbug3(str, arg1, arg2, arg3) \
  25.     if (debug) fprintf(stderr, str, arg1, arg2, arg3);
  26. #define dbug4(str, arg1, arg2, arg3, arg4) \
  27.     if (debug) fprintf(stderr, str, arg1, arg2, arg3, arg4);
  28.  
  29. extern char *malloc();
  30. /*
  31.  * NEW is a macro to malloc 'n' new variables of type 'type'.
  32.  */
  33. #define NEW(var, type, num) \
  34.     if ((var = (type *) malloc((num) * sizeof(type)))==NULL) \
  35.     {    fprintf(stderr,\
  36.         "ERROR: Out of memory.\nLast request:\n");\
  37.     fprintf(stderr,\
  38.         "\tNumber: num\n\tType  : type\n\tName  : var.\n");\
  39.     fprintf(stderr,"File %s, line %d\n", __FILE__, __LINE__);\
  40.     fprintf(stderr,\
  41.     "\tTotal requested: num=%d x sizeof(type)=%d\n\t =%d bytes.\n",\
  42.         num, sizeof(type), (num) * sizeof(type));\
  43.     exit(99); }
  44.