]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: One more adjustment coming from aliasing considerations
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 19 Mar 2024 09:56:34 +0000 (10:56 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 20 May 2024 07:47:03 +0000 (09:47 +0200)
It is needed on PowerPC platforms because of specific calling conventions.

gcc/ada/

* libgnat/g-sothco.ads (In_Addr): Add aspect Universal_Aliasing.

gcc/ada/libgnat/g-sothco.ads

index 8c21933364910399a60c75b6ae96f47ee7c02a54..da1e6f5bcddf7b9ef09c473cb5e909f4274d1b33 100644 (file)
@@ -123,10 +123,13 @@ package GNAT.Sockets.Thin_Common is
 
    type In_Addr is record
       S_B1, S_B2, S_B3, S_B4 : C.unsigned_char;
-   end record with Convention => C, Alignment => C.int'Alignment;
+   end record
+     with Convention => C, Alignment  => C.int'Alignment, Universal_Aliasing;
    --  IPv4 address, represented as a network-order C.int. Note that the
    --  underlying operating system may assume that values of this type have
-   --  C.int alignment, so we need to provide a suitable alignment clause here.
+   --  C.int's alignment, so we need to provide a suitable alignment clause.
+   --  We also need to inhibit strict type-based aliasing optimizations in
+   --  order to implement the following unchecked conversions efficiently.
 
    function To_In_Addr is new Ada.Unchecked_Conversion (C.int, In_Addr);
    function To_Int     is new Ada.Unchecked_Conversion (In_Addr, C.int);