aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/s-oscons-tmplt.c
diff options
context:
space:
mode:
authorDmitriy Anisimkov <anisimko@adacore.com>2019-09-17 07:59:23 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-09-17 07:59:23 +0000
commit38c4e50d8c738553de6f5e7a5fee3b55728ea457 (patch)
tree12f8f4d4fe58df84863fd3f7203becd9106b0dbf /gcc/ada/s-oscons-tmplt.c
parent37915d022449d21fe7bfa7db640a15e77cd3352e (diff)
downloadgcc-38c4e50d8c738553de6f5e7a5fee3b55728ea457.zip
gcc-38c4e50d8c738553de6f5e7a5fee3b55728ea457.tar.gz
gcc-38c4e50d8c738553de6f5e7a5fee3b55728ea457.tar.bz2
[Ada] Support for local unix sockets in GNAT.Sockets API
Sock_Addr_Type has Family_Unix variant now. This variant can be created with function Unix_Local_Addr call. And this variant is working in GNAT.Socket routines where it is appropriate. 2019-09-17 Dmitriy Anisimkov <anisimko@adacore.com> gcc/ada/ * gsocket.h: Include sys/un.h. * s-oscons-tmplt.c (AF_UNIX): New constant generation. (SIZEOF_sockaddr_un): Idem. * libgnat/g-socket.ads (Family_Type): New value Family_Unix added. (Family_Inet_4_6): New subtype only for network families. (Sock_Addr_Type): Add Unbounded_String field for Family_Unix variant. (Unix_Socket_Address): Create Sock_Addr_Type from socket pathname. (Network_Socket_Address): Create Sock_Addr_Type from Inet_Addr_Type and Port_Type parameters. * libgnat/g-socket.adb: Support local unix address in socket routines. (Get_Address_Info): Disable warning about Result may be referenced before it has a value. Remove duplicated code to exit from Look_For_Supported. * libgnat/g-sothco.ads (Unix_Name_Length): New constant defining maximum number of characters in local socket address path. (Sockaddr): Add variant for Family_Unix address family. Move Sin_Port and Sin_Family to Family_Inet section. Add Sin6_Port and Sin6_Family to Family_Inet6 section. (Set_Address): Add out parameter Length to return valuable Sockaddr data length. (Get_Address): Add input parameter Length to set valuable Sockaddr data length. * libgnat/g-sothco.adb: Support local unix address in socket routines. From-SVN: r275770
Diffstat (limited to 'gcc/ada/s-oscons-tmplt.c')
-rw-r--r--gcc/ada/s-oscons-tmplt.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/ada/s-oscons-tmplt.c b/gcc/ada/s-oscons-tmplt.c
index 655d68a..4c3ecc6 100644
--- a/gcc/ada/s-oscons-tmplt.c
+++ b/gcc/ada/s-oscons-tmplt.c
@@ -1053,6 +1053,11 @@ CND(AF_INET, "IPv4 address family")
#endif
CND(AF_INET6, "IPv6 address family")
+#ifndef AF_UNIX
+# define AF_UNIX -1
+#endif
+CND(AF_UNIX, "Local unix family")
+
#ifndef AF_UNSPEC
# define AF_UNSPEC -1
#else
@@ -1701,6 +1706,19 @@ CND(SIZEOF_sockaddr_in, "struct sockaddr_in")
#endif
CND(SIZEOF_sockaddr_in6, "struct sockaddr_in6")
+/**
+ ** The sockaddr_un structure is not defined in MINGW C headers
+ ** but Windows supports it from build 17063.
+ **/
+#if defined(__MINGW32__)
+struct sockaddr_un {
+ ADDRESS_FAMILY sun_family; /* AF_UNIX */
+ char sun_path[108]; /* Pathname */
+};
+#endif
+#define SIZEOF_sockaddr_un (sizeof (struct sockaddr_un))
+CND(SIZEOF_sockaddr_un, "struct sockaddr_un")
+
#define SIZEOF_fd_set (sizeof (fd_set))
CND(SIZEOF_fd_set, "fd_set")
CND(FD_SETSIZE, "Max fd value")