/bncsutil/src/bncsutil/mutil_types.h

http://ghostcb.googlecode.com/ · C Header · 145 lines · 94 code · 25 blank · 26 comment · 3 complexity · 962ce6b98e1ba278890f6a64ca66f4cb MD5 · raw file

  1. /**
  2. * BNCSutil
  3. * Battle.Net Utility Library
  4. *
  5. * Copyright (C) 2004-2006 Eric Naeseth
  6. *
  7. * Integer Types
  8. * November 12, 2004
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation; either
  13. * version 2.1 of the License, or (at your option) any later version.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * A copy of the GNU Lesser General Public License is included in the BNCSutil
  21. * distribution in the file COPYING. If you did not receive this copy,
  22. * write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  23. * Boston, MA 02111-1307 USA
  24. */
  25. #ifndef BNCSUTIL_MUTIL_TYPES_H_INCLUDED
  26. #define BNCSUTIL_MUTIL_TYPES_H_INCLUDED
  27. #ifdef WIN32
  28. #include "ms_stdint.h"
  29. #else
  30. #if defined(_MSC_VER) || (defined(HAVE_STDINT_H) && !HAVE_STDINT_H)
  31. // no stdint.h available
  32. // so just wing it
  33. typedef signed char int8_t;
  34. typedef unsigned char uint8_t;
  35. typedef short int16_t;
  36. typedef unsigned short uint16_t;
  37. typedef int int32_t;
  38. typedef unsigned int uint32_t;
  39. #ifdef _MSC_VER
  40. typedef __int64 int64_t;
  41. typedef unsigned __int64 uint64_t;
  42. #else
  43. typedef long long int64_t;
  44. typedef unsigned long long uint64_t;
  45. #endif
  46. typedef int32_t register_t;
  47. #ifndef _MSC_VER
  48. typedef long int intptr_t;
  49. typedef unsigned long int uintptr_t;
  50. #endif
  51. typedef int8_t int_least8_t;
  52. typedef int16_t int_least16_t;
  53. typedef int32_t int_least32_t;
  54. typedef int64_t int_least64_t;
  55. typedef uint8_t uint_least8_t;
  56. typedef uint16_t uint_least16_t;
  57. typedef uint32_t uint_least32_t;
  58. typedef uint64_t uint_least64_t;
  59. typedef int8_t int_fast8_t;
  60. typedef int16_t int_fast16_t;
  61. typedef int32_t int_fast32_t;
  62. typedef int64_t int_fast64_t;
  63. typedef uint8_t uint_fast8_t;
  64. typedef uint16_t uint_fast16_t;
  65. typedef uint32_t uint_fast32_t;
  66. typedef uint64_t uint_fast64_t;
  67. typedef long long intmax_t;
  68. typedef unsigned long long uintmax_t;
  69. #if (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS)
  70. #define INT8_MAX 127
  71. #define INT16_MAX 32767
  72. #define INT32_MAX 2147483647
  73. #define INT64_MAX 9223372036854775807LL
  74. #define INT8_MIN -128
  75. #define INT16_MIN -32768
  76. #define INT32_MIN (-INT32_MAX-1)
  77. #define INT64_MIN (-INT64_MAX-1)
  78. #define UINT8_MAX 255
  79. #define UINT16_MAX 65535
  80. #define UINT32_MAX 4294967295U
  81. #define UINT64_MAX 18446744073709551615ULL
  82. #define INT_LEAST8_MIN INT8_MIN
  83. #define INT_LEAST16_MIN INT16_MIN
  84. #define INT_LEAST32_MIN INT32_MIN
  85. #define INT_LEAST64_MIN INT64_MIN
  86. #define INT_LEAST8_MAX INT8_MAX
  87. #define INT_LEAST16_MAX INT16_MAX
  88. #define INT_LEAST32_MAX INT32_MAX
  89. #define INT_LEAST64_MAX INT64_MAX
  90. #define UINT_LEAST8_MAX UINT8_MAX
  91. #define UINT_LEAST16_MAX UINT16_MAX
  92. #define UINT_LEAST32_MAX UINT32_MAX
  93. #define UINT_LEAST64_MAX UINT64_MAX
  94. #define INT_FAST8_MIN INT8_MIN
  95. #define INT_FAST16_MIN INT16_MIN
  96. #define INT_FAST32_MIN INT32_MIN
  97. #define INT_FAST64_MIN INT64_MIN
  98. #define INT_FAST8_MAX INT8_MAX
  99. #define INT_FAST16_MAX INT16_MAX
  100. #define INT_FAST32_MAX INT32_MAX
  101. #define INT_FAST64_MAX INT64_MAX
  102. #define UINT_FAST8_MAX UINT8_MAX
  103. #define UINT_FAST16_MAX UINT16_MAX
  104. #define UINT_FAST32_MAX UINT32_MAX
  105. #define UINT_FAST64_MAX UINT64_MAX
  106. #define INTPTR_MIN INT32_MIN
  107. #define INTPTR_MAX INT32_MAX
  108. #define UINTPTR_MAX UINT32_MAX
  109. #define INTMAX_MIN INT64_MIN
  110. #define INTMAX_MAX INT64_MAX
  111. #define UINTMAX_MAX UINT64_MAX
  112. #define PTRDIFF_MIN INT32_MIN
  113. #define PTRDIFF_MAX INT32_MAX
  114. #define SIZE_MAX UINT32_MAX
  115. #endif /* if C++, then __STDC_LIMIT_MACROS enables the above macros */
  116. #else
  117. #include <stdint.h>
  118. #endif
  119. #endif /* WIN32 */
  120. #endif /* BNCSUTIL_MUTIL_TYPES_H_INCLUDED */