[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Tue, 7 Jul 2009 13:17:29 +0000 (15:17 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Tue, 7 Jul 2009 13:17:29 +0000 (15:17 +0200)
2009-07-07  Robert Dewar  <dewar@adacore.com>

* prj-nmsc.adb: Minor reformatting

2009-07-07  Pascal Obry  <obry@adacore.com>

* a-stwise.adb, a-stzsea.adb, a-strsea.adb (Index): properly handle
cases where Pattern is longer than Source.

2009-07-07  Pascal Obry  <obry@adacore.com>

* s-osprim-mingw.adb (Get_Base_Time): Avoid infinite loop.

From-SVN: r149326

gcc/ada/ChangeLog
gcc/ada/a-strsea.adb
gcc/ada/a-stwise.adb
gcc/ada/a-stzsea.adb
gcc/ada/prj-nmsc.adb
gcc/ada/s-osprim-mingw.adb

index 42a633170156eabff3b8aaa615278ea7e7c1c01f..4693dd40ad498df44a8e3882f5848f24e3609367 100644 (file)
@@ -1,3 +1,16 @@
+2009-07-07  Robert Dewar  <dewar@adacore.com>
+
+       * prj-nmsc.adb: Minor reformatting
+
+2009-07-07  Pascal Obry  <obry@adacore.com>
+
+       * a-stwise.adb, a-stzsea.adb, a-strsea.adb (Index): properly handle
+       cases where Pattern is longer than Source.
+
+2009-07-07  Pascal Obry  <obry@adacore.com>
+
+       * s-osprim-mingw.adb (Get_Base_Time): Avoid infinite loop.
+
 2009-07-07  Emmanuel Briot  <briot@adacore.com>
 
        * prj-nmsc.adb (Process_Naming): canonicalize file suffixes read in the
index a9093ed3bd71be730c7703636d2412a17622519f..dbeb0e462a43d121e1b303e18b2acd335b679282 100644 (file)
@@ -246,6 +246,12 @@ package body Ada.Strings.Search is
          raise Pattern_Error;
       end if;
 
+      --  If Pattern longer than Source it can't be found
+
+      if Pattern'Length > Source'Length then
+         return 0;
+      end if;
+
       --  Forwards case
 
       if Going = Forward then
@@ -348,6 +354,12 @@ package body Ada.Strings.Search is
          raise Constraint_Error;
       end if;
 
+      --  If Pattern longer than Source it can't be found
+
+      if Pattern'Length > Source'Length then
+         return 0;
+      end if;
+
       --  Forwards case
 
       if Going = Forward then
index 3add82b6d1e440be62a31a6fde79ff65303111c3..852b781233f25b8d6128443646cbd102e0105f8b 100644 (file)
@@ -241,6 +241,12 @@ package body Ada.Strings.Wide_Search is
          raise Pattern_Error;
       end if;
 
+      --  If Pattern longer than Source it can't be found
+
+      if Pattern'Length > Source'Length then
+         return 0;
+      end if;
+
       --  Forwards case
 
       if Going = Forward then
@@ -343,6 +349,12 @@ package body Ada.Strings.Wide_Search is
          raise Constraint_Error;
       end if;
 
+      --  If Pattern longer than Source it can't be found
+
+      if Pattern'Length > Source'Length then
+         return 0;
+      end if;
+
       --  Forwards case
 
       if Going = Forward then
index a9743e67d314a2dc667699eb2444807d625b2270..d6341ae12004cb83e42a0cff880e8c7a5c5a49a5 100644 (file)
@@ -245,6 +245,12 @@ package body Ada.Strings.Wide_Wide_Search is
          raise Pattern_Error;
       end if;
 
+      --  If Pattern longer than Source it can't be found
+
+      if Pattern'Length > Source'Length then
+         return 0;
+      end if;
+
       --  Forwards case
 
       if Going = Forward then
@@ -348,6 +354,12 @@ package body Ada.Strings.Wide_Wide_Search is
          raise Constraint_Error;
       end if;
 
+      --  If Pattern longer than Source it can't be found
+
+      if Pattern'Length > Source'Length then
+         return 0;
+      end if;
+
       --  Forwards case
 
       if Going = Forward then
index be323be1e0897fa9bb3bd098c8279894ec1f4671..aa5b10104c3114c3bdcd88633a2f298fba1434c7 100644 (file)
@@ -3358,26 +3358,27 @@ package body Prj.Nmsc is
       ----------------------------
 
       procedure Initialize_Naming_Data is
-         Specs  : Array_Element_Id :=
-           Util.Value_Of
-             (Name_Spec_Suffix,
-              Naming.Decl.Arrays,
-              In_Tree);
-         Impls  : Array_Element_Id :=
-           Util.Value_Of
-             (Name_Body_Suffix,
-              Naming.Decl.Arrays,
-              In_Tree);
+         Specs : Array_Element_Id :=
+                   Util.Value_Of
+                     (Name_Spec_Suffix,
+                      Naming.Decl.Arrays,
+                      In_Tree);
+
+         Impls : Array_Element_Id :=
+                   Util.Value_Of
+                     (Name_Body_Suffix,
+                      Naming.Decl.Arrays,
+                      In_Tree);
+
          Lang      : Language_Ptr;
          Lang_Name : Name_Id;
          Value     : Variable_Value;
          Extended  : Project_Id;
 
       begin
-         --  At this stage, the project already contains the default
-         --  extensions for the various languages. We now merge those
-         --  suffixes read in the user project, and they override the
-         --  default
+         --  At this stage, the project already contains the default extensions
+         --  for the various languages. We now merge those suffixes read in the
+         --  user project, and they override the default.
 
          while Specs /= No_Array_Element loop
             Lang_Name := In_Tree.Array_Elements.Table (Specs).Index;
index 8285271eb7334adcf9928df56948e4db4b9fe4ea..0984f49cacca550c31fe30ec0e5db9f44d7c7580 100644 (file)
@@ -156,23 +156,38 @@ package body System.OS_Primitives is
       --  Therefore, the elapsed time reported by GetSystemTime between both
       --  actions should be null.
 
-      Max_Elapsed : constant := 0;
-
-      Test_Now : aliased Long_Long_Integer;
+      Max_Elapsed    : constant := 0;
 
       epoch_1970     : constant := 16#19D_B1DE_D53E_8000#; -- win32 UTC epoch
       system_time_ns : constant := 100;                    -- 100 ns per tick
       Sec_Unit       : constant := 10#1#E9;
 
+      Test_Now       : aliased Long_Long_Integer;
+
+      Loc_Ticks      : aliased LARGE_INTEGER;
+      Loc_Time       : aliased Long_Long_Integer;
+      Elapsed        : Long_Long_Integer;
+      Current_Max    : Long_Long_Integer := Long_Long_Integer'Last;
+
    begin
       --  Here we must be sure that both of these calls are done in a short
       --  amount of time. Both are base time and should in theory be taken
       --  at the very same time.
 
-      loop
-         GetSystemTimeAsFileTime (Base_Time'Access);
+      --  The goal of the following loop is to synchronize the system time
+      --  with the Win32 performance counter by getting a base offset for both.
+      --  Using these offsets it is then possible to compute actual time using
+      --  a performance counter which has a better precision than the Win32
+      --  time API.
+
+      --  Try at most 10th times to reach the best synchronisation (below 1
+      --  millisecond) otherwise the runtime will use the best value
+      --  reached during the runs.
 
-         if QueryPerformanceCounter (Base_Ticks'Access) = Win32.FALSE then
+      for K in 1 .. 10 loop
+         GetSystemTimeAsFileTime (Loc_Time'Access);
+
+         if QueryPerformanceCounter (Loc_Ticks'Access) = Win32.FALSE then
             pragma Assert
               (Standard.False,
                "Could not query high performance counter in Clock");
@@ -181,7 +196,15 @@ package body System.OS_Primitives is
 
          GetSystemTimeAsFileTime (Test_Now'Access);
 
-         exit when Test_Now - Base_Time = Max_Elapsed;
+         Elapsed := Test_Now - Loc_Time;
+
+         if Elapsed < Current_Max then
+            Base_Time   := Loc_Time;
+            Base_Ticks  := Loc_Ticks;
+            Current_Max := Elapsed;
+         end if;
+
+         exit when Elapsed = Max_Elapsed;
       end loop;
 
       Base_Clock := Duration