1
|
1
|
|
2 /**
|
|
3 *
|
|
4 D constrains integral types to specific sizes. But efficiency
|
|
5 of different sizes varies from machine to machine,
|
|
6 pointer sizes vary, and the maximum integer size varies.
|
|
7 <b>stdint</b> offers a portable way of trading off size
|
|
8 vs efficiency, in a manner compatible with the <tt>stdint.h</tt>
|
|
9 definitions in C.
|
|
10
|
|
11 The exact aliases are types of exactly the specified number of bits.
|
|
12 The at least aliases are at least the specified number of bits
|
|
13 large, and can be larger.
|
|
14 The fast aliases are the fastest integral type supported by the
|
|
15 processor that is at least as wide as the specified number of bits.
|
|
16
|
|
17 The aliases are:
|
|
18
|
|
19 <table border=1 cellspacing=0 cellpadding=5>
|
|
20 <th>Exact Alias
|
|
21 <th>Description
|
|
22 <th>At Least Alias
|
|
23 <th>Description
|
|
24 <th>Fast Alias
|
|
25 <th>Description
|
|
26 <tr>
|
|
27 <td>int8_t
|
|
28 <td>exactly 8 bits signed
|
|
29 <td>int_least8_t
|
|
30 <td>at least 8 bits signed
|
|
31 <td>int_fast8_t
|
|
32 <td>fast 8 bits signed
|
|
33 <tr>
|
|
34 <td>uint8_t
|
|
35 <td>exactly 8 bits unsigned
|
|
36 <td>uint_least8_t
|
|
37 <td>at least 8 bits unsigned
|
|
38 <td>uint_fast8_t
|
|
39 <td>fast 8 bits unsigned
|
|
40
|
|
41 <tr>
|
|
42 <td>int16_t
|
|
43 <td>exactly 16 bits signed
|
|
44 <td>int_least16_t
|
|
45 <td>at least 16 bits signed
|
|
46 <td>int_fast16_t
|
|
47 <td>fast 16 bits signed
|
|
48 <tr>
|
|
49 <td>uint16_t
|
|
50 <td>exactly 16 bits unsigned
|
|
51 <td>uint_least16_t
|
|
52 <td>at least 16 bits unsigned
|
|
53 <td>uint_fast16_t
|
|
54 <td>fast 16 bits unsigned
|
|
55
|
|
56 <tr>
|
|
57 <td>int32_t
|
|
58 <td>exactly 32 bits signed
|
|
59 <td>int_least32_t
|
|
60 <td>at least 32 bits signed
|
|
61 <td>int_fast32_t
|
|
62 <td>fast 32 bits signed
|
|
63 <tr>
|
|
64 <td>uint32_t
|
|
65 <td>exactly 32 bits unsigned
|
|
66 <td>uint_least32_t
|
|
67 <td>at least 32 bits unsigned
|
|
68 <td>uint_fast32_t
|
|
69 <td>fast 32 bits unsigned
|
|
70
|
|
71 <tr>
|
|
72 <td>int64_t
|
|
73 <td>exactly 64 bits signed
|
|
74 <td>int_least64_t
|
|
75 <td>at least 64 bits signed
|
|
76 <td>int_fast64_t
|
|
77 <td>fast 64 bits signed
|
|
78 <tr>
|
|
79 <td>uint64_t
|
|
80 <td>exactly 64 bits unsigned
|
|
81 <td>uint_least64_t
|
|
82 <td>at least 64 bits unsigned
|
|
83 <td>uint_fast64_t
|
|
84 <td>fast 64 bits unsigned
|
|
85 </table>
|
|
86
|
|
87 The ptr aliases are integral types guaranteed to be large enough
|
|
88 to hold a pointer without losing bits:
|
|
89
|
|
90 <table border=1 cellspacing=0 cellpadding=5>
|
|
91 <th>Alias
|
|
92 <th>Description
|
|
93 <tr>
|
|
94 <td>intptr_t
|
|
95 <td>signed integral type large enough to hold a pointer
|
|
96 <tr>
|
|
97 <td>uintptr_t
|
|
98 <td>unsigned integral type large enough to hold a pointer
|
|
99 </table>
|
|
100
|
|
101 The max aliases are the largest integral types:
|
|
102
|
|
103 <table border=1 cellspacing=0 cellpadding=5>
|
|
104 <th>Alias
|
|
105 <th>Description
|
|
106 <tr>
|
|
107 <td>intmax_t
|
|
108 <td>the largest signed integral type
|
|
109 <tr>
|
|
110 <td>uintmax_t
|
|
111 <td>the largest unsigned integral type
|
|
112 </table>
|
|
113
|
|
114 * Authors: Walter Bright, www.digitalmars.com
|
|
115 * License: Public Domain
|
|
116 * Macros:
|
|
117 * WIKI=Phobos/StdStdint
|
|
118 */
|
|
119
|
|
120 /*
|
|
121 NOTE: This file has been patched from the original DMD distribution to
|
|
122 work with the LLVMDC compiler.
|
|
123
|
|
124 Modified by Tomas Lindquist Olsen, August 2007
|
|
125 */
|
|
126
|
|
127 module std.stdint;
|
|
128
|
|
129 /* Exact sizes */
|
|
130
|
|
131 alias byte int8_t;
|
|
132 alias ubyte uint8_t;
|
|
133 alias short int16_t;
|
|
134 alias ushort uint16_t;
|
|
135 alias int int32_t;
|
|
136 alias uint uint32_t;
|
|
137 alias long int64_t;
|
|
138 alias ulong uint64_t;
|
|
139
|
|
140 /* At least sizes */
|
|
141
|
|
142 alias byte int_least8_t;
|
|
143 alias ubyte uint_least8_t;
|
|
144 alias short int_least16_t;
|
|
145 alias ushort uint_least16_t;
|
|
146 alias int int_least32_t;
|
|
147 alias uint uint_least32_t;
|
|
148 alias long int_least64_t;
|
|
149 alias ulong uint_least64_t;
|
|
150
|
|
151 /* Fastest minimum width sizes */
|
|
152
|
|
153 alias byte int_fast8_t;
|
|
154 alias ubyte uint_fast8_t;
|
|
155 alias int int_fast16_t;
|
|
156 alias uint uint_fast16_t;
|
|
157 alias int int_fast32_t;
|
|
158 alias uint uint_fast32_t;
|
|
159 alias long int_fast64_t;
|
|
160 alias ulong uint_fast64_t;
|
|
161
|
|
162 /* Integer pointer holders */
|
|
163
|
|
164 version(LLVM64) {
|
|
165 alias long intptr_t;
|
|
166 alias ulong uintptr_t;
|
|
167 }
|
|
168 else {
|
|
169 alias int intptr_t;
|
|
170 alias uint uintptr_t;
|
|
171 }
|
|
172
|
|
173 /* Greatest width integer types */
|
|
174
|
|
175 alias long intmax_t;
|
|
176 alias ulong uintmax_t;
|
|
177
|