OSDN Git Service

* Makefile.in (reload1.o-warn): Remove.
[pf3gnuchains/gcc-fork.git] / gcc / ada / i-c.ads
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 ------------------------------------------------------------------------------
15
16 with System.Parameters;
17
18 package Interfaces.C is
19    pragma Pure;
20
21    --  Declaration's based on C's <limits.h>
22
23    CHAR_BIT  : constant := 8;
24    SCHAR_MIN : constant := -128;
25    SCHAR_MAX : constant := 127;
26    UCHAR_MAX : constant := 255;
27
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
30
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.
34
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;
39
40    type signed_char is range SCHAR_MIN .. SCHAR_MAX;
41    for signed_char'Size use CHAR_BIT;
42
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;
46
47    type unsigned_char is mod (UCHAR_MAX + 1);
48    for unsigned_char'Size use CHAR_BIT;
49
50    subtype plain_char is unsigned_char; -- ??? should be parametrized
51
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.
55
56    type ptrdiff_t is
57      range -(2 ** (Standard'Address_Size - Integer'(1))) ..
58            +(2 ** (Standard'Address_Size - Integer'(1)) - 1);
59
60    type size_t is mod 2 ** Standard'Address_Size;
61
62    --  Floating-Point
63
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;
67
68    ----------------------------
69    -- Characters and Strings --
70    ----------------------------
71
72    type char is new Character;
73
74    nul : constant char := char'First;
75
76    function To_C   (Item : Character) return char;
77    function To_Ada (Item : char)      return Character;
78
79    type char_array is array (size_t range <>) of aliased char;
80    for char_array'Component_Size use CHAR_BIT;
81
82    function Is_Nul_Terminated (Item : char_array) return Boolean;
83
84    function To_C
85      (Item       : String;
86       Append_Nul : Boolean := True) return char_array;
87
88    function To_Ada
89      (Item     : char_array;
90       Trim_Nul : Boolean := True) return String;
91
92    procedure To_C
93      (Item       : String;
94       Target     : out char_array;
95       Count      : out size_t;
96       Append_Nul : Boolean := True);
97
98    procedure To_Ada
99      (Item     : char_array;
100       Target   : out String;
101       Count    : out Natural;
102       Trim_Nul : Boolean := True);
103
104    ------------------------------------
105    -- Wide Character and Wide String --
106    ------------------------------------
107
108    type wchar_t is new Wide_Character;
109    for wchar_t'Size use Standard'Wchar_T_Size;
110
111    wide_nul : constant wchar_t := wchar_t'First;
112
113    function To_C   (Item : Wide_Character) return wchar_t;
114    function To_Ada (Item : wchar_t)        return Wide_Character;
115
116    type wchar_array is array (size_t range <>) of aliased wchar_t;
117
118    function Is_Nul_Terminated (Item : wchar_array) return Boolean;
119
120    function To_C
121      (Item       : Wide_String;
122       Append_Nul : Boolean := True) return wchar_array;
123
124    function To_Ada
125      (Item     : wchar_array;
126       Trim_Nul : Boolean := True) return Wide_String;
127
128    procedure To_C
129      (Item       : Wide_String;
130       Target     : out wchar_array;
131       Count      : out size_t;
132       Append_Nul : Boolean := True);
133
134    procedure To_Ada
135      (Item     : wchar_array;
136       Target   : out Wide_String;
137       Count    : out Natural;
138       Trim_Nul : Boolean := True);
139
140    Terminator_Error : exception;
141
142    --  The remaining declarations are for Ada 2005 (AI-285)
143
144    --  ISO/IEC 10646:2003 compatible types defined by SC22/WG14 document N1010
145
146    type char16_t is new Wide_Character;
147    pragma Ada_05 (char16_t);
148
149    char16_nul : constant char16_t := char16_t'Val (0);
150    pragma Ada_05 (char16_nul);
151
152    function To_C (Item : Wide_Character) return char16_t;
153    pragma Ada_05 (To_C);
154
155    function To_Ada (Item : char16_t) return Wide_Character;
156    pragma Ada_05 (To_Ada);
157
158    type char16_array is array (size_t range <>) of aliased char16_t;
159    pragma Ada_05 (char16_array);
160
161    function Is_Nul_Terminated (Item : char16_array) return Boolean;
162    pragma Ada_05 (Is_Nul_Terminated);
163
164    function To_C
165      (Item       : Wide_String;
166       Append_Nul : Boolean := True) return char16_array;
167    pragma Ada_05 (To_C);
168
169    function To_Ada
170      (Item     : char16_array;
171       Trim_Nul : Boolean := True) return Wide_String;
172    pragma Ada_05 (To_Ada);
173
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);
180
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);
187
188    type char32_t is new Wide_Wide_Character;
189    pragma Ada_05 (char32_t);
190
191    char32_nul : constant char32_t := char32_t'Val (0);
192    pragma Ada_05 (char32_nul);
193
194    function To_C (Item : Wide_Wide_Character) return char32_t;
195    pragma Ada_05 (To_C);
196
197    function To_Ada (Item : char32_t) return Wide_Wide_Character;
198    pragma Ada_05 (To_Ada);
199
200    type char32_array is array (size_t range <>) of aliased char32_t;
201    pragma Ada_05 (char32_array);
202
203    function Is_Nul_Terminated (Item : char32_array) return Boolean;
204    pragma Ada_05 (Is_Nul_Terminated);
205
206    function To_C
207      (Item       : Wide_Wide_String;
208       Append_Nul : Boolean := True) return char32_array;
209    pragma Ada_05 (To_C);
210
211    function To_Ada
212      (Item     : char32_array;
213       Trim_Nul : Boolean := True) return Wide_Wide_String;
214    pragma Ada_05 (To_Ada);
215
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);
222
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);
229
230 end Interfaces.C;