[U-Boot] [PATCH] crc32: Make crc32 build on non Linux too
Joakim Tjernlund
Joakim.Tjernlund at transmode.se
Tue Nov 17 09:26:14 CET 2009
The #include <asm/byteorder.h> is Linux specific. Use
compiler.h and adjust the code to cope.
Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund at transmode.se>
---
Mike, how does this work for you?
lib_generic/crc32.c | 14 ++++++--------
1 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/lib_generic/crc32.c b/lib_generic/crc32.c
index 770ea38..468b397 100644
--- a/lib_generic/crc32.c
+++ b/lib_generic/crc32.c
@@ -8,12 +8,10 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
-#ifndef USE_HOSTCC /* Shut down "ANSI does not permit..." warnings */
+#ifndef USE_HOSTCC
#include <common.h>
-#else
-#include <stdint.h>
#endif
-#include <asm/byteorder.h>
+#include <compiler.h>
#include <u-boot/crc.h>
#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
@@ -24,6 +22,8 @@
#define local static
#define ZEXPORT /* empty */
+#define tole(x) cpu_to_le32(x)
+
#ifdef DYNAMIC_CRC_TABLE
local int crc_table_empty = 1;
@@ -54,7 +54,6 @@ local void make_crc_table OF((void));
the information needed to generate CRC's on data a byte at a time for all
combinations of CRC register values and incoming bytes.
*/
-#define tole(x) __cpu_to_le32(x)
local void make_crc_table()
{
uint32_t c;
@@ -81,7 +80,6 @@ local void make_crc_table()
/* ========================================================================
* Table of CRC-32's of all single-byte values (made by make_crc_table)
*/
-#define tole(x) __constant_cpu_to_le32(x)
local const uint32_t crc_table[256] = {
tole(0x00000000L), tole(0x77073096L), tole(0xee0e612cL), tole(0x990951baL),
@@ -185,7 +183,7 @@ uint32_t ZEXPORT crc32_no_comp(uint32_t crc, const Bytef *buf, uInt len)
if (crc_table_empty)
make_crc_table();
#endif
- crc = __cpu_to_le32(crc);
+ crc = cpu_to_le32(crc);
/* Align it */
if (((long)b) & 3 && len) {
uint8_t *p = (uint8_t *)b;
@@ -214,7 +212,7 @@ uint32_t ZEXPORT crc32_no_comp(uint32_t crc, const Bytef *buf, uInt len)
} while (--len);
}
- return __le32_to_cpu(crc);
+ return le32_to_cpu(crc);
}
#undef DO_CRC
--
1.6.4.4
More information about the U-Boot
mailing list