diff options
author | Mike Frysinger <vapier@gentoo.org> | 2009-07-02 19:23:25 -0400 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2009-07-19 21:41:46 +0200 |
commit | 37566090766d61beef70c62986b90749920255d8 (patch) | |
tree | 6770441ddc1bc0b9e662e2ea7102da8e10b62d61 /tools | |
parent | 2a2ed845c085eb093b69fa6382fcf7534bb1f4b0 (diff) | |
download | u-boot-37566090766d61beef70c62986b90749920255d8.zip u-boot-37566090766d61beef70c62986b90749920255d8.tar.gz u-boot-37566090766d61beef70c62986b90749920255d8.tar.bz2 |
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')
-rw-r--r-- | tools/bmp_logo.c | 13 | ||||
-rw-r--r-- | tools/img2srec.c | 3 | ||||
-rw-r--r-- | tools/mingw_support.h | 3 | ||||
-rw-r--r-- | tools/mkimage.c | 14 | ||||
-rw-r--r-- | tools/mkimage.h | 33 | ||||
-rw-r--r-- | tools/os_support.c | 1 | ||||
-rw-r--r-- | tools/os_support.h | 2 | ||||
-rw-r--r-- | tools/ubsha1.c | 13 |
8 files changed, 9 insertions, 73 deletions
diff --git a/tools/bmp_logo.c b/tools/bmp_logo.c index e8dd8c8..47228d2 100644 --- a/tools/bmp_logo.c +++ b/tools/bmp_logo.c @@ -1,15 +1,4 @@ -#include <stdio.h> -#include <stdlib.h> - -#if defined(__linux__) -#include <stdint.h> -#else -#ifdef __CYGWIN__ -#include "elf.h" -#else -#include <inttypes.h> -#endif -#endif +#include "compiler.h" typedef struct bitmap_s { /* bitmap description */ uint16_t width; diff --git a/tools/img2srec.c b/tools/img2srec.c index b04abbd..f10379f 100644 --- a/tools/img2srec.c +++ b/tools/img2srec.c @@ -52,6 +52,7 @@ | INCLUDES |*************************************************************************/ +#include "os_support.h" #include <stddef.h> #include <stdio.h> #include <stdlib.h> @@ -61,8 +62,6 @@ #include <unistd.h> #include <errno.h> -extern int errno; - /************************************************************************* | DEFINES |*************************************************************************/ diff --git a/tools/mingw_support.h b/tools/mingw_support.h index 1fb6c93..9e45e64 100644 --- a/tools/mingw_support.h +++ b/tools/mingw_support.h @@ -34,9 +34,6 @@ #define MAP_SHARED 0x01 /* Share changes */ #define MAP_PRIVATE 0x02 /* Changes are private */ -/* Return value of `mmap' in case of an error */ -#define MAP_FAILED ((void *) -1) - /* Windows 64-bit access macros */ #define LODWORD(x) ((DWORD)((DWORDLONG)(x))) #define HIDWORD(x) ((DWORD)(((DWORDLONG)(x) >> 32) & 0xffffffff)) diff --git a/tools/mkimage.c b/tools/mkimage.c index 967fe9a..02cdb95 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); diff --git a/tools/mkimage.h b/tools/mkimage.h index c8df6e1..70c53ad 100644 --- a/tools/mkimage.h +++ b/tools/mkimage.h @@ -26,14 +26,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#ifndef __WIN32__ -#include <netinet/in.h> /* for host / network byte order conversions */ -#endif -#ifdef __MINGW32__ -#include <stdint.h> -#else -#include <sys/mman.h> -#endif #include <sys/stat.h> #include <time.h> #include <unistd.h> @@ -53,28 +45,3 @@ #define MKIMAGE_DEFAULT_DTC_OPTIONS "-I dts -O dtb -p 500" #define MKIMAGE_MAX_DTC_CMDLINE_LEN 512 #define MKIMAGE_DTC "dtc" /* assume dtc is in $PATH */ - -#if defined(__BEOS__) || defined(__NetBSD__) || defined(__APPLE__) -#include <inttypes.h> -#endif - -#ifdef __WIN32__ -typedef unsigned int __u32; - -#define SWAP_LONG(x) \ - ((__u32)( \ - (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \ - (((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \ - (((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \ - (((__u32)(x) & (__u32)0xff000000UL) >> 24) )) -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; - -#define ntohl(a) SWAP_LONG(a) -#define htonl(a) SWAP_LONG(a) -#endif /* __WIN32__ */ - -#ifndef O_BINARY /* should be define'd on __WIN32__ */ -#define O_BINARY 0 -#endif diff --git a/tools/os_support.c b/tools/os_support.c index 001fe64..5b919aa 100644 --- a/tools/os_support.c +++ b/tools/os_support.c @@ -19,6 +19,7 @@ /* * Include additional files required for supporting different operating systems */ +#include "compiler.h" #ifdef __MINGW32__ #include "mingw_support.c" #endif diff --git a/tools/os_support.h b/tools/os_support.h index f6f86b0..7bf930e 100644 --- a/tools/os_support.h +++ b/tools/os_support.h @@ -19,6 +19,8 @@ #ifndef __OS_SUPPORT_H_ #define __OS_SUPPORT_H_ +#include "compiler.h" + /* * Include additional files required for supporting different operating systems */ diff --git a/tools/ubsha1.c b/tools/ubsha1.c index c4203ed..9774eea 100644 --- a/tools/ubsha1.c +++ b/tools/ubsha1.c @@ -28,9 +28,6 @@ #include <fcntl.h> #include <errno.h> #include <string.h> -#ifndef __MINGW32__ -#include <sys/mman.h> -#endif #include <sys/stat.h> #include "sha1.h" @@ -40,16 +37,6 @@ #include <config.h> #undef __ASSEMBLY__ -#ifndef O_BINARY /* should be define'd on __WIN32__ */ -#define O_BINARY 0 -#endif - -#ifndef MAP_FAILED -#define MAP_FAILED (-1) -#endif - -extern int errno; - extern void sha1_csum (unsigned char *input, int ilen, unsigned char output[20]); int main (int argc, char **argv) |