diff options
author | Thomas Heijligen <thomas.heijligen@secunet.de> | 2021-10-12 16:47:43 +0200 |
---|---|---|
committer | Nico Huber <nico.h@gmx.de> | 2021-10-15 14:35:38 +0000 |
commit | b5836478888acf38780ae1ec0315282778916d2a (patch) | |
tree | 72cbf84d1371dc51b0cf0d971be93e4e13d9e264 /platform.h | |
parent | ba1c5eb12591c306604929b94b9046a37170c5ff (diff) | |
download | flashrom-b5836478888acf38780ae1ec0315282778916d2a.tar.gz flashrom-b5836478888acf38780ae1ec0315282778916d2a.tar.bz2 flashrom-b5836478888acf38780ae1ec0315282778916d2a.zip |
buildsystem: Determine the endianness only in the buildsystem
Let the buildsystem (make / meson) handle the endianness determination
and set the __FLASHROM_LITTLE_ENDIAN__ or __FLASHROM_BIG_ENDIAN__ macro
as cflag.
Change-Id: I37093528ae55e712cc30a0267a8ceac332750e7d
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58273
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
Diffstat (limited to 'platform.h')
-rw-r--r-- | platform.h | 89 |
1 files changed, 0 insertions, 89 deletions
@@ -71,93 +71,4 @@ #error Unknown architecture #endif -/* The next big hunk tries to guess endianness from various preprocessor macros */ -/* First some error checking in case some weird header has defined both. - * NB: OpenBSD always defines _BIG_ENDIAN and _LITTLE_ENDIAN. */ -#if defined (__LITTLE_ENDIAN__) && defined (__BIG_ENDIAN__) -#error Conflicting endianness #define -#endif - -#if IS_X86 - -/* All x86 is little-endian. */ -#define __FLASHROM_LITTLE_ENDIAN__ 1 - -#elif IS_MIPS - -/* MIPS can be either endian. */ -#if defined (__MIPSEL) || defined (__MIPSEL__) || defined (_MIPSEL) || defined (MIPSEL) -#define __FLASHROM_LITTLE_ENDIAN__ 1 -#elif defined (__MIPSEB) || defined (__MIPSEB__) || defined (_MIPSEB) || defined (MIPSEB) -#define __FLASHROM_BIG_ENDIAN__ 1 -#endif - -#elif IS_PPC - -/* PowerPC can be either endian. */ -#if defined (_BIG_ENDIAN) || defined (__BIG_ENDIAN__) -#define __FLASHROM_BIG_ENDIAN__ 1 -#elif defined (_LITTLE_ENDIAN) || defined (__LITTLE_ENDIAN__) -#define __FLASHROM_LITTLE_ENDIAN__ 1 -#endif - -#elif IS_ARM - -/* ARM can be either endian. */ -#if defined (__ARMEB__) || defined (__BIG_ENDIAN__) -#define __FLASHROM_BIG_ENDIAN__ 1 -#elif defined (__ARMEL__) || defined (__LITTLE_ENDIAN__) -#define __FLASHROM_LITTLE_ENDIAN__ 1 -#endif - -#elif IS_SPARC -/* SPARC is big endian in general (but allows to access data in little endian too). */ -#define __FLASHROM_BIG_ENDIAN__ 1 - -#elif IS_ARC -#if defined(__BIG_ENDIAN__) -#define __FLASHROM_BIG_ENDIAN__ 1 -#else -#define __FLASHROM_LITTLE_ENDIAN__ 1 -#endif - -#endif /* IS_? */ - -#if !defined (__FLASHROM_BIG_ENDIAN__) && !defined (__FLASHROM_LITTLE_ENDIAN__) - -/* If architecture-specific approaches fail try generic variants. First: BSD (works about everywhere). */ -#if !IS_WINDOWS -#include <sys/param.h> - -#if defined (__BYTE_ORDER) -#if __BYTE_ORDER == __LITTLE_ENDIAN -#define __FLASHROM_LITTLE_ENDIAN__ -#elif __BYTE_ORDER == __BIG_ENDIAN -#define __FLASHROM_BIG_ENDIAN__ -#else -#error Unknown byte order! -#endif -#endif /* defined __BYTE_ORDER */ -#endif /* !IS_WINDOWS */ - -#if !defined (__FLASHROM_BIG_ENDIAN__) && !defined (__FLASHROM_LITTLE_ENDIAN__) - -/* Nonstandard libc-specific macros for determining endianness. */ -/* musl provides an endian.h as well... but it can not be detected from within C. */ -#if defined(__GLIBC__) -#include <endian.h> -#if BYTE_ORDER == LITTLE_ENDIAN -#define __FLASHROM_LITTLE_ENDIAN__ 1 -#elif BYTE_ORDER == BIG_ENDIAN -#define __FLASHROM_BIG_ENDIAN__ 1 -#endif -#endif -#endif - -#endif - -#if !defined (__FLASHROM_BIG_ENDIAN__) && !defined (__FLASHROM_LITTLE_ENDIAN__) -#error Unable to determine endianness. -#endif - #endif /* !__PLATFORM_H__ */ |