summaryrefslogtreecommitdiff
path: root/include/compiler.h
AgeCommit message (Collapse)AuthorFilesLines
2020-12-26compiler.h: add host_build()Sebastian Reichel1-0/+9
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>
2020-07-09Update MEM_SUPPORT_64BIT_DATA to be always definedSimon Glass1-1/+3
Define this macro always so we don't need the preprocessor to check it. Convert the users to #if instead of #ifdef. Note that '#if MEM_SUPPORT_64BIT_DATA' does not give an error if the macro is not define. It just assumes zero. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Stefan Roese <sr@denx.de>
2020-01-18common: Move and rename CONFIG_SYS_SUPPORT_64BIT_DATASimon Glass1-0/+4
This is not really a CONFIG since it is not intended to be set by boards. Move it into the compiler header with other similar defines, and rename it. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-01-03include: fix 'ulong' definition on musl targetsSergei Trofimovich1-1/+1
The build failure was originally reported on arm64-musl target at https://bugs.gentoo.org/703132. Here is the amd64-musl variant: ``` $ LANG=C make CROSS_COMPILE=x86_64-gentoo-linux-musl- tools-only_defconfig -j$(nproc) $ LANG=C make CROSS_COMPILE=x86_64-gentoo-linux-musl- tools-all -j$(nproc) ... In file included from tools/env/../../env/flags.c:7, from tools/env/env_flags.c:1: include/env.h:159:1: error: unknown type name 'ulong'; did you mean 'long'? 159 | ulong env_get_ulong(const char *name, int base, ulong default_val); | ^~~~~ | long ``` Note: 'ulong' is not defined there. On glibc 'ulong' comes from <sys/types.h>: ```c /* Old compatibility names for C types. */ typedef unsigned long int ulong; ``` On musl it comes from <sys/types.h> as well but from under different guards: ```c typedef unsigned long u_long, ulong; ``` The change inlines 'ulong' define similar to 'uint' define. Bug: https://bugs.gentoo.org/703132 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2018-09-11Remove CONFIG_USE_STDINTMasahiro Yamada1-5/+0
You do not need to use the typedefs provided by compiler. Our compilers are either IPL32 or LP64. Hence, U-Boot can/should always use int-ll64.h typedefs like Linux kernel, whatever the typedefs the compiler internally uses. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-02-06Fix FreeBSD endian checksJustin Hibbits1-0/+3
FreeBSD, like OpenBSD, uses BIG_ENDIAN, LITTLE_ENDIAN, and BYTE_ORDER, whereas Linux and compatibles use __-prefixed names. Define the names the same as the OpenBSD block below it.
2016-12-03compiler.h: use u-boot endian macros on OpenBSDJonathan Gray1-14/+4
When building u-boot on sparc64 and powerpc hosts it became clear that u-boot expects endian conversion defines to be macros: lib/crc32.c:87: error: braced-group within expression allowed only inside a function For OpenBSD switch from using system definitions equivalent to the u-boot ones and define glibc __BYTE_ORDER __BIG_ENDIAN __LITTLE_ENDIAN names, as at least some parts of the non-cross build assumes those names are present (ie crc32.c). Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
2016-09-07compiler.h: use system endian macros on OpenBSDJonathan Gray1-2/+17
The u-boot endian macros map directly to system endian macros on OpenBSD. Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
2015-12-16Revert "include/linux: move typdef for uintptr_t"York Sun1-0/+3
This reverts commit e8f954a756a825130d11b9c8fca70101dd8b3ac5, which causes compiling errors on 32-bit hosts. Acked-by: Aneesh Bansal <aneesh.bansal@freescale.com> Signed-off-by: York Sun <yorksun@freescale.com>
2015-12-15include/linux: move typdef for uintptr_tAneesh Bansal1-3/+0
uintptr_t which is a typdef for unsigned long is needed for creating pointers (32 or 64 bit depending on Core) from 32 bit variables storing the address. If a 32 bit variable (u32) is typecasted to a pointer (void *), compiler gives a warning in case size of pointer on the core is 64 bit. The typdef has been moved from include/compiler.h to include/linux/types.h Signed-off-by: Aneesh Bansal <aneesh.bansal@freescale.com> Reviewed-by: York Sun <yorksun@freescale.com>
2014-10-27Provide option to avoid defining a custom version of uintptr_t.Gabe Black1-3/+8
There's a definition in stdint.h (provided by gcc) which will be more correct if available. Define CONFIG_USE_STDINT to use this feature, or USE_STDINT=1 on the 'make' commmand. This adjusts the settings for x86 and sandbox, with both have 64-bit options. Signed-off-by: Gabe Black <gabeblack@google.com> Reviewed-by: Gabe Black <gabeblack@chromium.org> Tested-by: Gabe Black <gabeblack@chromium.org> Reviewed-by: Bill Richardson <wfrichar@google.com> Rewritten to be an option, since stdint.h is often available only in glibc. Changed to preserve a clear boundary between stdint and non-stdint Signed-off-by: Simon Glass <sjg@chromium.org>
2014-10-11tools: compiler.h: Fix build on FreeBSDJeroen Hofstee1-0/+4
Commit 832472 "tools: socfpga: Add socfpga preloader signing to mkimage" added tools/socfpga.c which relies on htole32, le32toh and friends. While compiler.h includes these protypes for linux from endian.h, it doesn't do so for FreeBSD. Hence include <sys/endian.h> for FreeBSD. Cc: Marek Vasut <marex@denx.de> CC: Tom Rini <trini@ti.com> Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
2014-09-25compiler.h: remove duplicated uninitialized_varJeroen Hofstee1-3/+0
Since clang has a different definition for uninitialized_var it will complain that it is redefined in include/compiler.h. Since these are already defined in linux/compiler.h just remove this instance. Cc: Masahiro Yamada <yamada.m@jp.panasonic.com> Cc: Tom Rini <trini@ti.com> Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
2014-07-22tools: compiler.h: add missing time.hJeroen Hofstee1-0/+1
genimg_print_time uses time_t, but time.h is never included. Linux gets away with this since types.h includes time.h. Explicitly include the header file so building on e.g. FreeBSD also works. cc: Tom Rini <trini@ti.com> Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
2011-11-22Define uintptr_t as long int to simplify printf() format stringsSimon Glass1-9/+3
If uintptr_t can be either an unsigned int or an unsigned long int, it is tricky to use it in a printf() format string. This changes it to unsigned long int consistently. This should do the right thing on both 32-bit and 64-bit architectures. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Mike Frysinger <vapier@gentoo.org>
2011-10-18sandbox: Add compiler defines to support a 64-bit x86_64 platformSimon Glass1-1/+15
This sets __WORDSIZE to 8 correctly on 64-bit machines. Signed-off-by: Simon Glass <sjg@chromium.org>
2011-07-28include/compiler.h: typedef ulong for FreeBSDJeroen Hofstee1-1/+1
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
2010-10-07include/compiler.h: remove uint typedef for __MACH__Andreas Bießmann1-1/+0
uint is typedefed twice if __MACH__ is defined. This generates an error when calling MAKEALL for netstar bord on OS X. This patch removes the typedef for __MACH__ case in favor of general definiton some lines below. Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>
2010-06-20include/compiler.h: remove redundant declaration of errnoWolfgang Denk1-2/+0
Commit 37566090 "compiler.h: unify system ifdef cruft here" added both a "#include <errno.h>" and a "extern int errno;" to include/compiler.h which is causing build warnings for some systems, for example for the "netstar" board: In file included from /home/wd/git/u-boot/work/lib/crc32.c:15: include/compiler.h:28: warning: function declaration isn't a prototype The declaration of "errno" should be redundant, as <errno.h> is supposed to provide a correct declaration, so drop it. Signed-off-by: Wolfgang Denk <wd@denx.de> Cc: Mike Frysinger <vapier@gentoo.org>
2010-05-06compiler.h: add uint typedefMike Frysinger1-0/+1
Recent crc changes started using the "uint" type in headers that are used on the build system. This subsequently broke mingw targets as they do not provide such a type. So add this basic typedef to compiler.h so that we do not have to worry about this breaking again in the future. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2010-01-18move definition of macros likely and unlikely to compiler.hMatthias Kaehlcke1-0/+3
the macros likely and unlikely were defined in include/linux/mtd/compat.h, but used in code not related to MTD. moved the macro definitions to compiler.h Signed-off-by: Matthias Kaehlcke <matthias@kaehlcke.net>
2009-09-05Move uninitialized_var() macro from ubi_uboot.h to compiler.hAnton Vorontsov1-0/+3
This is needed so that we could use this macro for non-UBI code. Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
2009-07-19compiler.h: unify system ifdef cruft hereMike Frysinger1-0/+125
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>