Commit Graph

23 Commits

Author SHA1 Message Date
Sebastian Reichel db43c0b72d 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>
2020-12-26 12:37:28 +01:00
Simon Glass 3428faf23a Update MEM_SUPPORT_64BIT_DATA to be always defined
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-07-08 17:21:46 -04:00
Simon Glass 4d979bfdbc common: Move and rename CONFIG_SYS_SUPPORT_64BIT_DATA
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-17 17:53:52 -05:00
Sergei Trofimovich d11fa9c16b include: fix 'ulong' definition on musl targets
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>
2020-01-03 09:47:10 -05:00
Masahiro Yamada 9865543ae6 Remove CONFIG_USE_STDINT
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-09-10 20:48:16 -04:00
Justin Hibbits f29aa23b54 Fix FreeBSD endian checks
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.
2018-02-05 20:58:11 -05:00
Jonathan Gray fd184b9c80 compiler.h: use u-boot endian macros on OpenBSD
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-12-02 21:32:38 -05:00
Jonathan Gray 3715a540c4 compiler.h: use system endian macros on OpenBSD
The u-boot endian macros map directly to system endian
macros on OpenBSD.

Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
2016-09-07 08:49:06 -04:00
York Sun 2e680f92b8 Revert "include/linux: move typdef for uintptr_t"
This reverts commit e8f954a756, 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-16 07:11:15 -05:00
Aneesh Bansal e8f954a756 include/linux: move typdef for uintptr_t
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>
2015-12-15 08:57:34 +08:00
Gabe Black 0d296cc2d3 Provide option to avoid defining a custom version of uintptr_t.
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-27 11:04:01 -04:00
Jeroen Hofstee ed8271d11c tools: compiler.h: Fix build on FreeBSD
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-10-10 16:00:01 -04:00
Jeroen Hofstee 87f13aa00d compiler.h: remove duplicated uninitialized_var
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-09-24 18:30:29 -04:00
Jeroen Hofstee 9d16e93dc2 tools: compiler.h: add missing time.h
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>
2014-07-22 07:44:25 -04:00
Simon Glass c9502f4914 Define uintptr_t as long int to simplify printf() format strings
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-11-22 08:39:24 +01:00
Simon Glass a7551a3f79 sandbox: Add compiler defines to support a 64-bit x86_64 platform
This sets __WORDSIZE to 8 correctly on 64-bit machines.

Signed-off-by: Simon Glass <sjg@chromium.org>
2011-10-17 23:53:39 +02:00
Jeroen Hofstee 5bce5dc33d include/compiler.h: typedef ulong for FreeBSD
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
2011-07-28 21:17:11 +02:00
Andreas Bießmann 5933645904 include/compiler.h: remove uint typedef for __MACH__
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-10-06 23:09:42 +02:00
Wolfgang Denk 9312bba01a include/compiler.h: remove redundant declaration of errno
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-06-20 02:21:58 +02:00
Mike Frysinger b050c72d52 compiler.h: add uint typedef
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-05-06 00:38:05 +02:00
Matthias Kaehlcke b63815e313 move definition of macros likely and unlikely to compiler.h
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>
2010-01-18 00:28:27 +01:00
Anton Vorontsov d8bc55a6fb Move uninitialized_var() macro from ubi_uboot.h to compiler.h
This is needed so that we could use this macro for non-UBI code.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
2009-09-04 22:16:40 +02:00
Mike Frysinger 3756609076 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.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-07-19 21:41:46 +02:00