aboutsummaryrefslogtreecommitdiff
path: root/src/lib/gnat/i-c.ads
diff options
context:
space:
mode:
authorNico Huber <nico.huber@secunet.com>2015-09-29 16:41:19 +0200
committerNico Huber <nico.h@gmx.de>2016-09-19 11:14:49 +0200
commitbe5492aec0a02e416cf12a7ad7517900540d9991 (patch)
tree2ca46cf377203c8146378bcc74a0be6317f09ef2 /src/lib/gnat/i-c.ads
parent2e09d2b239ff2dfdba89011fd64d9a07da0d8717 (diff)
Add minimal GNAT run time system (RTS)
Add a stripped-down version of libgnat. This is somehow comparable to libgcc but for Ada programs. It's licensed under GPLv3 but with the runtime library exception. So it's totally fine to link it with our GPLv2 code and keep it under GPLv2. Change-Id: Ie6522abf093f0a516b9ae18ddc69131bd721dc0c Signed-off-by: Nico Huber <nico.huber@secunet.com> Signed-off-by: Nico Huber <nico.h@gmx.de> Reviewed-on: https://review.coreboot.org/11836 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Edward O'Callaghan <edward.ocallaghan@koparo.com>
Diffstat (limited to 'src/lib/gnat/i-c.ads')
-rw-r--r--src/lib/gnat/i-c.ads78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/lib/gnat/i-c.ads b/src/lib/gnat/i-c.ads
new file mode 100644
index 0000000000..1403fcec80
--- /dev/null
+++ b/src/lib/gnat/i-c.ads
@@ -0,0 +1,78 @@
+------------------------------------------------------------------------------
+-- --
+-- GNAT COMPILER COMPONENTS --
+-- --
+-- I N T E R F A C E S . C --
+-- --
+-- S p e c --
+-- --
+-- This specification is derived from the Ada Reference Manual for use with --
+-- GNAT. In accordance with the copyright of that document, you can freely --
+-- copy and modify this specification, provided that if you redistribute a --
+-- modified version, any changes that you have made are clearly indicated. --
+-- --
+------------------------------------------------------------------------------
+
+with System.Parameters;
+
+package Interfaces.C is
+ pragma Pure;
+
+ -- Declaration's based on C's <limits.h>
+
+ CHAR_BIT : constant := 8;
+ SCHAR_MIN : constant := -128;
+ SCHAR_MAX : constant := 127;
+ UCHAR_MAX : constant := 255;
+
+ -- Signed and Unsigned Integers. Note that in GNAT, we have ensured that
+ -- the standard predefined Ada types correspond to the standard C types
+
+ -- Note: the Integer qualifications used in the declaration of type long
+ -- avoid ambiguities when compiling in the presence of s-auxdec.ads and
+ -- a non-private system.address type.
+
+ type int is new Integer;
+ type short is new Short_Integer;
+ type long is range -(2 ** (System.Parameters.long_bits - Integer'(1)))
+ .. +(2 ** (System.Parameters.long_bits - Integer'(1))) - 1;
+
+ type signed_char is range SCHAR_MIN .. SCHAR_MAX;
+ for signed_char'Size use CHAR_BIT;
+
+ type unsigned is mod 2 ** int'Size;
+ type unsigned_short is mod 2 ** short'Size;
+ type unsigned_long is mod 2 ** long'Size;
+
+ type unsigned_char is mod (UCHAR_MAX + 1);
+ for unsigned_char'Size use CHAR_BIT;
+
+ subtype plain_char is unsigned_char; -- ??? should be parameterized
+
+ -- Note: the Integer qualifications used in the declaration of ptrdiff_t
+ -- avoid ambiguities when compiling in the presence of s-auxdec.ads and
+ -- a non-private system.address type.
+
+ type ptrdiff_t is
+ range -(2 ** (System.Parameters.ptr_bits - Integer'(1))) ..
+ +(2 ** (System.Parameters.ptr_bits - Integer'(1)) - 1);
+
+ type size_t is mod 2 ** System.Parameters.ptr_bits;
+
+ ----------------------------
+ -- Characters and Strings --
+ ----------------------------
+
+ type char is new Character;
+
+ nul : constant char := char'First;
+
+ function To_C (Item : Character) return char;
+ function To_Ada (Item : char) return Character;
+
+ type char_array is array (size_t range <>) of aliased char;
+ for char_array'Component_Size use CHAR_BIT;
+
+ function Is_Nul_Terminated (Item : char_array) return Boolean;
+
+end Interfaces.C;