summaryrefslogtreecommitdiff
path: root/gcc/ada/g-socket.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2013-04-24 14:18:30 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2013-04-24 14:18:30 +0000
commita1fd45f37e6450fd988fcf98a810073dee883941 (patch)
tree5288e0f51c7951d5e5361fedd68284f13d64cc55 /gcc/ada/g-socket.adb
parentb4f636a7eb900df1edf24dbe9e5954b90a51ff36 (diff)
downloadgcc-a1fd45f37e6450fd988fcf98a810073dee883941.tar.gz
2013-04-24 Thomas Quinot <quinot@adacore.com>
* 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 <moy@adacore.com> * repinfo.adb (List_Rep_Info): Set the value of Unit_Casing before calling subprograms which may read it. 2013-04-24 Hristian Kirtchev <kirtchev@adacore.com> * 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 <dewar@adacore.com> * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@198235 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/g-socket.adb')
-rw-r--r--gcc/ada/g-socket.adb24
1 files changed, 19 insertions, 5 deletions
diff --git a/gcc/ada/g-socket.adb b/gcc/ada/g-socket.adb
index 87493d2f60b..bafd224f5b9 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, <index>) 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;