diff options
author | Thomas Quinot <quinot@adacore.com> | 2009-04-20 09:42:48 +0000 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2009-04-20 11:42:48 +0200 |
commit | 5e39baa64cbb9805c30d16d391b3ad446a36ffe7 (patch) | |
tree | 51e0816eea433888837b017eb0316dd39c9b83b3 | |
parent | 3568b271428985245f19c6bbea5e59f79f42544a (diff) | |
download | gcc-5e39baa64cbb9805c30d16d391b3ad446a36ffe7.zip gcc-5e39baa64cbb9805c30d16d391b3ad446a36ffe7.tar.gz gcc-5e39baa64cbb9805c30d16d391b3ad446a36ffe7.tar.bz2 |
2009-04-20 Thomas Quinot <quinot@adacore.com>
* g-socket.adb, g-socket.ads, g-socthi-mingw.ads, g-socthi-vms.adb,
g-socthi-vms.ads, g-socthi-vxworks.ads, g-socthi.ads
(GNAT.Sockets.Thin.C_Inet_Addr): Remove.
(GNAT.Sockets.Thin.Inet_Aton): New function, imported from C library
except for VMS where it is reimplemented in Ada using DECC$INET_ADDR.
(GNAT.Sockets.Inet_Addr): Use inet_aton(3) instead of inet_addr(3).
* debug.adb: Fix typo
* gnat_rm.texi: Minor doc fix.
* sem_ch7.adb, freeze.adb: Minor reformatting
From-SVN: r146387
-rw-r--r-- | gcc/ada/ChangeLog | 15 | ||||
-rw-r--r-- | gcc/ada/debug.adb | 2 | ||||
-rw-r--r-- | gcc/ada/freeze.adb | 2 | ||||
-rw-r--r-- | gcc/ada/g-socket.adb | 23 | ||||
-rw-r--r-- | gcc/ada/g-socket.ads | 4 | ||||
-rw-r--r-- | gcc/ada/g-socthi-mingw.ads | 7 | ||||
-rw-r--r-- | gcc/ada/g-socthi-vms.adb | 43 | ||||
-rw-r--r-- | gcc/ada/g-socthi-vms.ads | 6 | ||||
-rw-r--r-- | gcc/ada/g-socthi-vxworks.ads | 7 | ||||
-rw-r--r-- | gcc/ada/g-socthi.ads | 7 | ||||
-rw-r--r-- | gcc/ada/gnat_rm.texi | 2 | ||||
-rw-r--r-- | gcc/ada/sem_ch7.adb | 12 |
12 files changed, 92 insertions, 38 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index bcebd6e..1a21d7a 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,20 @@ 2009-04-20 Thomas Quinot <quinot@adacore.com> + * g-socket.adb, g-socket.ads, g-socthi-mingw.ads, g-socthi-vms.adb, + g-socthi-vms.ads, g-socthi-vxworks.ads, g-socthi.ads + (GNAT.Sockets.Thin.C_Inet_Addr): Remove. + (GNAT.Sockets.Thin.Inet_Aton): New function, imported from C library + except for VMS where it is reimplemented in Ada using DECC$INET_ADDR. + (GNAT.Sockets.Inet_Addr): Use inet_aton(3) instead of inet_addr(3). + + * debug.adb: Fix typo + + * gnat_rm.texi: Minor doc fix. + + * sem_ch7.adb, freeze.adb: Minor reformatting + +2009-04-20 Thomas Quinot <quinot@adacore.com> + * g-socket.ads: Add new constants: Loopback_Inet_Addr Unspecified_Group_Inet_Addr diff --git a/gcc/ada/debug.adb b/gcc/ada/debug.adb index 0ce0db6..a37d4f0 100644 --- a/gcc/ada/debug.adb +++ b/gcc/ada/debug.adb @@ -283,7 +283,7 @@ package body Debug is -- list header is allocated, a line of output is generated. Certain -- other basic tree operations also cause a line of output to be -- generated. This option is useful in seeing where the parser is - -- blowing up.; + -- blowing up. -- do Print the source recreated from the generated tree. In the case -- where the tree has been rewritten, this output includes only the diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 31e32af..a74a6c2 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -2503,7 +2503,7 @@ package body Freeze is Next_Formal (Formal); end loop; - -- Case of function: similar checks on return type. + -- Case of function: similar checks on return type if Ekind (E) = E_Function then diff --git a/gcc/ada/g-socket.adb b/gcc/ada/g-socket.adb index 5ddbd42..f5b5d47 100644 --- a/gcc/ada/g-socket.adb +++ b/gcc/ada/g-socket.adb @@ -179,10 +179,6 @@ package body GNAT.Sockets is -- Reconstruct a Duration value from a Timeval record (seconds and -- microseconds). - procedure Raise_Socket_Error (Error : Integer); - -- Raise Socket_Error with an exception message describing the error code - -- from errno. - procedure Raise_Host_Error (H_Error : Integer); -- Raise Host_Error exception with message describing error code (note -- hstrerror seems to be obsolete) from h_errno. @@ -1274,36 +1270,29 @@ package body GNAT.Sockets is --------------- function Inet_Addr (Image : String) return Inet_Addr_Type is + use Interfaces.C; use Interfaces.C.Strings; - Img : chars_ptr; + Img : aliased char_array := To_C (Image); + Addr : aliased C.int; Res : C.int; Result : Inet_Addr_Type; begin - -- Special case for the all-ones broadcast address: this address has the - -- same in_addr_t value as Failure, and thus cannot be properly returned - -- by inet_addr(3). - - if Image = "255.255.255.255" then - return Broadcast_Inet_Addr; - -- Special case for an empty Image as on some platforms (e.g. Windows) -- calling Inet_Addr("") will not return an error. - elsif Image = "" then + if Image = "" then Raise_Socket_Error (SOSC.EINVAL); end if; - Img := New_String (Image); - Res := C_Inet_Addr (Img); - Free (Img); + Res := Inet_Aton (To_Chars_Ptr (Img'Unchecked_Access), Addr'Address); if Res = Failure then Raise_Socket_Error (SOSC.EINVAL); end if; - To_Inet_Addr (To_In_Addr (Res), Result); + To_Inet_Addr (To_In_Addr (Addr), Result); return Result; end Inet_Addr; diff --git a/gcc/ada/g-socket.ads b/gcc/ada/g-socket.ads index 3680d75..1b3ee63 100644 --- a/gcc/ada/g-socket.ads +++ b/gcc/ada/g-socket.ads @@ -1108,6 +1108,10 @@ package GNAT.Sockets is private + procedure Raise_Socket_Error (Error : Integer); + -- Raise Socket_Error with an exception message describing the error code + -- from errno. + type Socket_Type is new Integer; No_Socket : constant Socket_Type := -1; diff --git a/gcc/ada/g-socthi-mingw.ads b/gcc/ada/g-socthi-mingw.ads index ab4e7b0..5588dd0 100644 --- a/gcc/ada/g-socthi-mingw.ads +++ b/gcc/ada/g-socthi-mingw.ads @@ -115,8 +115,9 @@ package GNAT.Sockets.Thin is Optval : System.Address; Optlen : not null access C.int) return C.int; - function C_Inet_Addr - (Cp : C.Strings.chars_ptr) return C.int; + function Inet_Aton + (Cp : C.Strings.chars_ptr; + Inp : System.Address) return C.int; function C_Ioctl (S : C.int; @@ -232,7 +233,7 @@ private pragma Import (Stdcall, C_Getpeername, "getpeername"); pragma Import (Stdcall, C_Getsockname, "getsockname"); pragma Import (Stdcall, C_Getsockopt, "getsockopt"); - pragma Import (Stdcall, C_Inet_Addr, "inet_addr"); + pragma Import (Stdcall, Inet_Aton, "inet_aton"); pragma Import (Stdcall, C_Ioctl, "ioctlsocket"); pragma Import (Stdcall, C_Listen, "listen"); pragma Import (Stdcall, C_Recv, "recv"); diff --git a/gcc/ada/g-socthi-vms.adb b/gcc/ada/g-socthi-vms.adb index 8a410a4..8a143c1 100644 --- a/gcc/ada/g-socthi-vms.adb +++ b/gcc/ada/g-socthi-vms.adb @@ -38,6 +38,8 @@ with GNAT.Task_Lock; with Interfaces.C; use Interfaces.C; +with System.Address_To_Access_Conversions; + package body GNAT.Sockets.Thin is Non_Blocking_Sockets : aliased Fd_Set; @@ -351,6 +353,47 @@ package body GNAT.Sockets.Thin is package body Host_Error_Messages is separate; + --------------- + -- Inet_Aton -- + --------------- + + -- VMS does not support inet_aton(3), so emulate it here in terms of + -- inet_addr(3). + + function Inet_Aton + (Cp : C.Strings.chars_ptr; + Inp : System.Address) return C.int + is + use C.Strings; + use System; + + Res : aliased C.int; + package Conv is new System.Address_To_Access_Conversions (C.int); + function C_Inet_Addr (Cp : C.Strings.chars_ptr) return C.int; + pragma Import (C, C_Inet_Addr, "DECC$INET_ADDR"); + begin + if Cp = Null_Ptr or else Inp = Null_Address then + Raise_Socket_Error (SOSC.EINVAL); + end if; + + -- Special case for the all-ones broadcast address: this address has the + -- same in_addr_t value as Failure, and thus cannot be properly returned + -- by inet_addr(3). + + if String'(Value (Cp)) = "255.255.255.255" then + Conv.To_Pointer (Inp).all := -1; + return 0; + end if; + + Res := C_Inet_Addr (Cp); + if Res = -1 then + return Res; + end if; + + Conv.To_Pointer (Inp).all := Res; + return 0; + end Inet_Aton; + ---------------- -- Initialize -- ---------------- diff --git a/gcc/ada/g-socthi-vms.ads b/gcc/ada/g-socthi-vms.ads index 52a9d14..1abcbb3 100644 --- a/gcc/ada/g-socthi-vms.ads +++ b/gcc/ada/g-socthi-vms.ads @@ -118,8 +118,9 @@ package GNAT.Sockets.Thin is Optval : System.Address; Optlen : not null access C.int) return C.int; - function C_Inet_Addr - (Cp : C.Strings.chars_ptr) return C.int; + function Inet_Aton + (Cp : C.Strings.chars_ptr; + Inp : System.Address) return C.int; function C_Ioctl (S : C.int; @@ -249,7 +250,6 @@ private pragma Import (C, C_Getpeername, "DECC$GETPEERNAME"); pragma Import (C, C_Getsockname, "DECC$GETSOCKNAME"); pragma Import (C, C_Getsockopt, "DECC$GETSOCKOPT"); - pragma Import (C, C_Inet_Addr, "DECC$INET_ADDR"); pragma Import (C, C_Listen, "DECC$LISTEN"); pragma Import (C, C_Select, "DECC$SELECT"); pragma Import (C, C_Setsockopt, "DECC$SETSOCKOPT"); diff --git a/gcc/ada/g-socthi-vxworks.ads b/gcc/ada/g-socthi-vxworks.ads index df987d5..10c3754 100644 --- a/gcc/ada/g-socthi-vxworks.ads +++ b/gcc/ada/g-socthi-vxworks.ads @@ -116,8 +116,9 @@ package GNAT.Sockets.Thin is Optval : System.Address; Optlen : not null access C.int) return C.int; - function C_Inet_Addr - (Cp : C.Strings.chars_ptr) return C.int; + function Inet_Aton + (Cp : C.Strings.chars_ptr; + Inp : System.Address) return C.int; function C_Ioctl (S : C.int; @@ -226,7 +227,7 @@ private pragma Import (C, C_Getpeername, "getpeername"); pragma Import (C, C_Getsockname, "getsockname"); pragma Import (C, C_Getsockopt, "getsockopt"); - pragma Import (C, C_Inet_Addr, "inet_addr"); + pragma Import (C, Inet_Aton, "inet_aton"); pragma Import (C, C_Listen, "listen"); pragma Import (C, C_Readv, "readv"); pragma Import (C, C_Select, "select"); diff --git a/gcc/ada/g-socthi.ads b/gcc/ada/g-socthi.ads index 65660e3..e54d59c 100644 --- a/gcc/ada/g-socthi.ads +++ b/gcc/ada/g-socthi.ads @@ -117,8 +117,9 @@ package GNAT.Sockets.Thin is Optval : System.Address; Optlen : not null access C.int) return C.int; - function C_Inet_Addr - (Cp : C.Strings.chars_ptr) return C.int; + function Inet_Aton + (Cp : C.Strings.chars_ptr; + Inp : System.Address) return C.int; function C_Ioctl (S : C.int; @@ -251,7 +252,7 @@ private pragma Import (C, C_Getpeername, "getpeername"); pragma Import (C, C_Getsockname, "getsockname"); pragma Import (C, C_Getsockopt, "getsockopt"); - pragma Import (C, C_Inet_Addr, "inet_addr"); + pragma Import (C, Inet_Aton, "inet_aton"); pragma Import (C, C_Listen, "listen"); pragma Import (C, C_Readv, "readv"); pragma Import (C, C_Select, "select"); diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index 322e6fe..f3059ae 100644 --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -10478,7 +10478,7 @@ On a typical 32-bit architecture, the X component will be four bytes, and require four-byte alignment, and the Y component will be one byte. In this case @code{R'Value_Size} will be 40 (bits) since this is the minimum size required to store a value of this type, and for example, it is permissible -to have a component of type R in an outer record whose component size is +to have a component of type R in an outer array whose component size is specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits), since it must be rounded up so that this value is a multiple of the alignment (4 bytes = 32 bits). diff --git a/gcc/ada/sem_ch7.adb b/gcc/ada/sem_ch7.adb index e344a58..54d4a29 100644 --- a/gcc/ada/sem_ch7.adb +++ b/gcc/ada/sem_ch7.adb @@ -1510,9 +1510,9 @@ package body Sem_Ch7 is Next_Elmt (Op_Elmt_2); end loop; - -- Case 2: We have not found any explicit overriding and - -- hence we need to declare the operation (i.e., make it - -- visible). + -- Case 2: We have not found any explicit overriding and + -- hence we need to declare the operation (i.e., make it + -- visible). Derive_Subprogram (New_Op, Alias (Prim_Op), E, Etype (E)); @@ -1555,8 +1555,8 @@ package body Sem_Ch7 is end if; else - -- Non-tagged type, scan forward to locate inherited hidden - -- operations. + -- Non-tagged type, scan forward to locate inherited hidden + -- operations. Prim_Op := Next_Entity (E); while Present (Prim_Op) loop @@ -2296,7 +2296,7 @@ package body Sem_Ch7 is and then No (Full_View (Id)) then -- Mark Taft amendment types. Verify that there are no primitive - -- operations declared for the type (3.10.1 (9)). + -- operations declared for the type (3.10.1(9)). Set_Has_Completion_In_Body (Id); |