1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
5 -- SYSTEM.TASK_PRIMITIVES.OPERATIONS.ATCB_ALLOCATION --
9 -- Copyright (C) 2011, Free Software Foundation, Inc. --
11 -- GNARL is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
27 -- GNARL was developed by the GNARL team at Florida State University. --
28 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
30 ------------------------------------------------------------------------------
32 with Ada.Unchecked_Deallocation;
34 separate (System.Task_Primitives.Operations)
35 package body ATCB_Allocation is
41 procedure Free_ATCB (T : Task_Id) is
43 Is_Self : constant Boolean := T = Self;
46 Ada.Unchecked_Deallocation (Ada_Task_Control_Block, Task_Id);
51 Local_ATCB : aliased Ada_Task_Control_Block (0);
52 -- Create a dummy ATCB and initialize it minimally so that "Free"
53 -- can still call Self and Defer/Undefer_Abort after Tmp is freed
54 -- by the underlying memory management library.
57 Local_ATCB.Common.LL.Thread := T.Common.LL.Thread;
58 Local_ATCB.Common.Current_Priority := T.Common.Current_Priority;
60 Specific.Set (Local_ATCB'Unchecked_Access);
63 -- Note: it is assumed here that for all platforms, Specific.Set
64 -- deletes the task specific information if passed a null value.
78 function New_ATCB (Entry_Num : Task_Entry_Index) return Task_Id is
80 return new Ada_Task_Control_Block (Entry_Num);