compiler.h: unify system ifdef cruft here
PATCH 1/1 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.
--- include/compiler.h | 118 +++++++++++++++++++++++++++++++++++++++++++++++++ include/elf.h | 10 +---- include/environment.h | 6 +-- include/image.h | 9 +--- include/libfdt_env.h | 53 ++-------------------- tools/bmp_logo.c | 13 +----- tools/img2srec.c | 3 +- tools/mkimage.c | 14 ++---- tools/mkimage.h | 33 -------------- tools/os_support.h | 2 + tools/ubsha1.c | 13 ----- 11 files changed, 136 insertions(+), 138 deletions(-) create mode 100644 include/compiler.h
include/compiler.h new file +118 -0
@@ -0,0 +1,118 @@ +/* +* Keep all the ugly #ifdef for system stuff here +*/ + +#ifndef __COMPILER_H__ +#define __COMPILER_H__ + +#include <stddef.h> + +#ifdef USE_HOSTCC + +#if defined(__BEOS__) || \ + defined(__NetBSD__) || \ + defined(__FreeBSD__) || \ + defined(__sun__) || \ + defined(__APPLE__) +# include <inttypes.h> +#elif defined(__linux__) || defined(__WIN32__) || defined(__MINGW32__) +# include <stdint.h> +#endif + +#include <errno.h> +#include <stdlib.h> +#include <stdint.h> +#include <stdio.h> +#include <string.h> + +extern int errno; + +#if !defined(__WIN32__) && !defined(__MINGW32__) +# include <sys/mman.h> +#endif + +#ifndef MAP_FAILED +#define MAP_FAILED (-1) +#endif + +#include <fcntl.h> +#ifndef O_BINARY /* should be define'd on __WIN32__ */ +#define O_BINARY 0 +#endif + +#ifdef __linux__ +# include <endian.h> +# include <byteswap.h> +#elif defined(__MACH__) +# include <machine/endian.h> +typedef unsigned long ulong ; +typedef unsigned int uint ; +#endif + +#else /* !USE_HOSTCC */ + +#include <linux/string.h> +#include <linux/types.h> +#include <asm/byteorder.h> + +/* Types for `void *' pointers. */ +#if __WORDSIZE ==64 +typedef unsigned long int uintptr_t ; +#else +typedef unsigned int uintptr_t ; +#endif + +#endif + +#define uswap_16 (x) \ + ((((x) & 0xff00) >> 8) | \ + (((x) & 0x00ff) << 8)) +#define uswap_32 (x) \ + ((((x) & 0xff000000) >> 24) | \ + (((x) & 0x00ff0000) >> 8) | \ + (((x) & 0x0000ff00) << 8) | \ + (((x) & 0x000000ff) << 24)) +#define _uswap_64 (x, sfx) \ + ((((x) & 0xff00000000000000##sfx) >> 56) | \ + (((x) & 0x00ff000000000000##sfx) >> 40) | \ + (((x) & 0x0000ff0000000000##sfx) >> 24) | \ + (((x) & 0x000000ff00000000##sfx) >> 8) | \ + (((x) & 0x00000000ff000000##sfx) << 8) | \ + (((x) & 0x0000000000ff0000##sfx) << 24) | \ + (((x) & 0x000000000000ff00##sfx) << 40) | \ + (((x) & 0x00000000000000ff##sfx) << 56)) +#if defined(__GNUC__) +# define uswap_64 (x) _uswap_64(x, ull) +#else +# define uswap_64 (x) _uswap_64(x, ) +#endif + +#if __BYTE_ORDER == __LITTLE_ENDIAN +# define cpu_to_le16 (x) (x) +# define cpu_to_le32 (x) (x) +# define cpu_to_le64 (x) (x) +# define le16_to_cpu (x) (x) +# define le32_to_cpu (x) (x) +# define le64_to_cpu (x) (x) +# define cpu_to_be16 (x) uswap_16(x) +# define cpu_to_be32 (x) uswap_32(x) +# define cpu_to_be64 (x) uswap_64(x) +# define be16_to_cpu (x) uswap_16(x) +# define be32_to_cpu (x) uswap_32(x) +# define be64_to_cpu (x) uswap_64(x) +#else +# define cpu_to_le16 (x) uswap_16(x) +# define cpu_to_le32 (x) uswap_32(x) +# define cpu_to_le64 (x) uswap_64(x) +# define le16_to_cpu (x) uswap_16(x) +# define le32_to_cpu (x) uswap_32(x) +# define le64_to_cpu (x) uswap_64(x) +# define cpu_to_be16 (x) (x) +# define cpu_to_be32 (x) (x) +# define cpu_to_be64 (x) (x) +# define be16_to_cpu (x) (x) +# define be32_to_cpu (x) (x) +# define be64_to_cpu (x) (x) +#endif + +#endif
include/elf.h +1 -9
@@ -33,15 +33,7 @@#ifndef _ELF_H#define _ELF_H -#if defined(__BEOS__) || \ - defined(__NetBSD__) || \ - defined(__FreeBSD__) || \ - defined(__sun__) || \ - defined(__APPLE__) -#include <inttypes.h> -#elif (defined(__linux__) && defined(USE_HOSTCC )) || defined(__WIN32__) -#include <stdint.h> -#endif +#include "compiler.h" /* * This version doesn't work for 64-bit ABIs - Erik.
include/environment.h +1 -5
@@ -96,11 +96,7 @@# endif #endif /* CONFIG_ENV_IS_IN_MG_DISK */ -#ifdef USE_HOSTCC -# include <stdint.h> -#else -# include <linux/types.h> -#endif +#include "compiler.h" #ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT # define ENV_HEADER_SIZE (sizeof(uint32_t) + 1)
include/image.h +3 -6
@@ -33,10 +33,9 @@#ifndef __IMAGE_H__#define __IMAGE_H__ -#if USE_HOSTCC -#ifndef __MINGW32__ -#include <endian.h> -#endif +#include "compiler.h" + +#ifdef USE_HOSTCC /* new uImage format support enabled on host */ #define CONFIG_FIT 1
@@ -46,9 +45,7 @@#else #include <lmb.h> -#include <linux/string.h> #include <asm/u-boot.h> -#include <asm/byteorder.h> #endif /* USE_HOSTCC */
include/libfdt_env.h +5 -48
61 lines not on this page · raw message
tools/bmp_logo.c +1 -12
@@ -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;
tools/img2srec.c +1 -2
@@ -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 |*************************************************************************/
tools/mkimage.c +4 -10
@@ -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);
tools/mkimage.h +0 -33
@@ -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
tools/os_support.h +2 -0
@@ -19,6 +19,8 @@#ifndef __OS_SUPPORT_H_#define __OS_SUPPORT_H_ +#include "compiler.h" +/* * Include additional files required for supporting different operating systems */
tools/ubsha1.c +0 -13
@@ -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)
Signature · 1 line
1.6.3.1
PATCH 1/1 compiler.h: unify system ifdef cruft here
Quoted 6 lines · On Friday 29 May 2009 21:53:09 Mike Frysinger wrote:
Shove a lot of the HOSTCC and related #ifdef checking crap into the new
compiler.hheader 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.
this results in a few warnings for native builds. i'll send out a new one after the 2009.06 release so that i can test it more with the latest tree. -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/20090604/a7721949/attachment-0001.pgp
PATCH 1/1 compiler.h: unify system ifdef cruft here
In reply to Mike FrysingerShove 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.
--- include/compiler.h | 118 +++++++++++++++++++++++++++++++++++++++++++++++++ include/elf.h | 10 +---- include/environment.h | 6 +-- include/image.h | 9 +--- include/libfdt_env.h | 53 ++-------------------- tools/bmp_logo.c | 13 +----- tools/img2srec.c | 3 +- tools/mkimage.c | 14 ++---- tools/mkimage.h | 33 -------------- tools/os_support.h | 2 + tools/ubsha1.c | 13 ----- 11 files changed, 136 insertions(+), 138 deletions(-) create mode 100644 include/compiler.h
include/compiler.h new file +118 -0
@@ -0,0 +1,118 @@ +/* +* Keep all the ugly #ifdef for system stuff here +*/ + +#ifndef __COMPILER_H__ +#define __COMPILER_H__ + +#include <stddef.h> + +#ifdef USE_HOSTCC + +#if defined(__BEOS__) || \ + defined(__NetBSD__) || \ + defined(__FreeBSD__) || \ + defined(__sun__) || \ + defined(__APPLE__) +# include <inttypes.h> +#elif defined(__linux__) || defined(__WIN32__) || defined(__MINGW32__) +# include <stdint.h> +#endif + +#include <errno.h> +#include <stdlib.h> +#include <stdint.h> +#include <stdio.h> +#include <string.h> + +extern int errno; + +#if !defined(__WIN32__) && !defined(__MINGW32__) +# include <sys/mman.h> +#endif + +#ifndef MAP_FAILED +#define MAP_FAILED (-1) +#endif + +#include <fcntl.h> +#ifndef O_BINARY /* should be define'd on __WIN32__ */ +#define O_BINARY 0 +#endif + +#ifdef __linux__ +# include <endian.h> +# include <byteswap.h> +#elif defined(__MACH__) +# include <machine/endian.h> +typedef unsigned long ulong ; +typedef unsigned int uint ; +#endif + +#define uswap_16 (x) \ + ((((x) & 0xff00) >> 8) | \ + (((x) & 0x00ff) << 8)) +#define uswap_32 (x) \ + ((((x) & 0xff000000) >> 24) | \ + (((x) & 0x00ff0000) >> 8) | \ + (((x) & 0x0000ff00) << 8) | \ + (((x) & 0x000000ff) << 24)) +#define _uswap_64 (x, sfx) \ + ((((x) & 0xff00000000000000##sfx) >> 56) | \ + (((x) & 0x00ff000000000000##sfx) >> 40) | \ + (((x) & 0x0000ff0000000000##sfx) >> 24) | \ + (((x) & 0x000000ff00000000##sfx) >> 8) | \ + (((x) & 0x00000000ff000000##sfx) << 8) | \ + (((x) & 0x0000000000ff0000##sfx) << 24) | \ + (((x) & 0x000000000000ff00##sfx) << 40) | \ + (((x) & 0x00000000000000ff##sfx) << 56)) +#if defined(__GNUC__) +# define uswap_64 (x) _uswap_64(x, ull) +#else +# define uswap_64 (x) _uswap_64(x, ) +#endif + +#if __BYTE_ORDER == __LITTLE_ENDIAN +# define cpu_to_le16 (x) (x) +# define cpu_to_le32 (x) (x) +# define cpu_to_le64 (x) (x) +# define le16_to_cpu (x) (x) +# define le32_to_cpu (x) (x) +# define le64_to_cpu (x) (x) +# define cpu_to_be16 (x) uswap_16(x) +# define cpu_to_be32 (x) uswap_32(x) +# define cpu_to_be64 (x) uswap_64(x) +# define be16_to_cpu (x) uswap_16(x) +# define be32_to_cpu (x) uswap_32(x) +# define be64_to_cpu (x) uswap_64(x) +#else +# define cpu_to_le16 (x) uswap_16(x) +# define cpu_to_le32 (x) uswap_32(x) +# define cpu_to_le64 (x) uswap_64(x) +# define le16_to_cpu (x) uswap_16(x) +# define le32_to_cpu (x) uswap_32(x) +# define le64_to_cpu (x) uswap_64(x) +# define cpu_to_be16 (x) (x) +# define cpu_to_be32 (x) (x) +# define cpu_to_be64 (x) (x) +# define be16_to_cpu (x) (x) +# define be32_to_cpu (x) (x) +# define be64_to_cpu (x) (x) +#endif + +#else /* !USE_HOSTCC */ + +#include <linux/string.h> +#include <linux/types.h> +#include <asm/byteorder.h> + +/* Types for `void *' pointers. */ +#if __WORDSIZE ==64 +typedef unsigned long int uintptr_t ; +#else +typedef unsigned int uintptr_t ; +#endif + +#endif + +#endif
include/elf.h +1 -9
@@ -33,15 +33,7 @@#ifndef _ELF_H#define _ELF_H -#if defined(__BEOS__) || \ - defined(__NetBSD__) || \ - defined(__FreeBSD__) || \ - defined(__sun__) || \ - defined(__APPLE__) -#include <inttypes.h> -#elif (defined(__linux__) && defined(USE_HOSTCC )) || defined(__WIN32__) -#include <stdint.h> -#endif +#include "compiler.h" /* * This version doesn't work for 64-bit ABIs - Erik.
include/environment.h +1 -5
@@ -96,11 +96,7 @@# endif #endif /* CONFIG_ENV_IS_IN_MG_DISK */ -#ifdef USE_HOSTCC -# include <stdint.h> -#else -# include <linux/types.h> -#endif +#include "compiler.h" #ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT # define ENV_HEADER_SIZE (sizeof(uint32_t) + 1)
include/image.h +3 -6
@@ -33,10 +33,9 @@#ifndef __IMAGE_H__#define __IMAGE_H__ -#if USE_HOSTCC -#ifndef __MINGW32__ -#include <endian.h> -#endif +#include "compiler.h" + +#ifdef USE_HOSTCC /* new uImage format support enabled on host */ #define CONFIG_FIT 1
@@ -46,9 +45,7 @@#else #include <lmb.h> -#include <linux/string.h> #include <asm/u-boot.h> -#include <asm/byteorder.h> #endif /* USE_HOSTCC */
include/libfdt_env.h +5 -48
61 lines not on this page · raw message
tools/bmp_logo.c +1 -12
@@ -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;
tools/img2srec.c +1 -2
@@ -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 |*************************************************************************/
tools/mkimage.c +4 -10
@@ -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);
tools/mkimage.h +0 -33
@@ -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
tools/os_support.h +2 -0
@@ -19,6 +19,8 @@#ifndef __OS_SUPPORT_H_#define __OS_SUPPORT_H_ +#include "compiler.h" +/* * Include additional files required for supporting different operating systems */
tools/ubsha1.c +0 -13
@@ -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)
Signature · 1 line
1.6.3.1
PATCH v3 1/1 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.
---
v3
- integrate newer md5 code
include/compiler.h | 122 +++++++++++++++++++++++++++++++++++++++++++++++++ include/elf.h | 10 +---- include/environment.h | 6 +-- include/image.h | 9 +-- include/libfdt_env.h | 53 ++------------------- include/u-boot/md5.h | 2 +- lib_generic/md5.c | 8 +-- tools/bmp_logo.c | 13 +----- tools/img2srec.c | 3 +- tools/mkimage.c | 14 ++---- tools/mkimage.h | 33 ------------- tools/os_support.h | 2 + tools/ubsha1.c | 13 ----- 13 files changed, 144 insertions(+), 144 deletions(-) create mode 100644 include/compiler.h
include/compiler.h new file +122 -0
@@ -0,0 +1,122 @@ +/* +* Keep all the ugly #ifdef for system stuff here +*/ + +#ifndef __COMPILER_H__ +#define __COMPILER_H__ + +#include <stddef.h> + +#ifdef USE_HOSTCC + +#if defined(__BEOS__) || \ + defined(__NetBSD__) || \ + defined(__FreeBSD__) || \ + defined(__sun__) || \ + defined(__APPLE__) +# include <inttypes.h> +#elif defined(__linux__) || defined(__WIN32__) || defined(__MINGW32__) +# include <stdint.h> +#endif + +#include <errno.h> +#include <stdlib.h> +#include <stdint.h> +#include <stdio.h> +#include <string.h> + +extern int errno; + +#if !defined(__WIN32__) && !defined(__MINGW32__) +# include <sys/mman.h> +#endif + +#ifndef MAP_FAILED +#define MAP_FAILED (-1) +#endif + +#include <fcntl.h> +#ifndef O_BINARY /* should be define'd on __WIN32__ */ +#define O_BINARY 0 +#endif + +#ifdef __linux__ +# include <endian.h> +# include <byteswap.h> +#elif defined(__MACH__) +# include <machine/endian.h> +typedef unsigned long ulong ; +typedef unsigned int uint ; +#endif + +typedef uint8_t __u8 ; +typedef uint16_t __u16 ; +typedef uint32_t __u32 ; + +#define uswap_16 (x) \ + ((((x) & 0xff00) >> 8) | \ + (((x) & 0x00ff) << 8)) +#define uswap_32 (x) \ + ((((x) & 0xff000000) >> 24) | \ + (((x) & 0x00ff0000) >> 8) | \ + (((x) & 0x0000ff00) << 8) | \ + (((x) & 0x000000ff) << 24)) +#define _uswap_64 (x, sfx) \ + ((((x) & 0xff00000000000000##sfx) >> 56) | \ + (((x) & 0x00ff000000000000##sfx) >> 40) | \ + (((x) & 0x0000ff0000000000##sfx) >> 24) | \ + (((x) & 0x000000ff00000000##sfx) >> 8) | \ + (((x) & 0x00000000ff000000##sfx) << 8) | \ + (((x) & 0x0000000000ff0000##sfx) << 24) | \ + (((x) & 0x000000000000ff00##sfx) << 40) | \ + (((x) & 0x00000000000000ff##sfx) << 56)) +#if defined(__GNUC__) +# define uswap_64 (x) _uswap_64(x, ull) +#else +# define uswap_64 (x) _uswap_64(x, ) +#endif + +#if __BYTE_ORDER == __LITTLE_ENDIAN +# define cpu_to_le16 (x) (x) +# define cpu_to_le32 (x) (x) +# define cpu_to_le64 (x) (x) +# define le16_to_cpu (x) (x) +# define le32_to_cpu (x) (x) +# define le64_to_cpu (x) (x) +# define cpu_to_be16 (x) uswap_16(x) +# define cpu_to_be32 (x) uswap_32(x) +# define cpu_to_be64 (x) uswap_64(x) +# define be16_to_cpu (x) uswap_16(x) +# define be32_to_cpu (x) uswap_32(x) +# define be64_to_cpu (x) uswap_64(x) +#else +# define cpu_to_le16 (x) uswap_16(x) +# define cpu_to_le32 (x) uswap_32(x) +# define cpu_to_le64 (x) uswap_64(x) +# define le16_to_cpu (x) uswap_16(x) +# define le32_to_cpu (x) uswap_32(x) +# define le64_to_cpu (x) uswap_64(x) +# define cpu_to_be16 (x) (x) +# define cpu_to_be32 (x) (x) +# define cpu_to_be64 (x) (x) +# define be16_to_cpu (x) (x) +# define be32_to_cpu (x) (x) +# define be64_to_cpu (x) (x) +#endif + +#else /* !USE_HOSTCC */ + +#include <linux/string.h> +#include <linux/types.h> +#include <asm/byteorder.h> + +/* Types for `void *' pointers. */ +#if __WORDSIZE ==64 +typedef unsigned long int uintptr_t ; +#else +typedef unsigned int uintptr_t ; +#endif + +#endif + +#endif
include/elf.h +1 -9
@@ -33,15 +33,7 @@#ifndef _ELF_H#define _ELF_H -#if defined(__BEOS__) || \ - defined(__NetBSD__) || \ - defined(__FreeBSD__) || \ - defined(__sun__) || \ - defined(__APPLE__) -#include <inttypes.h> -#elif (defined(__linux__) && defined(USE_HOSTCC )) || defined(__WIN32__) -#include <stdint.h> -#endif +#include "compiler.h" /* * This version doesn't work for 64-bit ABIs - Erik.
include/environment.h +1 -5
@@ -96,11 +96,7 @@# endif #endif /* CONFIG_ENV_IS_IN_MG_DISK */ -#ifdef USE_HOSTCC -# include <stdint.h> -#else -# include <linux/types.h> -#endif +#include "compiler.h" #ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT # define ENV_HEADER_SIZE (sizeof(uint32_t) + 1)
include/image.h +3 -6
@@ -33,10 +33,9 @@#ifndef __IMAGE_H__#define __IMAGE_H__ -#if USE_HOSTCC -#ifndef __MINGW32__ -#include <endian.h> -#endif +#include "compiler.h" + +#ifdef USE_HOSTCC /* new uImage format support enabled on host */ #define CONFIG_FIT 1
@@ -46,9 +45,7 @@#else #include <lmb.h> -#include <linux/string.h> #include <asm/u-boot.h> -#include <asm/byteorder.h> #endif /* USE_HOSTCC */
include/libfdt_env.h +5 -48
61 lines not on this page · raw message
include/u-boot/md5.h +1 -1
@@ -6,7 +6,7 @@ #ifndef _MD5_H #define _MD5_H -#include <linux/types.h> +#include "compiler.h" struct MD5Context { __u32 buf[4];
lib_generic/md5.c +3 -5
@@ -25,14 +25,12 @@and to fit the cifs vfs by Steve French sfrench at us.ibm.com */ +#include "compiler.h" +#ifndef USE_HOSTCC #include <common.h> -#include <linux/string.h> -#else -#include <string.h> -#endif /* USE_HOSTCC */ #include <watchdog.h> -#include <linux/types.h> +#endif /* USE_HOSTCC */ #include <u-boot/md5.h> static void
tools/bmp_logo.c +1 -12
@@ -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;
tools/img2srec.c +1 -2
@@ -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 |*************************************************************************/
tools/mkimage.c +4 -10
@@ -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);
tools/mkimage.h +0 -33
@@ -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
tools/os_support.h +2 -0
@@ -19,6 +19,8 @@#ifndef __OS_SUPPORT_H_#define __OS_SUPPORT_H_ +#include "compiler.h" +/* * Include additional files required for supporting different operating systems */
tools/ubsha1.c +0 -13
@@ -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)
Signature · 1 line
1.6.3.1
PATCH v4 1/1 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.
---
this version has been tested with Blackfin targets on Linux, Darwin, and now MinGW host systems. needed a small fix in image.h to use the cpu funcs rather than ntoh/hton.
include/compiler.h | 125 +++++++++++++++++++++++++++++++++++++++++++++++++ include/elf.h | 10 +---- include/environment.h | 6 +-- include/image.h | 13 ++--- include/libfdt_env.h | 53 ++------------------- include/u-boot/md5.h | 2 +- lib_generic/md5.c | 8 +-- tools/bmp_logo.c | 13 +----- tools/img2srec.c | 3 +- tools/mingw_support.h | 3 - tools/mkimage.c | 14 ++---- tools/mkimage.h | 33 ------------- tools/os_support.c | 1 + tools/os_support.h | 2 + tools/ubsha1.c | 13 ----- 15 files changed, 150 insertions(+), 149 deletions(-) create mode 100644 include/compiler.h
include/compiler.h new file +125 -0
@@ -0,0 +1,125 @@ +/* +* Keep all the ugly #ifdef for system stuff here +*/ + +#ifndef __COMPILER_H__ +#define __COMPILER_H__ + +#include <stddef.h> + +#ifdef USE_HOSTCC + +#if defined(__BEOS__) || \ + defined(__NetBSD__) || \ + defined(__FreeBSD__) || \ + defined(__sun__) || \ + defined(__APPLE__) +# include <inttypes.h> +#elif defined(__linux__) || defined(__WIN32__) || defined(__MINGW32__) +# include <stdint.h> +#endif + +#include <errno.h> +#include <stdlib.h> +#include <stdint.h> +#include <stdio.h> +#include <string.h> + +extern int errno; + +#if !defined(__WIN32__) && !defined(__MINGW32__) +# include <sys/mman.h> +#endif + +/* Not all systems (like Windows) has this define, and yes +* we do replace/emulate mmap() on those systems ... +*/ +#ifndef MAP_FAILED +# define MAP_FAILED ((void *)-1) +#endif + +#include <fcntl.h> +#ifndef O_BINARY /* should be define'd on __WIN32__ */ +#define O_BINARY 0 +#endif + +#ifdef __linux__ +# include <endian.h> +# include <byteswap.h> +#elif defined(__MACH__) +# include <machine/endian.h> +typedef unsigned long ulong ; +typedef unsigned int uint ; +#endif + +typedef uint8_t __u8 ; +typedef uint16_t __u16 ; +typedef uint32_t __u32 ; + +#define uswap_16 (x) \ + ((((x) & 0xff00) >> 8) | \ + (((x) & 0x00ff) << 8)) +#define uswap_32 (x) \ + ((((x) & 0xff000000) >> 24) | \ + (((x) & 0x00ff0000) >> 8) | \ + (((x) & 0x0000ff00) << 8) | \ + (((x) & 0x000000ff) << 24)) +#define _uswap_64 (x, sfx) \ + ((((x) & 0xff00000000000000##sfx) >> 56) | \ + (((x) & 0x00ff000000000000##sfx) >> 40) | \ + (((x) & 0x0000ff0000000000##sfx) >> 24) | \ + (((x) & 0x000000ff00000000##sfx) >> 8) | \ + (((x) & 0x00000000ff000000##sfx) << 8) | \ + (((x) & 0x0000000000ff0000##sfx) << 24) | \ + (((x) & 0x000000000000ff00##sfx) << 40) | \ + (((x) & 0x00000000000000ff##sfx) << 56)) +#if defined(__GNUC__) +# define uswap_64 (x) _uswap_64(x, ull) +#else +# define uswap_64 (x) _uswap_64(x, ) +#endif + +#if __BYTE_ORDER == __LITTLE_ENDIAN +# define cpu_to_le16 (x) (x) +# define cpu_to_le32 (x) (x) +# define cpu_to_le64 (x) (x) +# define le16_to_cpu (x) (x) +# define le32_to_cpu (x) (x) +# define le64_to_cpu (x) (x) +# define cpu_to_be16 (x) uswap_16(x) +# define cpu_to_be32 (x) uswap_32(x) +# define cpu_to_be64 (x) uswap_64(x) +# define be16_to_cpu (x) uswap_16(x) +# define be32_to_cpu (x) uswap_32(x) +# define be64_to_cpu (x) uswap_64(x) +#else +# define cpu_to_le16 (x) uswap_16(x) +# define cpu_to_le32 (x) uswap_32(x) +# define cpu_to_le64 (x) uswap_64(x) +# define le16_to_cpu (x) uswap_16(x) +# define le32_to_cpu (x) uswap_32(x) +# define le64_to_cpu (x) uswap_64(x) +# define cpu_to_be16 (x) (x) +# define cpu_to_be32 (x) (x) +# define cpu_to_be64 (x) (x) +# define be16_to_cpu (x) (x) +# define be32_to_cpu (x) (x) +# define be64_to_cpu (x) (x) +#endif + +#else /* !USE_HOSTCC */ + +#include <linux/string.h> +#include <linux/types.h> +#include <asm/byteorder.h> + +/* Types for `void *' pointers. */ +#if __WORDSIZE ==64 +typedef unsigned long int uintptr_t ; +#else +typedef unsigned int uintptr_t ; +#endif + +#endif + +#endif
include/elf.h +1 -9
@@ -33,15 +33,7 @@#ifndef _ELF_H#define _ELF_H -#if defined(__BEOS__) || \ - defined(__NetBSD__) || \ - defined(__FreeBSD__) || \ - defined(__sun__) || \ - defined(__APPLE__) -#include <inttypes.h> -#elif (defined(__linux__) && defined(USE_HOSTCC )) || defined(__WIN32__) -#include <stdint.h> -#endif +#include "compiler.h" /* * This version doesn't work for 64-bit ABIs - Erik.
include/environment.h +1 -5
@@ -96,11 +96,7 @@# endif #endif /* CONFIG_ENV_IS_IN_MG_DISK */ -#ifdef USE_HOSTCC -# include <stdint.h> -#else -# include <linux/types.h> -#endif +#include "compiler.h" #ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT # define ENV_HEADER_SIZE (sizeof(uint32_t) + 1)
include/image.h +5 -8
@@ -33,10 +33,9 @@#ifndef __IMAGE_H__#define __IMAGE_H__ -#if USE_HOSTCC -#ifndef __MINGW32__ -#include <endian.h> -#endif +#include "compiler.h" + +#ifdef USE_HOSTCC /* new uImage format support enabled on host */ #define CONFIG_FIT 1
@@ -46,9 +45,7 @@#else #include <lmb.h> -#include <linux/string.h> #include <asm/u-boot.h> -#include <asm/byteorder.h> #endif /* USE_HOSTCC */
@@ -284,8 +281,8 @@ typedef struct bootm_headers {#define CHUNKSZ_SHA1 (64 * 1024)#endif -#define uimage_to_cpu (x) ntohl(x) -#define cpu_to_uimage (x) htonl(x) +#define uimage_to_cpu (x) be32_to_cpu(x) +#define cpu_to_uimage (x) cpu_to_be32(x)const char *genimg_get_os_name (uint8_t os);const char *genimg_get_arch_name (uint8_t arch);
include/libfdt_env.h +5 -48
61 lines not on this page · raw message
include/u-boot/md5.h +1 -1
@@ -6,7 +6,7 @@ #ifndef _MD5_H #define _MD5_H -#include <linux/types.h> +#include "compiler.h" struct MD5Context { __u32 buf[4];
lib_generic/md5.c +3 -5
@@ -25,14 +25,12 @@and to fit the cifs vfs by Steve French sfrench at us.ibm.com */ +#include "compiler.h" +#ifndef USE_HOSTCC #include <common.h> -#include <linux/string.h> -#else -#include <string.h> -#endif /* USE_HOSTCC */ #include <watchdog.h> -#include <linux/types.h> +#endif /* USE_HOSTCC */ #include <u-boot/md5.h> static void
tools/bmp_logo.c +1 -12
@@ -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;
tools/img2srec.c +1 -2
@@ -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 |*************************************************************************/
tools/mingw_support.h +0 -3
@@ -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))
tools/mkimage.c +4 -10
@@ -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);
tools/mkimage.h +0 -33
@@ -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
tools/os_support.c +1 -0
@@ -19,6 +19,7 @@/* * Include additional files required for supporting different operating systems */ +#include "compiler.h" #ifdef __MINGW32__#include "mingw_support.c" #endif
tools/os_support.h +2 -0
@@ -19,6 +19,8 @@#ifndef __OS_SUPPORT_H_#define __OS_SUPPORT_H_ +#include "compiler.h" +/* * Include additional files required for supporting different operating systems */
tools/ubsha1.c +0 -13
@@ -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)
Signature · 1 line
1.6.3.3
Wolfgang Denk
AppliedPATCH v4 1/1 compiler.h: unify system ifdef cruft here
Dear Mike Frysinger,
Quoted 22 lines · In message <[email protected]> you wrote:
Shove a lot of the HOSTCC and related #ifdef checking crap into the new
compiler.hheader 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 <[email protected]>---
this version has been tested with Blackfin targets on Linux, Darwin, and now MinGW host systems. needed a small fix inimage.hto use the cpu funcs rather than ntoh/hton.include/compiler.h | 125 +++++++++++++++++++++++++++++++++++++++++++++++++ include/elf.h | 10 +---- include/environment.h | 6 +-- include/image.h | 13 ++--- include/libfdt_env.h | 53 ++------------------- include/u-boot/md5.h | 2 +- lib_generic/md5.c | 8 +-- tools/bmp_logo.c | 13 +----- tools/img2srec.c | 3 +-
Quoted 8 lines
tools/mingw_support.h | 3 - tools/mkimage.c | 14 ++---- tools/mkimage.h | 33 ------------- tools/os_support.c | 1 + tools/os_support.h | 2 + tools/ubsha1.c | 13 ----- 15 files changed, 150 insertions(+), 149 deletions(-) create mode 100644 include/compiler.h
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Always borrow money from a pessimist; they don't expect to be paid back.