PageRenderTime 38ms CodeModel.GetById 30ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 26#ifndef BNCSUTIL_MUTIL_TYPES_H_INCLUDED
 27#define BNCSUTIL_MUTIL_TYPES_H_INCLUDED
 28
 29#ifdef WIN32
 30 #include "ms_stdint.h"
 31#else
 32
 33#if defined(_MSC_VER) || (defined(HAVE_STDINT_H) && !HAVE_STDINT_H)
 34// no stdint.h available
 35// so just wing it
 36typedef signed char int8_t;
 37typedef unsigned char uint8_t;
 38typedef short int16_t;
 39typedef unsigned short uint16_t;
 40typedef int int32_t;
 41typedef unsigned int uint32_t;
 42#ifdef _MSC_VER
 43typedef __int64 int64_t;
 44typedef unsigned __int64 uint64_t;
 45#else
 46typedef long long int64_t;
 47typedef unsigned long long uint64_t;
 48#endif
 49typedef int32_t register_t;
 50
 51#ifndef _MSC_VER
 52typedef long int intptr_t;
 53typedef unsigned long int uintptr_t;
 54#endif
 55
 56typedef int8_t           int_least8_t;
 57typedef int16_t         int_least16_t;
 58typedef int32_t         int_least32_t;
 59typedef int64_t         int_least64_t;
 60typedef uint8_t         uint_least8_t;
 61typedef uint16_t       uint_least16_t;
 62typedef uint32_t       uint_least32_t;
 63typedef uint64_t       uint_least64_t;
 64
 65typedef int8_t            int_fast8_t;
 66typedef int16_t          int_fast16_t;
 67typedef int32_t          int_fast32_t;
 68typedef int64_t          int_fast64_t;
 69typedef uint8_t          uint_fast8_t;
 70typedef uint16_t        uint_fast16_t;
 71typedef uint32_t        uint_fast32_t;
 72typedef uint64_t        uint_fast64_t;
 73
 74typedef long long                intmax_t;
 75typedef unsigned long long      uintmax_t;
 76
 77#if (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS)
 78#define INT8_MAX         127
 79#define INT16_MAX        32767
 80#define INT32_MAX        2147483647
 81#define INT64_MAX        9223372036854775807LL
 82
 83#define INT8_MIN          -128
 84#define INT16_MIN         -32768
 85#define INT32_MIN        (-INT32_MAX-1)
 86#define INT64_MIN        (-INT64_MAX-1)
 87
 88#define UINT8_MAX         255
 89#define UINT16_MAX        65535
 90#define UINT32_MAX        4294967295U
 91#define UINT64_MAX        18446744073709551615ULL
 92
 93#define INT_LEAST8_MIN    INT8_MIN
 94#define INT_LEAST16_MIN   INT16_MIN
 95#define INT_LEAST32_MIN   INT32_MIN
 96#define INT_LEAST64_MIN   INT64_MIN
 97
 98#define INT_LEAST8_MAX    INT8_MAX
 99#define INT_LEAST16_MAX   INT16_MAX
100#define INT_LEAST32_MAX   INT32_MAX
101#define INT_LEAST64_MAX   INT64_MAX
102
103#define UINT_LEAST8_MAX   UINT8_MAX
104#define UINT_LEAST16_MAX  UINT16_MAX
105#define UINT_LEAST32_MAX  UINT32_MAX
106#define UINT_LEAST64_MAX  UINT64_MAX
107
108#define INT_FAST8_MIN     INT8_MIN
109#define INT_FAST16_MIN    INT16_MIN
110#define INT_FAST32_MIN    INT32_MIN
111#define INT_FAST64_MIN    INT64_MIN
112
113#define INT_FAST8_MAX     INT8_MAX
114#define INT_FAST16_MAX    INT16_MAX
115#define INT_FAST32_MAX    INT32_MAX
116#define INT_FAST64_MAX    INT64_MAX
117
118#define UINT_FAST8_MAX    UINT8_MAX
119#define UINT_FAST16_MAX   UINT16_MAX
120#define UINT_FAST32_MAX   UINT32_MAX
121#define UINT_FAST64_MAX   UINT64_MAX
122
123#define INTPTR_MIN        INT32_MIN
124#define INTPTR_MAX        INT32_MAX
125                             
126#define UINTPTR_MAX       UINT32_MAX
127
128#define INTMAX_MIN        INT64_MIN
129#define INTMAX_MAX        INT64_MAX
130
131#define UINTMAX_MAX       UINT64_MAX
132
133#define PTRDIFF_MIN       INT32_MIN
134#define PTRDIFF_MAX       INT32_MAX
135
136#define SIZE_MAX          UINT32_MAX
137#endif /* if C++, then __STDC_LIMIT_MACROS enables the above macros */
138
139#else
140#include <stdint.h>
141#endif
142
143#endif /* WIN32 */
144
145#endif /* BNCSUTIL_MUTIL_TYPES_H_INCLUDED */