From 67b231749b7fdd10bfb4cd7ff6244e4848bfb6a1 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@gmail.com>
Date: Wed, 22 Oct 2014 21:47:40 +0200
Subject: Preliminary Haiku support.


diff --git a/diskio.h b/diskio.h
index 0bdaba4..d8645b7 100644
--- a/diskio.h
+++ b/diskio.h
@@ -29,7 +29,7 @@
 #include <sys/dkio.h>
 #endif
 
-#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined (__APPLE__)
+#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined (__APPLE__) || defined(__HAIKU__)
 #define fstat64 fstat
 #define stat64 stat
 #endif
diff --git a/gptcurses.cc b/gptcurses.cc
index 3e9b240..9037269 100644
--- a/gptcurses.cc
+++ b/gptcurses.cc
@@ -22,6 +22,7 @@
 #include <iostream>
 #include <string>
 #include <sstream>
+#include <clocale>
 #include <ncurses.h>
 #include "gptcurses.h"
 #include "support.h"
diff --git a/support.h b/support.h
index 8f976da..745bb57 100644
--- a/support.h
+++ b/support.h
@@ -16,6 +16,10 @@
 #define lseek64 lseek
 #endif
 
+#if defined(__HAIKU__)
+#define lseek64 lseek
+#endif
+
 #if defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
 #define DEFAULT_GPT_TYPE 0xA503
 #endif
-- 
2.16.1


From 43151ba0e882e40163086578d5b6fbda1ec543f5 Mon Sep 17 00:00:00 2001
From: fbrosson <fbrosson@localhost>
Date: Fri, 8 Apr 2016 21:24:56 +0000
Subject: Accept character devices on Haiku.


diff --git a/diskio-unix.cc b/diskio-unix.cc
index d9f8b8d..6f38118 100644
--- a/diskio-unix.cc
+++ b/diskio-unix.cc
@@ -78,6 +78,7 @@ int DiskIO::OpenForRead(void) {
             if (S_ISDIR(st.st_mode))
                cerr << "The specified path is a directory!\n";
 #if !(defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) \
+                       && !defined(__HAIKU__) \
                        && !defined(__APPLE__)
             else if (S_ISCHR(st.st_mode))
                cerr << "The specified path is a character device!\n";
-- 
2.16.1


From ce3cdab4d24c693a97912c2550a6ace6a068836f Mon Sep 17 00:00:00 2001
From: fbrosson <fbrosson@localhost>
Date: Fri, 8 Apr 2016 21:24:56 +0000
Subject: Use the correct CRC32 polynom on big-endian architectures.


diff --git a/crc32.cc b/crc32.cc
index d253dd9..8da42ed 100644
--- a/crc32.cc
+++ b/crc32.cc
@@ -16,6 +16,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/types.h>
+#include <posix/endian.h>
 #include "crc32.h"
 
 /* crc_tab[] -- this crcTable is being build by chksum_crc32GenTab().
@@ -52,7 +53,17 @@ void chksum_crc32gentab ()
    unsigned long crc, poly;
    int i, j;
 
+#if defined( BYTE_ORDER )
+#	if defined( LITTLE_ENDIAN ) && (BYTE_ORDER == LITTLE_ENDIAN)
    poly = 0xEDB88320L;
+#	elif defined( BIG_ENDIAN ) && (BYTE_ORDER == BIG_ENDIAN)
+   poly = 0x04C11DB7L;
+#	else
+#	error Unknown byte-order
+#	endif
+#else
+#error Undefined byte-order
+#endif
    for (i = 0; i < 256; i++)
    {
       crc = i;
-- 
2.16.1

