From 47752af2e8442f1141f1025e58f9dcb76cdd7422 Mon Sep 17 00:00:00 2001 From: Thomas Quinot Date: Mon, 24 Feb 2014 16:59:24 +0000 Subject: [PATCH] g-stheme.adb, [...] (Host_Error_Message): Return a string... 2014-02-24 Thomas Quinot * g-stheme.adb, g-socthi-vms.adb, g-socthi-vms.ads, g-socthi-vxworks.adb, g-socthi-vxworks.ads, g-stseme.adb, g-socthi-mingw.adb, g-socthi-mingw.ads, g-socthi.adb, g-socthi.ads, g-socket.adb (Host_Error_Message): Return a string, not a chars_ptr, because on Windows this is a renaming of Socket_Error_Message. From-SVN: r208082 --- gcc/ada/ChangeLog | 9 ++++ gcc/ada/g-socket.adb | 2 +- gcc/ada/g-socthi-mingw.adb | 96 ++++++++++++++++++------------------ gcc/ada/g-socthi-mingw.ads | 5 +- gcc/ada/g-socthi-vms.adb | 3 -- gcc/ada/g-socthi-vms.ads | 5 +- gcc/ada/g-socthi-vxworks.adb | 3 -- gcc/ada/g-socthi-vxworks.ads | 5 +- gcc/ada/g-socthi.adb | 2 - gcc/ada/g-socthi.ads | 5 +- gcc/ada/g-stheme.adb | 33 +++---------- gcc/ada/g-stseme.adb | 2 +- 12 files changed, 74 insertions(+), 96 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index a7b2b9c32687..c07dcd8782ea 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,12 @@ +2014-02-24 Thomas Quinot + + * g-stheme.adb, g-socthi-vms.adb, g-socthi-vms.ads, + g-socthi-vxworks.adb, g-socthi-vxworks.ads, g-stseme.adb, + g-socthi-mingw.adb, g-socthi-mingw.ads, g-socthi.adb, + g-socthi.ads, g-socket.adb (Host_Error_Message): Return a string, not + a chars_ptr, because on Windows this is a renaming of + Socket_Error_Message. + 2014-02-24 Robert Dewar * a-direct.adb, sem_ch5.adb, a-cfdlli.adb, a-cfhase.adb, a-tags.adb, diff --git a/gcc/ada/g-socket.adb b/gcc/ada/g-socket.adb index f65b2709ea29..d5b74c6d0491 100644 --- a/gcc/ada/g-socket.adb +++ b/gcc/ada/g-socket.adb @@ -1709,7 +1709,7 @@ package body GNAT.Sockets is begin raise Host_Error with Err_Code_Image (H_Error) - & C.Strings.Value (Host_Error_Messages.Host_Error_Message (H_Error)); + & Host_Error_Messages.Host_Error_Message (H_Error); end Raise_Host_Error; ------------------------ diff --git a/gcc/ada/g-socthi-mingw.adb b/gcc/ada/g-socthi-mingw.adb index 98f4c7cb9424..719ab5477551 100644 --- a/gcc/ada/g-socthi-mingw.adb +++ b/gcc/ada/g-socthi-mingw.adb @@ -535,8 +535,7 @@ package body GNAT.Sockets.Thin is -- error messages are provided by Socket_Error_Message, so the default -- separate body for Host_Error_Messages is not used in this case. - function Host_Error_Message - (H_Errno : Integer) return C.Strings.chars_ptr + function Host_Error_Message (H_Errno : Integer) return String renames Socket_Error_Message; end Host_Error_Messages; @@ -572,61 +571,62 @@ package body GNAT.Sockets.Thin is begin case Errno is - when EINTR => Errm := N_EINTR; - when EBADF => Errm := N_EBADF; - when EACCES => Errm := N_EACCES; - when EFAULT => Errm := N_EFAULT; - when EINVAL => Errm := N_EINVAL; - when EMFILE => Errm := N_EMFILE; - when EWOULDBLOCK => Errm := N_EWOULDBLOCK; - when EINPROGRESS => Errm := N_EINPROGRESS; - when EALREADY => Errm := N_EALREADY; - when ENOTSOCK => Errm := N_ENOTSOCK; - when EDESTADDRREQ => Errm := N_EDESTADDRREQ; - when EMSGSIZE => Errm := N_EMSGSIZE; - when EPROTOTYPE => Errm := N_EPROTOTYPE; - when ENOPROTOOPT => Errm := N_ENOPROTOOPT; - when EPROTONOSUPPORT => Errm := N_EPROTONOSUPPORT; - when ESOCKTNOSUPPORT => Errm := N_ESOCKTNOSUPPORT; - when EOPNOTSUPP => Errm := N_EOPNOTSUPP; - when EPFNOSUPPORT => Errm := N_EPFNOSUPPORT; - when EAFNOSUPPORT => Errm := N_EAFNOSUPPORT; - when EADDRINUSE => Errm := N_EADDRINUSE; - when EADDRNOTAVAIL => Errm := N_EADDRNOTAVAIL; - when ENETDOWN => Errm := N_ENETDOWN; - when ENETUNREACH => Errm := N_ENETUNREACH; - when ENETRESET => Errm := N_ENETRESET; - when ECONNABORTED => Errm := N_ECONNABORTED; - when ECONNRESET => Errm := N_ECONNRESET; - when ENOBUFS => Errm := N_ENOBUFS; - when EISCONN => Errm := N_EISCONN; - when ENOTCONN => Errm := N_ENOTCONN; - when ESHUTDOWN => Errm := N_ESHUTDOWN; - when ETOOMANYREFS => Errm := N_ETOOMANYREFS; - when ETIMEDOUT => Errm := N_ETIMEDOUT; - when ECONNREFUSED => Errm := N_ECONNREFUSED; - when ELOOP => Errm := N_ELOOP; - when ENAMETOOLONG => Errm := N_ENAMETOOLONG; - when EHOSTDOWN => Errm := N_EHOSTDOWN; - when EHOSTUNREACH => Errm := N_EHOSTUNREACH; + when EINTR => Errm := Error_Messages (N_EINTR); + when EBADF => Errm := Error_Messages (N_EBADF); + when EACCES => Errm := Error_Messages (N_EACCES); + when EFAULT => Errm := Error_Messages (N_EFAULT); + when EINVAL => Errm := Error_Messages (N_EINVAL); + when EMFILE => Errm := Error_Messages (N_EMFILE); + when EWOULDBLOCK => Errm := Error_Messages (N_EWOULDBLOCK); + when EINPROGRESS => Errm := Error_Messages (N_EINPROGRESS); + when EALREADY => Errm := Error_Messages (N_EALREADY); + when ENOTSOCK => Errm := Error_Messages (N_ENOTSOCK); + when EDESTADDRREQ => Errm := Error_Messages (N_EDESTADDRREQ); + when EMSGSIZE => Errm := Error_Messages (N_EMSGSIZE); + when EPROTOTYPE => Errm := Error_Messages (N_EPROTOTYPE); + when ENOPROTOOPT => Errm := Error_Messages (N_ENOPROTOOPT); + when EPROTONOSUPPORT => Errm := Error_Messages (N_EPROTONOSUPPORT); + when ESOCKTNOSUPPORT => Errm := Error_Messages (N_ESOCKTNOSUPPORT); + when EOPNOTSUPP => Errm := Error_Messages (N_EOPNOTSUPP); + when EPFNOSUPPORT => Errm := Error_Messages (N_EPFNOSUPPORT); + when EAFNOSUPPORT => Errm := Error_Messages (N_EAFNOSUPPORT); + when EADDRINUSE => Errm := Error_Messages (N_EADDRINUSE); + when EADDRNOTAVAIL => Errm := Error_Messages (N_EADDRNOTAVAIL); + when ENETDOWN => Errm := Error_Messages (N_ENETDOWN); + when ENETUNREACH => Errm := Error_Messages (N_ENETUNREACH); + when ENETRESET => Errm := Error_Messages (N_ENETRESET); + when ECONNABORTED => Errm := Error_Messages (N_ECONNABORTED); + when ECONNRESET => Errm := Error_Messages (N_ECONNRESET); + when ENOBUFS => Errm := Error_Messages (N_ENOBUFS); + when EISCONN => Errm := Error_Messages (N_EISCONN); + when ENOTCONN => Errm := Error_Messages (N_ENOTCONN); + when ESHUTDOWN => Errm := Error_Messages (N_ESHUTDOWN); + when ETOOMANYREFS => Errm := Error_Messages (N_ETOOMANYREFS); + when ETIMEDOUT => Errm := Error_Messages (N_ETIMEDOUT); + when ECONNREFUSED => Errm := Error_Messages (N_ECONNREFUSED); + when ELOOP => Errm := Error_Messages (N_ELOOP); + when ENAMETOOLONG => Errm := Error_Messages (N_ENAMETOOLONG); + when EHOSTDOWN => Errm := Error_Messages (N_EHOSTDOWN); + when EHOSTUNREACH => Errm := Error_Messages (N_EHOSTUNREACH); -- Windows-specific error codes - when WSASYSNOTREADY => Errm := N_WSASYSNOTREADY; + when WSASYSNOTREADY => Errm := Error_Messages (N_WSASYSNOTREADY); when WSAVERNOTSUPPORTED => - Errm := N_WSAVERNOTSUPPORTED; + Errm := Error_Messages (N_WSAVERNOTSUPPORTED); when WSANOTINITIALISED => - Errm := N_WSANOTINITIALISED; - when WSAEDISCON => Errm := N_WSAEDISCON; + Errm := Error_Messages (N_WSANOTINITIALISED); + when WSAEDISCON => + Errm := Error_Messages (N_WSAEDISCON); -- h_errno values - when HOST_NOT_FOUND => Errm := N_HOST_NOT_FOUND; - when TRY_AGAIN => Errm := N_TRY_AGAIN; - when NO_RECOVERY => Errm := N_NO_RECOVERY; - when NO_DATA => Errm := N_NO_DATA; + when HOST_NOT_FOUND => Errm := Error_Messages (N_HOST_NOT_FOUND); + when TRY_AGAIN => Errm := Error_Messages (N_TRY_AGAIN); + when NO_RECOVERY => Errm := Error_Messages (N_NO_RECOVERY); + when NO_DATA => Errm := Error_Messages (N_NO_DATA); - when others => Errm := N_OTHERS; + when others => Errm := Error_Messages (N_OTHERS); end case; return Value (Errm); diff --git a/gcc/ada/g-socthi-mingw.ads b/gcc/ada/g-socthi-mingw.ads index 4a7c51fe3f3a..202297d5732f 100644 --- a/gcc/ada/g-socthi-mingw.ads +++ b/gcc/ada/g-socthi-mingw.ads @@ -35,7 +35,7 @@ -- This version is for NT -with Interfaces.C.Strings; +with Interfaces.C; with GNAT.Sockets.Thin_Common; @@ -66,8 +66,7 @@ package GNAT.Sockets.Thin is package Host_Error_Messages is - function Host_Error_Message - (H_Errno : Integer) return C.Strings.chars_ptr; + function Host_Error_Message (H_Errno : Integer) return String; -- Returns the error message string for the host error number H_Errno. -- If H_Errno is not known, returns "Unknown system error". diff --git a/gcc/ada/g-socthi-vms.adb b/gcc/ada/g-socthi-vms.adb index 5248c62f0666..4005cd30787f 100644 --- a/gcc/ada/g-socthi-vms.adb +++ b/gcc/ada/g-socthi-vms.adb @@ -66,9 +66,6 @@ package body GNAT.Sockets.Thin is -- mode and we spend a period of time Quantum between two attempts on a -- blocking operation. - Unknown_System_Error : constant C.Strings.chars_ptr := - C.Strings.New_String ("Unknown system error"); - function Syscall_Accept (S : C.int; Addr : System.Address; diff --git a/gcc/ada/g-socthi-vms.ads b/gcc/ada/g-socthi-vms.ads index 9be7e4a198c4..25c587057036 100644 --- a/gcc/ada/g-socthi-vms.ads +++ b/gcc/ada/g-socthi-vms.ads @@ -35,7 +35,7 @@ -- This is the Alpha/VMS version -with Interfaces.C.Strings; +with Interfaces.C; with GNAT.OS_Lib; with GNAT.Sockets.Thin_Common; @@ -69,8 +69,7 @@ package GNAT.Sockets.Thin is package Host_Error_Messages is - function Host_Error_Message - (H_Errno : Integer) return C.Strings.chars_ptr; + function Host_Error_Message (H_Errno : Integer) return String; -- Returns the error message string for the host error number H_Errno. -- If H_Errno is not known, returns "Unknown system error". diff --git a/gcc/ada/g-socthi-vxworks.adb b/gcc/ada/g-socthi-vxworks.adb index 689f450e6596..0e3f7d7dab78 100644 --- a/gcc/ada/g-socthi-vxworks.adb +++ b/gcc/ada/g-socthi-vxworks.adb @@ -57,9 +57,6 @@ package body GNAT.Sockets.Thin is -- non-blocking mode and we spend a period of time Quantum between -- two attempts on a blocking operation. - Unknown_System_Error : constant C.Strings.chars_ptr := - C.Strings.New_String ("Unknown system error"); - ----------------------- -- Local Subprograms -- ----------------------- diff --git a/gcc/ada/g-socthi-vxworks.ads b/gcc/ada/g-socthi-vxworks.ads index 4eb3a0f22301..8fe96ce7a362 100644 --- a/gcc/ada/g-socthi-vxworks.ads +++ b/gcc/ada/g-socthi-vxworks.ads @@ -35,7 +35,7 @@ -- This is the version for VxWorks -with Interfaces.C.Strings; +with Interfaces.C; with GNAT.OS_Lib; with GNAT.Sockets.Thin_Common; @@ -67,8 +67,7 @@ package GNAT.Sockets.Thin is package Host_Error_Messages is - function Host_Error_Message - (H_Errno : Integer) return C.Strings.chars_ptr; + function Host_Error_Message (H_Errno : Integer) return String; -- Returns the error message string for the host error number H_Errno. -- If H_Errno is not known, returns "Unknown system error". diff --git a/gcc/ada/g-socthi.adb b/gcc/ada/g-socthi.adb index fe7119e3a561..76d82a8a413b 100644 --- a/gcc/ada/g-socthi.adb +++ b/gcc/ada/g-socthi.adb @@ -57,8 +57,6 @@ package body GNAT.Sockets.Thin is -- non-blocking mode and we spend a period of time Quantum between -- two attempts on a blocking operation. - Unknown_System_Error : constant String := "Unknown system error"; - -- Comments required for following functions ??? function Syscall_Accept diff --git a/gcc/ada/g-socthi.ads b/gcc/ada/g-socthi.ads index 250f7a1c4e64..062ad186fec8 100644 --- a/gcc/ada/g-socthi.ads +++ b/gcc/ada/g-socthi.ads @@ -35,7 +35,7 @@ -- This is the default version -with Interfaces.C.Strings; +with Interfaces.C; with GNAT.OS_Lib; with GNAT.Sockets.Thin_Common; @@ -68,8 +68,7 @@ package GNAT.Sockets.Thin is package Host_Error_Messages is - function Host_Error_Message - (H_Errno : Integer) return C.Strings.chars_ptr; + function Host_Error_Message (H_Errno : Integer) return String; -- Returns the error message string for the host error number H_Errno. -- If H_Errno is not known, returns "Unknown system error". diff --git a/gcc/ada/g-stheme.adb b/gcc/ada/g-stheme.adb index f3f283f0ac46..ceccba0ba01c 100644 --- a/gcc/ada/g-stheme.adb +++ b/gcc/ada/g-stheme.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2007-2010, AdaCore -- +-- Copyright (C) 2007-2013, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -36,38 +36,19 @@ separate (GNAT.Sockets.Thin) package body Host_Error_Messages is - package Messages is - HOST_NOT_FOUND : aliased char_array := "Host not found" & nul; - TRY_AGAIN : aliased char_array := "Try again" & nul; - NO_RECOVERY : aliased char_array := "No recovery" & nul; - NO_DATA : aliased char_array := "No address" & nul; - Unknown_Error : aliased char_array := "Unknown error" & nul; - end Messages; - - function Host_Error_Message (H_Errno : Integer) return C.Strings.chars_ptr - is - use Interfaces.C.Strings; - function TCP - (P : char_array_access; Nul_Check : Boolean := False) return chars_ptr - renames To_Chars_Ptr; - + function Host_Error_Message (H_Errno : Integer) return String is begin case H_Errno is when SOSC.HOST_NOT_FOUND => - return TCP (Messages.HOST_NOT_FOUND'Access); - + return "Host not found"; when SOSC.TRY_AGAIN => - return TCP (Messages.TRY_AGAIN'Access); - + return "Try again"; when SOSC.NO_RECOVERY => - return TCP (Messages.NO_RECOVERY'Access); - + return "No recovery"; when SOSC.NO_DATA => - return TCP (Messages.NO_DATA'Access); - + return "No address"; when others => - return TCP (Messages.Unknown_Error'Access); - + return "Unknown error"; end case; end Host_Error_Message; diff --git a/gcc/ada/g-stseme.adb b/gcc/ada/g-stseme.adb index 40e7c495af3d..2b6aeeb48568 100644 --- a/gcc/ada/g-stseme.adb +++ b/gcc/ada/g-stseme.adb @@ -44,5 +44,5 @@ function Socket_Error_Message (Errno : Integer) return String is begin - return Errno_Message (Errno, Default => Unknown_System_Error); + return Errno_Message (Errno, Default => "Unknown system error"); end Socket_Error_Message; -- 2.47.2