1--  GHDL Run Time (GRT) - mono-thread version.
2--  Copyright (C) 2005 - 2014 Tristan Gingold
3--
4--  This program is free software: you can redistribute it and/or modify
5--  it under the terms of the GNU General Public License as published by
6--  the Free Software Foundation, either version 2 of the License, or
7--  (at your option) any later version.
8--
9--  This program is distributed in the hope that it will be useful,
10--  but WITHOUT ANY WARRANTY; without even the implied warranty of
11--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12--  GNU General Public License for more details.
13--
14--  You should have received a copy of the GNU General Public License
15--  along with this program.  If not, see <gnu.org/licenses>.
16--
17--  As a special exception, if other files instantiate generics from this
18--  unit, or you link this unit with other files to produce an executable,
19--  this unit does not by itself cause the resulting executable to be
20--  covered by the GNU General Public License. This exception does not
21--  however invalidate any other reasons why the executable file might be
22--  covered by the GNU Public License.
23
24package body Grt.Unithread is
25   procedure Init is
26   begin
27      null;
28   end Init;
29
30   procedure Finish is
31   begin
32      null;
33   end Finish;
34
35   procedure Run_Parallel (Subprg : Parallel_Subprg_Acc) is
36   begin
37      Subprg.all;
38   end Run_Parallel;
39
40   function Atomic_Insert (List : access Ghdl_Signal_Ptr; El : Ghdl_Signal_Ptr)
41                          return Ghdl_Signal_Ptr
42   is
43      Prev : Ghdl_Signal_Ptr;
44   begin
45      Prev := List.all;
46      List.all := El;
47      return Prev;
48   end Atomic_Insert;
49
50   function Atomic_Inc (Val : access Natural) return Natural
51   is
52      Res : Natural;
53   begin
54      Res := Val.all;
55      Val.all := Val.all + 1;
56      return Res;
57   end Atomic_Inc;
58
59   Current_Process : Process_Acc;
60
61   --  Called by linux.c
62   function Grt_Get_Current_Process return Process_Acc;
63   pragma Export (C, Grt_Get_Current_Process);
64
65   function Grt_Get_Current_Process return Process_Acc is
66   begin
67      return Current_Process;
68   end Grt_Get_Current_Process;
69
70   procedure Set_Current_Process (Proc : Process_Acc) is
71   begin
72      Current_Process := Proc;
73   end Set_Current_Process;
74
75   function Get_Current_Process return Process_Acc is
76   begin
77      return Current_Process;
78   end Get_Current_Process;
79
80   Common_Stack2 : constant Stack2_Ptr := Create;
81
82   function Get_Common_Stack2 return Stack2_Ptr is
83   begin
84      return Common_Stack2;
85   end Get_Common_Stack2;
86end Grt.Unithread;
87