Changeset - r5841:c7ac3e15da3e
[Not reviewed]
master
0 1 0
truelight - 18 years ago 2007-01-26 08:27:59
truelight@openttd.org
(svn r8411) [MorphOS] -Fix: tons of unneeded warnings in networking code, because MorphOS wants UBYTE arrays and we use char arrays. Solution is a bit hackish.
1 file changed with 3 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/network/core/os_abstraction.h
Show inline comments
 
@@ -79,96 +79,99 @@ typedef unsigned long in_addr_t;
 
#	endif /* BEOS_NET_SERVER */
 

	
 
#	if !defined(__BEOS__) && defined(__GLIBC__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 1)
 
		typedef uint32_t in_addr_t;
 
#	endif
 

	
 
#	include <errno.h>
 
#	include <sys/time.h>
 
#	include <netdb.h>
 
#endif // UNIX
 

	
 
#ifdef __BEOS__
 
	typedef int socklen_t;
 
#endif
 

	
 
/* OS/2 stuff */
 
#if defined(__OS2__)
 
#	define SOCKET int
 
#	define INVALID_SOCKET -1
 
#	define ioctlsocket ioctl
 
#	define closesocket close
 
#	define GET_LAST_ERROR() (sock_errno())
 

	
 
/* Includes needed for OS/2 systems */
 
#	include <types.h>
 
#	include <unistd.h>
 
#	include <sys/ioctl.h>
 
#	include <sys/socket.h>
 
#	include <netinet/in.h>
 
#	include <netinet/tcp.h>
 
#	include <arpa/inet.h>
 
#	include <net/if.h>
 
#	include <errno.h>
 
#	include <sys/time.h>
 
#	include <netdb.h>
 
#	include <nerrno.h>
 
#	define INADDR_NONE 0xffffffff
 

	
 
typedef int socklen_t;
 
#if !defined(__INNOTEK_LIBC__)
 
typedef unsigned long in_addr_t;
 
#endif /* __INNOTEK_LIBC__ */
 
#endif /* OS/2 */
 

	
 
/* MorphOS and Amiga stuff */
 
#if defined(__MORPHOS__) || defined(__AMIGA__)
 
#	include <exec/types.h>
 
#	include <proto/exec.h>   // required for Open/CloseLibrary()
 
	/* MorphOS defines his network functions with UBYTE arrays while we
 
	 *  use char arrays. This gives tons of unneeded warnings */
 
#	define UBYTE char
 
#	if defined(__MORPHOS__)
 
#		include <sys/filio.h>  // FIO* defines
 
#		include <sys/sockio.h> // SIO* defines
 
#		include <netinet/in.h>
 
#	else /* __AMIGA__ */
 
#		include	<proto/socket.h>
 
#	endif
 

	
 
/* Make the names compatible */
 
#	define closesocket(s) CloseSocket(s)
 
#	define GET_LAST_ERROR() Errno()
 
#	define ioctlsocket(s,request,status) IoctlSocket((LONG)s,(ULONG)request,(char*)status)
 
#	define ioctl ioctlsocket
 

	
 
	typedef unsigned int in_addr_t;
 
	typedef long         socklen_t;
 
	extern struct Library *SocketBase;
 

	
 
#	ifdef __AMIGA__
 
	/* for usleep() implementation */
 
	extern struct Device      *TimerBase;
 
	extern struct MsgPort     *TimerPort;
 
	extern struct timerequest *TimerRequest;
 
#	endif
 
#endif // __MORPHOS__ || __AMIGA__
 

	
 
static inline bool SetNonBlocking(const int d)
 
{
 
#ifdef WIN32
 
	u_long nonblocking = 1;
 
#else
 
	int nonblocking = 1;
 
#endif
 
#if defined(__BEOS__) && defined(BEOS_NET_SERVER)
 
	return setsockopt(d, SOL_SOCKET, SO_NONBLOCK, &nonblocking, sizeof(nonblocking)) == 0;
 
#else
 
	return ioctlsocket(d, FIONBIO, &nonblocking) == 0;
 
#endif
 
}
 

	
 
static inline bool SetNoDelay(const int d)
 
{
 
	/* XXX should this be done at all? */
 
#if !defined(BEOS_NET_SERVER) // not implemented on BeOS net_server
 
	int b = 1;
 
	/* The (const char*) cast is needed for windows */
 
	return setsockopt(d, IPPROTO_TCP, TCP_NODELAY, (const char*)&b, sizeof(b)) == 0;
 
#else
0 comments (0 inline, 0 general)