[U-Boot] [PATCH v2] crc32: Impl. linux optimized crc32()
Mike Frysinger
vapier at gentoo.org
Tue Nov 17 05:01:59 CET 2009
On Friday 13 November 2009 03:52:05 Joakim Tjernlund wrote:
> --- a/lib_generic/crc32.c
> +++ b/lib_generic/crc32.c
> @@ -13,6 +13,8 @@
> #else
> #include <stdint.h>
> #endif
> +#include <asm/byteorder.h>
> +#include <u-boot/crc.h>
the target system improvements are awesome, but this breaks cross-compiling
crc32 code for anything other than linux hosts (and even that is spotty).
i'd suggest these changes
@@ -10,10 +10,10 @@
#ifndef USE_HOSTCC /* Shut down "ANSI does not permit..." warnings */
#include <common.h>
+#include <asm/byteorder.h>
#else
-#include <stdint.h>
+#include <compiler.h>
#endif
-#include <asm/byteorder.h>
#include <u-boot/crc.h>
#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
@@ -24,6 +24,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 +56,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 +82,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 +185,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 +214,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
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20091116/0f7c5c00/attachment.pgp
More information about the U-Boot
mailing list