From d436b30d99371fec40a60e617f86e3ede5701ac2 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Wed, 24 Apr 2013 16:18:30 +0200 Subject: [multiple changes] 2013-04-24 Thomas Quinot * g-socket.adb (Host_Entry): Introduce intermediate copy of memory location pointed to by Hostent_H_Addr, as it might not have sufficient alignment. 2013-04-24 Yannick Moy * repinfo.adb (List_Rep_Info): Set the value of Unit_Casing before calling subprograms which may read it. 2013-04-24 Hristian Kirtchev * einfo.adb: Remove Loop_Entry_Attributes from the usage of nodes. Flag 260 is now used. (Has_Loop_Entry_Attributes): New routine. (Loop_Entry_Attributes): Removed. (Set_Has_Loop_Entry_Attributes): New routine. (Set_Loop_Entry_Attributes): Removed. (Write_Entity_Flags): Write out Flag 260. (Write_Field10_Name): Remove the output for Loop_Entry_Attributes. * einfo.ads: Remove attribute Loop_Entry_Attributes, its related comment and uses in nodes. Add new attribute Has_Loop_Entry_Attributes, related comment and uses in loop nodes. (Has_Loop_Entry_Attributes): New routine and pragma Inline. (Loop_Entry_Attributes): Removed along with pragma Inline. (Set_Has_Loop_Entry_Attributes): New routine and pragma Inline. (Set_Loop_Entry_Attributes): Removed along with pragma Inline. * exp_attr.adb (Expand_Loop_Entry_Attribute): New routine. (Expand_N_Attribute_Reference): Expand attribute 'Loop_Entry. * exp_ch5.adb: Remove with and use clause for Elists. (Expand_Loop_Entry_Attributes): Removed. (Expand_N_Loop_Statement): Add local variable Stmt. Rename local constant Isc to Scheme. When a loop is subject to attribute 'Loop_Entry, retrieve the nested loop from the conditional block. Move the processing of controlled object at the end of loop expansion. * sem_attr.adb (Analyze_Attribute): Do not chain attribute 'Loop_Entry to its related loop. * sem_ch5.adb (Analyze_Loop_Statement): Add local variable Stmt. When the iteration scheme mentions attribute 'Loop_Entry, the entire loop is rewritten into a block. Retrieve the nested loop in such cases to complete the analysis. * sem_util.ads, sem_util.adb (Find_Loop_In_Conditional_Block): New routine. (Subject_To_Loop_Entry_Attributes): New routine. 2013-04-24 Robert Dewar * exp_prag.adb (Expand_Loop_Variant): Generate pragma Check (Loop_Variant, xxx) rather than Assert (xxx). * gnat_rm.texi: Document pragma Loop_Variant. * sem_prag.adb (Analyze_Pragma, case Loop_Variant): Remove call to S14_Pragma. From-SVN: r198235 --- gcc/ada/g-socket.adb | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'gcc/ada/g-socket.adb') diff --git a/gcc/ada/g-socket.adb b/gcc/ada/g-socket.adb index 87493d2..bafd224 100644 --- a/gcc/ada/g-socket.adb +++ b/gcc/ada/g-socket.adb @@ -2485,8 +2485,8 @@ package body GNAT.Sockets is Aliases_Count, Addresses_Count : Natural; - -- H_Length is not used because it is currently only set to 4 - -- H_Addrtype is always AF_INET + -- H_Length is not used because it is currently only ever set to 4, as + -- H_Addrtype is always AF_INET. begin Aliases_Count := 0; @@ -2514,10 +2514,24 @@ package body GNAT.Sockets is for J in Result.Addresses'Range loop declare Addr : In_Addr; - for Addr'Address use - Hostent_H_Addr (E, C.int (J - Result.Addresses'First)); - pragma Import (Ada, Addr); + + -- Hostent_H_Addr (E, ) may return an address that is + -- not correctly aligned for In_Addr, so we need to use + -- an intermediate copy operation on a type with an alignemnt + -- of 1 to recover the value. + + subtype Addr_Buf_T is C.char_array (1 .. Addr'Size / 8); + Unaligned_Addr : Addr_Buf_T; + for Unaligned_Addr'Address + use Hostent_H_Addr (E, C.int (J - Result.Addresses'First)); + pragma Import (Ada, Unaligned_Addr); + + Aligned_Addr : Addr_Buf_T; + for Aligned_Addr'Address use Addr'Address; + pragma Import (Ada, Aligned_Addr); + begin + Aligned_Addr := Unaligned_Addr; To_Inet_Addr (Addr, Result.Addresses (J)); end; end loop; -- cgit v1.1