home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / linux / backup / star-1.3.1.tar.gz / star-1.3.1.tar / star-1.3.1 / include / utypes.h < prev    next >
C/C++ Source or Header  |  1999-07-31  |  4KB  |  199 lines

  1. /* @(#)utypes.h    1.5 99/07/31 Copyright 1997 J. Schilling */
  2. /*
  3.  *    Definitions for some user defined types
  4.  *
  5.  *    Copyright (c) 1997 J. Schilling
  6.  */
  7. /*
  8.  * This program is free software; you can redistribute it and/or modify
  9.  * it under the terms of the GNU General Public License as published by
  10.  * the Free Software Foundation; either version 2, or (at your option)
  11.  * any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  * GNU General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU General Public License
  19.  * along with this program; see the file COPYING.  If not, write to
  20.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23. #ifndef    _UTYPES_H
  24. #define    _UTYPES_H
  25.  
  26. #ifndef    _MCONFIG_H
  27. #include <mconfig.h>
  28. #endif
  29.  
  30. #ifdef    __CHAR_UNSIGNED__    /* GNU GCC define     (dynamic)    */
  31. #ifndef CHAR_IS_UNSIGNED
  32. #define    CHAR_IS_UNSIGNED    /* Sing Schily define (static)    */
  33. #endif
  34. #endif
  35.  
  36. /*
  37.  * Several unsigned cardinal types
  38.  */
  39. typedef    unsigned long    Ulong;
  40. typedef    unsigned int    Uint;
  41. typedef    unsigned short    Ushort;
  42. typedef    unsigned char    Uchar;
  43.  
  44. /*
  45.  * This is a definition for a compiler dependant 64 bit type.
  46.  * It currently is silently a long if the compiler does not
  47.  * support it. Check if this is the right way.
  48.  */
  49. #ifndef    NO_LONGLONG
  50. #    if    defined(HAVE_LONGLONG)
  51. #        define    USE_LONGLONG
  52. #    endif
  53. #endif
  54.  
  55. #ifdef    USE_LONGLONG
  56.  
  57. typedef    long long        Llong;
  58. typedef    unsigned long long    Ullong;
  59.  
  60. #else
  61.  
  62. typedef    long            Llong;
  63. typedef    unsigned long        Ullong;
  64.  
  65. #endif
  66.  
  67. /*
  68.  * The IBM AIX C-compiler seems to be the only compiler on the world
  69.  * which does not allow to use unsigned char bit fields as a hint
  70.  * for packed bit fields. Define a pesical type to avoid warnings.
  71.  * The packed attribute is honored wit unsigned int in this case too.
  72.  */
  73. #ifdef    _AIX
  74.  
  75. typedef unsigned int    Ucbit;
  76.  
  77. #else
  78.  
  79. typedef unsigned char    Ucbit;
  80.  
  81. #endif
  82.  
  83. /*
  84.  * Start inttypes.h emulation.
  85.  *
  86.  * Thanks to Solaris 2.4 and even recent 1999 Linux versions, we
  87.  * cannot use the official UNIX-98 names here. Old Solaris versions
  88.  * define parts of the types in some exotic include files.
  89.  * Linux even defines incompatible types in <sys/types.h>.
  90.  */
  91.  
  92. #ifdef    HAVE_INTTYPES_H
  93. #    include <inttypes.h>
  94. #    define    HAVE_INT64_T
  95. #    define    HAVE_UINT64_T
  96.  
  97. #define    Int8_t            int8_t
  98. #define    Int16_t            int16_t
  99. #define    Int32_t            int32_t
  100. #define    Int64_t            int64_t
  101. #define    UInt8_t            uint8_t
  102. #define    UInt16_t        uint16_t
  103. #define    UInt32_t        uint32_t
  104. #define    UInt64_t        uint64_t
  105.  
  106. #define    Intptr_t        intptr_t
  107. #define    UIntptr_t        uintptr_t
  108.  
  109. #else    /* !HAVE_INTTYPES_H */
  110.  
  111. #if SIZEOF_CHAR != 1 || SIZEOF_UNSIGNED_CHAR != 1
  112. /*
  113.  * #error will not work for all compilers (e.g. sunos4)
  114.  * The following line will abort compilation on all compilers
  115.  * if the above is true. And that's what we want.
  116.  */
  117. error  Sizeof char is not equal 1
  118. #endif
  119.  
  120. #if    defined(__STDC__) || defined(CHAR_IS_UNSIGNED)
  121.     typedef    signed char        Int8_t;
  122. #else
  123.     typedef    char            Int8_t;
  124. #endif
  125.  
  126. #if SIZEOF_SHORT_INT == 2
  127.     typedef    short            Int16_t;
  128. #else
  129.     error        No int16_t found
  130. #endif
  131.  
  132. #if SIZEOF_INT == 4
  133.     typedef    int            Int32_t;
  134. #else
  135.     error        No int32_t found
  136. #endif
  137.  
  138. #if SIZEOF_LONG_INT == 8
  139.     typedef        long        Int64_t;
  140. #    define    HAVE_INT64_T
  141. #else
  142. #if SIZEOF_LONG_LONG == 8
  143.     typedef        long long    Int64_t;
  144. #    define    HAVE_INT64_T
  145. #else
  146. /*    error        No int64_t found*/
  147. #endif
  148. #endif
  149.  
  150. #if SIZEOF_CHAR_P == SIZEOF_INT
  151.     typedef        int        Intptr_t;
  152. #else
  153. #if SIZEOF_CHAR_P == SIZEOF_LONG_INT
  154.     typedef        long        Intptr_t;
  155. #else
  156.     error        No intptr_t found
  157. #endif
  158. #endif
  159.  
  160. typedef    unsigned char        UInt8_t;
  161.  
  162. #if SIZEOF_UNSIGNED_SHORT_INT == 2
  163.     typedef    unsigned short        UInt16_t;
  164. #else
  165.     error        No uint16_t found
  166. #endif
  167.  
  168. #if SIZEOF_UNSIGNED_INT == 4
  169.     typedef    unsigned int        UInt32_t;
  170. #else
  171.     error        No int32_t found
  172. #endif
  173.  
  174. #if SIZEOF_UNSIGNED_LONG_INT == 8
  175.     typedef    unsigned long        UInt64_t;
  176. #    define    HAVE_UINT64_T
  177. #else
  178. #if SIZEOF_UNSIGNED_LONG_LONG == 8
  179.     typedef    unsigned long long    UInt64_t;
  180. #    define    HAVE_UINT64_T
  181. #else
  182. /*    error        No uint64_t found*/
  183. #endif
  184. #endif
  185.  
  186. #if SIZEOF_CHAR_P == SIZEOF_UNSIGNED_INT
  187.     typedef        unsigned int    UIntptr_t;
  188. #else
  189. #if SIZEOF_CHAR_P == SIZEOF_UNSIGNED_LONG_INT
  190.     typedef        unsigned long    UIntptr_t;
  191. #else
  192.     error        No uintptr_t found
  193. #endif
  194. #endif
  195.  
  196. #endif    /* HAVE_INTTYPES_H */
  197.  
  198. #endif    /* _UTYPES_H */
  199.