Add an UNSPEC_PROLOGUE_USE to prevent the link register from being considered dead.
[official-gcc.git] / gcc / ada / i-c.ads
blob509ad416705a371458b95604d3c40af599761ffb
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 -- --
10 -- This specification is adapted from the Ada Reference Manual for use with --
11 -- GNAT. In accordance with the copyright of that document, you can freely --
12 -- copy and modify this specification, provided that if you redistribute a --
13 -- modified version, any changes that you have made are clearly indicated. --
14 -- --
15 ------------------------------------------------------------------------------
17 with System.Parameters;
19 package Interfaces.C is
20 pragma Pure (C);
22 -- Declaration's based on C's <limits.h>
24 CHAR_BIT : constant := 8;
25 SCHAR_MIN : constant := -128;
26 SCHAR_MAX : constant := 127;
27 UCHAR_MAX : constant := 255;
29 -- Signed and Unsigned Integers. Note that in GNAT, we have ensured that
30 -- the standard predefined Ada types correspond to the standard C types
32 type int is new Integer;
33 type short is new Short_Integer;
34 type long is range -(2 ** (System.Parameters.long_bits - 1))
35 .. +(2 ** (System.Parameters.long_bits - 1)) - 1;
37 type signed_char is range SCHAR_MIN .. SCHAR_MAX;
38 for signed_char'Size use CHAR_BIT;
40 type unsigned is mod 2 ** int'Size;
41 type unsigned_short is mod 2 ** short'Size;
42 type unsigned_long is mod 2 ** long'Size;
44 type unsigned_char is mod (UCHAR_MAX + 1);
45 for unsigned_char'Size use CHAR_BIT;
47 subtype plain_char is unsigned_char; -- ??? should be parametrized
49 type ptrdiff_t is
50 range -(2 ** (Standard'Address_Size - 1)) ..
51 +(2 ** (Standard'Address_Size - 1) - 1);
53 type size_t is mod 2 ** Standard'Address_Size;
55 -- Floating-Point
57 type C_float is new Float;
58 type double is new Standard.Long_Float;
59 type long_double is new Standard.Long_Long_Float;
61 ----------------------------
62 -- Characters and Strings --
63 ----------------------------
65 type char is new Character;
67 nul : constant char := char'First;
69 function To_C (Item : Character) return char;
70 function To_Ada (Item : char) return Character;
72 type char_array is array (size_t range <>) of aliased char;
73 for char_array'Component_Size use CHAR_BIT;
75 function Is_Nul_Terminated (Item : in char_array) return Boolean;
77 function To_C
78 (Item : in String;
79 Append_Nul : in Boolean := True)
80 return char_array;
82 function To_Ada
83 (Item : in char_array;
84 Trim_Nul : in Boolean := True)
85 return String;
87 procedure To_C
88 (Item : in String;
89 Target : out char_array;
90 Count : out size_t;
91 Append_Nul : in Boolean := True);
93 procedure To_Ada
94 (Item : in char_array;
95 Target : out String;
96 Count : out Natural;
97 Trim_Nul : in Boolean := True);
99 ------------------------------------
100 -- Wide Character and Wide String --
101 ------------------------------------
103 type wchar_t is new Wide_Character;
104 for wchar_t'Size use Standard'Wchar_T_Size;
106 wide_nul : constant wchar_t := wchar_t'First;
108 function To_C (Item : in Wide_Character) return wchar_t;
109 function To_Ada (Item : in wchar_t) return Wide_Character;
111 type wchar_array is array (size_t range <>) of aliased wchar_t;
113 function Is_Nul_Terminated (Item : in wchar_array) return Boolean;
115 function To_C
116 (Item : in Wide_String;
117 Append_Nul : in Boolean := True)
118 return wchar_array;
120 function To_Ada
121 (Item : in wchar_array;
122 Trim_Nul : in Boolean := True)
123 return Wide_String;
125 procedure To_C
126 (Item : in Wide_String;
127 Target : out wchar_array;
128 Count : out size_t;
129 Append_Nul : in Boolean := True);
131 procedure To_Ada
132 (Item : in wchar_array;
133 Target : out Wide_String;
134 Count : out Natural;
135 Trim_Nul : in Boolean := True);
137 Terminator_Error : exception;
139 end Interfaces.C;