Commit 7c46e926 by Dmitriy Anisimkov Committed by Pierre-Marie de Rodat

[Ada] GNAT.Sockets: fix Get_Address when AF_INET6 is not defined

2019-07-01  Dmitriy Anisimkov  <anisimko@adacore.com>

gcc/ada/

	* libgnat/g-sothco.adb (Get_Address): Fix the case when AF_INET6
	is not defined.

From-SVN: r272856
parent 6a04c943
2019-07-01 Dmitriy Anisimkov <anisimko@adacore.com>
* libgnat/g-sothco.adb (Get_Address): Fix the case when AF_INET6
is not defined.
2019-07-01 Ed Schonberg <schonberg@adacore.com> 2019-07-01 Ed Schonberg <schonberg@adacore.com>
* exp_attr.adb (Expand_Attribute_Reference, case Invalid_Value): * exp_attr.adb (Expand_Attribute_Reference, case Invalid_Value):
......
...@@ -59,14 +59,15 @@ package body GNAT.Sockets.Thin_Common is ...@@ -59,14 +59,15 @@ package body GNAT.Sockets.Thin_Common is
----------------- -----------------
function Get_Address (Sin : Sockaddr) return Sock_Addr_Type is function Get_Address (Sin : Sockaddr) return Sock_Addr_Type is
use type C.unsigned_short;
Family : constant C.unsigned_short := Family : constant C.unsigned_short :=
(if SOSC.Has_Sockaddr_Len = 0 then Sin.Sin_Family.Short_Family (if SOSC.Has_Sockaddr_Len = 0 then Sin.Sin_Family.Short_Family
else C.unsigned_short (Sin.Sin_Family.Char_Family)); else C.unsigned_short (Sin.Sin_Family.Char_Family));
AF_INET6_Defined : constant Boolean := SOSC.AF_INET6 > 0;
Result : Sock_Addr_Type Result : Sock_Addr_Type
(case Family is (if AF_INET6_Defined and then SOSC.AF_INET6 = Family then Family_Inet6
when SOSC.AF_INET6 => Family_Inet6, elsif SOSC.AF_INET = Family then Family_Inet
when SOSC.AF_INET => Family_Inet, else Family_Unspec);
when others => Family_Unspec);
begin begin
Result.Port := Port_Type (Network_To_Short (Sin.Sin_Port)); Result.Port := Port_Type (Network_To_Short (Sin.Sin_Port));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment