From 07cf4d7799b3c89ccc39b6ede13d661617738b5d Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sun, 21 Sep 2014 10:40:38 +0200
Subject: Avoid include name conflict with Haiku.


diff --git a/common/image.c b/common/image.c
index f084d2b..9d11a15 100644
--- a/common/image.c
+++ b/common/image.c
@@ -43,7 +43,7 @@
 #include <rtc.h>
 #endif
 
-#include <image.h>
+#include <uimage.h>
 
 #if defined(CONFIG_FIT) || defined(CONFIG_OF_LIBFDT)
 #include <fdt.h>
@@ -71,7 +71,7 @@ static const image_header_t *image_get_ramdisk(ulong rd_addr, uint8_t arch,
 #include "mkimage.h"
 #include <u-boot/md5.h>
 #include <time.h>
-#include <image.h>
+#include <uimage.h>
 #endif /* !USE_HOSTCC*/
 
 static const table_entry_t uimage_arch[] = {
diff --git a/include/compiler.h b/include/compiler.h
index 0734ed4..5ddcfd2 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -52,7 +52,9 @@ typedef unsigned long ulong;
 typedef uint8_t __u8;
 typedef uint16_t __u16;
 typedef uint32_t __u32;
+#ifndef __HAIKU__
 typedef unsigned int uint;
+#endif
 
 #define uswap_16(x) \
 	((((x) & 0xff00) >> 8) | \
diff --git a/tools/aisimage.c b/tools/aisimage.c
index c645708..8c961f5 100644
--- a/tools/aisimage.c
+++ b/tools/aisimage.c
@@ -26,7 +26,7 @@
 
 #include "mkimage.h"
 #include "aisimage.h"
-#include <image.h>
+#include <uimage.h>
 
 #define IS_FNC_EXEC(c)	(cmd_table[c].AIS_cmd == AIS_CMD_FNLOAD)
 #define WORD_ALIGN0	4
diff --git a/tools/default_image.c b/tools/default_image.c
index e9d0729..194bc21 100644
--- a/tools/default_image.c
+++ b/tools/default_image.c
@@ -28,7 +28,7 @@
  */
 
 #include "mkimage.h"
-#include <image.h>
+#include <uimage.h>
 #include <u-boot/crc.h>
 
 static image_header_t header;
diff --git a/tools/fit_image.c b/tools/fit_image.c
index ef9ffee..0288d24 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -28,7 +28,7 @@
  */
 
 #include "mkimage.h"
-#include <image.h>
+#include <uimage.h>
 #include <u-boot/crc.h>
 
 static image_header_t header;
diff --git a/tools/imximage.c b/tools/imximage.c
index 03a7716..2e2e2f6 100644
--- a/tools/imximage.c
+++ b/tools/imximage.c
@@ -29,9 +29,13 @@
 #define _GNU_SOURCE
 
 #include "mkimage.h"
-#include <image.h>
+#include <uimage.h>
 #include "imximage.h"
 
+#if __GNUC__ < 4
+#define __builtin_expect(a,b) (a)
+#endif
+
 /*
  * Supported commands for configuration file
  */
diff --git a/tools/kwbimage.c b/tools/kwbimage.c
index f327b07..686d361 100644
--- a/tools/kwbimage.c
+++ b/tools/kwbimage.c
@@ -26,7 +26,7 @@
 #define _GNU_SOURCE
 
 #include "mkimage.h"
-#include <image.h>
+#include <uimage.h>
 #include "kwbimage.h"
 
 /*
diff --git a/tools/mkimage.c b/tools/mkimage.c
index e43b09f..babc24b 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -22,9 +22,13 @@
  */
 
 #include "mkimage.h"
-#include <image.h>
+#include <uimage.h>
 #include <version.h>
 
+#if __GNUC__ < 4
+#define __builtin_expect(a,b) (a)
+#endif
+
 static void copy_file(int, const char *, int);
 static void usage(void);
 
diff --git a/tools/omapimage.c b/tools/omapimage.c
index 5e739ac..eea8dfc 100644
--- a/tools/omapimage.c
+++ b/tools/omapimage.c
@@ -34,7 +34,7 @@
 #define _GNU_SOURCE
 
 #include "mkimage.h"
-#include <image.h>
+#include <uimage.h>
 #include "omapimage.h"
 
 /* Header size is CH header rounded up to 512 bytes plus GP header */
diff --git a/tools/pblimage.c b/tools/pblimage.c
index 508a747..c9001fc 100644
--- a/tools/pblimage.c
+++ b/tools/pblimage.c
@@ -22,7 +22,7 @@
 #define _GNU_SOURCE
 
 #include "mkimage.h"
-#include <image.h>
+#include <uimage.h>
 #include "pblimage.h"
 
 /*
@@ -55,9 +55,10 @@ static union
 static void generate_pbl_cmd(void)
 {
 	uint32_t val = next_pbl_cmd;
-	next_pbl_cmd += 0x40;
 	int i;
 
+	next_pbl_cmd += 0x40;
+
 	for (i = 3; i >= 0; i--) {
 		*pmem_buf++ = (val >> (i * 8)) & 0xff;
 		pbl_size++;
diff --git a/tools/ublimage.c b/tools/ublimage.c
index d6b4017..8387b3d 100644
--- a/tools/ublimage.c
+++ b/tools/ublimage.c
@@ -33,9 +33,13 @@
 #define _GNU_SOURCE
 
 #include "mkimage.h"
-#include <image.h>
+#include <uimage.h>
 #include "ublimage.h"
 
+#if __GNUC__ < 4
+#define __builtin_expect(a,b) (a)
+#endif
+
 /*
  * Supported commands for configuration file
  */
-- 
1.8.3.4

