From 49ff4bf74fef8c191e72658f3b939ec3db46102c Mon Sep 17 00:00:00 2001
From: Scott McCreary <scottmc2@gmail.com>
Date: Wed, 14 Jan 2015 20:47:28 -0800
Subject: Haiku fixes


diff --git a/libgc/include/private/gcconfig.h b/libgc/include/private/gcconfig.h
index 5f897a4..2882878 100644
--- a/libgc/include/private/gcconfig.h
+++ b/libgc/include/private/gcconfig.h
@@ -229,6 +229,16 @@
 #    define BEOS
 #    define mach_type_known
 # endif
+# if defined(__HAIKU__) && defined(_X86_)
+#    define I386
+#    define BEOS
+#    define mach_type_known
+# endif
+# if defined(__HAIKU__) && defined(_X86_64_)
+#    define X86_64
+#    define BEOS
+#    define mach_type_known
+# endif
 # if defined(LINUX) && (defined(i386) || defined(__i386__))
 #    define I386
 #    define mach_type_known
-- 
1.8.3.4


From 92ed68680f8d2940f29e6571bd998e699f4d33c0 Mon Sep 17 00:00:00 2001
From: Scott McCreary <scottmc2@gmail.com>
Date: Wed, 14 Jan 2015 23:31:05 -0800
Subject: Fix a few gcc2 issues


diff --git a/engine/debugger.c b/engine/debugger.c
index 65f52c7..e6cef4a 100644
--- a/engine/debugger.c
+++ b/engine/debugger.c
@@ -104,6 +104,7 @@ static int SocketIO_Open(ILDebuggerIO *io, const char *connectionString)
 {
 	ILSysIOHandle sockfd;
 	int port = 4571;
+	unsigned char addr[16];
 
 	/*
 	 * Create socket descriptor
@@ -120,7 +121,6 @@ static int SocketIO_Open(ILDebuggerIO *io, const char *connectionString)
 
 	/* Convert the end point into a sockaddr buffer like in
 	 * CombinedToSerialized() in socket.c */
-	unsigned char addr[16];
 	addr[0] = 2;								/* address family - AF_INET */
 	addr[1] = 0; 
 	addr[2] = (unsigned char)(port >> 8);		/* port */
diff --git a/engine/lib_string.c b/engine/lib_string.c
index bb2a081..3206794 100644
--- a/engine/lib_string.c
+++ b/engine/lib_string.c
@@ -1025,12 +1025,15 @@ ILInt32 _IL_String_FindInRange(ILExecThread *thread, System_String *_this,
 							   ILInt32 srcFirst, ILInt32 srcLast,
 							   ILInt32 step, System_String *dest)
 {
+  	ILUInt16 *buf1;
+	ILUInt16 *buf2;
+	ILUInt32 size;
   	/* Searches for zero length strings always match */
   	if(dest->length == 0)
 	  	return srcFirst;
-	ILUInt16 *buf1 = StringToBuffer(_this) + srcFirst;
-	ILUInt16 *buf2 = StringToBuffer(dest);
-	ILUInt32 size = (ILUInt32)(dest->length * sizeof(ILUInt16));
+	buf1 = StringToBuffer(_this) + srcFirst;
+	buf2 = StringToBuffer(dest);
+	size = (ILUInt32)(dest->length * sizeof(ILUInt16));
 	if(step > 0)
 	{
 		/* Scan forwards for the string */
-- 
1.8.3.4


From b378bbb5da796ae92b7b3c64ee7c34cdbf2c277d Mon Sep 17 00:00:00 2001
From: Scott McCreary <scottmc2@gmail.com>
Date: Thu, 15 Jan 2015 00:44:19 -0800
Subject: Add Haiku build support into configure.in


diff --git a/configure.in b/configure.in
index 04db657..740f963 100644
--- a/configure.in
+++ b/configure.in
@@ -6,7 +6,7 @@ AC_CANONICAL_SYSTEM
 
 dnl Initialize automake.
 AM_INIT_AUTOMAKE(pnet, 0.8.0)
-AM_CONFIG_HEADER(include/il_config.h)
+AC_CONFIG_HEADERS(include/il_config.h)
 AM_MAINTAINER_MODE
 
 # Tell everyone if we are crosscompiling
@@ -44,6 +44,10 @@ else
       WINLIBS="-lole32"
       suppress_libm=yes
 	;;
+	*-*-haiku*)
+	  SOCKETLIBS="-lnetwork"
+	  suppress_libm=yes
+	;;
 	*) ;;
   esac
 fi
@@ -261,6 +265,8 @@ if test "$THREADS" = "no"; then
 	*-*-beos*)
 			THREADS=beos
 			;;	
+	*-*-haiku*)
+			THREADS=posix
 	esac
 fi
 
@@ -326,6 +332,11 @@ case "$THREADS" in
      *-*-irix*)
 	AC_DEFINE(GC_IRIX_THREADS, 1, [Define to use libgc irix thread support])
 	;;
+     *-*-haiku*)
+	AC_DEFINE(GC_LINUX_THREADS, 1, [Define to use libgc haiku thread support])
+	INCLUDES="$INCLUDES"
+	THREADLIBS=""
+	;;
     esac
     ;;
  win32)
-- 
1.8.3.4

