summaryrefslogtreecommitdiff
path: root/tools/mkimage.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-07-02 19:23:25 -0400
committerWolfgang Denk <wd@denx.de>2009-07-19 21:41:46 +0200
commit37566090766d61beef70c62986b90749920255d8 (patch)
tree6770441ddc1bc0b9e662e2ea7102da8e10b62d61 /tools/mkimage.c
parent2a2ed845c085eb093b69fa6382fcf7534bb1f4b0 (diff)
compiler.h: unify system ifdef cruft here
Shove a lot of the HOSTCC and related #ifdef checking crap into the new compiler.h header so that we can keep all other headers nice and clean. Also introduce custom uswap functions so we don't have to rely on the non standard implementations that a host may (or may not in the case of OS X) provide. This allows mkimage to finally build cleanly on an OS X system. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'tools/mkimage.c')
-rw-r--r--tools/mkimage.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/tools/mkimage.c b/tools/mkimage.c
index 967fe9a776..02cdb95387 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -25,12 +25,6 @@
#include "mkimage.h"
#include <image.h>
-extern int errno;
-
-#ifndef MAP_FAILED
-#define MAP_FAILED (void *)(-1)
-#endif
-
extern unsigned long crc32 (unsigned long crc, const char *buf, unsigned int len);
static void copy_file (int, const char *, int);
static void usage (void);
@@ -502,7 +496,7 @@ image_verify_header (char *ptr, int image_size)
*/
memcpy (hdr, ptr, sizeof(image_header_t));
- if (ntohl(hdr->ih_magic) != IH_MAGIC) {
+ if (be32_to_cpu(hdr->ih_magic) != IH_MAGIC) {
fprintf (stderr,
"%s: Bad Magic Number: \"%s\" is no valid image\n",
cmdname, imagefile);
@@ -512,8 +506,8 @@ image_verify_header (char *ptr, int image_size)
data = (char *)hdr;
len = sizeof(image_header_t);
- checksum = ntohl(hdr->ih_hcrc);
- hdr->ih_hcrc = htonl(0); /* clear for re-calculation */
+ checksum = be32_to_cpu(hdr->ih_hcrc);
+ hdr->ih_hcrc = cpu_to_be32(0); /* clear for re-calculation */
if (crc32 (0, data, len) != checksum) {
fprintf (stderr,
@@ -525,7 +519,7 @@ image_verify_header (char *ptr, int image_size)
data = ptr + sizeof(image_header_t);
len = image_size - sizeof(image_header_t) ;
- if (crc32 (0, data, len) != ntohl(hdr->ih_dcrc)) {
+ if (crc32 (0, data, len) != be32_to_cpu(hdr->ih_dcrc)) {
fprintf (stderr,
"%s: ERROR: \"%s\" has corrupted data!\n",
cmdname, imagefile);