Merge tag 'u-boot-imx-20200623' of https://gitlab.denx.de/u-boot/custodians/u-boot-imx
[oweals/u-boot.git] / lib / bch.c
index 7a2d9d3b86b7a69b213662f4dd1e6be836aa21f2..de66b1acba54d11e70a2831cb2f724817c6f4a6a 100644 (file)
--- a/lib/bch.c
+++ b/lib/bch.c
@@ -1,8 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Generic binary BCH encoding/decoding library
  *
- * SPDX-License-Identifier:    GPL-2.0
- *
  * Copyright © 2011 Parrot S.A.
  *
  * Author: Ivan Djelic <ivan.djelic@parrot.com>
 
 #ifndef USE_HOSTCC
 #include <common.h>
+#include <log.h>
+#include <malloc.h>
 #include <ubi_uboot.h>
+#include <dm/devres.h>
 
 #include <linux/bitops.h>
 #else
 #include <errno.h>
 #if defined(__FreeBSD__)
 #include <sys/endian.h>
+#elif defined(__APPLE__)
+#include <machine/endian.h>
+#include <libkern/OSByteOrder.h>
 #else
 #include <endian.h>
 #endif
 #include <string.h>
 
 #undef cpu_to_be32
+#if defined(__APPLE__)
+#define cpu_to_be32 OSSwapHostToBigInt32
+#else
 #define cpu_to_be32 htobe32
+#endif
 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
 #define kmalloc(size, flags)   malloc(size)
 #define kzalloc(size, flags)   calloc(1, size)
@@ -117,7 +126,7 @@ struct gf_poly_deg1 {
 };
 
 #ifdef USE_HOSTCC
-#ifndef __BSD_VISIBLE
+#if !defined(__DragonFly__) && !defined(__FreeBSD__) && !defined(__APPLE__)
 static int fls(int x)
 {
        int r = 32;