diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-11-15 13:50:37 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-11-15 13:50:37 +0000 |
commit | 02747205c562d60e12b1c96b8cd6d3ee6eedea3a (patch) | |
tree | d1576a6497bfbada92fc3b0b451f8c360df4d37d /gcc/ada/g-socthi-vxworks.adb | |
parent | aa976da570b177e1a38dddbb3bf035c240bb415f (diff) | |
download | gcc-02747205c562d60e12b1c96b8cd6d3ee6eedea3a.tar.gz |
2005-11-14 Thomas Quinot <quinot@adacore.com>
* g-soccon.ads: Minor reformatting. Update comments.
* gsocket.h: Include <sys/times.h> in the VxWorks case, in order to
gain visibility on the declaration of struct timeval.
* g-soccon-freebsd.ads,
g-soccon-darwin.ads,
g-soccon-tru64.ads,
g-soccon-aix.ads,
g-soccon-irix.ads,
g-soccon-hpux.ads,
g-soccon-solaris.ads,
g-soccon-vms.ads,
g-soccon-mingw.ads,
g-soccon-vxworks.ads (SIZEOF_tv_sec, SIZEOF_tv_usec): New constants.
* g-soccon-hpux-ia64.ads, g-soccon-linux-ppc.ads,
g-soccon-solaris-64.ads, g-soccon-linux-64.ads,
g-soccon-linux-x86.ads: New files.
* g-socthi-mingw.adb:
(Socket_Error_Message): Remove redundant use of GNAT.Sockets.Constants
* g-socthi-vxworks.ads, g-socthi-vms.ads, g-socthi-mingw.ads
(time_t, suseconds_t): New types constructed to match the tv_sec
and tv_usec fields of C struct timeval.
(Timeval): Construct structure in terms of the new types.
(Host_Errno): New function (imported from socket.c), returns last hosts
database error.
* g-socthi-vxworks.adb: Add error handling circuitry.
* g-socket.ads, g-socket.adb (To_Timeval): Reflect change of type for
components of struct timeval.
(Get_Host_By_Name, Get_Host_By_Address): Fix error reporting circuitry.
(Check_Selector): In error conditions, clear internal socket sets to
avoid a memory leak.
(Get_Socket_Option, Set_Socket_Option): Support for Multicast_If,
Send_Timeout, Receive_Timeout.
* g-socthi.ads (time_t, suseconds_t): New types constructed to match
the tv_sec and tv_usec fields of C struct timeval.
(Timeval): Construct structure in terms of the new types.
(Host_Errno): New function (imported from socket.c), returns last hosts
database error.
* socket.c (__gnat_get_h_errno): New function to retrieve h_errno, the
hosts database last error code.
* gen-soccon.c: Complete value expansion should not be performed on
TARGET, as it has the form of a math expression, and some components
may be platform-defined macros.
For VxWorks, generate the OK and ERROR values.
New constants giving the sizes of the components of C struct timeval.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@106949 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/g-socthi-vxworks.adb')
-rw-r--r-- | gcc/ada/g-socthi-vxworks.adb | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/gcc/ada/g-socthi-vxworks.adb b/gcc/ada/g-socthi-vxworks.adb index 95de193ecf7..02a0df3fe33 100644 --- a/gcc/ada/g-socthi-vxworks.adb +++ b/gcc/ada/g-socthi-vxworks.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2002-2004 Ada Core Technologies, Inc. -- +-- Copyright (C) 2002-2005, 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- -- @@ -267,14 +267,19 @@ package body GNAT.Sockets.Thin is function To_Pointer is new Unchecked_Conversion (System.Address, int_Access); - procedure VxWorks_Gethostbyaddr - (Addr : C.int; Buf : out C.char_array); - pragma Import (C, VxWorks_Gethostbyaddr, "hostGetByAddr"); + function VxWorks_hostGetByAddr + (Addr : C.int; Buf : System.Address) return C.int; + pragma Import (C, VxWorks_hostGetByAddr, "hostGetByAddr"); - Host_Name : C.char_array (1 .. Max_Name_Length); + Host_Name : aliased C.char_array (1 .. Max_Name_Length); begin - VxWorks_Gethostbyaddr (To_Pointer (Addr).all, Host_Name); + if VxWorks_hostGetByAddr (To_Pointer (Addr).all, + Host_Name (Host_Name'First)'Address) + /= Constants.OK + then + return null; + end if; In_Addr_Access_Ptr.all.all := To_In_Addr (To_Pointer (Addr).all); Local_Hostent.all.H_Name := C.Strings.New_Char_Array (Host_Name); @@ -289,14 +294,17 @@ package body GNAT.Sockets.Thin is function C_Gethostbyname (Name : C.char_array) return Hostent_Access is - function VxWorks_Gethostbyname + function VxWorks_hostGetByName (Name : C.char_array) return C.int; - pragma Import (C, VxWorks_Gethostbyname, "hostGetByName"); + pragma Import (C, VxWorks_hostGetByName, "hostGetByName"); Addr : C.int; begin - Addr := VxWorks_Gethostbyname (Name); + Addr := VxWorks_hostGetByName (Name); + if Addr /= Constants.OK then + return null; + end if; In_Addr_Access_Ptr.all.all := To_In_Addr (Addr); Local_Hostent.all.H_Name := C.Strings.New_Char_Array (To_C (Host_Name)); @@ -515,7 +523,6 @@ package body GNAT.Sockets.Thin is function Non_Blocking_Socket (S : C.int) return Boolean is R : Boolean; - begin Task_Lock.Lock; R := (Is_Socket_In_Set (Non_Blocking_Sockets, S) /= 0); |