home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1994 June / NEBULA_SE.ISO / SourceCode / libcs / include / c.h next >
Encoding:
C/C++ Source or Header  |  1990-12-12  |  3.0 KB  |  87 lines

  1. /*
  2.  * Copyright (c) 1990 Carnegie Mellon University
  3.  * All Rights Reserved.
  4.  * 
  5.  * Permission to use, copy, modify and distribute this software and its
  6.  * documentation is hereby granted, provided that both the copyright
  7.  * notice and this permission notice appear in all copies of the
  8.  * software, derivative works or modified versions, and any portions
  9.  * thereof, and that both notices appear in supporting documentation.
  10.  *
  11.  * THE SOFTWARE IS PROVIDED "AS IS" AND CARNEGIE MELLON UNIVERSITY
  12.  * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  13.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO EVENT
  14.  * SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE FOR ANY SPECIAL, DIRECT,
  15.  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  16.  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  17.  * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  18.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  19.  *
  20.  * Users of this software agree to return to Carnegie Mellon any
  21.  * improvements or extensions that they make and grant Carnegie the
  22.  * rights to redistribute these changes.
  23.  *
  24.  * Export of this software is permitted only after complying with the
  25.  * regulations of the U.S. Deptartment of Commerce relating to the
  26.  * Export of Technical Data.
  27.  */
  28. /*
  29.  * Standard C macros
  30.  *
  31.  **********************************************************************
  32.  * HISTORY
  33.  * $Log:    c.h,v $
  34.  * Revision 1.2  90/12/12  20:55:27  mja
  35.  *     Add copyright/disclaimer for distribution.
  36.  * 
  37.  * 02-Feb-86  Glenn Marcy (gm0w) at Carnegie-Mellon University
  38.  *    Added check to allow multiple or recursive inclusion of this
  39.  *    file.  Added bool enum from machine/types.h for regular users
  40.  *    that want a real boolean type.
  41.  *
  42.  * 29-Dec-85  Glenn Marcy (gm0w) at Carnegie-Mellon University
  43.  *    Also change spacing of MAX and MIN to coincide with that of
  44.  *    sys/param.h.
  45.  *
  46.  * 19-Nov-85  Glenn Marcy (gm0w) at Carnegie-Mellon University
  47.  *    Changed the number of tabs between TRUE, FALSE and their
  48.  *    respective values to match those in sys/types.h.
  49.  *
  50.  * 17-Dec-84  Glenn Marcy (gm0w) at Carnegie-Mellon University
  51.  *    Only define TRUE and FALSE if not defined.  Added caseE macro
  52.  *    for using enumerated types in switch statements.
  53.  *
  54.  * 23-Apr-81  Mike Accetta (mja) at Carnegie-Mellon University
  55.  *    Added "sizeofS" and "sizeofA" macros which expand to the size
  56.  *    of a string constant and array respectively.
  57.  *
  58.  **********************************************************************
  59.  */
  60.  
  61. #ifndef    _C_INCLUDE_
  62. #define    _C_INCLUDE_
  63.  
  64. #define ABS(x) ((x)>=0?(x):-(x))
  65. #define    MIN(a,b) (((a)<(b))?(a):(b))
  66. #define    MAX(a,b) (((a)>(b))?(a):(b))
  67.  
  68. #ifndef    FALSE
  69. #define FALSE    0
  70. #endif    FALSE
  71. #ifndef    TRUE
  72. #define TRUE    1
  73. #endif    TRUE
  74.  
  75. #define    CERROR        (-1)
  76.  
  77. #ifndef    bool
  78. typedef enum    { false = 0, true = 1 } bool;
  79. #endif    bool
  80.  
  81. #define    sizeofS(string)    (sizeof(string) - 1)
  82. #define sizeofA(array)    (sizeof(array)/sizeof(array[0]))
  83.  
  84. #define caseE(enum_type)    case (int)(enum_type)
  85.  
  86. #endif    _C_INCLUDE_
  87.