]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
g-stheme.adb, [...] (Host_Error_Message): Return a string...
authorThomas Quinot <quinot@adacore.com>
Mon, 24 Feb 2014 16:59:24 +0000 (16:59 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Mon, 24 Feb 2014 16:59:24 +0000 (17:59 +0100)
2014-02-24  Thomas Quinot  <quinot@adacore.com>

* 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

12 files changed:
gcc/ada/ChangeLog
gcc/ada/g-socket.adb
gcc/ada/g-socthi-mingw.adb
gcc/ada/g-socthi-mingw.ads
gcc/ada/g-socthi-vms.adb
gcc/ada/g-socthi-vms.ads
gcc/ada/g-socthi-vxworks.adb
gcc/ada/g-socthi-vxworks.ads
gcc/ada/g-socthi.adb
gcc/ada/g-socthi.ads
gcc/ada/g-stheme.adb
gcc/ada/g-stseme.adb

index a7b2b9c32687558be62807ad22cc54d4a2ce3864..c07dcd8782eafd7d62795f5c98b6e90d5b7f51b6 100644 (file)
@@ -1,3 +1,12 @@
+2014-02-24  Thomas Quinot  <quinot@adacore.com>
+
+       * 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  <dewar@adacore.com>
 
        * a-direct.adb, sem_ch5.adb, a-cfdlli.adb, a-cfhase.adb, a-tags.adb,
index f65b2709ea299c276df2934ff2faf70920d4c7ca..d5b74c6d0491a5961df68c753e6067ab0bdd82ad 100644 (file)
@@ -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;
 
    ------------------------
index 98f4c7cb942435fc74864ba6a2f971d877d0c6fe..719ab5477551c6c91fdec1ba726f660f095e7a88 100644 (file)
@@ -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);
index 4a7c51fe3f3a9d18f9297c32c3e926ffa4beca39..202297d5732fd08e7ea448bf84887d51697ef997 100644 (file)
@@ -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".
 
index 5248c62f0666affc1afb7e4ff88f78f17d66e44c..4005cd30787f1e6f27f35c60ecee9ba01426cb37 100644 (file)
@@ -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;
index 9be7e4a198c481d088071c90486cbb5dba000486..25c587057036f32304cb8d42b3d0f49445879dfd 100644 (file)
@@ -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".
 
index 689f450e6596f4306025db505d8876695ff5233a..0e3f7d7dab78515185b68ebe212f13becc0ebf14 100644 (file)
@@ -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 --
    -----------------------
index 4eb3a0f2230178b93f1e4131f0eaf418e12910c4..8fe96ce7a3625dcdc020ee227846d4f8fe26869d 100644 (file)
@@ -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".
 
index fe7119e3a561c9ea98668d187e0c90417a6b303b..76d82a8a413b21f0c7c64940aa7ec1c9ccc79c63 100644 (file)
@@ -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
index 250f7a1c4e642071caaf80474fe40801458c4f4a..062ad186fec86af900a7e1d235ed2a3c3e782779 100644 (file)
@@ -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".
 
index f3f283f0ac467d78c76e6f0bde492a5830bf54a9..ceccba0ba01c86a47f8a9c62441a9db4513a1436 100644 (file)
@@ -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- --
 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;
 
index 40e7c495af3d35de1703da3495badc38a7c79d60..2b6aeeb485685e1c3382d61ebf771cf2f5c67cf4 100644 (file)
@@ -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;