1 /**
2  * D header file for C99.
3  *
4  * Copyright: Public Domain
5  * License:   Public Domain
6  * Authors:   Sean Kelly
7  * Standards: ISO/IEC 9899:1999 (E)
8  */
9 module tango.stdc.stdint;
10 
11 private
12 {
13     template typify(T)
14     {
15         T typify( T val ) { return val; }
16     }
17 }
18 
19 extern (C):
20 
21 alias byte      int8_t;
22 alias short     int16_t;
23 alias int       int32_t;
24 alias long      int64_t;
25 //alias cent      int128_t;
26 
27 alias ubyte     uint8_t;
28 alias ushort    uint16_t;
29 alias uint      uint32_t;
30 alias ulong     uint64_t;
31 //alias ucent     uint128_t;
32 
33 alias byte      int_least8_t;
34 alias short     int_least16_t;
35 alias int       int_least32_t;
36 alias long      int_least64_t;
37 
38 alias ubyte     uint_least8_t;
39 alias ushort    uint_least16_t;
40 alias uint      uint_least32_t;
41 alias ulong     uint_least64_t;
42 
43 alias byte      int_fast8_t;
44 alias int       int_fast16_t;
45 alias int       int_fast32_t;
46 alias long      int_fast64_t;
47 
48 alias ubyte     uint_fast8_t;
49 alias uint      uint_fast16_t;
50 alias uint      uint_fast32_t;
51 alias ulong     uint_fast64_t;
52 
53 version( X86_64 )
54 {
55     alias long  intptr_t;
56     alias ulong uintptr_t;
57 }
58 else
59 {
60     alias int   intptr_t;
61     alias uint  uintptr_t;
62 }
63 
64 alias long      intmax_t;
65 alias ulong     uintmax_t;
66 
67 version( VerboseC )
68 {
69     private import tango.stdc.stddef;
70     private import tango.stdc.signal; // for sig_atomic_t
71 
72     const int8_t  INT8_MIN  = int8_t.min;
73     const int8_t  INT8_MAX  = int8_t.max;
74     const int16_t INT16_MIN = int16_t.min;
75     const int16_t INT16_MAX = int16_t.max;
76     const int32_t INT32_MIN = int32_t.min;
77     const int32_t INT32_MAX = int32_t.max;
78     const int64_t INT64_MIN = int64_t.min;
79     const int64_t INT64_MAX = int64_t.max;
80 
81     const uint8_t  UINT8_MAX  = uint8_t.max;
82     const uint16_t UINT16_MAX = uint16_t.max;
83     const uint32_t UINT32_MAX = uint32_t.max;
84     const uint64_t UINT64_MAX = uint64_t.max;
85 
86     const int_least8_t   INT_LEAST8_MIN  = int_least8_t.min;
87     const int_least8_t   INT_LEAST8_MAX  = int_least8_t.max;
88     const int_least16_t  INT_LEAST16_MIN = int_least16_t.min;
89     const int_least16_t  INT_LEAST16_MAX = int_least16_t.max;
90     const int_least32_t  INT_LEAST32_MIN = int_least32_t.min;
91     const int_least32_t  INT_LEAST32_MAX = int_least32_t.max;
92     const int_least64_t  INT_LEAST64_MIN = int_least64_t.min;
93     const int_least64_t  INT_LEAST64_MAX = int_least64_t.max;
94 
95     const uint_least8_t   UINT_LEAST8_MAX  = uint_least8_t.max;
96     const uint_least16_t  UINT_LEAST16_MAX = uint_least16_t.max;
97     const uint_least32_t  UINT_LEAST32_MAX = uint_least32_t.max;
98     const uint_least64_t  UINT_LEAST64_MAX = uint_least64_t.max;
99 
100     const int_fast8_t   INT_FAST8_MIN  = int_fast8_t.min;
101     const int_fast8_t   INT_FAST8_MAX  = int_fast8_t.max;
102     const int_fast16_t  INT_FAST16_MIN = int_fast16_t.min;
103     const int_fast16_t  INT_FAST16_MAX = int_fast16_t.max;
104     const int_fast32_t  INT_FAST32_MIN = int_fast32_t.min;
105     const int_fast32_t  INT_FAST32_MAX = int_fast32_t.max;
106     const int_fast64_t  INT_FAST64_MIN = int_fast64_t.min;
107     const int_fast64_t  INT_FAST64_MAX = int_fast64_t.max;
108 
109     const uint_fast8_t   UINT_FAST8_MAX  = uint_fast8_t.max;
110     const uint_fast16_t  UINT_FAST16_MAX = uint_fast16_t.max;
111     const uint_fast32_t  UINT_FAST32_MAX = uint_fast32_t.max;
112     const uint_fast64_t  UINT_FAST64_MAX = uint_fast64_t.max;
113 
114     const intptr_t INTPTR_MIN = intptr_t.min;
115     const intptr_t INTPTR_MAX = intptr_t.max;
116 
117     const uintptr_t UINTPTR_MIN = uintptr_t.min;
118     const uintptr_t UINTPTR_MAX = uintptr_t.max;
119 
120     const intmax_t INTMAX_MIN = intmax_t.min;
121     const intmax_t INTMAX_MAX = intmax_t.max;
122 
123     const uintmax_t UINTMAX_MAX = uintmax_t.max;
124 
125     const ptrdiff_t PTRDIFF_MIN = ptrdiff_t.min;
126     const ptrdiff_t PTRDIFF_MAX = ptrdiff_t.max;
127 
128     const sig_atomic_t SIG_ATOMIC_MIN = sig_atomic_t.min;
129     const sig_atomic_t SIG_ATOMIC_MAX = sig_atomic_t.max;
130 
131     const size_t    SIZE_MAX    = size_t.max;
132 
133     const wchar_t   WCHAR_MIN   = wchar_t.min;
134     const wchar_t   WCHAR_MAX   = wchar_t.max;
135 
136     const wint_t    WINT_MIN    = wint_t.min;
137     const wint_t    WINT_MAX    = wint_t.max;
138 }
139 
140 alias typify!(int8_t)  INT8_C;
141 alias typify!(int16_t) INT16_C;
142 alias typify!(int32_t) INT32_C;
143 alias typify!(int64_t) INT64_C;
144 
145 alias typify!(uint8_t)  UINT8_C;
146 alias typify!(uint16_t) UINT16_C;
147 alias typify!(uint32_t) UINT32_C;
148 alias typify!(uint64_t) UINT64_C;
149 
150 alias typify!(intmax_t)  INTMAX_C;
151 alias typify!(uintmax_t) UINTMAX_C;