tools/mkimage: update to 2020.04
[openwrt/staging/jow.git] / tools / mkimage / patches / 050-Add-compatibility-with-non-Linux-hosts.patch
1 From 590b23a46b7ae0f5ec5e8f57a85c0e7578c71141 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Sun, 26 Apr 2020 17:15:17 +0200
4 Subject: [PATCH 1/2] Add compatibility with non Linux hosts
5
6 This adds some changes to the u-boot tools to make it possible to build
7 them on non Linux hosts like MacOS or FreeBSD.
8
9 asm/byteorder.h, asm/posix_types.h, asm/types.h and linux/kernel.h are
10 not available on such systems. Remove the include and add the necessary
11 parts for these header files manually or remove the usage too.
12
13 __u64 is not available on FreeBSD, remove its usage.
14
15 <malloc.h> has been replaced by <stdlib.h>
16
17 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
18 ---
19 include/image.h | 2 ++
20 include/imx8image.h | 5 +++++
21 include/linux/posix_types.h | 2 ++
22 include/linux/types.h | 4 +++-
23 lib/rsa/rsa-sign.c | 2 +-
24 5 files changed, 13 insertions(+), 2 deletions(-)
25
26 --- a/include/image.h
27 +++ b/include/image.h
28 @@ -16,7 +16,9 @@
29 #define __IMAGE_H__
30
31 #include "compiler.h"
32 +#ifdef linux
33 #include <asm/byteorder.h>
34 +#endif
35 #include <stdbool.h>
36
37 /* Define this to avoid #ifdefs later on */
38 --- a/include/imx8image.h
39 +++ b/include/imx8image.h
40 @@ -11,7 +11,12 @@
41 #include <image.h>
42 #include <inttypes.h>
43 #include "imagetool.h"
44 +#ifdef linux
45 #include "linux/kernel.h"
46 +#else
47 +#define ALIGN(x,a) __ALIGN_MASK((x),(typeof(x))(a)-1)
48 +#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
49 +#endif
50
51 #define __packed __attribute__((packed))
52
53 --- a/include/linux/posix_types.h
54 +++ b/include/linux/posix_types.h
55 @@ -43,6 +43,8 @@ typedef void (*__kernel_sighandler_t)(in
56 /* Type of a SYSV IPC key. */
57 typedef int __kernel_key_t;
58
59 +#ifdef linux
60 #include <asm/posix_types.h>
61 +#endif
62
63 #endif /* _LINUX_POSIX_TYPES_H */
64 --- a/include/linux/types.h
65 +++ b/include/linux/types.h
66 @@ -2,7 +2,9 @@
67 #define _LINUX_TYPES_H
68
69 #include <linux/posix_types.h>
70 +#ifdef linux
71 #include <asm/types.h>
72 +#endif
73 #include <stdbool.h>
74
75 #ifndef __KERNEL_STRICT_NAMES
76 @@ -142,7 +144,7 @@ typedef __u16 __bitwise __le16;
77 typedef __u16 __bitwise __be16;
78 typedef __u32 __bitwise __le32;
79 typedef __u32 __bitwise __be32;
80 -#if defined(__GNUC__)
81 +#if defined(__GNUC__) && defined(linux)
82 typedef __u64 __bitwise __le64;
83 typedef __u64 __bitwise __be64;
84 #endif
85 --- a/lib/rsa/rsa-sign.c
86 +++ b/lib/rsa/rsa-sign.c
87 @@ -4,7 +4,7 @@
88 */
89
90 #include "mkimage.h"
91 -#include <malloc.h>
92 +#include <stdlib.h>
93 #include <stdio.h>
94 #include <string.h>
95 #include <image.h>