X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=include%2Fcompiler.h;h=8cf11792e24853ffe20b3fac548b3a0a0d14e30d;hb=5fac11e6d5ab350429b8c8ddf47d3d3877ca89d1;hp=4e047c7fd2cd08646a5e5b0bea47bb2dd46666c7;hpb=5bce5dc33d6313ace88bef2081f71532c9e6a4f1;p=platform%2Fkernel%2Fu-boot.git diff --git a/include/compiler.h b/include/compiler.h index 4e047c7..8cf1179 100644 --- a/include/compiler.h +++ b/include/compiler.h @@ -6,6 +6,7 @@ #define __COMPILER_H__ #include +#include #ifdef USE_HOSTCC @@ -15,7 +16,7 @@ defined(__sun__) || \ defined(__APPLE__) # include -#elif defined(__linux__) || defined(__WIN32__) || defined(__MINGW32__) +#elif defined(__linux__) || defined(__WIN32__) || defined(__MINGW32__) || defined(__OpenBSD__) # include #endif @@ -46,13 +47,29 @@ # include #elif defined(__MACH__) || defined(__FreeBSD__) # include -typedef unsigned long ulong; +#endif +#ifdef __FreeBSD__ +# include /* htole32 and friends */ +# define __BYTE_ORDER BYTE_ORDER +# define __LITTLE_ENDIAN LITTLE_ENDIAN +# define __BIG_ENDIAN BIG_ENDIAN +#elif defined(__OpenBSD__) +# include +# define __BYTE_ORDER BYTE_ORDER +# define __LITTLE_ENDIAN LITTLE_ENDIAN +# define __BIG_ENDIAN BIG_ENDIAN #endif +#include + typedef uint8_t __u8; typedef uint16_t __u16; typedef uint32_t __u32; typedef unsigned int uint; +typedef unsigned long ulong; + +/* Define these on the host so we can build some target code */ +typedef __u32 u32; #define uswap_16(x) \ ((((x) & 0xff00) >> 8) | \ @@ -107,23 +124,48 @@ typedef unsigned int uint; #else /* !USE_HOSTCC */ +/* Type for `void *' pointers. */ +typedef unsigned long int uintptr_t; + #include #include #include -/* Types for `void *' pointers. */ -#if __WORDSIZE == 64 -typedef unsigned long int uintptr_t; +#if __SIZEOF_LONG__ == 8 +# define __WORDSIZE 64 +#elif __SIZEOF_LONG__ == 4 +# define __WORDSIZE 32 #else -typedef unsigned int uintptr_t; -#endif - +/* + * Assume 32-bit for now - only newer toolchains support this feature and + * this is only required for sandbox support at present. + */ +#define __WORDSIZE 32 #endif -/* compiler options */ -#define uninitialized_var(x) x = x +#endif /* USE_HOSTCC */ #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) +#ifdef __LP64__ +#define MEM_SUPPORT_64BIT_DATA 1 +#else +#define MEM_SUPPORT_64BIT_DATA 0 +#endif + +/** + * tools_build() - check if we are building host tools + * + * @return true if building for the host, false if for a target + */ +static inline bool tools_build(void) +{ +#ifdef USE_HOSTCC + return true; +#else + return false; +#endif +} + #endif