The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/EXTERNAL_HEADERS/stdint.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
    3  *
    4  * We build on <machine/types.h> rather than <sys/types.h> in order to
    5  * minimize the global namespace pollution (i.e., we'd like to define
    6  * *only* those identifiers that the C standard mandates should be
    7  * defined by <stdint.h>).   Using <machine/types.h> means that (at
    8  * least as of January 2001) all of the extra macros that do get
    9  * #defined by #include'ing <stdint.h> are in the implementor's
   10  * namespace ("_[A-Z].*" or "__.*").
   11  *
   12  * The reason that we do #include the relevant ...types.h instead of
   13  * creating several "competing" typedefs is to make header collisions
   14  * less likely during the transition to C99.
   15  *
   16  * Caveat:  There are still five extra typedef's defined by doing it
   17  * this way:  "u_int{8,16,32,64}_t" and "register_t".  Might be
   18  * fixable via pre- and post- #defines, but probably not worth it.
   19  */
   20 
   21 #ifndef _STDINT_H_
   22 #define _STDINT_H_
   23 
   24 #include <machine/types.h>
   25 
   26 /* from ISO/IEC 988:1999 spec */
   27 
   28 /* 7.18.1.1 Exact-width integer types */
   29                                          /* int8_t is defined in <machine/types.h> */
   30                                          /* int16_t is defined in <machine/types.h> */
   31                                          /* int32_t is defined in <machine/types.h> */
   32                                          /* int64_t is defined in <machine/types.h> */
   33 typedef u_int8_t              uint8_t;   /* u_int8_t is defined in <machine/types.h> */
   34 typedef u_int16_t            uint16_t;   /* u_int16_t is defined in <machine/types.h> */
   35 typedef u_int32_t            uint32_t;   /* u_int32_t is defined in <machine/types.h> */
   36 typedef u_int64_t            uint64_t;   /* u_int64_t is defined in <machine/types.h> */
   37 
   38 
   39 /* 7.18.1.2 Minumun-width integer types */
   40 typedef int8_t           int_least8_t;
   41 typedef int16_t         int_least16_t;
   42 typedef int32_t         int_least32_t;
   43 typedef int64_t         int_least64_t;
   44 typedef uint8_t         uint_least8_t;
   45 typedef uint16_t       uint_least16_t;
   46 typedef uint32_t       uint_least32_t;
   47 typedef uint64_t       uint_least64_t;
   48 
   49 
   50 /* 7.18.1.3 Fastest-width integer types */
   51 typedef int8_t            int_fast8_t;
   52 typedef int16_t          int_fast16_t;
   53 typedef int32_t          int_fast32_t;
   54 typedef int64_t          int_fast64_t;
   55 typedef uint8_t          uint_fast8_t;
   56 typedef uint16_t        uint_fast16_t;
   57 typedef uint32_t        uint_fast32_t;
   58 typedef uint64_t        uint_fast64_t;
   59 
   60 
   61 /* 7.18.1.4 Integer types capable of hgolding object pointers */
   62                                         /* intptr_t is defined in <machine/types.h> */
   63                                         /* uintptr_t is defined in <machine/types.h> */
   64 
   65 
   66 /* 7.18.1.5 Greatest-width integer types */
   67 typedef long long                intmax_t;
   68 typedef unsigned long long      uintmax_t;
   69 
   70 
   71 /* "C++ implementations should define these macros only when
   72  *  __STDC_LIMIT_MACROS is defined before <stdint.h> is included."
   73  * In other words, if C++, then __STDC_LIMIT_MACROS enables the
   74  * macros below.  (Note that there also exists a different enabling
   75  * macro (__STDC_CONSTANT_MACROS) for the last few, below.)
   76  */
   77 #if (! defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS)
   78 
   79 
   80 /* 7.18.2 Limits of specified-width integer types:
   81  *   These #defines specify the minimum and maximum limits
   82  *   of each of the types declared above.
   83  */
   84 
   85 
   86 /* 7.18.2.1 Limits of exact-width integer types */
   87 #define INT8_MIN         (-127-1)
   88 #define INT16_MIN        (-32767-1)
   89 #define INT32_MIN        (-2147483647-1)
   90 #define INT64_MIN        (-9223372036854775807LL-1LL)
   91 
   92 #define INT8_MAX         +127
   93 #define INT16_MAX        +32767
   94 #define INT32_MAX        +2147483647
   95 #define INT64_MAX        +9223372036854775807LL
   96 
   97 #define UINT8_MAX         255
   98 #define UINT16_MAX        65535
   99 #define UINT32_MAX        4294967295U
  100 #define UINT64_MAX        18446744073709551615ULL
  101 
  102 /* 7.18.2.2 Limits of minimum-width integer types */
  103 #define INT_LEAST8_MIN    INT8_MIN
  104 #define INT_LEAST16_MIN   INT16_MIN
  105 #define INT_LEAST32_MIN   INT32_MIN
  106 #define INT_LEAST64_MIN   INT64_MIN
  107 
  108 #define INT_LEAST8_MAX    INT8_MAX
  109 #define INT_LEAST16_MAX   INT16_MAX
  110 #define INT_LEAST32_MAX   INT32_MAX
  111 #define INT_LEAST64_MAX   INT64_MAX
  112 
  113 #define UINT_LEAST8_MAX   UINT8_MAX
  114 #define UINT_LEAST16_MAX  UINT16_MAX
  115 #define UINT_LEAST32_MAX  UINT32_MAX
  116 #define UINT_LEAST64_MAX  UINT64_MAX
  117 
  118 /* 7.18.2.3 Limits of fastest minimum-width integer types */
  119 #define INT_FAST8_MIN     INT8_MIN
  120 #define INT_FAST16_MIN    INT16_MIN
  121 #define INT_FAST32_MIN    INT32_MIN
  122 #define INT_FAST64_MIN    INT64_MIN
  123 
  124 #define INT_FAST8_MAX     INT8_MAX
  125 #define INT_FAST16_MAX    INT16_MAX
  126 #define INT_FAST32_MAX    INT32_MAX
  127 #define INT_FAST64_MAX    INT64_MAX
  128 
  129 #define UINT_FAST8_MAX    UINT8_MAX
  130 #define UINT_FAST16_MAX   UINT16_MAX
  131 #define UINT_FAST32_MAX   UINT32_MAX
  132 #define UINT_FAST64_MAX   UINT64_MAX
  133 
  134 /* 7.18.2.4 Limits of integer types capable of holding object pointers */
  135 #if defined(__LP64__)
  136 #define INTPTR_MIN        INT64_MIN
  137 #define INTPTR_MAX        INT64_MAX
  138 #define UINTPTR_MAX       UINT64_MAX
  139 #else
  140 #define INTPTR_MIN        INT32_MIN
  141 #define INTPTR_MAX        INT32_MAX
  142 #define UINTPTR_MAX       UINT32_MAX
  143 #endif
  144 
  145 /* 7.18.2.5 Limits of greatest-width integer types */
  146 #define INTMAX_MIN        INT64_MIN
  147 #define INTMAX_MAX        INT64_MAX
  148 
  149 #define UINTMAX_MAX       UINT64_MAX
  150 
  151 /* 7.18.3 "Other" */
  152 #if defined(__LP64__)
  153 #define PTRDIFF_MIN       INT64_MIN
  154 #define PTRDIFF_MAX       INT64_MAX
  155 #else
  156 #define PTRDIFF_MIN       INT32_MIN
  157 #define PTRDIFF_MAX       INT32_MAX
  158 #endif
  159 /* We have no sig_atomic_t yet, so no SIG_ATOMIC_{MIN,MAX}.
  160    Should end up being {-127,127} or {0,255} ... or bigger.
  161    My bet would be on one of {U}INT32_{MIN,MAX}. */
  162 
  163 #define SIZE_MAX          UINT32_MAX
  164 
  165 #define WCHAR_MAX         INT32_MAX
  166 
  167 /* We have no wint_t yet, so no WINT_{MIN,MAX}.
  168    Should end up being {U}INT32_{MIN,MAX}, depending.  */
  169 
  170 
  171 #endif /* if C++, then __STDC_LIMIT_MACROS enables the above macros */
  172 
  173 /* "C++ implementations should define these macros only when
  174  *  __STDC_CONSTANT_MACROS is defined before <stdint.h> is included."
  175  */ 
  176 #if (! defined(__cplusplus)) || defined(__STDC_CONSTANT_MACROS)
  177 
  178 /* 7.18.4 Macros for integer constants */
  179 #define INT8_C(v)    ((int8_t)v)
  180 #define INT16_C(v)   ((int16_t)v)
  181 #define INT32_C(v)   (v ## L)
  182 #define INT64_C(v)   (v ## LL)
  183 
  184 #define UINT8_C(v)   ((uint8_t)v)
  185 #define UINT16_C(v)  ((uint16_t)v)
  186 #define UINT32_C(v)  (v ## UL)
  187 #define UINT64_C(v)  (v ## ULL)
  188 
  189 #define INTMAX_C(v)  (v ## LL)
  190 #define UINTMAX_C(v) (v ## ULL)
  191 
  192 #endif /* if C++, then __STDC_CONSTANT_MACROS enables the above macros */
  193 
  194 #endif /* _STDINT_H_ */

Cache object: 63303976e1b5c0c75d3f6c4128ee4aa3


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.