From a82320c3f0bf541c6c400cbaafda7a5f50b6ba12 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Mon, 2 Jun 2014 20:07:15 +0000
Subject: checks for uint32, uint16, uint8 and uses SupportsDefs.h


diff --git a/configure.ac b/configure.ac
index e7cf804..90e782c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -154,11 +154,14 @@ AC_CHECK_SIZEOF(long)
 AC_HEADER_TIME
 AC_STRUCT_TM
 dnl Some compilers (IBM VisualAge) has these types defined, so check it here:
-AC_CHECK_TYPES([int8, int16, int32],,,
+AC_CHECK_TYPES([int8, int16, int32, uint8, uint16, uint32],,,
 [
 #if HAVE_INTTYPES_H
 # include <inttypes.h>
 #endif
+#ifdef __HAIKU__
+# include <SupportDefs.h>
+#endif
 ])
 
 # Obtain size of a 'signed long' and define as SIZEOF_SIGNED_LONG
diff --git a/libtiff/tif_config.h.in b/libtiff/tif_config.h.in
index 95db77a..41a5772 100644
--- a/libtiff/tif_config.h.in
+++ b/libtiff/tif_config.h.in
@@ -142,6 +142,15 @@
 /* Define to 1 if you have the <sys/types.h> header file. */
 #undef HAVE_SYS_TYPES_H
 
+/* Define to 1 if the system has the type `uint16'. */
+#undef HAVE_UINT16
+
+/* Define to 1 if the system has the type `uint32'. */
+#undef HAVE_UINT32
+
+/* Define to 1 if the system has the type `uint8'. */
+#undef HAVE_UINT8
+
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
diff --git a/libtiff/tiff.h b/libtiff/tiff.h
index 0d4ab9f..c70f214 100644
--- a/libtiff/tiff.h
+++ b/libtiff/tiff.h
@@ -28,6 +28,10 @@
 #define	_TIFF_
 
 #include "tiffconf.h"
+#ifdef __HAIKU__
+ #include <SupportDefs.h>
+ // needed for uint* types, avoid massive changes in libtiff
+#endif
 
 /*
  * Tag Image File Format (TIFF)
@@ -64,22 +68,30 @@
 #ifndef HAVE_INT8
 typedef	signed char int8;	/* NB: non-ANSI compilers may not grok */
 #endif
+#ifndef HAVE_UINT8
 typedef	unsigned char uint8;
+#endif
 #ifndef HAVE_INT16
 typedef	short int16;
 #endif
+#ifndef HAVE_UINT16
 typedef	unsigned short uint16;	/* sizeof (uint16) must == 2 */
+#endif
 #if SIZEOF_INT == 4
 #ifndef HAVE_INT32
 typedef	int int32;
 #endif
+#ifndef HAVE_UINT32
 typedef	unsigned int uint32;	/* sizeof (uint32) must == 4 */
+#endif
 #elif SIZEOF_LONG == 4
 #ifndef HAVE_INT32
 typedef	long int32;
 #endif
+#ifndef HAVE_UINT32
 typedef	unsigned long uint32;	/* sizeof (uint32) must == 4 */
 #endif
+#endif
 
 /* For TIFFReassignTagToIgnore */
 enum TIFFIgnoreSense /* IGNORE tag table */
diff --git a/libtiff/tiffconf.h.in b/libtiff/tiffconf.h.in
index 1a52b37..3cdcc28 100644
--- a/libtiff/tiffconf.h.in
+++ b/libtiff/tiffconf.h.in
@@ -16,6 +16,15 @@
 /* Define to 1 if the system has the type `int8'. */
 #undef HAVE_INT8
 
+/* Define to 1 if the system has the type `uint16'. */
+#undef HAVE_UINT16
+
+/* Define to 1 if the system has the type `uint32'. */
+#undef HAVE_UINT32
+
+/* Define to 1 if the system has the type `uint8'. */
+#undef HAVE_UINT8
+
 /* The size of a `int', as computed by sizeof. */
 #undef SIZEOF_INT
 
diff --git a/libtiff/tiffiop.h b/libtiff/tiffiop.h
index 2ecc994..fa5fb1c 100644
--- a/libtiff/tiffiop.h
+++ b/libtiff/tiffiop.h
@@ -62,7 +62,7 @@ extern void *lfind(const void *, const void *, size_t *, size_t,
   utilities may use it.  
 */
 
-#if !defined(__xlC__) && !defined(__xlc__) // Already defined there (#2301)
+#if !defined(__xlC__) && !defined(__xlc__) && !defined(__HAIKU__) // Already defined there (#2301)
 typedef TIFF_INT64_T  int64;
 typedef TIFF_UINT64_T uint64;
 #endif
-- 
1.8.3.4

