diff options
author | Tom Rini <trini@konsulko.com> | 2017-04-08 09:28:02 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2017-04-08 09:28:02 -0400 |
commit | 089795090a627f4216c5f21eaf436ba1672cf02e (patch) | |
tree | 386074cdee0ea3fe02cc6ee8228c5adb8d7e7ea7 /lib/bch.c | |
parent | b09ece0836e0267b86f37defec267aa3806cb03a (diff) | |
parent | f7d4d9e52cdcff2a8fcdc80b567a41f48b61951c (diff) |
Merge branch 'master' of git://git.denx.de/u-boot-sunxi
Diffstat (limited to 'lib/bch.c')
-rw-r--r-- | lib/bch.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/bch.c b/lib/bch.c index 147715afd06..ec53483774b 100644 --- a/lib/bch.c +++ b/lib/bch.c @@ -54,10 +54,27 @@ * finite fields GF(2^q). In Rapport de recherche INRIA no 2829, 1996. */ +#ifndef USE_HOSTCC #include <common.h> #include <ubi_uboot.h> #include <linux/bitops.h> +#else +#include <errno.h> +#include <endian.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> + +#undef cpu_to_be32 +#define cpu_to_be32 htobe32 +#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) +#define kmalloc(size, flags) malloc(size) +#define kzalloc(size, flags) calloc(1, size) +#define kfree free +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) +#endif + #include <asm/byteorder.h> #include <linux/bch.h> @@ -95,6 +112,37 @@ struct gf_poly_deg1 { unsigned int c[2]; }; +#ifdef USE_HOSTCC +static int fls(int x) +{ + int r = 32; + + if (!x) + return 0; + if (!(x & 0xffff0000u)) { + x <<= 16; + r -= 16; + } + if (!(x & 0xff000000u)) { + x <<= 8; + r -= 8; + } + if (!(x & 0xf0000000u)) { + x <<= 4; + r -= 4; + } + if (!(x & 0xc0000000u)) { + x <<= 2; + r -= 2; + } + if (!(x & 0x80000000u)) { + x <<= 1; + r -= 1; + } + return r; +} +#endif + /* * same as encode_bch(), but process input data one byte at a time */ |