gonzui


Format: Advanced Search

t2ex/bsd_source/lib/libc/src_bsd/include/stdint.hbare sourcepermlink (0.01 seconds)

Search this content:

    1: /*      $OpenBSD: stdint.h,v 1.7 2012/01/05 20:37:50 kettenis Exp $  */
    2: 
    3: /*
    4:  * Copyright (c) 1997, 2005 Todd C. Miller <Todd.Miller@courtesan.com>
    5:  *
    6:  * Permission to use, copy, modify, and distribute this software for any
    7:  * purpose with or without fee is hereby granted, provided that the above
    8:  * copyright notice and this permission notice appear in all copies.
    9:  *
   10:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
   11:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
   12:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
   13:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
   14:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
   15:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
   16:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   17:  */
   18: 
   19: #ifndef _SYS_STDINT_H_
   20: #define _SYS_STDINT_H_
   21: 
   22: #include <sys/cdefs.h>
   23: #include <machine/_types.h>
   24: 
   25: #ifndef __BIT_TYPES_DEFINED__
   26: #define __BIT_TYPES_DEFINED__
   27: #endif
   28: 
   29: /* 7.18.1.1 Exact-width integer types (also in sys/types.h) */
   30: #ifndef _INT8_T_DEFINED_
   31: #define _INT8_T_DEFINED_
   32: typedef __int8_t                int8_t;
   33: #endif
   34: 
   35: #ifndef _UINT8_T_DEFINED_
   36: #define _UINT8_T_DEFINED_
   37: typedef __uint8_t               uint8_t;
   38: #endif
   39: 
   40: #ifndef _INT16_T_DEFINED_
   41: #define _INT16_T_DEFINED_
   42: typedef __int16_t               int16_t;
   43: #endif
   44: 
   45: #ifndef _UINT16_T_DEFINED_
   46: #define _UINT16_T_DEFINED_
   47: typedef __uint16_t              uint16_t;
   48: #endif
   49: 
   50: #ifndef _INT32_T_DEFINED_
   51: #define _INT32_T_DEFINED_
   52: typedef __int32_t               int32_t;
   53: #endif
   54: 
   55: #ifndef _UINT32_T_DEFINED_
   56: #define _UINT32_T_DEFINED_
   57: typedef __uint32_t              uint32_t;
   58: #endif
   59: 
   60: #ifndef _INT64_T_DEFINED_
   61: #define _INT64_T_DEFINED_
   62: typedef __int64_t               int64_t;
   63: #endif
   64: 
   65: #ifndef _UINT64_T_DEFINED_
   66: #define _UINT64_T_DEFINED_
   67: typedef __uint64_t              uint64_t;
   68: #endif
   69: 
   70: /* 7.18.1.2 Minimum-width integer types */
   71: typedef __int_least8_t          int_least8_t;
   72: typedef __uint_least8_t         uint_least8_t;
   73: typedef __int_least16_t         int_least16_t;
   74: typedef __uint_least16_t        uint_least16_t;
   75: typedef __int_least32_t         int_least32_t;
   76: typedef __uint_least32_t        uint_least32_t;
   77: typedef __int_least64_t         int_least64_t;
   78: typedef __uint_least64_t        uint_least64_t;
   79: 
   80: /* 7.18.1.3 Fastest minimum-width integer types */
   81: typedef __int_fast8_t           int_fast8_t;
   82: typedef __uint_fast8_t          uint_fast8_t;
   83: typedef __int_fast16_t          int_fast16_t;
   84: typedef __uint_fast16_t         uint_fast16_t;
   85: typedef __int_fast32_t          int_fast32_t;
   86: typedef __uint_fast32_t         uint_fast32_t;
   87: typedef __int_fast64_t          int_fast64_t;
   88: typedef __uint_fast64_t         uint_fast64_t;
   89: 
   90: /* 7.18.1.4 Integer types capable of holding object pointers */
   91: typedef __intptr_t              intptr_t;
   92: typedef __uintptr_t             uintptr_t;
   93: 
   94: /* 7.18.1.5 Greatest-width integer types */
   95: typedef __intmax_t              intmax_t;
   96: typedef __uintmax_t             uintmax_t;
   97: 
   98: #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
   99: /*
  100:  * 7.18.2 Limits of specified-width integer types.
  101:  *
  102:  * The following object-like macros specify the minimum and maximum limits
  103:  * of integer types corresponding to the typedef names defined above.
  104:  */
  105: 
  106: /* 7.18.2.1 Limits of exact-width integer types */
  107: #define INT8_MIN                (-0x7f - 1)
  108: #define INT16_MIN               (-0x7fff - 1)
  109: #define INT32_MIN               (-0x7fffffff - 1)
  110: #define INT64_MIN               (-0x7fffffffffffffffLL - 1)
  111: 
  112: #define INT8_MAX                0x7f
  113: #define INT16_MAX               0x7fff
  114: #define INT32_MAX               0x7fffffff
  115: #define INT64_MAX               0x7fffffffffffffffLL
  116: 
  117: #define UINT8_MAX               0xff
  118: #define UINT16_MAX              0xffff
  119: #define UINT32_MAX              0xffffffffU
  120: #define UINT64_MAX              0xffffffffffffffffULL
  121: 
  122: /* 7.18.2.2 Limits of minimum-width integer types */
  123: #define INT_LEAST8_MIN          INT8_MIN
  124: #define INT_LEAST16_MIN         INT16_MIN
  125: #define INT_LEAST32_MIN         INT32_MIN
  126: #define INT_LEAST64_MIN         INT64_MIN
  127: 
  128: #define INT_LEAST8_MAX          INT8_MAX
  129: #define INT_LEAST16_MAX         INT16_MAX
  130: #define INT_LEAST32_MAX         INT32_MAX
  131: #define INT_LEAST64_MAX         INT64_MAX
  132: 
  133: #define UINT_LEAST8_MAX         UINT8_MAX
  134: #define UINT_LEAST16_MAX        UINT16_MAX
  135: #define UINT_LEAST32_MAX        UINT32_MAX
  136: #define UINT_LEAST64_MAX        UINT64_MAX
  137: 
  138: /* 7.18.2.3 Limits of fastest minimum-width integer types */
  139: #define INT_FAST8_MIN           __INT_FAST8_MIN
  140: #define INT_FAST16_MIN          __INT_FAST16_MIN
  141: #define INT_FAST32_MIN          __INT_FAST32_MIN
  142: #define INT_FAST64_MIN          __INT_FAST64_MIN
  143: 
  144: #define INT_FAST8_MAX           __INT_FAST8_MAX
  145: #define INT_FAST16_MAX          __INT_FAST16_MAX
  146: #define INT_FAST32_MAX          __INT_FAST32_MAX
  147: #define INT_FAST64_MAX          __INT_FAST64_MAX
  148: 
  149: #define UINT_FAST8_MAX          __UINT_FAST8_MAX
  150: #define UINT_FAST16_MAX         __UINT_FAST16_MAX
  151: #define UINT_FAST32_MAX         __UINT_FAST32_MAX
  152: #define UINT_FAST64_MAX         __UINT_FAST64_MAX
  153: 
  154: /* 7.18.2.4 Limits of integer types capable of holding object pointers */
  155: #ifdef __LP64__
  156: #define INTPTR_MIN              (-0x7fffffffffffffffL - 1)
  157: #define INTPTR_MAX              0x7fffffffffffffffL
  158: #define UINTPTR_MAX             0xffffffffffffffffUL
  159: #else
  160: #define INTPTR_MIN              (-0x7fffffffL - 1)
  161: #define INTPTR_MAX              0x7fffffffL
  162: #define UINTPTR_MAX             0xffffffffUL
  163: #endif
  164: 
  165: /* 7.18.2.5 Limits of greatest-width integer types */
  166: #define INTMAX_MIN              INT64_MIN
  167: #define INTMAX_MAX              INT64_MAX
  168: #define UINTMAX_MAX             UINT64_MAX
  169: 
  170: /*
  171:  * 7.18.3 Limits of other integer types.
  172:  *
  173:  * The following object-like macros specify the minimum and maximum limits
  174:  * of integer types corresponding to types specified in other standard
  175:  * header files.
  176:  */
  177: 
  178: /* Limits of ptrdiff_t */
  179: #define PTRDIFF_MIN             INTPTR_MIN
  180: #define PTRDIFF_MAX             INTPTR_MAX
  181: 
  182: /* Limits of sig_atomic_t */
  183: #define SIG_ATOMIC_MIN          INT32_MIN
  184: #define SIG_ATOMIC_MAX          INT32_MAX
  185: 
  186: /* Limits of size_t (also in limits.h) */
  187: #ifndef SIZE_MAX
  188: #define SIZE_MAX                UINTPTR_MAX
  189: #endif
  190: 
  191: /* Limits of wchar_t */
  192: #ifndef WCHAR_MIN
  193: #define WCHAR_MIN               INT32_MIN
  194: #endif
  195: #ifndef WCHAR_MAX
  196: #define WCHAR_MAX               INT32_MAX
  197: #endif
  198: 
  199: /* Limits of wint_t */
  200: #define WINT_MIN                INT32_MIN
  201: #define WINT_MAX                INT32_MAX
  202: 
  203: #endif /* __cplusplus || __STDC_LIMIT_MACROS */
  204: 
  205: #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
  206: /*
  207:  * 7.18.4 Macros for integer constants.
  208:  *
  209:  * The following function-like macros expand to integer constants
  210:  * suitable for initializing objects that have integer types corresponding
  211:  * to types defined in <stdint.h>.  The argument in any instance of
  212:  * these macros shall be a decimal, octal, or hexadecimal constant with
  213:  * a value that does not exceed the limits for the corresponding type.
  214:  */
  215: 
  216: /* 7.18.4.1 Macros for minimum-width integer constants. */
  217: #define INT8_C(_c)              (_c)
  218: #define INT16_C(_c)             (_c)
  219: #define INT32_C(_c)             (_c)
  220: #define INT64_C(_c)             __CONCAT(_c, LL)
  221: 
  222: #define UINT8_C(_c)             (_c)
  223: #define UINT16_C(_c)            (_c)
  224: #define UINT32_C(_c)            __CONCAT(_c, U)
  225: #define UINT64_C(_c)            __CONCAT(_c, ULL)
  226: 
  227: /* 7.18.4.2 Macros for greatest-width integer constants. */
  228: #define INTMAX_C(_c)            __CONCAT(_c, LL)
  229: #define UINTMAX_C(_c)           __CONCAT(_c, ULL)
  230: 
  231: #endif /* __cplusplus || __STDC_CONSTANT_MACROS */
  232: 
  233: #endif /* _SYS_STDINT_H_ */