ada: implemented add in ada

Fixes #2515
This commit is contained in:
Johannes Kliemann 2017-09-05 14:26:43 +02:00 committed by Christian Helmuth
parent d43a5a6ef1
commit d3f5a369a7
7 changed files with 28 additions and 14 deletions

View File

@ -10,11 +10,10 @@
using Genode::log;
extern "C" void add(int a, int b, int *result)
extern "C" void print_add(int a, int b, int *result)
{
log("add called with a=", a, ", b=", b, ", result at address ",
(void*)result);
*result = a + b;
}

View File

@ -0,0 +1,14 @@
package body add_package is
procedure Add(A: in Integer;
B: in Integer;
R: out Integer)
is
procedure ext_c_print_add(a, b : Integer; result : out Integer);
pragma import(C, ext_c_print_add, "print_add");
begin
ext_c_print_add(A, B, R);
R := A + B;
end Add;
end add_package;

View File

@ -0,0 +1,4 @@
package add_package is
procedure Add(A: in Integer; B: in Integer; R: out Integer);
end add_package;

View File

@ -4,7 +4,7 @@
-- \date 2009-09-23
--
with test_package;
with add_package;
--
-- Main program
@ -16,13 +16,10 @@ procedure main is
--
-- Declarations of external C functions
--
procedure ext_c_add(a, b : Integer; result : out Integer);
pragma import(C, ext_c_add, "add");
procedure ext_c_print_int(a : Integer);
pragma import(C, ext_c_print_int, "print_int");
begin
ext_c_add(13, 14, result);
add_package.Add(13, 14, result);
ext_c_print_int(result);
end main;

View File

@ -12,6 +12,7 @@
* Declaration of the Ada main procedure
*/
extern "C" void _ada_main(void);
extern "C" void add_package__add(int, int, int*);
/**
* Make the linker happy
@ -21,6 +22,11 @@ extern "C" void __gnat_eh_personality()
Genode::warning(__func__, " not implemented");
}
extern "C" void __gnat_rcheck_CE_Overflow_Check()
{
Genode::warning(__func__, " not implemented");
}
/**
* Wrapper for the Ada main program
*

View File

@ -1,4 +1,4 @@
TARGET = test-ada
SRC_ADA = main.adb
SRC_ADA = main.adb add_package.adb
SRC_CC = add.cc startup.cc
LIBS = base

View File

@ -1,6 +0,0 @@
package test_package
is
type some_range_t is range 1..99;
end test_package;