]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Thu, 16 Apr 2009 12:29:14 +0000 (14:29 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Thu, 16 Apr 2009 12:29:14 +0000 (14:29 +0200)
2009-04-16  Ed Schonberg  <schonberg@adacore.com>

* sprint.adb (Write_Itype): If the itype is an array subtype, preserve
the original location of the index expressions and the index subtypes,
to prevent spurious out-of-scope references in gigi.

2009-04-16  Tristan Gingold  <gingold@adacore.com>

* init.c, s-osinte-darwin.ads, system-darwin-x86_64.ads:
Add support for stack checking on darwin.

2009-04-16  Vincent Celier  <celier@adacore.com>

* prj-attr.adb: New attribute Runtime_Source_Dir

* prj-nmsc.adb (Process_Project_Level_Array_Attributes): Process
attribute Runtime_Source_Dir.
(Check_Naming_Schemes): Give default values to out parameters to avoid
invalid data.

* prj.ads (Language_Config): New component Runtime_Source_Dir

* snames.ads-tmpl: New standard name Runtime_Source_Dir

From-SVN: r146177

gcc/ada/ChangeLog
gcc/ada/init.c
gcc/ada/prj-attr.adb
gcc/ada/prj-nmsc.adb
gcc/ada/prj.ads
gcc/ada/s-osinte-darwin.ads
gcc/ada/snames.ads-tmpl
gcc/ada/sprint.adb
gcc/ada/system-darwin-x86_64.ads

index aba44e835d0324f158043afb30c7b1d5d630cbac..154974ac1a3e1506149a9e5c9b850f9ce9b2ae19 100644 (file)
@@ -1,3 +1,27 @@
+2009-04-16  Ed Schonberg  <schonberg@adacore.com>
+
+       * sprint.adb (Write_Itype): If the itype is an array subtype, preserve
+       the original location of the index expressions and the index subtypes,
+       to prevent spurious out-of-scope references in gigi.
+
+2009-04-16  Tristan Gingold  <gingold@adacore.com>
+
+       * init.c, s-osinte-darwin.ads, system-darwin-x86_64.ads:
+       Add support for stack checking on darwin.
+
+2009-04-16  Vincent Celier  <celier@adacore.com>
+
+       * prj-attr.adb: New attribute Runtime_Source_Dir
+
+       * prj-nmsc.adb (Process_Project_Level_Array_Attributes): Process
+       attribute Runtime_Source_Dir.
+       (Check_Naming_Schemes): Give default values to out parameters to avoid
+       invalid data.
+
+       * prj.ads (Language_Config): New component Runtime_Source_Dir
+
+       * snames.ads-tmpl: New standard name Runtime_Source_Dir
+
 2009-04-16  Pascal Obry  <obry@adacore.com>
 
        * adaint.h, adaint.c (__gnat_rmdir): New routine.
index 5b97d56be99a0a55513026d3da5e6c1aa79edcfc..af9ae61d397c3a67e4846101e8d6203b621a78bb 100644 (file)
@@ -2099,8 +2099,15 @@ __gnat_install_handler(void)
 
 #include <signal.h>
 
+/* This must be in keeping with System.OS_Interface.Alternate_Stack_Size.  */
+char __gnat_alternate_stack[64 * 1024]; /* 2 * MINSIGSTKSZ */
+
 static void __gnat_error_handler (int sig, siginfo_t * si, void * uc);
 
+/* Defined in xnu unix_signal.c  */
+#define        UC_RESET_ALT_STACK      0x80000000
+extern int sigreturn (void *uc, int flavour);
+
 static void
 __gnat_error_handler (int sig, siginfo_t * si, void * uc)
 {
@@ -2113,6 +2120,9 @@ __gnat_error_handler (int sig, siginfo_t * si, void * uc)
       /* FIXME: we need to detect the case of a *real* SIGSEGV.  */
       exception = &storage_error;
       msg = "stack overflow or erroneous memory access";
+      /* Reset the use of alt stack, so that the alt stack will be used
+        for the next signal delivery.  */
+      sigreturn (NULL, UC_RESET_ALT_STACK);
       break;
 
     case SIGBUS:
@@ -2140,7 +2150,16 @@ __gnat_install_handler (void)
 
   /* Set up signal handler to map synchronous signals to appropriate
      exceptions.  Make sure that the handler isn't interrupted by another
-     signal that might cause a scheduling event!  */
+     signal that might cause a scheduling event!  Also setup an alternate
+     stack region for the handler execution so that stack overflows can be
+     handled properly, avoiding a SEGV generation from stack usage by the
+     handler itself (and it is required by Darwin).  */
+
+  stack_t stack;
+  stack.ss_sp = __gnat_alternate_stack;
+  stack.ss_size = sizeof (__gnat_alternate_stack);
+  stack.ss_flags = 0;
+  sigaltstack (&stack, NULL);
 
   act.sa_flags = SA_NODEFER | SA_RESTART | SA_SIGINFO;
   act.sa_sigaction = __gnat_error_handler;
@@ -2153,11 +2172,13 @@ __gnat_install_handler (void)
     sigaction (SIGFPE,  &act, NULL);
   if (__gnat_get_interrupt_state (SIGILL) != 's')
     sigaction (SIGILL,  &act, NULL);
-  if (__gnat_get_interrupt_state (SIGSEGV) != 's')
-    sigaction (SIGSEGV, &act, NULL);
   if (__gnat_get_interrupt_state (SIGBUS) != 's')
     sigaction (SIGBUS,  &act, NULL);
 
+  act.sa_flags |= SA_ONSTACK;
+  if (__gnat_get_interrupt_state (SIGSEGV) != 's')
+    sigaction (SIGSEGV, &act, NULL);
+
   __gnat_handler_installed = 1;
 }
 
index 7e30de6876229fb7eadae1d9808b4fed914cf471..6818737673ecd489a4a64d62e326df18e4075b45 100644 (file)
@@ -140,6 +140,7 @@ package body Prj.Attr is
    "LVshared_library_minimum_switches#" &
    "LVlibrary_version_switches#" &
    "Saruntime_library_dir#" &
+   "Saruntime_source_dir#" &
 
    --  package Naming
 
index 16125109054f5df908b0d2715da64aefe3c151c3..4b377eee788cf68a36f4be5cbe35cafca6eaf1c8 100644 (file)
@@ -2290,6 +2290,14 @@ package body Prj.Nmsc is
                           (Lang_Index).Config.Runtime_Library_Dir :=
                           Element.Value.Value;
 
+                     when Name_Runtime_Source_Dir =>
+
+                        --  Attribute Runtime_Library_Dir (<language>)
+
+                        In_Tree.Languages_Data.Table
+                          (Lang_Index).Config.Runtime_Source_Dir :=
+                          Element.Value.Value;
+
                      when Name_Object_Generated =>
                         declare
                            pragma Unsuppress (All_Checks);
@@ -7724,7 +7732,7 @@ package body Prj.Nmsc is
       Config         : Language_Config;
       Lang           : Name_List_Index := Data.Languages;
       Header_File    : Boolean := False;
-      First_Language : Language_Index;
+      First_Language : Language_Index := No_Language_Index;
       OK             : Boolean;
 
       Last_Spec : Natural;
@@ -7732,8 +7740,15 @@ package body Prj.Nmsc is
       Last_Sep  : Natural;
 
    begin
-      Unit := No_Name;
-      Alternate_Languages := No_Alternate_Language;
+      --  Default values
+
+      Alternate_Languages   := No_Alternate_Language;
+      Language              := No_Language_Index;
+      Language_Name         := No_Name;
+      Display_Language_Name := No_Name;
+      Unit                  := No_Name;
+      Lang_Kind             := File_Based;
+      Kind                  := Spec;
 
       while Lang /= No_Name_List loop
          Language_Name := In_Tree.Name_Lists.Table (Lang).Name;
index 0d506338055507fee32b52e1e36b6d93c21093e5..ca09a9d8c445c5b0e2a267e7acfb5607aceb991d 100644 (file)
@@ -456,6 +456,9 @@ package Prj is
       Runtime_Library_Dir        : Name_Id := No_Name;
       --  Path name of the runtime library directory, if any
 
+      Runtime_Source_Dir        : Name_Id := No_Name;
+      --  Path name of the runtime source directory, if any
+
       Mapping_File_Switches  : Name_List_Index := No_Name_List;
       --  The option(s) to provide a mapping file to the compiler. Specified in
       --  the configuration. When value is No_Name_List, there is no mapping
@@ -558,6 +561,7 @@ package Prj is
                            Object_Generated             => True,
                            Objects_Linked               => True,
                            Runtime_Library_Dir          => No_Name,
+                           Runtime_Source_Dir           => No_Name,
                            Mapping_File_Switches        => No_Name_List,
                            Mapping_Spec_Suffix          => No_File,
                            Mapping_Body_Suffix          => No_File,
index f8c67117c79e9db3df2dce295b1be863aa0c1f56..c880c0087c37d2679aca186c4b46a5c07197ba55 100644 (file)
@@ -279,10 +279,11 @@ package System.OS_Interface is
    pragma Import (C, sigaltstack, "sigaltstack");
 
    Alternate_Stack : aliased System.Address;
-   --  This is a dummy definition, never used (Alternate_Stack_Size is null)
+   pragma Import (C, Alternate_Stack, "__gnat_alternate_stack");
+   --  The alternate signal stack for stack overflows
 
-   Alternate_Stack_Size : constant := 0;
-   --  No alternate signal stack is used on this platform
+   Alternate_Stack_Size : constant := 64 * 1024;
+   --  This must be in keeping with init.c:__gnat_alternate_stack
 
    Stack_Base_Available : constant Boolean := False;
    --  Indicates whether the stack base is available on this target. This
index cec5f5124b30662ce8ef9473adb1262c69ad2fe9..285f92e105fdcdd3e4e7e4715a6a5be8edab7b72 100644 (file)
@@ -1134,6 +1134,7 @@ package Snames is
    Name_Toolchain_Description            : constant Name_Id := N + $;
    Name_Toolchain_Version                : constant Name_Id := N + $;
    Name_Runtime_Library_Dir              : constant Name_Id := N + $;
+   Name_Runtime_Source_Dir               : constant Name_Id := N + $;
 
    --  Other miscellaneous names used in front end
 
index 1ea8bac1e486f3cb7b05d6e1b03d409a2c36109b..4d6041dc20069db6ad60b0aa4fe381b30cc559b3 100644 (file)
@@ -3719,7 +3719,7 @@ package body Sprint is
 
                      Write_Id (Directly_Designated_Type (Typ));
 
-                     --  Array types and string types
+                  --  Array types and string types
 
                   when E_Array_Type | E_String_Type =>
                      Write_Header;
@@ -3748,7 +3748,8 @@ package body Sprint is
                      Sprint_Node (X);
                      Set_Sloc (X, Old_Sloc);
 
-                     --  Array subtypes and string subtypes
+                     --  Array subtypes and string subtypes.
+                     --  Preserve Sloc of index subtypes, as above.
 
                   when E_Array_Subtype | E_String_Subtype =>
                      Write_Header (False);
@@ -3757,7 +3758,9 @@ package body Sprint is
 
                      X := First_Index (Typ);
                      loop
+                        Old_Sloc := Sloc (X);
                         Sprint_Node (X);
+                        Set_Sloc (X, Old_Sloc);
                         Next_Index (X);
                         exit when No (X);
                         Write_Str (", ");
@@ -3765,7 +3768,7 @@ package body Sprint is
 
                      Write_Char (')');
 
-                     --  Signed integer types, and modular integer subtypes
+                  --  Signed integer types, and modular integer subtypes
 
                   when E_Signed_Integer_Type     |
                        E_Signed_Integer_Subtype  |
@@ -3821,14 +3824,14 @@ package body Sprint is
                         end if;
                      end;
 
-                     --  Modular integer types
+                  --  Modular integer types
 
                   when E_Modular_Integer_Type =>
                      Write_Header;
                      Write_Str (" mod ");
                      Write_Uint_With_Col_Check (Modulus (Typ), Auto);
 
-                     --  Floating point types and subtypes
+                  --  Floating point types and subtypes
 
                   when E_Floating_Point_Type    |
                        E_Floating_Point_Subtype =>
@@ -4104,8 +4107,8 @@ package body Sprint is
             exit when Spec = Empty;
 
             --  Add semicolon, unless we are printing original tree and the
-            --  next specification is part of a list (but not the first
-            --  element of that list)
+            --  next specification is part of a list (but not the first element
+            --  of that list).
 
             if not Dump_Original_Only or else not Prev_Ids (Spec) then
                Write_Str ("; ");
index e7ab795216338b9f394668e077c2001d760422bf..4211f347c8efad65d81e3c907969220520511fff 100644 (file)
@@ -155,7 +155,7 @@ private
    Preallocated_Stacks       : constant Boolean := False;
    Signed_Zeros              : constant Boolean := True;
    Stack_Check_Default       : constant Boolean := False;
-   Stack_Check_Probes        : constant Boolean := False;
+   Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_64_Bit_Divides    : constant Boolean := True;
    Support_Aggregates        : constant Boolean := True;