| 1 |
|
| 2 |
// Copyright (c) 2003-2019 Xsens Technologies B.V. or subsidiaries worldwide. |
| 3 |
// All rights reserved. |
| 4 |
// |
| 5 |
// Redistribution and use in source and binary forms, with or without modification, |
| 6 |
// are permitted provided that the following conditions are met: |
| 7 |
// |
| 8 |
// 1. Redistributions of source code must retain the above copyright notice, |
| 9 |
// this list of conditions, and the following disclaimer. |
| 10 |
// |
| 11 |
// 2. Redistributions in binary form must reproduce the above copyright notice, |
| 12 |
// this list of conditions, and the following disclaimer in the documentation |
| 13 |
// and/or other materials provided with the distribution. |
| 14 |
// |
| 15 |
// 3. Neither the names of the copyright holders nor the names of their contributors |
| 16 |
// may be used to endorse or promote products derived from this software without |
| 17 |
// specific prior written permission. |
| 18 |
// |
| 19 |
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
| 20 |
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 21 |
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
| 22 |
// THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 |
// SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
| 24 |
// OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 25 |
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR |
| 26 |
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 27 |
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS |
| 28 |
// SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES |
| 29 |
// OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE |
| 30 |
// ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES. |
| 31 |
// |
| 32 |
|
| 33 |
/* A portable stdint.h |
| 34 |
**************************************************************************** |
| 35 |
* BSD License: |
| 36 |
**************************************************************************** |
| 37 |
* |
| 38 |
* Copyright (c) 2005-2007 Paul Hsieh |
| 39 |
* All rights reserved. |
| 40 |
* |
| 41 |
* Redistribution and use in source and binary forms, with or without |
| 42 |
* modification, are permitted provided that the following conditions |
| 43 |
* are met: |
| 44 |
* |
| 45 |
* 1. Redistributions of source code must retain the above copyright |
| 46 |
* notice, this list of conditions and the following disclaimer. |
| 47 |
* 2. Redistributions in binary form must reproduce the above copyright |
| 48 |
* notice, this list of conditions and the following disclaimer in the |
| 49 |
* documentation and/or other materials provided with the distribution. |
| 50 |
* 3. The name of the author may not be used to endorse or promote products |
| 51 |
* derived from this software without specific prior written permission. |
| 52 |
* |
| 53 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 54 |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 55 |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 56 |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 57 |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 58 |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 59 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 60 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 61 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 62 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 63 |
* |
| 64 |
**************************************************************************** |
| 65 |
* |
| 66 |
* Version 0.1.11 |
| 67 |
* |
| 68 |
* The ANSI C standard committee, for the C99 standard, specified the |
| 69 |
* inclusion of a new standard include file called stdint.h. This is |
| 70 |
* a very useful and long desired include file which contains several |
| 71 |
* very precise definitions for integer scalar types that is |
| 72 |
* critically important for making portable several classes of |
| 73 |
* applications including cryptography, hashing, variable length |
| 74 |
* integer libraries and so on. But for most developers its likely |
| 75 |
* useful just for programming sanity. |
| 76 |
* |
| 77 |
* The problem is that most compiler vendors have decided not to |
| 78 |
* implement the C99 standard, and the next C++ language standard |
| 79 |
* (which has a lot more mindshare these days) will be a long time in |
| 80 |
* coming and its unknown whether or not it will include stdint.h or |
| 81 |
* how much adoption it will have. Either way, it will be a long time |
| 82 |
* before all compilers come with a stdint.h and it also does nothing |
| 83 |
* for the extremely large number of compilers available today which |
| 84 |
* do not include this file, or anything comparable to it. |
| 85 |
* |
| 86 |
* So that's what this file is all about. Its an attempt to build a |
| 87 |
* single universal include file that works on as many platforms as |
| 88 |
* possible to deliver what stdint.h is supposed to. A few things |
| 89 |
* that should be noted about this file: |
| 90 |
* |
| 91 |
* 1) It is not guaranteed to be portable and/or present an identical |
| 92 |
* interface on all platforms. The extreme variability of the |
| 93 |
* ANSI C standard makes this an impossibility right from the |
| 94 |
* very get go. Its really only meant to be useful for the vast |
| 95 |
* majority of platforms that possess the capability of |
| 96 |
* implementing usefully and precisely defined, standard sized |
| 97 |
* integer scalars. Systems which are not intrinsically 2s |
| 98 |
* complement may produce invalid constants. |
| 99 |
* |
| 100 |
* 2) There is an unavoidable use of non-reserved symbols. |
| 101 |
* |
| 102 |
* 3) Other standard include files are invoked. |
| 103 |
* |
| 104 |
* 4) This file may come in conflict with future platforms that do |
| 105 |
* include stdint.h. The hope is that one or the other can be |
| 106 |
* used with no real difference. |
| 107 |
* |
| 108 |
* 5) In the current verison, if your platform can't represent |
| 109 |
* int32_t, int16_t and int8_t, it just dumps out with a compiler |
| 110 |
* error. |
| 111 |
* |
| 112 |
* 6) 64 bit integers may or may not be defined. Test for their |
| 113 |
* presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX. |
| 114 |
* Note that this is different from the C99 specification which |
| 115 |
* requires the existence of 64 bit support in the compiler. If |
| 116 |
* this is not defined for your platform, yet it is capable of |
| 117 |
* dealing with 64 bits then it is because this file has not yet |
| 118 |
* been extended to cover all of your system's capabilities. |
| 119 |
* |
| 120 |
* 7) (u)intptr_t may or may not be defined. Test for its presence |
| 121 |
* with the test: #ifdef PTRDIFF_MAX. If this is not defined |
| 122 |
* for your platform, then it is because this file has not yet |
| 123 |
* been extended to cover all of your system's capabilities, not |
| 124 |
* because its optional. |
| 125 |
* |
| 126 |
* 8) The following might not been defined even if your platform is |
| 127 |
* capable of defining it: |
| 128 |
* |
| 129 |
* WCHAR_MIN |
| 130 |
* WCHAR_MAX |
| 131 |
* (u)int64_t |
| 132 |
* PTRDIFF_MIN |
| 133 |
* PTRDIFF_MAX |
| 134 |
* (u)intptr_t |
| 135 |
* |
| 136 |
* 9) The following have not been defined: |
| 137 |
* |
| 138 |
* WINT_MIN |
| 139 |
* WINT_MAX |
| 140 |
* |
| 141 |
* 10) The criteria for defining (u)int_least(*)_t isn't clear, |
| 142 |
* except for systems which don't have a type that precisely |
| 143 |
* defined 8, 16, or 32 bit types (which this include file does |
| 144 |
* not support anyways). Default definitions have been given. |
| 145 |
* |
| 146 |
* 11) The criteria for defining (u)int_fast(*)_t isn't something I |
| 147 |
* would trust to any particular compiler vendor or the ANSI C |
| 148 |
* committee. It is well known that "compatible systems" are |
| 149 |
* commonly created that have very different performance |
| 150 |
* characteristics from the systems they are compatible with, |
| 151 |
* especially those whose vendors make both the compiler and the |
| 152 |
* system. Default definitions have been given, but its strongly |
| 153 |
* recommended that users never use these definitions for any |
| 154 |
* reason (they do *NOT* deliver any serious guarantee of |
| 155 |
* improved performance -- not in this file, nor any vendor's |
| 156 |
* stdint.h). |
| 157 |
* |
| 158 |
* 12) The following macros: |
| 159 |
* |
| 160 |
* PRINTF_INTMAX_MODIFIER |
| 161 |
* PRINTF_INT64_MODIFIER |
| 162 |
* PRINTF_INT32_MODIFIER |
| 163 |
* PRINTF_INT16_MODIFIER |
| 164 |
* PRINTF_LEAST64_MODIFIER |
| 165 |
* PRINTF_LEAST32_MODIFIER |
| 166 |
* PRINTF_LEAST16_MODIFIER |
| 167 |
* PRINTF_INTPTR_MODIFIER |
| 168 |
* |
| 169 |
* are strings which have been defined as the modifiers required |
| 170 |
* for the "d", "u" and "x" printf formats to correctly output |
| 171 |
* (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t, |
| 172 |
* (u)least32_t, (u)least16_t and (u)intptr_t types respectively. |
| 173 |
* PRINTF_INTPTR_MODIFIER is not defined for some systems which |
| 174 |
* provide their own stdint.h. PRINTF_INT64_MODIFIER is not |
| 175 |
* defined if INT64_MAX is not defined. These are an extension |
| 176 |
* beyond what C99 specifies must be in stdint.h. |
| 177 |
* |
| 178 |
* In addition, the following macros are defined: |
| 179 |
* |
| 180 |
* PRINTF_INTMAX_HEX_WIDTH |
| 181 |
* PRINTF_INT64_HEX_WIDTH |
| 182 |
* PRINTF_INT32_HEX_WIDTH |
| 183 |
* PRINTF_INT16_HEX_WIDTH |
| 184 |
* PRINTF_INT8_HEX_WIDTH |
| 185 |
* PRINTF_INTMAX_DEC_WIDTH |
| 186 |
* PRINTF_INT64_DEC_WIDTH |
| 187 |
* PRINTF_INT32_DEC_WIDTH |
| 188 |
* PRINTF_INT16_DEC_WIDTH |
| 189 |
* PRINTF_INT8_DEC_WIDTH |
| 190 |
* |
| 191 |
* Which specifies the maximum number of characters required to |
| 192 |
* print the number of that type in either hexadecimal or decimal. |
| 193 |
* These are an extension beyond what C99 specifies must be in |
| 194 |
* stdint.h. |
| 195 |
* |
| 196 |
* Compilers tested (all with 0 warnings at their highest respective |
| 197 |
* settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32 |
| 198 |
* bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio |
| 199 |
* .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3 |
| 200 |
* |
| 201 |
* This file should be considered a work in progress. Suggestions for |
| 202 |
* improvements, especially those which increase coverage are strongly |
| 203 |
* encouraged. |
| 204 |
* |
| 205 |
* Acknowledgements |
| 206 |
* |
| 207 |
* The following people have made significant contributions to the |
| 208 |
* development and testing of this file: |
| 209 |
* |
| 210 |
* Chris Howie |
| 211 |
* John Steele Scott |
| 212 |
* Dave Thorup |
| 213 |
* |
| 214 |
*/ |
| 215 |
|
| 216 |
#ifndef _PSTDINT_H_INCLUDED |
| 217 |
#include <stddef.h> |
| 218 |
#include <limits.h> |
| 219 |
|
| 220 |
/* |
| 221 |
* For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and |
| 222 |
* do nothing else. On the Mac OS X version of gcc this is _STDINT_H_. |
| 223 |
*/ |
| 224 |
|
| 225 |
#if (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && __WATCOMC__ >= 1250) || (defined(__GNUC__) && __GNUC__ > 2) || (defined(_MSC_VER) && _MSC_VER >= 1600) || defined(IAR_ARM_CM3) || (defined(__ICCARM__) && __ICCARM__) || (defined(_ADI_COMPILER) && _ADI_COMPILER) || (defined(__ICC8051__) && __ICC8051__) || (defined(__arm__) && defined(__ARMCC_VERSION)) |
| 226 |
#include <stdint.h> |
| 227 |
#endif |
| 228 |
|
| 229 |
#if (defined (_STDINT_H_INCLUDED) || defined (_STDINT) || defined (_STDINT_H) || defined (_STDINT_H_) || defined (BOOST_CSTDINT_HPP)) && !defined (_PSTDINT_H_INCLUDED) || defined(__stdint_h) |
| 230 |
#define _PSTDINT_H_INCLUDED |
| 231 |
# ifndef PRINTF_INT64_MODIFIER |
| 232 |
# if (__WORDSIZE == 64) |
| 233 |
# if defined(__APPLE__) |
| 234 |
# define PRINTF_INT64_MODIFIER "ll" |
| 235 |
# else |
| 236 |
# define PRINTF_INT64_MODIFIER "l" |
| 237 |
# endif |
| 238 |
# else |
| 239 |
# define PRINTF_INT64_MODIFIER "ll" |
| 240 |
# endif |
| 241 |
# endif |
| 242 |
# ifndef PRINTF_INT32_MODIFIER |
| 243 |
# if defined(__ARMEL__) && !defined(__linux) |
| 244 |
# define PRINTF_INT32_MODIFIER "l" |
| 245 |
# else |
| 246 |
# define PRINTF_INT32_MODIFIER "" |
| 247 |
# endif |
| 248 |
# endif |
| 249 |
# ifndef PRINTF_INT16_MODIFIER |
| 250 |
# define PRINTF_INT16_MODIFIER "h" |
| 251 |
# endif |
| 252 |
# ifndef PRINTF_INTMAX_MODIFIER |
| 253 |
# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER |
| 254 |
# endif |
| 255 |
# ifndef PRINTF_INT64_HEX_WIDTH |
| 256 |
# define PRINTF_INT64_HEX_WIDTH "16" |
| 257 |
# endif |
| 258 |
# ifndef PRINTF_INT32_HEX_WIDTH |
| 259 |
# define PRINTF_INT32_HEX_WIDTH "8" |
| 260 |
# endif |
| 261 |
# ifndef PRINTF_INT16_HEX_WIDTH |
| 262 |
# define PRINTF_INT16_HEX_WIDTH "4" |
| 263 |
# endif |
| 264 |
# ifndef PRINTF_INT8_HEX_WIDTH |
| 265 |
# define PRINTF_INT8_HEX_WIDTH "2" |
| 266 |
# endif |
| 267 |
# ifndef PRINTF_INT64_DEC_WIDTH |
| 268 |
# define PRINTF_INT64_DEC_WIDTH "20" |
| 269 |
# endif |
| 270 |
# ifndef PRINTF_INT32_DEC_WIDTH |
| 271 |
# define PRINTF_INT32_DEC_WIDTH "10" |
| 272 |
# endif |
| 273 |
# ifndef PRINTF_INT16_DEC_WIDTH |
| 274 |
# define PRINTF_INT16_DEC_WIDTH "5" |
| 275 |
# endif |
| 276 |
# ifndef PRINTF_INT8_DEC_WIDTH |
| 277 |
# define PRINTF_INT8_DEC_WIDTH "3" |
| 278 |
# endif |
| 279 |
# ifndef PRINTF_INTMAX_HEX_WIDTH |
| 280 |
# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH |
| 281 |
# endif |
| 282 |
# ifndef PRINTF_INTMAX_DEC_WIDTH |
| 283 |
# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH |
| 284 |
# endif |
| 285 |
|
| 286 |
/* |
| 287 |
* Something really weird is going on with Open Watcom. Just pull some of |
| 288 |
* these duplicated definitions from Open Watcom's stdint.h file for now. |
| 289 |
*/ |
| 290 |
|
| 291 |
# if defined (__WATCOMC__) && __WATCOMC__ >= 1250 |
| 292 |
# if !defined (INT64_C) |
| 293 |
# define INT64_C(x) (x + (INT64_MAX - INT64_MAX)) |
| 294 |
# endif |
| 295 |
# if !defined (UINT64_C) |
| 296 |
# define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX)) |
| 297 |
# endif |
| 298 |
# if !defined (INT32_C) |
| 299 |
# define INT32_C(x) (x + (INT32_MAX - INT32_MAX)) |
| 300 |
# endif |
| 301 |
# if !defined (UINT32_C) |
| 302 |
# define UINT32_C(x) (x + (UINT32_MAX - UINT32_MAX)) |
| 303 |
# endif |
| 304 |
# if !defined (INT16_C) |
| 305 |
# define INT16_C(x) (x) |
| 306 |
# endif |
| 307 |
# if !defined (UINT16_C) |
| 308 |
# define UINT16_C(x) (x) |
| 309 |
# endif |
| 310 |
# if !defined (INT8_C) |
| 311 |
# define INT8_C(x) (x) |
| 312 |
# endif |
| 313 |
# if !defined (UINT8_C) |
| 314 |
# define UINT8_C(x) (x) |
| 315 |
# endif |
| 316 |
# if !defined (UINT64_MAX) |
| 317 |
# define UINT64_MAX 18446744073709551615ULL |
| 318 |
# endif |
| 319 |
# if !defined (INT64_MAX) |
| 320 |
# define INT64_MAX 9223372036854775807LL |
| 321 |
# endif |
| 322 |
# if !defined (UINT32_MAX) |
| 323 |
# define UINT32_MAX 4294967295UL |
| 324 |
# endif |
| 325 |
# if !defined (INT32_MAX) |
| 326 |
# define INT32_MAX 2147483647L |
| 327 |
# endif |
| 328 |
# if !defined (INTMAX_MAX) |
| 329 |
# define INTMAX_MAX INT64_MAX |
| 330 |
# endif |
| 331 |
# if !defined (INTMAX_MIN) |
| 332 |
# define INTMAX_MIN INT64_MIN |
| 333 |
# endif |
| 334 |
# endif |
| 335 |
|
| 336 |
/* Some of the targets compiled by Visual Dsp++ (like the Sharc) do not have a notion of 8bit of 16bit value |
| 337 |
We define these here although the actual storage size is 32 bits |
| 338 |
*/ |
| 339 |
#if (defined(_ADI_COMPILER) && _ADI_COMPILER) |
| 340 |
# ifndef int8_t |
| 341 |
typedef signed char int8_t; |
| 342 |
# endif |
| 343 |
# ifndef uint8_t |
| 344 |
typedef unsigned char uint8_t; |
| 345 |
# endif |
| 346 |
# ifndef int16_t |
| 347 |
typedef signed short int16_t; |
| 348 |
# endif |
| 349 |
# ifndef uint16_t |
| 350 |
typedef unsigned short uint16_t; |
| 351 |
# endif |
| 352 |
#endif //(defined(_ADI_COMPILER) && _ADI_COMPILER) |
| 353 |
|
| 354 |
#endif |
| 355 |
|
| 356 |
#ifndef _PSTDINT_H_INCLUDED |
| 357 |
#define _PSTDINT_H_INCLUDED |
| 358 |
|
| 359 |
#ifndef SIZE_MAX |
| 360 |
#ifdef DOXYGEN |
| 361 |
# define SIZE_MAX (~0) |
| 362 |
#else |
| 363 |
# define SIZE_MAX (~(size_t)0) |
| 364 |
#endif |
| 365 |
#endif |
| 366 |
|
| 367 |
/* |
| 368 |
* Deduce the type assignments from limits.h under the assumption that |
| 369 |
* integer sizes in bits are powers of 2, and follow the ANSI |
| 370 |
* definitions. |
| 371 |
*/ |
| 372 |
|
| 373 |
#ifndef UINT8_MAX |
| 374 |
# define UINT8_MAX 0xff |
| 375 |
#endif |
| 376 |
#ifndef uint8_t |
| 377 |
# if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S) |
| 378 |
typedef unsigned char uint8_t; |
| 379 |
# define UINT8_C(v) ((uint8_t) v) |
| 380 |
# else |
| 381 |
# error "Platform not supported" |
| 382 |
# endif |
| 383 |
#endif |
| 384 |
|
| 385 |
#ifndef INT8_MAX |
| 386 |
# define INT8_MAX 0x7f |
| 387 |
#endif |
| 388 |
#ifndef INT8_MIN |
| 389 |
# define INT8_MIN INT8_C(0x80) |
| 390 |
#endif |
| 391 |
#ifndef int8_t |
| 392 |
# if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S) |
| 393 |
typedef signed char int8_t; |
| 394 |
# define INT8_C(v) ((int8_t) v) |
| 395 |
# else |
| 396 |
# error "Platform not supported" |
| 397 |
# endif |
| 398 |
#endif |
| 399 |
|
| 400 |
#ifndef UINT16_MAX |
| 401 |
# define UINT16_MAX 0xffff |
| 402 |
#endif |
| 403 |
#ifndef uint16_t |
| 404 |
#if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S) |
| 405 |
typedef unsigned int uint16_t; |
| 406 |
# ifndef PRINTF_INT16_MODIFIER |
| 407 |
# define PRINTF_INT16_MODIFIER "" |
| 408 |
# endif |
| 409 |
# define UINT16_C(v) ((uint16_t) (v)) |
| 410 |
#elif (USHRT_MAX == UINT16_MAX) |
| 411 |
typedef unsigned short uint16_t; |
| 412 |
# define UINT16_C(v) ((uint16_t) (v)) |
| 413 |
# ifndef PRINTF_INT16_MODIFIER |
| 414 |
# define PRINTF_INT16_MODIFIER "h" |
| 415 |
# endif |
| 416 |
#else |
| 417 |
#error "Platform not supported" |
| 418 |
#endif |
| 419 |
#endif |
| 420 |
|
| 421 |
#ifndef INT16_MAX |
| 422 |
# define INT16_MAX 0x7fff |
| 423 |
#endif |
| 424 |
#ifndef INT16_MIN |
| 425 |
# define INT16_MIN INT16_C(0x8000) |
| 426 |
#endif |
| 427 |
#ifndef int16_t |
| 428 |
#if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S) |
| 429 |
typedef signed int int16_t; |
| 430 |
# define INT16_C(v) ((int16_t) (v)) |
| 431 |
# ifndef PRINTF_INT16_MODIFIER |
| 432 |
# define PRINTF_INT16_MODIFIER "" |
| 433 |
# endif |
| 434 |
#elif (SHRT_MAX == INT16_MAX) |
| 435 |
typedef signed short int16_t; |
| 436 |
# define INT16_C(v) ((int16_t) (v)) |
| 437 |
# ifndef PRINTF_INT16_MODIFIER |
| 438 |
# define PRINTF_INT16_MODIFIER "h" |
| 439 |
# endif |
| 440 |
#else |
| 441 |
#error "Platform not supported" |
| 442 |
#endif |
| 443 |
#endif |
| 444 |
|
| 445 |
#ifndef UINT32_MAX |
| 446 |
# define UINT32_MAX (0xffffffffUL) |
| 447 |
#endif |
| 448 |
#ifndef uint32_t |
| 449 |
#if (SIZE_MAX == UINT32_MAX) && !defined (S_SPLINT_S) && !defined(_lint) |
| 450 |
typedef unsigned int uint32_t; |
| 451 |
# ifndef PRINTF_INT32_MODIFIER |
| 452 |
# define PRINTF_INT32_MODIFIER "" |
| 453 |
# endif |
| 454 |
# define UINT32_C(v) v ## U |
| 455 |
#elif (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S) |
| 456 |
typedef unsigned long uint32_t; |
| 457 |
# define UINT32_C(v) v ## UL |
| 458 |
# ifndef PRINTF_INT32_MODIFIER |
| 459 |
# define PRINTF_INT32_MODIFIER "l" |
| 460 |
# endif |
| 461 |
#elif (USHRT_MAX == UINT32_MAX) |
| 462 |
typedef unsigned short uint32_t; |
| 463 |
# define UINT32_C(v) ((unsigned short) (v)) |
| 464 |
# ifndef PRINTF_INT32_MODIFIER |
| 465 |
# define PRINTF_INT32_MODIFIER "" |
| 466 |
# endif |
| 467 |
#else |
| 468 |
#error "Platform not supported" |
| 469 |
#endif |
| 470 |
#endif |
| 471 |
|
| 472 |
#ifndef INT32_MAX |
| 473 |
# define INT32_MAX (0x7fffffffL) |
| 474 |
#endif |
| 475 |
#ifndef INT32_MIN |
| 476 |
# define INT32_MIN INT32_C(0x80000000) |
| 477 |
#endif |
| 478 |
#ifndef int32_t |
| 479 |
#if (SIZE_MAX/2 == INT32_MAX) && defined (__GNUC__) && (__GNUC__ > 3) |
| 480 |
typedef signed int int32_t; |
| 481 |
# define INT32_C(v) v |
| 482 |
# ifndef PRINTF_INT32_MODIFIER |
| 483 |
# define PRINTF_INT32_MODIFIER "" |
| 484 |
# endif |
| 485 |
#elif (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S) |
| 486 |
typedef signed long int32_t; |
| 487 |
# define INT32_C(v) v ## L |
| 488 |
# ifndef PRINTF_INT32_MODIFIER |
| 489 |
# define PRINTF_INT32_MODIFIER "l" |
| 490 |
# endif |
| 491 |
#elif (SIZE_MAX/2 == INT32_MAX) |
| 492 |
typedef signed int int32_t; |
| 493 |
# define INT32_C(v) v |
| 494 |
# ifndef PRINTF_INT32_MODIFIER |
| 495 |
# define PRINTF_INT32_MODIFIER "" |
| 496 |
# endif |
| 497 |
#elif (SHRT_MAX == INT32_MAX) |
| 498 |
typedef signed short int32_t; |
| 499 |
# define INT32_C(v) ((short) (v)) |
| 500 |
# ifndef PRINTF_INT32_MODIFIER |
| 501 |
# define PRINTF_INT32_MODIFIER "" |
| 502 |
# endif |
| 503 |
#else |
| 504 |
#error "Platform not supported" |
| 505 |
#endif |
| 506 |
#endif |
| 507 |
|
| 508 |
/* |
| 509 |
* The macro stdint_int64_defined is temporarily used to record |
| 510 |
* whether or not 64 integer support is available. It must be |
| 511 |
* defined for any 64 integer extensions for new platforms that are |
| 512 |
* added. |
| 513 |
*/ |
| 514 |
|
| 515 |
#undef stdint_int64_defined |
| 516 |
#if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S) |
| 517 |
# if (__STDC__ && __STDC_VERSION >= 199901L) || defined (S_SPLINT_S) |
| 518 |
# define stdint_int64_defined |
| 519 |
typedef long long int64_t; |
| 520 |
typedef unsigned long long uint64_t; |
| 521 |
# define UINT64_C(v) v ## ULL |
| 522 |
# define INT64_C(v) v ## LL |
| 523 |
# ifndef PRINTF_INT64_MODIFIER |
| 524 |
# define PRINTF_INT64_MODIFIER "ll" |
| 525 |
# endif |
| 526 |
# endif |
| 527 |
#endif |
| 528 |
|
| 529 |
#if !defined (stdint_int64_defined) |
| 530 |
# if defined(__GNUC__) && __WORDSIZE == 64 |
| 531 |
# define stdint_int64_defined |
| 532 |
__extension__ typedef long int64_t; |
| 533 |
__extension__ typedef unsigned long uint64_t; |
| 534 |
# define UINT64_C(v) v ## UL |
| 535 |
# define INT64_C(v) v ## L |
| 536 |
# ifndef PRINTF_INT64_MODIFIER |
| 537 |
# define PRINTF_INT64_MODIFIER "l" |
| 538 |
# endif |
| 539 |
#elif defined(__GNUC__) |
| 540 |
# define stdint_int64_defined |
| 541 |
__extension__ typedef long long int64_t; |
| 542 |
__extension__ typedef unsigned long long uint64_t; |
| 543 |
# define UINT64_C(v) v ## ULL |
| 544 |
# define INT64_C(v) v ## LL |
| 545 |
# ifndef PRINTF_INT64_MODIFIER |
| 546 |
# define PRINTF_INT64_MODIFIER "ll" |
| 547 |
# endif |
| 548 |
# elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S) |
| 549 |
# define stdint_int64_defined |
| 550 |
typedef long long int64_t; |
| 551 |
typedef unsigned long long uint64_t; |
| 552 |
# define UINT64_C(v) v ## ULL |
| 553 |
# define INT64_C(v) v ## LL |
| 554 |
# ifndef PRINTF_INT64_MODIFIER |
| 555 |
# define PRINTF_INT64_MODIFIER "ll" |
| 556 |
# endif |
| 557 |
# elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC) |
| 558 |
# define stdint_int64_defined |
| 559 |
typedef __int64 int64_t; |
| 560 |
typedef unsigned __int64 uint64_t; |
| 561 |
# define UINT64_C(v) v ## UI64 |
| 562 |
# define INT64_C(v) v ## I64 |
| 563 |
# ifndef PRINTF_INT64_MODIFIER |
| 564 |
# define PRINTF_INT64_MODIFIER "I64" |
| 565 |
# endif |
| 566 |
# endif |
| 567 |
#endif |
| 568 |
|
| 569 |
#if !defined (LONG_LONG_MAX) && defined (INT64_C) |
| 570 |
# define LONG_LONG_MAX INT64_C (9223372036854775807LL) |
| 571 |
#endif |
| 572 |
#ifndef ULONG_LONG_MAX |
| 573 |
# define ULONG_LONG_MAX UINT64_C (18446744073709551615ULL) |
| 574 |
#endif |
| 575 |
|
| 576 |
#if !defined (INT64_MAX) && defined (INT64_C) |
| 577 |
# define INT64_MAX INT64_C (9223372036854775807LL) |
| 578 |
#endif |
| 579 |
#if !defined (INT64_MIN) && defined (INT64_C) |
| 580 |
# define INT64_MIN INT64_C (-9223372036854775808LL) |
| 581 |
#endif |
| 582 |
#if !defined (UINT64_MAX) && defined (INT64_C) |
| 583 |
# define UINT64_MAX UINT64_C (18446744073709551615ULL) |
| 584 |
#endif |
| 585 |
|
| 586 |
/* |
| 587 |
* Width of hexadecimal for number field. |
| 588 |
*/ |
| 589 |
|
| 590 |
#ifndef PRINTF_INT64_HEX_WIDTH |
| 591 |
# define PRINTF_INT64_HEX_WIDTH "16" |
| 592 |
#endif |
| 593 |
#ifndef PRINTF_INT32_HEX_WIDTH |
| 594 |
# define PRINTF_INT32_HEX_WIDTH "8" |
| 595 |
#endif |
| 596 |
#ifndef PRINTF_INT16_HEX_WIDTH |
| 597 |
# define PRINTF_INT16_HEX_WIDTH "4" |
| 598 |
#endif |
| 599 |
#ifndef PRINTF_INT8_HEX_WIDTH |
| 600 |
# define PRINTF_INT8_HEX_WIDTH "2" |
| 601 |
#endif |
| 602 |
|
| 603 |
#ifndef PRINTF_INT64_DEC_WIDTH |
| 604 |
# define PRINTF_INT64_DEC_WIDTH "20" |
| 605 |
#endif |
| 606 |
#ifndef PRINTF_INT32_DEC_WIDTH |
| 607 |
# define PRINTF_INT32_DEC_WIDTH "10" |
| 608 |
#endif |
| 609 |
#ifndef PRINTF_INT16_DEC_WIDTH |
| 610 |
# define PRINTF_INT16_DEC_WIDTH "5" |
| 611 |
#endif |
| 612 |
#ifndef PRINTF_INT8_DEC_WIDTH |
| 613 |
# define PRINTF_INT8_DEC_WIDTH "3" |
| 614 |
#endif |
| 615 |
|
| 616 |
/* |
| 617 |
* Ok, lets not worry about 128 bit integers for now. Moore's law says |
| 618 |
* we don't need to worry about that until about 2040 at which point |
| 619 |
* we'll have bigger things to worry about. |
| 620 |
*/ |
| 621 |
|
| 622 |
#ifdef stdint_int64_defined |
| 623 |
typedef int64_t intmax_t; |
| 624 |
typedef uint64_t uintmax_t; |
| 625 |
# define INTMAX_MAX INT64_MAX |
| 626 |
# define INTMAX_MIN INT64_MIN |
| 627 |
# define UINTMAX_MAX UINT64_MAX |
| 628 |
# define UINTMAX_C(v) UINT64_C(v) |
| 629 |
# define INTMAX_C(v) INT64_C(v) |
| 630 |
# ifndef PRINTF_INTMAX_MODIFIER |
| 631 |
# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER |
| 632 |
# endif |
| 633 |
# ifndef PRINTF_INTMAX_HEX_WIDTH |
| 634 |
# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH |
| 635 |
# endif |
| 636 |
# ifndef PRINTF_INTMAX_DEC_WIDTH |
| 637 |
# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH |
| 638 |
# endif |
| 639 |
#else |
| 640 |
typedef int32_t intmax_t; |
| 641 |
typedef uint32_t uintmax_t; |
| 642 |
# define INTMAX_MAX INT32_MAX |
| 643 |
# define UINTMAX_MAX UINT32_MAX |
| 644 |
# define UINTMAX_C(v) UINT32_C(v) |
| 645 |
# define INTMAX_C(v) INT32_C(v) |
| 646 |
# ifndef PRINTF_INTMAX_MODIFIER |
| 647 |
# define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER |
| 648 |
# endif |
| 649 |
# ifndef PRINTF_INTMAX_HEX_WIDTH |
| 650 |
# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH |
| 651 |
# endif |
| 652 |
# ifndef PRINTF_INTMAX_DEC_WIDTH |
| 653 |
# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH |
| 654 |
# endif |
| 655 |
#endif |
| 656 |
|
| 657 |
/* |
| 658 |
* Because this file currently only supports platforms which have |
| 659 |
* precise powers of 2 as bit sizes for the default integers, the |
| 660 |
* least definitions are all trivial. Its possible that a future |
| 661 |
* version of this file could have different definitions. |
| 662 |
*/ |
| 663 |
|
| 664 |
#ifndef stdint_least_defined |
| 665 |
typedef int8_t int_least8_t; |
| 666 |
typedef uint8_t uint_least8_t; |
| 667 |
typedef int16_t int_least16_t; |
| 668 |
typedef uint16_t uint_least16_t; |
| 669 |
typedef int32_t int_least32_t; |
| 670 |
typedef uint32_t uint_least32_t; |
| 671 |
# define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER |
| 672 |
# define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER |
| 673 |
# define UINT_LEAST8_MAX UINT8_MAX |
| 674 |
# define INT_LEAST8_MAX INT8_MAX |
| 675 |
# define UINT_LEAST16_MAX UINT16_MAX |
| 676 |
# define INT_LEAST16_MAX INT16_MAX |
| 677 |
# define UINT_LEAST32_MAX UINT32_MAX |
| 678 |
# define INT_LEAST32_MAX INT32_MAX |
| 679 |
# define INT_LEAST8_MIN INT8_MIN |
| 680 |
# define INT_LEAST16_MIN INT16_MIN |
| 681 |
# define INT_LEAST32_MIN INT32_MIN |
| 682 |
# ifdef stdint_int64_defined |
| 683 |
typedef int64_t int_least64_t; |
| 684 |
typedef uint64_t uint_least64_t; |
| 685 |
# define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER |
| 686 |
# define UINT_LEAST64_MAX UINT64_MAX |
| 687 |
# define INT_LEAST64_MAX INT64_MAX |
| 688 |
# define INT_LEAST64_MIN INT64_MIN |
| 689 |
# endif |
| 690 |
#endif |
| 691 |
#undef stdint_least_defined |
| 692 |
|
| 693 |
/* |
| 694 |
* The ANSI C committee pretending to know or specify anything about |
| 695 |
* performance is the epitome of misguided arrogance. The mandate of |
| 696 |
* this file is to *ONLY* ever support that absolute minimum |
| 697 |
* definition of the fast integer types, for compatibility purposes. |
| 698 |
* No extensions, and no attempt to suggest what may or may not be a |
| 699 |
* faster integer type will ever be made in this file. Developers are |
| 700 |
* warned to stay away from these types when using this or any other |
| 701 |
* stdint.h. |
| 702 |
*/ |
| 703 |
|
| 704 |
#ifndef int_fast8_t |
| 705 |
typedef int_least8_t int_fast8_t; |
| 706 |
#endif |
| 707 |
#ifndef uint_fast8_t |
| 708 |
typedef uint_least8_t uint_fast8_t; |
| 709 |
#endif |
| 710 |
#ifndef int_fast16_t |
| 711 |
typedef int_least16_t int_fast16_t; |
| 712 |
#endif |
| 713 |
#ifndef uint_fast16_t |
| 714 |
typedef uint_least16_t uint_fast16_t; |
| 715 |
#endif |
| 716 |
#ifndef int_fast32_t |
| 717 |
typedef int_least32_t int_fast32_t; |
| 718 |
#endif |
| 719 |
#ifndef uint_fast32_t |
| 720 |
typedef uint_least32_t uint_fast32_t; |
| 721 |
#endif |
| 722 |
#define UINT_FAST8_MAX UINT_LEAST8_MAX |
| 723 |
#define INT_FAST8_MAX INT_LEAST8_MAX |
| 724 |
#define UINT_FAST16_MAX UINT_LEAST16_MAX |
| 725 |
#define INT_FAST16_MAX INT_LEAST16_MAX |
| 726 |
#define UINT_FAST32_MAX UINT_LEAST32_MAX |
| 727 |
#define INT_FAST32_MAX INT_LEAST32_MAX |
| 728 |
#define INT_FAST8_MIN INT_LEAST8_MIN |
| 729 |
#define INT_FAST16_MIN INT_LEAST16_MIN |
| 730 |
#define INT_FAST32_MIN INT_LEAST32_MIN |
| 731 |
#ifdef stdint_int64_defined |
| 732 |
typedef int_least64_t int_fast64_t; |
| 733 |
typedef uint_least64_t uint_fast64_t; |
| 734 |
# define UINT_FAST64_MAX UINT_LEAST64_MAX |
| 735 |
# define INT_FAST64_MAX INT_LEAST64_MAX |
| 736 |
# define INT_FAST64_MIN INT_LEAST64_MIN |
| 737 |
#endif |
| 738 |
|
| 739 |
/* |
| 740 |
* Whatever piecemeal, per compiler thing we can do about the wchar_t |
| 741 |
* type limits. |
| 742 |
*/ |
| 743 |
|
| 744 |
#if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__) |
| 745 |
# include <wchar.h> |
| 746 |
# ifndef WCHAR_MIN |
| 747 |
# define WCHAR_MIN 0 |
| 748 |
# endif |
| 749 |
# ifndef WCHAR_MAX |
| 750 |
# define WCHAR_MAX ((wchar_t)-1) |
| 751 |
# endif |
| 752 |
#endif |
| 753 |
|
| 754 |
/* |
| 755 |
* Whatever piecemeal, per compiler/platform thing we can do about the |
| 756 |
* (u)intptr_t types and limits. |
| 757 |
*/ |
| 758 |
|
| 759 |
#if defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED) |
| 760 |
# define STDINT_H_UINTPTR_T_DEFINED |
| 761 |
#endif |
| 762 |
|
| 763 |
#ifndef STDINT_H_UINTPTR_T_DEFINED |
| 764 |
# if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64) |
| 765 |
# define stdint_intptr_bits 64 |
| 766 |
# elif defined (__WATCOMC__) || defined (__TURBOC__) |
| 767 |
# if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__) |
| 768 |
# define stdint_intptr_bits 16 |
| 769 |
# else |
| 770 |
# define stdint_intptr_bits 32 |
| 771 |
# endif |
| 772 |
# elif defined (__i386__) || defined (_WIN32) || defined (WIN32) |
| 773 |
# define stdint_intptr_bits 32 |
| 774 |
# elif defined (__INTEL_COMPILER) |
| 775 |
/* TODO -- what will Intel do about x86-64? */ |
| 776 |
# endif |
| 777 |
|
| 778 |
# ifdef stdint_intptr_bits |
| 779 |
# define stdint_intptr_glue3_i(a,b,c) a##b##c |
| 780 |
# define stdint_intptr_glue3(a,b,c) stdint_intptr_glue3_i(a,b,c) |
| 781 |
# ifndef PRINTF_INTPTR_MODIFIER |
| 782 |
# define PRINTF_INTPTR_MODIFIER stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER) |
| 783 |
# endif |
| 784 |
# ifndef PTRDIFF_MAX |
| 785 |
# define PTRDIFF_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX) |
| 786 |
# endif |
| 787 |
# ifndef PTRDIFF_MIN |
| 788 |
# define PTRDIFF_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN) |
| 789 |
# endif |
| 790 |
# ifndef UINTPTR_MAX |
| 791 |
# define UINTPTR_MAX stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX) |
| 792 |
# endif |
| 793 |
# ifndef INTPTR_MAX |
| 794 |
# define INTPTR_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX) |
| 795 |
# endif |
| 796 |
# ifndef INTPTR_MIN |
| 797 |
# define INTPTR_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN) |
| 798 |
# endif |
| 799 |
# ifndef INTPTR_C |
| 800 |
# define INTPTR_C(x) stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x) |
| 801 |
# endif |
| 802 |
# ifndef UINTPTR_C |
| 803 |
# define UINTPTR_C(x) stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x) |
| 804 |
# endif |
| 805 |
typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t; |
| 806 |
typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t) intptr_t; |
| 807 |
# else |
| 808 |
/* TODO -- This following is likely wrong for some platforms, and does |
| 809 |
nothing for the definition of uintptr_t. */ |
| 810 |
typedef ptrdiff_t intptr_t; |
| 811 |
# endif |
| 812 |
# define STDINT_H_UINTPTR_T_DEFINED |
| 813 |
#endif |
| 814 |
|
| 815 |
/* |
| 816 |
* Assumes sig_atomic_t is signed and we have a 2s complement machine. |
| 817 |
*/ |
| 818 |
|
| 819 |
#ifndef SIG_ATOMIC_MAX |
| 820 |
# define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1) |
| 821 |
#endif |
| 822 |
|
| 823 |
#endif |
| 824 |
|
| 825 |
#if defined (__TEST_PSTDINT_FOR_CORRECTNESS) |
| 826 |
|
| 827 |
/* |
| 828 |
* Please compile with the maximum warning settings to make sure macros are not |
| 829 |
* defined more than once. |
| 830 |
*/ |
| 831 |
|
| 832 |
#include <stdlib.h> |
| 833 |
#include <stdio.h> |
| 834 |
#include <string.h> |
| 835 |
|
| 836 |
#define glue3_aux(x,y,z) x ## y ## z |
| 837 |
#define glue3(x,y,z) glue3_aux(x,y,z) |
| 838 |
|
| 839 |
#define DECLU(bits) glue3(uint,bits,_t) glue3(u,bits,=) glue3(UINT,bits,_C) (0); |
| 840 |
#define DECLI(bits) glue3(int,bits,_t) glue3(i,bits,=) glue3(INT,bits,_C) (0); |
| 841 |
|
| 842 |
#define DECL(us,bits) glue3(DECL,us,) (bits) |
| 843 |
|
| 844 |
#define TESTUMAX(bits) glue3(u,bits,=) glue3(~,u,bits); if (glue3(UINT,bits,_MAX) glue3(!=,u,bits)) printf ("Something wrong with UINT%d_MAX\n", bits) |
| 845 |
|
| 846 |
int main () { |
| 847 |
DECL(I,8) |
| 848 |
DECL(U,8) |
| 849 |
DECL(I,16) |
| 850 |
DECL(U,16) |
| 851 |
DECL(I,32) |
| 852 |
DECL(U,32) |
| 853 |
#ifdef INT64_MAX |
| 854 |
DECL(I,64) |
| 855 |
DECL(U,64) |
| 856 |
#endif |
| 857 |
intmax_t imax = INTMAX_C(0); |
| 858 |
uintmax_t umax = UINTMAX_C(0); |
| 859 |
char str0[256], str1[256]; |
| 860 |
|
| 861 |
sprintf (str0, "%d %x\n", 0, ~0); |
| 862 |
|
| 863 |
sprintf (str1, "%d %x\n", i8, ~0); |
| 864 |
if (0 != strcmp (str0, str1)) printf ("Something wrong with i8 : %s\n", str1); |
| 865 |
sprintf (str1, "%u %x\n", u8, ~0); |
| 866 |
if (0 != strcmp (str0, str1)) printf ("Something wrong with u8 : %s\n", str1); |
| 867 |
sprintf (str1, "%d %x\n", i16, ~0); |
| 868 |
if (0 != strcmp (str0, str1)) printf ("Something wrong with i16 : %s\n", str1); |
| 869 |
sprintf (str1, "%u %x\n", u16, ~0); |
| 870 |
if (0 != strcmp (str0, str1)) printf ("Something wrong with u16 : %s\n", str1); |
| 871 |
sprintf (str1, "%" PRINTF_INT32_MODIFIER "d %x\n", i32, ~0); |
| 872 |
if (0 != strcmp (str0, str1)) printf ("Something wrong with i32 : %s\n", str1); |
| 873 |
sprintf (str1, "%" PRINTF_INT32_MODIFIER "u %x\n", u32, ~0); |
| 874 |
if (0 != strcmp (str0, str1)) printf ("Something wrong with u32 : %s\n", str1); |
| 875 |
#ifdef INT64_MAX |
| 876 |
sprintf (str1, "%" PRINTF_INT64_MODIFIER "d %x\n", i64, ~0); |
| 877 |
if (0 != strcmp (str0, str1)) printf ("Something wrong with i64 : %s\n", str1); |
| 878 |
#endif |
| 879 |
sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "d %x\n", imax, ~0); |
| 880 |
if (0 != strcmp (str0, str1)) printf ("Something wrong with imax : %s\n", str1); |
| 881 |
sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "u %x\n", umax, ~0); |
| 882 |
if (0 != strcmp (str0, str1)) printf ("Something wrong with umax : %s\n", str1); |
| 883 |
|
| 884 |
TESTUMAX(8); |
| 885 |
TESTUMAX(16); |
| 886 |
TESTUMAX(32); |
| 887 |
#ifdef INT64_MAX |
| 888 |
TESTUMAX(64); |
| 889 |
#endif |
| 890 |
|
| 891 |
return EXIT_SUCCESS; |
| 892 |
} |
| 893 |
|
| 894 |
#endif |
| 895 |
|
| 896 |
#if defined(_STDINT) && defined(_MSC_VER) |
| 897 |
#define stdint_int64_defined |
| 898 |
#endif |
| 899 |
|
| 900 |
#endif |