summaryrefslogtreecommitdiff
path: root/gcc/ada/s-taprop-linux.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2008-04-08 06:43:15 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2008-04-08 06:43:15 +0000
commit0244eba9499e50ee95d1b579cdd9dab7582ac878 (patch)
tree0e9bcf675dab91b0449162ce9f89d2a5215ca347 /gcc/ada/s-taprop-linux.adb
parent1f39e3a77c742111144284de796328ff5796a421 (diff)
downloadgcc-0244eba9499e50ee95d1b579cdd9dab7582ac878.tar.gz
2008-04-08 Eric Botcazou <ebotcazou@adacore.com>
Arnaud Charlet <charlet@adacore.com> * s-osinte-linux-alpha.ads, s-osinte-linux-hppa.ads: Removed. s-taspri-posix-noaltstack.ads, s-linux.ads, s-linux-alpha.ads, s-linux-hppa.ads: New files. Disable alternate stack on ia64-hpux. * s-osinte-lynxos-3.ads, (Alternate_Stack): Remove when not needed. Simplify declaration otherwise. (Alternate_Stack_Size): New constant. s-osinte-mingw.ads, s-taprop-mingw.adb: Code clean up: avoid use of 'Unrestricted_Access. * s-osinte-hpux.ads, s-osinte-solaris-posix.ads, s-osinte-aix.ads, s-osinte-lynxos.ads, s-osinte-freebsd.ads s-osinte-darwin.ads, s-osinte-tru64.ads, s-osinte-irix.ads, s-osinte-linux.ads, s-osinte-solaris.ads, s-osinte-vms.ads (SA_ONSTACK): New constant. (stack_t): New record type. (sigaltstack): New imported function. (Alternate_Stack): New imported variable. (Alternate_Stack_Size): New constant. * system-linux-x86_64.ads: (Stack_Check_Probes): Set to True. * s-taspri-lynxos.ads, s-taspri-solaris.ads, s-taspri-tru64.ads, s-taspri-hpux-dce.ads (Task_Address): New subtype of System.Address (Task_Address_Size): New constant size of System.Address (Alternate_Stack_Size): New constant. * s-taprop-posix.adb, s-taprop-linux.adb (Get_Stack_Attributes): Delete. (Enter_Task): Do not notify stack to System.Stack_Checking.Operations. Establish the alternate stack if the platform makes use of n alternate signal stack for stack overflows. (Create_Task): Take into account the alternate stack in the stack size. (Initialize): Save the address of the alternate stack into the ATCB for the environment task. (Create_Task): Fix assertions for NPTL library (vs old LinuxThreads). * s-parame.adb (Minimum_Stack_Size): Increase value to 16K to * system-linux-x86.ads: (Stack_Check_Probes): Set to True. * s-intman-posix.adb: (Initialize): Set SA_ONSTACK for SIGSEGV if the platform makes use of an alternate signal stack for stack overflows. * init.c (__gnat_adjust_context_for_raise, Linux version): On i386 and x86-64, adjust the saved value of the stack pointer if the signal was raised by a stack checking probe. (HP-UX section): Use global __gnat_alternate_stack as signal handler stack and only for SIGSEGV. (Linux section): Likewise on x86 and x86-64. [VxWorks section] (__gnat_map_signal): Now static. (__gnat_error_handler): Not static any more. (__gnat_adjust_context_for_raise): New function. Signal context adjustment for PPC && !VTHREADS && !RTP, as required by the zcx propagation circuitry. (__gnat_error_handler): Second argument of a sigaction handler is a pointer, not an int, and is unused. Adjust signal context before mapping to exception. Install signal handlers for LynxOS case. * s-taskin.ads (Common_ATCB): New field Task_Alternate_Stack. (Task_Id): Set size to Task_Address_Size (To_Task_id): Unchecked convert from Task_Address vice System.Address (To_Address): Unchecked convert to Task_Address vice System.Address * s-tassta.adb (Task_Wrapper): Define the alternate stack and save its address into the ATCB if the platform makes use of an alternate signal stack for stack overflows. (Free_Task): Add call to Finalize_Attributes_Link. Add argument Relative_Deadline to pass the value specified for the task. This is not yet used for any target. * s-tassta.ads (Create_Task): Add argument Relative_Deadline to pass the value specified for the task. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@134004 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/s-taprop-linux.adb')
-rw-r--r--gcc/ada/s-taprop-linux.adb104
1 files changed, 32 insertions, 72 deletions
diff --git a/gcc/ada/s-taprop-linux.adb b/gcc/ada/s-taprop-linux.adb
index 6c64f341eec..a4bc9495719 100644
--- a/gcc/ada/s-taprop-linux.adb
+++ b/gcc/ada/s-taprop-linux.adb
@@ -49,7 +49,6 @@ with System.Task_Info;
with System.Tasking.Debug;
with System.Interrupt_Management;
with System.OS_Primitives;
-with System.Storage_Elements;
with System.Stack_Checking.Operations;
with System.Soft_Links;
@@ -69,9 +68,11 @@ package body System.Task_Primitives.Operations is
use System.OS_Interface;
use System.Parameters;
use System.OS_Primitives;
- use System.Storage_Elements;
use System.Task_Info;
+ Use_Alternate_Stack : constant Boolean := Alternate_Stack_Size /= 0;
+ -- Whether to use an alternate signal stack for stack overflows
+
----------------
-- Local Data --
----------------
@@ -161,13 +162,6 @@ package body System.Task_Primitives.Operations is
function To_pthread_t is new Ada.Unchecked_Conversion
(unsigned_long, System.OS_Interface.pthread_t);
- procedure Get_Stack_Attributes
- (T : Task_Id;
- ISP : out System.Address;
- Size : out Storage_Offset);
- -- Fill ISP and Size with the Initial Stack Pointer value and the
- -- thread stack size for task T.
-
-------------------
-- Abort_Handler --
-------------------
@@ -696,50 +690,6 @@ package body System.Task_Primitives.Operations is
return T.Common.Current_Priority;
end Get_Priority;
- --------------------------
- -- Get_Stack_Attributes --
- --------------------------
-
- procedure Get_Stack_Attributes
- (T : Task_Id;
- ISP : out System.Address;
- Size : out Storage_Offset)
- is
- function pthread_getattr_np
- (thread : pthread_t;
- attr : System.Address) return Interfaces.C.int;
- pragma Import (C, pthread_getattr_np, "pthread_getattr_np");
-
- function pthread_attr_getstack
- (attr : System.Address;
- base : System.Address;
- size : System.Address) return Interfaces.C.int;
- pragma Import (C, pthread_attr_getstack, "pthread_attr_getstack");
-
- Result : Interfaces.C.int;
-
- Attributes : aliased pthread_attr_t;
- Stack_Base : aliased System.Address;
- Stack_Size : aliased Storage_Offset;
-
- begin
- Result :=
- pthread_getattr_np
- (T.Common.LL.Thread, Attributes'Address);
- pragma Assert (Result = 0);
-
- Result :=
- pthread_attr_getstack
- (Attributes'Address, Stack_Base'Address, Stack_Size'Address);
- pragma Assert (Result = 0);
-
- Result := pthread_attr_destroy (Attributes'Access);
- pragma Assert (Result = 0);
-
- ISP := Stack_Base + Stack_Size;
- Size := Stack_Size;
- end Get_Stack_Attributes;
-
----------------
-- Enter_Task --
----------------
@@ -747,8 +697,7 @@ package body System.Task_Primitives.Operations is
procedure Enter_Task (Self_ID : Task_Id) is
begin
if Self_ID.Common.Task_Info /= null
- and then
- Self_ID.Common.Task_Info.CPU_Affinity = No_CPU
+ and then Self_ID.Common.Task_Info.CPU_Affinity = No_CPU
then
raise Invalid_CPU_Number;
end if;
@@ -769,17 +718,18 @@ package body System.Task_Primitives.Operations is
Unlock_RTS;
- -- Determine where the task stack starts, how large it is, and let the
- -- stack checking engine know about it.
-
- declare
- Initial_SP : System.Address;
- Stack_Size : Storage_Offset;
- begin
- Get_Stack_Attributes (Self_ID, Initial_SP, Stack_Size);
- System.Stack_Checking.Operations.Notify_Stack_Attributes
- (Initial_SP, Stack_Size);
- end;
+ if Use_Alternate_Stack then
+ declare
+ Stack : aliased stack_t;
+ Result : Interfaces.C.int;
+ begin
+ Stack.ss_sp := Self_ID.Common.Task_Alternate_Stack;
+ Stack.ss_size := Alternate_Stack_Size;
+ Stack.ss_flags := 0;
+ Result := sigaltstack (Stack'Access, null);
+ pragma Assert (Result = 0);
+ end;
+ end if;
end Enter_Task;
--------------
@@ -864,10 +814,14 @@ package body System.Task_Primitives.Operations is
Priority : System.Any_Priority;
Succeeded : out Boolean)
is
- Attributes : aliased pthread_attr_t;
- Result : Interfaces.C.int;
+ Attributes : aliased pthread_attr_t;
+ Adjusted_Stack_Size : Interfaces.C.size_t;
+ Result : Interfaces.C.int;
begin
+ Adjusted_Stack_Size :=
+ Interfaces.C.size_t (Stack_Size + Alternate_Stack_Size);
+
Result := pthread_attr_init (Attributes'Access);
pragma Assert (Result = 0 or else Result = ENOMEM);
@@ -878,7 +832,7 @@ package body System.Task_Primitives.Operations is
Result :=
pthread_attr_setstacksize
- (Attributes'Access, Interfaces.C.size_t (Stack_Size));
+ (Attributes'Access, Adjusted_Stack_Size);
pragma Assert (Result = 0);
Result :=
@@ -896,7 +850,8 @@ package body System.Task_Primitives.Operations is
Attributes'Access,
Thread_Body_Access (Wrapper),
To_Address (T));
- pragma Assert (Result = 0 or else Result = EAGAIN);
+ pragma Assert
+ (Result = 0 or else Result = EAGAIN or else Result = ENOMEM);
if Result /= 0 then
Succeeded := False;
@@ -1148,8 +1103,7 @@ package body System.Task_Primitives.Operations is
pragma Assert (Result = 0);
SSL.Abort_Undefer.all;
- end
- if;
+ end if;
end Suspend_Until_True;
----------------
@@ -1253,6 +1207,7 @@ package body System.Task_Primitives.Operations is
old_act : aliased struct_sigaction;
Tmp_Set : aliased sigset_t;
Result : Interfaces.C.int;
+ -- Whether to use an alternate signal stack for stack overflows
function State
(Int : System.Interrupt_Management.Interrupt_ID) return Character;
@@ -1297,6 +1252,11 @@ package body System.Task_Primitives.Operations is
Specific.Initialize (Environment_Task);
+ if Use_Alternate_Stack then
+ Environment_Task.Common.Task_Alternate_Stack :=
+ Alternate_Stack'Address;
+ end if;
+
Enter_Task (Environment_Task);
-- Install the abort-signal handler