* gcc.dg/Wtrampolines.c: XFAIL AIX.
[official-gcc.git] / gcc / ada / i-c.ads
blob1088836e25ed022458f75490bb05bca0b9b9b828
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- I N T E R F A C E S . C --
6 -- --
7 -- S p e c --
8 -- --
9 -- This specification is derived from the Ada Reference Manual for use with --
10 -- GNAT. In accordance with the copyright of that document, you can freely --
11 -- copy and modify this specification, provided that if you redistribute a --
12 -- modified version, any changes that you have made are clearly indicated. --
13 -- --
14 ------------------------------------------------------------------------------
16 with System.Parameters;
18 package Interfaces.C is
19 pragma Pure;
21 -- Declaration's based on C's <limits.h>
23 CHAR_BIT : constant := 8;
24 SCHAR_MIN : constant := -128;
25 SCHAR_MAX : constant := 127;
26 UCHAR_MAX : constant := 255;
28 -- Signed and Unsigned Integers. Note that in GNAT, we have ensured that
29 -- the standard predefined Ada types correspond to the standard C types
31 -- Note: the Integer qualifications used in the declaration of type long
32 -- avoid ambiguities when compiling in the presence of s-auxdec.ads and
33 -- a non-private system.address type.
35 type int is new Integer;
36 type short is new Short_Integer;
37 type long is range -(2 ** (System.Parameters.long_bits - Integer'(1)))
38 .. +(2 ** (System.Parameters.long_bits - Integer'(1))) - 1;
40 type signed_char is range SCHAR_MIN .. SCHAR_MAX;
41 for signed_char'Size use CHAR_BIT;
43 type unsigned is mod 2 ** int'Size;
44 type unsigned_short is mod 2 ** short'Size;
45 type unsigned_long is mod 2 ** long'Size;
47 type unsigned_char is mod (UCHAR_MAX + 1);
48 for unsigned_char'Size use CHAR_BIT;
50 subtype plain_char is unsigned_char; -- ??? should be parameterized
52 -- Note: the Integer qualifications used in the declaration of ptrdiff_t
53 -- avoid ambiguities when compiling in the presence of s-auxdec.ads and
54 -- a non-private system.address type.
56 type ptrdiff_t is
57 range -(2 ** (System.Parameters.ptr_bits - Integer'(1))) ..
58 +(2 ** (System.Parameters.ptr_bits - Integer'(1)) - 1);
60 type size_t is mod 2 ** System.Parameters.ptr_bits;
62 -- Floating-Point
64 type C_float is new Float;
65 type double is new Standard.Long_Float;
66 type long_double is new Standard.Long_Long_Float;
68 ----------------------------
69 -- Characters and Strings --
70 ----------------------------
72 type char is new Character;
74 nul : constant char := char'First;
76 function To_C (Item : Character) return char;
77 function To_Ada (Item : char) return Character;
79 type char_array is array (size_t range <>) of aliased char;
80 for char_array'Component_Size use CHAR_BIT;
82 function Is_Nul_Terminated (Item : char_array) return Boolean;
84 function To_C
85 (Item : String;
86 Append_Nul : Boolean := True) return char_array;
88 function To_Ada
89 (Item : char_array;
90 Trim_Nul : Boolean := True) return String;
92 procedure To_C
93 (Item : String;
94 Target : out char_array;
95 Count : out size_t;
96 Append_Nul : Boolean := True);
98 procedure To_Ada
99 (Item : char_array;
100 Target : out String;
101 Count : out Natural;
102 Trim_Nul : Boolean := True);
104 ------------------------------------
105 -- Wide Character and Wide String --
106 ------------------------------------
108 type wchar_t is new Wide_Character;
109 for wchar_t'Size use Standard'Wchar_T_Size;
111 wide_nul : constant wchar_t := wchar_t'First;
113 function To_C (Item : Wide_Character) return wchar_t;
114 function To_Ada (Item : wchar_t) return Wide_Character;
116 type wchar_array is array (size_t range <>) of aliased wchar_t;
118 function Is_Nul_Terminated (Item : wchar_array) return Boolean;
120 function To_C
121 (Item : Wide_String;
122 Append_Nul : Boolean := True) return wchar_array;
124 function To_Ada
125 (Item : wchar_array;
126 Trim_Nul : Boolean := True) return Wide_String;
128 procedure To_C
129 (Item : Wide_String;
130 Target : out wchar_array;
131 Count : out size_t;
132 Append_Nul : Boolean := True);
134 procedure To_Ada
135 (Item : wchar_array;
136 Target : out Wide_String;
137 Count : out Natural;
138 Trim_Nul : Boolean := True);
140 Terminator_Error : exception;
142 -- The remaining declarations are for Ada 2005 (AI-285)
144 -- ISO/IEC 10646:2003 compatible types defined by SC22/WG14 document N1010
146 type char16_t is new Wide_Character;
147 pragma Ada_05 (char16_t);
149 char16_nul : constant char16_t := char16_t'Val (0);
150 pragma Ada_05 (char16_nul);
152 function To_C (Item : Wide_Character) return char16_t;
153 pragma Ada_05 (To_C);
155 function To_Ada (Item : char16_t) return Wide_Character;
156 pragma Ada_05 (To_Ada);
158 type char16_array is array (size_t range <>) of aliased char16_t;
159 pragma Ada_05 (char16_array);
161 function Is_Nul_Terminated (Item : char16_array) return Boolean;
162 pragma Ada_05 (Is_Nul_Terminated);
164 function To_C
165 (Item : Wide_String;
166 Append_Nul : Boolean := True) return char16_array;
167 pragma Ada_05 (To_C);
169 function To_Ada
170 (Item : char16_array;
171 Trim_Nul : Boolean := True) return Wide_String;
172 pragma Ada_05 (To_Ada);
174 procedure To_C
175 (Item : Wide_String;
176 Target : out char16_array;
177 Count : out size_t;
178 Append_Nul : Boolean := True);
179 pragma Ada_05 (To_C);
181 procedure To_Ada
182 (Item : char16_array;
183 Target : out Wide_String;
184 Count : out Natural;
185 Trim_Nul : Boolean := True);
186 pragma Ada_05 (To_Ada);
188 type char32_t is new Wide_Wide_Character;
189 pragma Ada_05 (char32_t);
191 char32_nul : constant char32_t := char32_t'Val (0);
192 pragma Ada_05 (char32_nul);
194 function To_C (Item : Wide_Wide_Character) return char32_t;
195 pragma Ada_05 (To_C);
197 function To_Ada (Item : char32_t) return Wide_Wide_Character;
198 pragma Ada_05 (To_Ada);
200 type char32_array is array (size_t range <>) of aliased char32_t;
201 pragma Ada_05 (char32_array);
203 function Is_Nul_Terminated (Item : char32_array) return Boolean;
204 pragma Ada_05 (Is_Nul_Terminated);
206 function To_C
207 (Item : Wide_Wide_String;
208 Append_Nul : Boolean := True) return char32_array;
209 pragma Ada_05 (To_C);
211 function To_Ada
212 (Item : char32_array;
213 Trim_Nul : Boolean := True) return Wide_Wide_String;
214 pragma Ada_05 (To_Ada);
216 procedure To_C
217 (Item : Wide_Wide_String;
218 Target : out char32_array;
219 Count : out size_t;
220 Append_Nul : Boolean := True);
221 pragma Ada_05 (To_C);
223 procedure To_Ada
224 (Item : char32_array;
225 Target : out Wide_Wide_String;
226 Count : out Natural;
227 Trim_Nul : Boolean := True);
228 pragma Ada_05 (To_Ada);
230 end Interfaces.C;