Commit 73b59230 authored by yoogx's avatar yoogx

* Reorganize code to avoid usage of the secondary stack

        For openaadl/ocarina#141
parent 926df680
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2006-2009 Telecom ParisTech, 2010-2015 ESA & ISAE. --
-- Copyright (C) 2006-2009 Telecom ParisTech, 2010-2018 ESA & ISAE. --
-- --
-- PolyORB-HI is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -77,14 +77,14 @@ package body PolyORB_HI.Messages is
L : constant Stream_Element_Count := Message.Last + Header_Size;
R : Stream_Element_Array (1 .. L) := (others => 0);
P : constant Stream_Element_Array (1 .. Length (Message))
:= Payload (Message);
P : Stream_Element_Array renames
Message.Content (Message.First .. Message.Last);
begin
R (1 .. Message_Length_Size) := To_Buffer (L - 1);
R (Receiver_Offset) := Stream_Element (Internal_Code (Entity));
R (Sender_Offset) := Stream_Element (Internal_Code (From));
R (Header_Size + 1 .. Header_Size + Length (Message)) := P;
-- XXX GNATProve GPL 2014 limitation ?
return R;
end Encapsulate;
......@@ -97,6 +97,11 @@ package body PolyORB_HI.Messages is
return Corresponding_Entity (Unsigned_8 (M (Sender_Offset)));
end Sender;
function Sender (M : Message_Type) return Entity_Type is
begin
return Corresponding_Entity (Unsigned_8 (M.Content (Sender_Offset)));
end Sender;
----------
-- Read --
----------
......
......@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 2006-2009 Telecom ParisTech, 2010-2015 ESA & ISAE. --
-- Copyright (C) 2006-2009 Telecom ParisTech, 2010-2018 ESA & ISAE. --
-- --
-- PolyORB-HI is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -82,10 +82,6 @@ package PolyORB_HI.Messages is
procedure Reallocate (M : in out Message_Type);
-- Reset M
function Payload (M : Message_Type) return Stream_Element_Array
with Pre => (Valid (M));
-- Return the remaining payload of message M
function Sender (M : Message_Type) return Entity_Type
with Pre => (Valid (M));
function Sender (M : Stream_Element_Array) return Entity_Type;
......@@ -116,17 +112,10 @@ private
end record;
function Valid (Message : Message_Type) return Boolean is
(Message.First >= Message.Content'First
and then Message.Last <= Message.Content'Last);
-- The following part cannot be correct in the case Message is
-- not initialized, see defaults for Message_Type
-- and then Message.First <= Message.Last
function Payload (M : Message_Type) return Stream_Element_Array is
(M.Content (M.First .. M.Last));
function Sender (M : Message_Type) return Entity_Type is
(Sender (Payload (M)));
(Message.First >= Message.Content'First);
-- The following part cannot be correct in the case Message is
-- not initialized, see defaults for Message_Type
-- and then Message.First <= Message.Last
pragma Inline (To_Length);
pragma Inline (To_Buffer);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment