home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / c / sozobon / sozlib15.zoo / sozdistr / include / xdlibs / macros.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-03  |  723 b   |  31 lines

  1. /*
  2.  * @(#)macros.h, XdLibs, SozobonX
  3.  *
  4.  * commonly useful macros
  5.  */
  6.  
  7. #ifndef    MACROS_H
  8. #define    MACROS_H
  9.  
  10. /* absolute value for any type of number */
  11. #ifndef abs
  12. #define    abs(x)        ((x)<0?(-(x)):(x))
  13. #endif
  14.  
  15. /* maximum and minumum for any type of number */
  16. #define max(x,y)       (((x)>(y))?(x):(y))
  17. #define    min(x,y)       (((x)<(y))?(x):(y))
  18.  
  19. /* swap any objects which can be XORed */
  20. #define    swap(a,b)    ((a)=(a)^((b)=(b)^((a)=(a)^(b))))
  21.  
  22. /*pointer to lo and hi byte of a word */
  23. #define    lobyte(x)    (((unsigned char *)&(x))[1])
  24. #define    hibyte(x)    (((unsigned char *)&(x))[0])
  25.  
  26. /*pointer to lo and hi word of a long */
  27. #define    loword(x)    (((unsigned int *)&(x))[1])
  28. #define    hiword(x)    (((unsigned int *)&(x))[0])
  29.  
  30. #endif     /* MACROS_H    */
  31.