mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-09 03:21:51 +00:00
compiler.h: add host_build()
Add a host_build() function, so that it's possible to check for software being build with USE_HOSTCC without relying on preprocessor conditions. In other words #ifdef USE_HOSTCC host_only_code(); #endif can be written like this instead: if (host_build()) host_only_code(); This improves code readability and test coverage and compiler will eleminate this unreachable code. Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
72397c9621
commit
db43c0b72d
1 changed files with 9 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
||||||
#define __COMPILER_H__
|
#define __COMPILER_H__
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#ifdef USE_HOSTCC
|
#ifdef USE_HOSTCC
|
||||||
|
|
||||||
|
@ -150,4 +151,12 @@ typedef unsigned long int uintptr_t;
|
||||||
#define MEM_SUPPORT_64BIT_DATA 0
|
#define MEM_SUPPORT_64BIT_DATA 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static inline bool host_build(void) {
|
||||||
|
#ifdef USE_HOSTCC
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue