Patchwork [Ada] Removes workaround for an old GNU/Linker limitation on Windows

login
register
mail settings
Submitter Arnaud Charlet
Date Feb. 6, 2013, 10:44 a.m.
Message ID <20130206104442.GA18480@adacore.com>
Download mbox | patch
Permalink /patch/218540/
State New
Headers show

Comments

Arnaud Charlet - Feb. 6, 2013, 10:44 a.m.
Removes the access to all variables. This was put in place to workaround
a limitation of the linker auto-import support which was not able to
handle works lager than 32 bits.

Tested on x86_64-pc-linux-gnu, committed on trunk

2013-02-06  Pascal Obry  <obry@adacore.com>

	* s-osprim-mingw.adb: Removes workaround for an old GNU/Linker
	limitation on Windows.
	(DA): Removed.
	(LIA): Removed.
	(LLIA): Removed.
	(TFA): Removed.
	(BTA): Removed.
	(BMTA): Removed.
	(BCA): Removed.
	(BMCA): Removed.
	(BTiA): Removed.
	(Clock): Use variable corresponding to access.
	(Get_Base_Time): Likewise.
	(Monotonic_Clock): Likewise.

Patch

Index: s-osprim-mingw.adb
===================================================================
--- s-osprim-mingw.adb	(revision 195784)
+++ s-osprim-mingw.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1998-2012, Free Software Foundation, Inc.         --
+--          Copyright (C) 1998-2013, 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- --
@@ -42,46 +42,23 @@ 
    -- Data for the high resolution clock --
    ----------------------------------------
 
-   --  Declare some pointers to access multi-word data above. This is needed
-   --  to workaround a limitation in the GNU/Linker auto-import feature used
-   --  to build the GNAT runtime DLLs. In fact the Clock and Monotonic_Clock
-   --  routines are inlined and they are using some multi-word variables.
-   --  GNU/Linker will fail to auto-import those variables when building
-   --  libgnarl.dll. The indirection level introduced here has no measurable
-   --  penalties.
-
-   type DA is access all Duration;
-   --  Use to have indirect access to multi-word variables
-
-   type LIA is access all LARGE_INTEGER;
-   --  Use to have indirect access to multi-word variables
-
-   type LLIA is access all Long_Long_Integer;
-   --  Use to have indirect access to multi-word variables
-
    Tick_Frequency : aliased LARGE_INTEGER;
-   TFA : constant LIA := Tick_Frequency'Access;
    --  Holds frequency of high-performance counter used by Clock
    --  Windows NT uses a 1_193_182 Hz counter on PCs.
 
-   Base_Ticks : aliased LARGE_INTEGER;
-   BTA : constant LIA := Base_Ticks'Access;
+   Base_Ticks : LARGE_INTEGER;
    --  Holds the Tick count for the base time
 
-   Base_Monotonic_Ticks : aliased LARGE_INTEGER;
-   BMTA : constant LIA := Base_Monotonic_Ticks'Access;
+   Base_Monotonic_Ticks : LARGE_INTEGER;
    --  Holds the Tick count for the base monotonic time
 
-   Base_Clock : aliased Duration;
-   BCA : constant DA := Base_Clock'Access;
+   Base_Clock : Duration;
    --  Holds the current clock for the standard clock's base time
 
-   Base_Monotonic_Clock : aliased Duration;
-   BMCA : constant DA := Base_Monotonic_Clock'Access;
+   Base_Monotonic_Clock : Duration;
    --  Holds the current clock for monotonic clock's base time
 
-   Base_Time : aliased Long_Long_Integer;
-   BTiA : constant LLIA := Base_Time'Access;
+   Base_Time : Long_Long_Integer;
    --  Holds the base time used to check for system time change, used with
    --  the standard clock.
 
@@ -118,12 +95,12 @@ 
       GetSystemTimeAsFileTime (Now'Access);
 
       Elap_Secs_Sys :=
-        Duration (Long_Long_Float (abs (Now - BTiA.all)) /
+        Duration (Long_Long_Float (abs (Now - Base_Time)) /
                     Hundreds_Nano_In_Sec);
 
       Elap_Secs_Tick :=
-        Duration (Long_Long_Float (Current_Ticks - BTA.all) /
-                  Long_Long_Float (TFA.all));
+        Duration (Long_Long_Float (Current_Ticks - Base_Ticks) /
+                  Long_Long_Float (Tick_Frequency));
 
       --  If we have a shift of more than Max_Shift seconds we resynchronize
       --  the Clock. This is probably due to a manual Clock adjustment, a DST
@@ -134,11 +111,11 @@ 
          Get_Base_Time;
 
          Elap_Secs_Tick :=
-           Duration (Long_Long_Float (Current_Ticks - BTA.all) /
-                     Long_Long_Float (TFA.all));
+           Duration (Long_Long_Float (Current_Ticks - Base_Ticks) /
+                     Long_Long_Float (Tick_Frequency));
       end if;
 
-      return BCA.all + Elap_Secs_Tick;
+      return Base_Clock + Elap_Secs_Tick;
    end Clock;
 
    -------------------
@@ -243,9 +220,9 @@ 
 
       else
          Elap_Secs_Tick :=
-           Duration (Long_Long_Float (Current_Ticks - BMTA.all) /
-                       Long_Long_Float (TFA.all));
-         return BMCA.all + Elap_Secs_Tick;
+           Duration (Long_Long_Float (Current_Ticks - Base_Monotonic_Ticks) /
+                       Long_Long_Float (Tick_Frequency));
+         return Base_Monotonic_Clock + Elap_Secs_Tick;
       end if;
    end Monotonic_Clock;