home *** CD-ROM | disk | FTP | other *** search
/ Total Destruction / Total_Destruction.iso / addons / Lccwin32.exe / Lccwin32 / lccpub / include / minmax.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-27  |  1.9 KB  |  67 lines

  1. /*  Header : maxmin.h
  2.     Author : Richard A. O'Keefe (ok@goanna.cs.rmit.edu.au)
  3.     Updated: 19907-04-08
  4.     Defines: *max(_,_) and *min(_,_) functions for scalars. 
  5.  
  6.     Note:  if your compiler requires an `inline' keyword other than GCC's
  7.     __inline__ you will need to provide an additional definition.  The
  8.     author would appreciate hearing what change is required.
  9.  
  10.     The prefixes i, u, l, ul, ll, ull, f, d, ld, and p
  11.     stand for int, unsigned, long, unsigned long, long long,
  12.     unsigned long long, float, double, long double, and pointer
  13.     respectively.
  14.  
  15.     Note:  if you want long long, you will have to #define HAS_LONG_LONG.
  16.     That's not in the current ISO C standard, and although 64-bit integers
  17.     will be in C9X, they will probably NOT use 'long long' but will use the
  18.     features in the new <inttypes.h> header instead.
  19.  
  20.     This has been tested under SPARCompiler C 4.2 and GCC 2.7.2
  21.     on a SuperSPARC running Solaris 2.5.
  22.  
  23.     There is no copyright on this file.  There is nothing in it that is not
  24.     obvious to any good C programmer.  Do what you please with it.
  25. */
  26.  
  27. #ifndef    MAXMIN_H_
  28. #define MAXMIN_H_ 1997
  29.  
  30. #ifdef __GNUC__
  31. #define MM(n,r,t) \
  32.     static __inline__ t n(t x, t y) { return x r y ? x : y; }
  33. #else
  34. #define MM(n,r,t) \
  35.     static t n(t x, t y) { return x r y ? x : y; }
  36. #endif
  37.  
  38. MM(pmax,   >, void *)
  39. MM(fmax,   >, float)
  40. MM(dmax,   >, double)
  41. MM(ldmax,  >, long double)
  42. MM(imax,   >, int)
  43. MM(umax,   >, unsigned)
  44. MM(lmax,   >, long)
  45. MM(ulmax,  >, unsigned long)
  46. #ifdef HAS_LONG_LONG
  47. MM(llmax,  >, long long)
  48. MM(ullmax, >, unsigned long long)
  49. #endif
  50.  
  51. MM(pmin,   <, void *)
  52. MM(fmin,   <, float)
  53. MM(dmin,   <, double)
  54. MM(ldmin,  <, long double)
  55. MM(imin,   <, int)
  56. MM(umin,   <, unsigned)
  57. MM(lmin,   <, long)
  58. MM(ulmin,  <, unsigned long)
  59. #ifdef HAS_LONG_LONG
  60. MM(llmin,  <, long long)
  61. MM(ullmin, <, unsigned long long)
  62. #endif
  63.  
  64. #undef    MM
  65. #endif/*MAXMIN_H_*/
  66.  
  67.