diff mbox

[v6,05/19] arm64:uapi: set __BITS_PER_LONG correctly for ILP32 and LP64

Message ID 1447795019-30176-6-git-send-email-ynorov@caviumnetworks.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yury Norov Nov. 17, 2015, 9:16 p.m. UTC
From: Andrew Pinski <apinski@cavium.com>

Define __BITS_PER_LONG depending on the ABI used (i.e. check whether
__ILP32__ or __LP64__ is defined).  This is necessary for glibc to
determine the appropriate type definitions for the system call interface.

Reviewed-by: David Daney <ddaney@caviumnetworks.com>

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
---
 arch/arm64/include/uapi/asm/bitsperlong.h | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Catalin Marinas Dec. 3, 2015, 11:31 a.m. UTC | #1
On Wed, Nov 18, 2015 at 12:16:45AM +0300, Yury Norov wrote:
> diff --git a/arch/arm64/include/uapi/asm/bitsperlong.h b/arch/arm64/include/uapi/asm/bitsperlong.h
> index fce9c29..4265243 100644
> --- a/arch/arm64/include/uapi/asm/bitsperlong.h
> +++ b/arch/arm64/include/uapi/asm/bitsperlong.h
> @@ -16,7 +16,14 @@
>  #ifndef __ASM_BITSPERLONG_H
>  #define __ASM_BITSPERLONG_H
>  
> -#define __BITS_PER_LONG 64
> +#if defined(__LP64__)
> +/* Assuming __LP64__ will be defined for native ELF64's and not for ILP32. */
> +#  define __BITS_PER_LONG 64
> +#elif defined(__ILP32__)
> +#  define __BITS_PER_LONG 32
> +#else
> +#  error "Neither LP64 nor ILP32: unsupported ABI in asm/bitsperlong.h"
> +#endif

Quick question: IIRC, earlier aarch64 gcc versions did not generate
__ILP32__ when -mabi=ilp32, they only removed __LP64__. When did the
change happen? Could we assume that all compiler versions used to
generate ILP32 would define this?
Philipp Tomsich Dec. 3, 2015, 11:36 a.m. UTC | #2
Catalin,

> Quick question: IIRC, earlier aarch64 gcc versions did not generate
> __ILP32__ when -mabi=ilp32, they only removed __LP64__. When did the
> change happen? Could we assume that all compiler versions used to
> generate ILP32 would define this?

The __ILP32__ define has been supported since 
> commit b01b37f5768911598640cf8a8c82beacb4200c13
> Author: yufeng <yufeng@138bc75d-0d04-0410-961f-82ee72b054a4>
> Date:   Tue Jul 23 12:26:33 2013 +0000
> 
>     [AArch64, ILP32] 4/6 Define _ILP32 and __ILP32__.
>     
>     gcc/
>     
>         * config/aarch64/aarch64.h (TARGET_CPU_CPP_BUILTINS): Define _ILP32
>         and __ILP32__ when the ILP32 model is in use.
>     
>     
>     git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@201167 138bc75d-0d04-0410-961f-82ee72b054a4

Best regards,
Philipp.
diff mbox

Patch

diff --git a/arch/arm64/include/uapi/asm/bitsperlong.h b/arch/arm64/include/uapi/asm/bitsperlong.h
index fce9c29..4265243 100644
--- a/arch/arm64/include/uapi/asm/bitsperlong.h
+++ b/arch/arm64/include/uapi/asm/bitsperlong.h
@@ -16,7 +16,14 @@ 
 #ifndef __ASM_BITSPERLONG_H
 #define __ASM_BITSPERLONG_H
 
-#define __BITS_PER_LONG 64
+#if defined(__LP64__)
+/* Assuming __LP64__ will be defined for native ELF64's and not for ILP32. */
+#  define __BITS_PER_LONG 64
+#elif defined(__ILP32__)
+#  define __BITS_PER_LONG 32
+#else
+#  error "Neither LP64 nor ILP32: unsupported ABI in asm/bitsperlong.h"
+#endif
 
 #include <asm-generic/bitsperlong.h>