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 16with System.Parameters; 17 18package 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 parameterized 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 ** (System.Parameters.ptr_bits - Integer'(1))) .. 58 +(2 ** (System.Parameters.ptr_bits - Integer'(1)) - 1); 59 60 type size_t is mod 2 ** System.Parameters.ptr_bits; 61 62 -- For convenience, also provide an uintptr_t type 63 type uintptr_t is mod 2 ** System.Parameters.ptr_bits; 64 65 ---------------------------- 66 -- Characters and Strings -- 67 ---------------------------- 68 69 type char is new Character; 70 71 nul : constant char := char'First; 72 73 function To_C (Item : Character) return char; 74 function To_Ada (Item : char) return Character; 75 76 type char_array is array (size_t range <>) of aliased char; 77 for char_array'Component_Size use CHAR_BIT; 78 79 function Is_Nul_Terminated (Item : char_array) return Boolean; 80 81end Interfaces.C; 82