(svn r17606) -Add: initial support for Haiku; a dedicated server with zlib and libpng compiles and links (for me). Something's fishy with the network so it doesn't actually work (yet)

This commit is contained in:
rubidium
2009-09-21 18:36:33 +00:00
parent 3dd202ba1c
commit 01ab1c6001
8 changed files with 52 additions and 34 deletions

View File

@@ -19,9 +19,11 @@
#include <unistd.h>
#if defined(SUNOS) && !defined(_LP64) && !defined(_I32LPx)
#if (defined(SUNOS) && !defined(_LP64) && !defined(_I32LPx)) || defined(__HAIKU__)
/* Solaris has, in certain situation, pid_t defined as long, while in other
* cases it has it defined as int... this handles all cases nicely. */
* cases it has it defined as int... this handles all cases nicely.
* Haiku has also defined pid_t as a long.
*/
# define PRINTF_PID_T "%ld"
#else
# define PRINTF_PID_T "%d"

View File

@@ -279,6 +279,8 @@ void AskExitGame()
SetDParam(0, STR_OSNAME_OSX);
#elif defined(__BEOS__)
SetDParam(0, STR_OSNAME_BEOS);
#elif defined(__HAIKU__)
SetDParam(0, STR_OSNAME_HAIKU);
#elif defined(__MORPHOS__)
SetDParam(0, STR_OSNAME_MORPHOS);
#elif defined(__AMIGA__)

View File

@@ -1344,6 +1344,7 @@ STR_OSNAME_DOS :DOS
STR_OSNAME_UNIX :Unix
STR_OSNAME_OSX :OS X
STR_OSNAME_BEOS :BeOS
STR_OSNAME_HAIKU :Haiku
STR_OSNAME_MORPHOS :MorphOS
STR_OSNAME_AMIGAOS :AmigaOS
STR_OSNAME_OS2 :OS/2

View File

@@ -30,9 +30,9 @@ static void NetworkFindBroadcastIPsInternal(NetworkAddressList *broadcast) // PS
{
}
#elif defined(BEOS_NET_SERVER) /* doesn't have neither getifaddrs or net/if.h */
#elif defined(BEOS_NET_SERVER) || defined(__HAIKU__) /* doesn't have neither getifaddrs or net/if.h */
/* Based on Andrew Bachmann's netstat+.c. Big thanks to him! */
int _netstat(int fd, char **output, int verbose);
extern "C" int _netstat(int fd, char **output, int verbose);
int seek_past_header(char **pos, const char *header)
{
@@ -63,9 +63,9 @@ static void NetworkFindBroadcastIPsInternal(NetworkAddressList *broadcast) // BE
char **output = &output_pointer;
if (seek_past_header(output, "IP Interfaces:") == B_OK) {
for (;;) {
uint32 n, fields, read;
uint32 n;
int fields, read;
uint8 i1, i2, i3, i4, j1, j2, j3, j4;
struct in_addr inaddr;
uint32 ip;
uint32 netmask;
@@ -85,7 +85,6 @@ static void NetworkFindBroadcastIPsInternal(NetworkAddressList *broadcast) // BE
((sockaddr_in*)&address)->sin_addr.s_addr = htonl(ip | ~netmask);
NetworkAddress addr(address, sizeof(sockaddr));
if (!broadcast->Contains(addr)) *broadcast->Append() = addr;
index++;
}
if (read < 0) {
break;

View File

@@ -155,7 +155,7 @@ static inline void OTTDfreeaddrinfo(struct addrinfo *ai)
# include <arpa/inet.h>
# include <net/if.h>
/* According to glibc/NEWS, <ifaddrs.h> appeared in glibc-2.3. */
# if !defined(__sgi__) && !defined(SUNOS) && !defined(__MORPHOS__) && !defined(__BEOS__) && !defined(__INNOTEK_LIBC__) \
# if !defined(__sgi__) && !defined(SUNOS) && !defined(__MORPHOS__) && !defined(__BEOS__) && !defined(__HAIKU__) && !defined(__INNOTEK_LIBC__) \
&& !(defined(__GLIBC__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 2)) && !defined(__dietlibc__) && !defined(HPUX)
/* If for any reason ifaddrs.h does not exist on your system, comment out
* the following two lines and an alternative way will be used to fetch
@@ -185,6 +185,10 @@ static inline void OTTDfreeaddrinfo(struct addrinfo *ai)
typedef int socklen_t;
#endif
#ifdef __HAIKU__
#define IPV6_V6ONLY 27
#endif
#if defined(PSP)
# include <sys/socket.h>
# include <netinet/in.h>

View File

@@ -16,15 +16,15 @@
#include "os/macosx/osx_stdafx.h"
#endif /* __APPLE__ */
#if defined(__NDS__)
#if defined(__BEOS__) || defined(__HAIKU__)
#include <SupportDefs.h>
#include <unistd.h>
#define _GNU_SOURCE
#define TROUBLED_INTS
#elif defined(__NDS__)
#include <nds/jtypes.h>
/* NDS' types for uint32/int32 are based on longs, which causes
* trouble all over the place in OpenTTD. */
#define uint32 uint32_ugly_hack
#define int32 int32_ugly_hack
typedef unsigned int uint32_ugly_hack;
typedef signed int int32_ugly_hack;
#endif /* __NDS__ */
#define TROUBLED_INTS
#endif
/* It seems that we need to include stdint.h before anything else
* We need INT64_MAX, which for most systems comes from stdint.h. However, MSVC
@@ -82,10 +82,6 @@
#include <pspthreadman.h>
#endif
#if defined(__BEOS__)
#include <SupportDefs.h>
#endif
#if defined(SUNOS) || defined(HPUX)
#include <alloca.h>
#endif
@@ -282,11 +278,18 @@
typedef unsigned char byte;
/* This is already defined in unix, but not in QNX Neutrino (6.x)*/
#if (!defined(UNIX) && !defined(__CYGWIN__) && !defined(__BEOS__) && !defined(__MORPHOS__)) || defined(__QNXNTO__)
#if (!defined(UNIX) && !defined(__CYGWIN__) && !defined(__BEOS__) && !defined(__HAIKU__) && !defined(__MORPHOS__)) || defined(__QNXNTO__)
typedef unsigned int uint;
#endif
#if !defined(__BEOS__) && !defined(__NDS__) /* Already defined on BEOS and NDS */
#if defined(TROUBLED_INTS)
/* NDS'/BeOS'/Haiku's types for uint32/int32 are based on longs, which causes
* trouble all over the place in OpenTTD. */
#define uint32 uint32_ugly_hack
#define int32 int32_ugly_hack
typedef unsigned int uint32_ugly_hack;
typedef signed int int32_ugly_hack;
#else
typedef unsigned char uint8;
typedef signed char int8;
typedef unsigned short uint16;
@@ -295,7 +298,7 @@ typedef unsigned char byte;
typedef signed int int32;
typedef unsigned __int64 uint64;
typedef signed __int64 int64;
#endif /* !__BEOS__ && !__NDS__ */
#endif /* !TROUBLED_INTS */
#if !defined(WITH_PERSONAL_DIR)
#define PERSONAL_DIR ""