Skip to content

Commit

Permalink
Provide option to avoid defining a custom version of uintptr_t.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Gabe Black <[email protected]>
Tested-by: Gabe Black <[email protected]>
Reviewed-by: Bill Richardson <[email protected]>
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 <[email protected]>
  • Loading branch information
Gabe Black authored and trini committed Oct 27, 2014
1 parent 4bf3a56 commit 0d296cc
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 4 deletions.
5 changes: 5 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -4054,6 +4054,11 @@ Configuration Settings:
be asserted. See doc/README.omap-reset-time for details on how
the value can be calulated on a given board.

- CONFIG_USE_STDINT
If stdint.h is available with your toolchain you can define this
option to enable it. You can provide option 'USE_STDINT=1' when
building U-Boot to enable this.

The following definitions that deal with the placement and management
of environment data (variable area); in general, we support the
following configurations:
Expand Down
5 changes: 5 additions & 0 deletions arch/sandbox/include/asm/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ typedef unsigned short u16;
typedef signed int s32;
typedef unsigned int u32;

#if !defined(CONFIG_USE_STDINT) || !defined(__INT64_TYPE__)
typedef signed long long s64;
typedef unsigned long long u64;
#else
typedef __INT64_TYPE__ s64;
typedef __UINT64_TYPE__ u64;
#endif

#define BITS_PER_LONG CONFIG_SANDBOX_BITS_PER_LONG

Expand Down
5 changes: 5 additions & 0 deletions arch/x86/include/asm/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ typedef unsigned short u16;
typedef signed int s32;
typedef unsigned int u32;

#if !defined(CONFIG_USE_STDINT) || !defined(__INT64_TYPE__)
typedef signed long long s64;
typedef unsigned long long u64;
#else
typedef __INT64_TYPE__ s64;
typedef __UINT64_TYPE__ u64;
#endif

#define BITS_PER_LONG 32

Expand Down
5 changes: 5 additions & 0 deletions config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ ifdef FTRACE
PLATFORM_CPPFLAGS += -finstrument-functions -DFTRACE
endif

# Allow use of stdint.h if available
ifneq ($(USE_STDINT),)
PLATFORM_CPPFLAGS += -DCONFIG_USE_STDINT
endif

#########################################################################

RELFLAGS := $(PLATFORM_RELFLAGS)
Expand Down
11 changes: 8 additions & 3 deletions include/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ typedef unsigned int uint;

#else /* !USE_HOSTCC */

#ifdef CONFIG_USE_STDINT
/* Provided by gcc. */
#include <stdint.h>
#else
/* Type for `void *' pointers. */
typedef unsigned long int uintptr_t;
#endif

#include <linux/string.h>
#include <linux/types.h>
#include <asm/byteorder.h>
Expand All @@ -128,9 +136,6 @@ typedef unsigned int uint;
#define __WORDSIZE 32
#endif

/* Type for `void *' pointers. */
typedef unsigned long int uintptr_t;

#endif /* USE_HOSTCC */

#define likely(x) __builtin_expect(!!(x), 1)
Expand Down
9 changes: 8 additions & 1 deletion include/linux/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,21 @@ typedef __u8 uint8_t;
typedef __u16 uint16_t;
typedef __u32 uint32_t;

#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
#if defined(__GNUC__) && !defined(__STRICT_ANSI__) && \
(!defined(CONFIG_USE_STDINT) || !defined(__INT64_TYPE__))
typedef __u64 uint64_t;
typedef __u64 u_int64_t;
typedef __s64 int64_t;
#endif

#endif /* __KERNEL_STRICT_NAMES */

#if defined(CONFIG_USE_STDINT) && defined(__INT64_TYPE__)
typedef __UINT64_TYPE__ uint64_t;
typedef __UINT64_TYPE__ u_int64_t;
typedef __INT64_TYPE__ int64_t;
#endif

/*
* Below are truly Linux-specific types that should never collide with
* any application/library that wants linux/types.h.
Expand Down

0 comments on commit 0d296cc

Please sign in to comment.