From 86e066aa7a971af4b8e9deeb853bc3b3a2b479bd Mon Sep 17 00:00:00 2001 From: Doug Rupp Date: Wed, 18 Nov 2015 10:39:37 +0000 Subject: [PATCH] s-parame-vxworks.adb: Reduce default stack size for stack limit check to a reasonable value 2015-11-18 Doug Rupp * s-parame-vxworks.adb: Reduce default stack size for stack limit check to a reasonable value * s-tpopsp-vxworks.adb: Make Stack_Limit a task variable for vx5 and vxmils. From-SVN: r230534 --- gcc/ada/ChangeLog | 7 +++++++ gcc/ada/s-parame-vxworks.adb | 2 +- gcc/ada/s-tpopsp-vxworks.adb | 37 ++++++++++++++++++++++++++++++++---- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 275d15792f0..4f3dde05f90 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2015-11-18 Doug Rupp + + * s-parame-vxworks.adb: Reduce default stack size for stack + limit check to a reasonable value + * s-tpopsp-vxworks.adb: Make Stack_Limit a task variable for vx5 and + vxmils. + 2015-11-18 Ed Schonberg * sem_ch5.adb (Analyze_Assignment): Diagnose assignment where diff --git a/gcc/ada/s-parame-vxworks.adb b/gcc/ada/s-parame-vxworks.adb index d023c8c5276..c27b092a498 100644 --- a/gcc/ada/s-parame-vxworks.adb +++ b/gcc/ada/s-parame-vxworks.adb @@ -58,7 +58,7 @@ package body System.Parameters is begin if Default_Stack_Size = -1 then if Stack_Check_Limits then - return 60 * 1024; + return 32 * 1024; -- Extra stack to allow for 12K exception area. else return 20 * 1024; diff --git a/gcc/ada/s-tpopsp-vxworks.adb b/gcc/ada/s-tpopsp-vxworks.adb index fb75510a735..c3a23c26509 100644 --- a/gcc/ada/s-tpopsp-vxworks.adb +++ b/gcc/ada/s-tpopsp-vxworks.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2015, Free Software Foundation, Inc. -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -44,6 +44,18 @@ package body Specific is -- implementation. This mechanism is used to minimize impact on other -- targets. + Stack_Limit : aliased System.Address; + + pragma Import (C, Stack_Limit, "__gnat_stack_limit"); + + type Set_Stack_Limit_Proc_Acc is access procedure; + pragma Convention (C, Set_Stack_Limit_Proc_Acc); + + Set_Stack_Limit_Hook : Set_Stack_Limit_Proc_Acc; + pragma Import (C, Set_Stack_Limit_Hook, "__gnat_set_stack_limit_hook"); + -- Procedure to be called when a task is created to set stack limit if + -- limit checking is used. + ---------------- -- Initialize -- ---------------- @@ -80,12 +92,29 @@ package body Specific is return; end if; - if taskVarGet (0, ATCB_Key'Access) = ERROR then - Result := taskVarAdd (0, ATCB_Key'Access); + if not Is_Valid_Task then + Result := taskVarAdd (Self_Id.Common.LL.Thread, ATCB_Key'Access); pragma Assert (Result = OK); + + if Stack_Check_Limits + and then Result /= ERROR + and then Set_Stack_Limit_Hook /= null + then + -- This will be initialized from taskInfoGet() once the task is + -- is running. + + Result := + taskVarAdd (Self_Id.Common.LL.Thread, Stack_Limit'Access); + pragma Assert (Result /= ERROR); + end if; end if; - ATCB_Key := To_Address (Self_Id); + Result := + taskVarSet + (Self_Id.Common.LL.Thread, + ATCB_Key'Access, + To_Address (Self_Id)); + pragma Assert (Result /= ERROR); end Set; ---------- -- 2.30.2