Types.h
1 /*
2  * Copyright (C) 2004-2013 Marc Boris Duerner
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * As a special exception, you may use this file as part of a free
10  * software library without restriction. Specifically, if other files
11  * instantiate templates or use macros or inline functions from this
12  * file, or you compile this file and link it with other files to
13  * produce an executable, this file does not by itself cause the
14  * resulting executable to be covered by the GNU General Public
15  * License. This exception does not however invalidate any other
16  * reasons why the executable file might be covered by the GNU Library
17  * General Public License.
18  *
19  * This library is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  * Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public
25  * License along with this library; if not, write to the Free Software
26  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27  */
28 
29 #ifndef Pt_Types_h
30 #define Pt_Types_h
31 
32 #include <Pt/Api.h>
33 #include <climits>
34 #include <cstddef>
35 
36 namespace Pt {
37 
38  typedef unsigned char uchar;
39  typedef unsigned short ushort;
40  typedef unsigned int uint;
41  typedef unsigned long ulong;
42 
43  typedef std::size_t size_t;
44  typedef std::ptrdiff_t ssize_t;
45 
46  typedef signed char int8_t;
47  typedef unsigned char uint8_t;
48 
49 #if USHRT_MAX == 0xffff
50 
51  typedef short int16_t;
52  typedef unsigned short uint16_t;
53 
54 #elif UINT_MAX == 0xffff
55 
56  typedef int int16_t;
57  typedef unsigned int uint16_t;
58 
59 #endif
60 
61 #if UINT_MAX == 0xffffffffUL
62 
63  typedef int int32_t;
64  typedef unsigned int uint32_t;
65 
66 #elif ULONG_MAX == 0xffffffffUL
67 
68  typedef long int32_t;
69  typedef unsigned long uint32_t;
70 
71 #endif
72 
73 #if ULONG_MAX == 18446744073709551615ULL
74  #define PT_WITH_INT64 1
75 
76  typedef long int64_t;
77  typedef unsigned long uint64_t;
78 
79 #elif ULLONG_MAX == 18446744073709551615ULL
80  #define PT_WITH_INT64 1
81 
82  typedef long long int64_t;
83  typedef unsigned long long uint64_t;
84 
85 #elif defined(__GNUC__) || defined(__MWERKS_SYMBIAN__)
86  #define PT_WITH_INT64 1
87 
88  typedef long long int64_t;
89  typedef unsigned long long uint64_t;
90 
91 #endif
92 
93 #ifdef ULLONG_MAX
94  #define PT_WITH_LONG_LONG 1
95 #endif
96 
98 union varint_t
99 {
100  void* ptr;
101  bool b;
102  int i;
103  unsigned u;
104  long l;
105  unsigned long ul;
106  std::size_t s;
107  Pt::uint64_t u64;
108 };
109 
110 } // namespace Pt
111 
112 #endif // Pt_Types_h
uint_type uint16_t
Unsigned 16-bit integer type.
Definition: Types.h:30
int_type int16_t
Signed 16-bit integer type.
Definition: Types.h:24
int_type int32_t
Signed 32-bit integer type.
Definition: Types.h:36
int_type int64_t
Signed 64-bit integer type.
Definition: Types.h:48
int_type int8_t
Signed 8-bit integer type.
Definition: Types.h:12
uint_type uint64_t
Unsigned 64-bit integer type.
Definition: Types.h:54
uint_type uint32_t
Unsigned 32-bit integer type.
Definition: Types.h:42
uint_type uint8_t
Unsigned 8-bit integer type.
Definition: Types.h:18