CACAO
types.hpp
Go to the documentation of this file.
1 /* src/vm/types.hpp - type definitions for CACAO's internal types
2 
3  Copyright (C) 1996-2013
4  CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 
6  This file is part of CACAO.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2, or (at
11  your option) any later version.
12 
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  02110-1301, USA.
22 
23 */
24 
25 
26 #ifndef CACAO_TYPES_HPP_
27 #define CACAO_TYPES_HPP_ 1
28 
29 #include "config.h"
30 
31 #include <stdint.h>
32 #include <climits>
33 
34 /* In this file we check for unknown pointersizes, so we don't have to
35  do this somewhere else. */
36 
37 /* Define the sizes of the integer types used internally by CACAO. ************/
38 
39 typedef int8_t s1;
40 typedef uint8_t u1;
41 
42 typedef int16_t s2;
43 typedef uint16_t u2;
44 
45 typedef int32_t s4;
46 typedef uint32_t u4;
47 
48 typedef int64_t s8;
49 typedef uint64_t u8;
50 
51 
52 /* Define the size of a function pointer used in function pointer casts. ******/
53 
54 typedef uintptr_t ptrint;
55 
56 namespace cacao {
57 
58 // numeric limits template
59 //
60 // std::numeric_limits<T>::max() can not be used in some cases because it is no
61 // constant expression.
62 
63 template <class T> struct numeric_limits {
64 public:
65  static const T min;
66  static const T max;
67 };
68 
69 /**
70  * C++11 INTXX_MIN etc are available in C++11
71  */
72 #if 0
73 template <> struct numeric_limits<int8_t> {
74 public:
75  static const int8_t min = INT8_MIN;
76  static const int8_t max = INT8_MAX;
77 };
78 template <> struct numeric_limits<uint8_t> {
79 public:
80  static const uint8_t min = 0;
81  static const uint8_t max = UINT8_MAX;
82 };
83 template <> struct numeric_limits<int16_t> {
84 public:
85  static const int16_t min = INT16_MIN;
86  static const int16_t max = INT16_MAX;
87 };
88 template <> struct numeric_limits<uint16_t> {
89 public:
90  static const uint16_t min = 0;
91  static const uint16_t max = UINT16_MAX;
92 };
93 template <> struct numeric_limits<int32_t> {
94 public:
95  static const int32_t min = INT32_MIN;
96  static const int32_t max = INT32_MAX;
97 };
98 template <> struct numeric_limits<uint32_t> {
99 public:
100  static const uint32_t min = 0;
101  static const uint32_t max = UINT32_MAX;
102 };
103 template <> struct numeric_limits<int64_t> {
104 public:
105  static const int64_t min = INT64_MIN;
106  static const int64_t max = INT64_MAX;
107 };
108 template <> struct numeric_limits<uint64_t> {
109 public:
110  static const uint64_t min = 0;
111  static const uint64_t max = UINT64_MAX;
112 };
113 #endif
114 template <> struct numeric_limits<signed char> {
115 public:
116  static const signed char min = SCHAR_MIN;
117  static const signed char max = SCHAR_MAX;
118 };
119 template <> struct numeric_limits<char> {
120 public:
121  static const char min = CHAR_MIN;
122  static const char max = CHAR_MAX;
123 };
124 template <> struct numeric_limits<short> {
125 public:
126  static const short min = SHRT_MIN;
127  static const short max = SHRT_MAX;
128 };
129 template <> struct numeric_limits<int> {
130 public:
131  static const int min = INT_MIN;
132  static const int max = INT_MAX;
133 };
134 template <> struct numeric_limits<long> {
135 public:
136  static const long min = LONG_MIN;
137  static const long max = LONG_MAX;
138 };
139 
140 template <> struct numeric_limits<unsigned short> {
141 public:
142  static const unsigned short min = 0;
143  static const unsigned short max = USHRT_MAX;
144 };
145 template <> struct numeric_limits<unsigned int> {
146 public:
147  static const unsigned int min = 0;
148  static const unsigned int max = UINT_MAX;
149 };
150 template <> struct numeric_limits<unsigned char> {
151 public:
152  static const unsigned char min = 0;
153  static const unsigned char max = UCHAR_MAX;
154 };
155 template <> struct numeric_limits<unsigned long int> {
156 public:
157  static const unsigned long int min = 0;
158  static const unsigned long int max = ULONG_MAX;
159 };
160 
161 template <class T,class A>
162 inline bool fits_into(A a) {
164 }
165 
166 } // end namespace cacao
167 
168 #endif // CACAO_TYPES_HPP_
169 
170 
171 /*
172  * These are local overrides for various environment variables in Emacs.
173  * Please do not remove this and leave it at the end of the file, where
174  * Emacs will automagically detect them.
175  * ---------------------------------------------------------------------
176  * Local variables:
177  * mode: c++
178  * indent-tabs-mode: t
179  * c-basic-offset: 4
180  * tab-width: 4
181  * End:
182  * vim:noexpandtab:sw=4:ts=4:
183  */
#define max(a, b)
Definition: lsra.hpp:80
static const T min
Definition: types.hpp:65
uint8_t u1
Definition: types.hpp:40
int64_t s8
Definition: types.hpp:48
uint16_t u2
Definition: types.hpp:43
uint64_t u8
Definition: types.hpp:49
int32_t s4
Definition: types.hpp:45
uint32_t u4
Definition: types.hpp:46
static const T max
Definition: types.hpp:66
int8_t s1
Definition: types.hpp:39
int16_t s2
Definition: types.hpp:42
bool fits_into(A a)
Definition: types.hpp:162
uintptr_t ptrint
Definition: types.hpp:54