]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
s-osinte-tru64.adb: (Hide_Yellow_Zone): Add On parameter.
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 15 Oct 2007 13:53:30 +0000 (15:53 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Mon, 15 Oct 2007 13:53:30 +0000 (15:53 +0200)
2007-10-15  Eric Botcazou  <ebotcazou@adacore.com>

* s-osinte-tru64.adb: (Hide_Yellow_Zone): Add On parameter.
Set the protection status of the guard page based on the value of On.

* s-osinte-tru64.ads: (Hide_Yellow_Zone): Add On parameter.

* s-taprop-tru64.adb: (Enter_Task): Pass True to Hide_Yellow_Zone.
(Exit_Task): Pass False to Hide_Yellow_Zone.

From-SVN: r129317

gcc/ada/s-osinte-tru64.adb
gcc/ada/s-osinte-tru64.ads
gcc/ada/s-taprop-tru64.adb

index 3599c33495df7a8d0045f29cbdf560d84c899dff..88cc2fdd3ec03f28987a4247301f839509d7ca24 100644 (file)
@@ -83,7 +83,7 @@ package body System.OS_Interface is
    -- Hide_Yellow_Zone --
    ----------------------
 
-   procedure Hide_Yellow_Zone is
+   procedure Hide_Unhide_Yellow_Zone (Hide : Boolean) is
       type Teb_Ptr is access all pthread_teb_t;
       Teb : Teb_Ptr;
       Res : Interfaces.C.int;
@@ -101,9 +101,13 @@ package body System.OS_Interface is
       --  Stick a guard page right above the Yellow Zone if it exists
 
       if Teb.all.stack_yellow /= Teb.all.stack_guard then
-         Res := mprotect (Teb.all.stack_yellow, Get_Page_Size, PROT_ON);
+         if Hide then
+            Res := mprotect (Teb.all.stack_yellow, Get_Page_Size, PROT_ON);
+         else
+            Res := mprotect (Teb.all.stack_yellow, Get_Page_Size, PROT_OFF);
+         end if;
       end if;
-   end Hide_Yellow_Zone;
+   end Hide_Unhide_Yellow_Zone;
 
    -----------------
    -- To_Duration --
index 5fe84b2e733ac0405999696a7ed9bd7ad6106eec..aa3eb057b43740793bb8a25459c6d8c650c70b3d 100644 (file)
@@ -7,7 +7,7 @@
 --                                  S p e c                                 --
 --                                                                          --
 --             Copyright (C) 1991-1994, Florida State University            --
---             Copyright (C) 1995-2007, Free Software Foundation, Inc.      --
+--          Copyright (C) 1995-2007, 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- --
@@ -273,18 +273,17 @@ package System.OS_Interface is
    -----------
 
    Stack_Base_Available : constant Boolean := False;
-   --  Indicates wether the stack base is available on this target.
+   --  Indicates if the stack base is available on this target
 
    function Get_Stack_Base (thread : pthread_t) return Address;
    pragma Inline (Get_Stack_Base);
-   --  returns the stack base of the specified thread.
-   --  Only call this function when Stack_Base_Available is True.
+   --  Returns the stack base of the specified thread. Only call this function
+   --  when Stack_Base_Available is True.
 
    function Get_Page_Size return size_t;
    function Get_Page_Size return Address;
    pragma Import (C, Get_Page_Size, "getpagesize");
-   --  returns the size of a page, or 0 if this is not relevant on this
-   --  target
+   --  Returns the size of a page, or 0 if this is not relevant on this target
 
    PROT_NONE  : constant := 0;
    PROT_READ  : constant := 1;
@@ -298,11 +297,14 @@ package System.OS_Interface is
    function mprotect (addr : Address; len : size_t; prot : int) return int;
    pragma Import (C, mprotect);
 
-   procedure Hide_Yellow_Zone;
+   procedure Hide_Unhide_Yellow_Zone (Hide : Boolean);
    --  Every thread except the initial one features an overflow warning area
-   --  just above the overflow guard area on the stack. They are called
-   --  the Yellow Zone and the Red Zone respectively. This procedure hides
-   --  the former so that the latter could be exposed to stack probing.
+   --  (called the Yellow Zone) which is just above the overflow guard area
+   --  on the stack (called the Red Zone). During task execution, we want
+   --  signals from the Red Zone, so we need to hide the Yellow Zone. This
+   --  procedure is called at the start of task execution (with Hide set True)
+   --  to hide the Yellow Zone, and at the end of task execution (with Hide
+   --  set False) to unhide the Yellow Zone.
 
    ---------------------------------------
    -- Nonstandard Thread Initialization --
index 975bae11f4fd14a666f9666494300384749e2469..35acb26ce5859eb00fb5ce1ce67b5247425efa46 100644 (file)
@@ -173,9 +173,11 @@ package body System.Task_Primitives.Operations is
       pragma Unreferenced (Sig);
 
       T       : constant Task_Id := Self;
-      Result  : Interfaces.C.int;
       Old_Set : aliased sigset_t;
 
+      Result : Interfaces.C.int;
+      pragma Warnings (Off, Result);
+
    begin
       --  It is not safe to raise an exception when using ZCX and the GCC
       --  exception handling mechanism.
@@ -720,7 +722,7 @@ package body System.Task_Primitives.Operations is
 
    procedure Enter_Task (Self_ID : Task_Id) is
    begin
-      Hide_Yellow_Zone;
+      Hide_Unhide_Yellow_Zone (Hide => True);
       Self_ID.Common.LL.Thread := pthread_self;
       Specific.Set (Self_ID);
 
@@ -843,8 +845,8 @@ package body System.Task_Primitives.Operations is
       use System.Task_Info;
 
    begin
-      --  Account for the Yellow Zone (2 pages) and the guard page
-      --  right above. See Hide_Yellow_Zone for the rationale.
+      --  Account for the Yellow Zone (2 pages) and the guard page right above.
+      --  See Hide_Unhide_Yellow_Zone for the rationale.
 
       Adjusted_Stack_Size :=
         Interfaces.C.size_t (Stack_Size) + 3 * Get_Page_Size;
@@ -1006,6 +1008,7 @@ package body System.Task_Primitives.Operations is
    procedure Exit_Task is
    begin
       Specific.Set (null);
+      Hide_Unhide_Yellow_Zone (Hide => False);
    end Exit_Task;
 
    ----------------