* [PATCH] x86: uapi: Fix __BITS_PER_LONG for x32
@ 2015-10-01 0:40 Ben Hutchings
2015-10-01 8:23 ` Ingo Molnar
2015-10-02 7:45 ` [tip:x86/urgent] x86/headers/uapi: Fix __BITS_PER_LONG value for x32 builds tip-bot for Ben Hutchings
0 siblings, 2 replies; 6+ messages in thread
From: Ben Hutchings @ 2015-10-01 0:40 UTC (permalink / raw)
To: x86; +Cc: LKML
[-- Attachment #1: Type: text/plain, Size: 1100 bytes --]
On x32, gcc predefines __x86_64__ but long is only 32-bit. Use
__ILP32__ to distinguish x32.
Fixes this compiler error in perf:
/«PKGBUILDDIR»/tools/include/asm-generic/bitops/__ffs.h: In function '__ffs':
/«PKGBUILDDIR»/tools/include/asm-generic/bitops/__ffs.h:19:8: error: right shift count >= width of type [-Werror=shift-count-overflow]
word >>= 32;
^
This isn't sufficient to build perf for x32, though.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
arch/x86/include/uapi/asm/bitsperlong.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/include/uapi/asm/bitsperlong.h b/arch/x86/include/uapi/asm/bitsperlong.h
index b0ae1c4..217909b 100644
--- a/arch/x86/include/uapi/asm/bitsperlong.h
+++ b/arch/x86/include/uapi/asm/bitsperlong.h
@@ -1,7 +1,7 @@
#ifndef __ASM_X86_BITSPERLONG_H
#define __ASM_X86_BITSPERLONG_H
-#ifdef __x86_64__
+#if defined(__x86_64__) && !defined(__ILP32__)
# define __BITS_PER_LONG 64
#else
# define __BITS_PER_LONG 32
--
Ben Hutchings
Knowledge is power. France is bacon.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] x86: uapi: Fix __BITS_PER_LONG for x32
2015-10-01 0:40 [PATCH] x86: uapi: Fix __BITS_PER_LONG for x32 Ben Hutchings
@ 2015-10-01 8:23 ` Ingo Molnar
2015-10-01 13:02 ` Brian Gerst
2015-10-02 7:45 ` [tip:x86/urgent] x86/headers/uapi: Fix __BITS_PER_LONG value for x32 builds tip-bot for Ben Hutchings
1 sibling, 1 reply; 6+ messages in thread
From: Ingo Molnar @ 2015-10-01 8:23 UTC (permalink / raw)
To: Ben Hutchings; +Cc: x86, LKML, Peter Zijlstra
* Ben Hutchings <ben@decadent.org.uk> wrote:
> diff --git a/arch/x86/include/uapi/asm/bitsperlong.h b/arch/x86/include/uapi/asm/bitsperlong.h
> index b0ae1c4..217909b 100644
> --- a/arch/x86/include/uapi/asm/bitsperlong.h
> +++ b/arch/x86/include/uapi/asm/bitsperlong.h
> @@ -1,7 +1,7 @@
> #ifndef __ASM_X86_BITSPERLONG_H
> #define __ASM_X86_BITSPERLONG_H
>
> -#ifdef __x86_64__
> +#if defined(__x86_64__) && !defined(__ILP32__)
> # define __BITS_PER_LONG 64
Can we write this as:
#ifdef __ILP64__
?
Thanks,
Ingo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] x86: uapi: Fix __BITS_PER_LONG for x32
2015-10-01 8:23 ` Ingo Molnar
@ 2015-10-01 13:02 ` Brian Gerst
2015-10-01 20:54 ` Ben Hutchings
0 siblings, 1 reply; 6+ messages in thread
From: Brian Gerst @ 2015-10-01 13:02 UTC (permalink / raw)
To: Ingo Molnar; +Cc: Ben Hutchings, the arch/x86 maintainers, LKML, Peter Zijlstra
On Thu, Oct 1, 2015 at 4:23 AM, Ingo Molnar <mingo@kernel.org> wrote:
>
> * Ben Hutchings <ben@decadent.org.uk> wrote:
>
>> diff --git a/arch/x86/include/uapi/asm/bitsperlong.h b/arch/x86/include/uapi/asm/bitsperlong.h
>> index b0ae1c4..217909b 100644
>> --- a/arch/x86/include/uapi/asm/bitsperlong.h
>> +++ b/arch/x86/include/uapi/asm/bitsperlong.h
>> @@ -1,7 +1,7 @@
>> #ifndef __ASM_X86_BITSPERLONG_H
>> #define __ASM_X86_BITSPERLONG_H
>>
>> -#ifdef __x86_64__
>> +#if defined(__x86_64__) && !defined(__ILP32__)
>> # define __BITS_PER_LONG 64
>
> Can we write this as:
>
> #ifdef __ILP64__
Do all versions of gcc/clang define that, even if x32 isn't supported?
--
Brian Gerst
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] x86: uapi: Fix __BITS_PER_LONG for x32
2015-10-01 13:02 ` Brian Gerst
@ 2015-10-01 20:54 ` Ben Hutchings
2015-10-02 1:52 ` Ben Hutchings
0 siblings, 1 reply; 6+ messages in thread
From: Ben Hutchings @ 2015-10-01 20:54 UTC (permalink / raw)
To: Brian Gerst, Ingo Molnar; +Cc: the arch/x86 maintainers, LKML, Peter Zijlstra
[-- Attachment #1: Type: text/plain, Size: 1296 bytes --]
On Thu, 2015-10-01 at 09:02 -0400, Brian Gerst wrote:
> On Thu, Oct 1, 2015 at 4:23 AM, Ingo Molnar <mingo@kernel.org> wrote:
> >
> > * Ben Hutchings <ben@decadent.org.uk> wrote:
> >
> > > diff --git a/arch/x86/include/uapi/asm/bitsperlong.h
> > > b/arch/x86/include/uapi/asm/bitsperlong.h
> > > index b0ae1c4..217909b 100644
> > > --- a/arch/x86/include/uapi/asm/bitsperlong.h
> > > +++ b/arch/x86/include/uapi/asm/bitsperlong.h
> > > @@ -1,7 +1,7 @@
> > > #ifndef __ASM_X86_BITSPERLONG_H
> > > #define __ASM_X86_BITSPERLONG_H
> > >
> > > -#ifdef __x86_64__
> > > +#if defined(__x86_64__) && !defined(__ILP32__)
> > > # define __BITS_PER_LONG 64
> >
> > Can we write this as:
> >
> > #ifdef __ILP64__
Assuming you meant __LP64__...
> Do all versions of gcc/clang define that, even if x32 isn't
> supported?
For gcc, it's been defined since 2003 (gcc 3.3):
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=0bdab2d89e28ca4dc84f8f0fafed85a4822bca49
For clang, it's been defined since before its first public release:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?r1=38978&r2=38987&pathrev=161685
So gcc 3.1 and 3.2 didn't define it, but everything newer does.
Ben.
--
Ben Hutchings
Knowledge is power. France is bacon.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] x86: uapi: Fix __BITS_PER_LONG for x32
2015-10-01 20:54 ` Ben Hutchings
@ 2015-10-02 1:52 ` Ben Hutchings
0 siblings, 0 replies; 6+ messages in thread
From: Ben Hutchings @ 2015-10-02 1:52 UTC (permalink / raw)
To: Brian Gerst, Ingo Molnar; +Cc: the arch/x86 maintainers, LKML, Peter Zijlstra
[-- Attachment #1: Type: text/plain, Size: 1560 bytes --]
On Thu, 2015-10-01 at 21:54 +0100, Ben Hutchings wrote:
> On Thu, 2015-10-01 at 09:02 -0400, Brian Gerst wrote:
> > On Thu, Oct 1, 2015 at 4:23 AM, Ingo Molnar <mingo@kernel.org> wrote:
> > >
> > > * Ben Hutchings <ben@decadent.org.uk> wrote:
> > >
> > > > diff --git a/arch/x86/include/uapi/asm/bitsperlong.h
> > > > b/arch/x86/include/uapi/asm/bitsperlong.h
> > > > index b0ae1c4..217909b 100644
> > > > --- a/arch/x86/include/uapi/asm/bitsperlong.h
> > > > +++ b/arch/x86/include/uapi/asm/bitsperlong.h
> > > > @@ -1,7 +1,7 @@
> > > > #ifndef __ASM_X86_BITSPERLONG_H
> > > > #define __ASM_X86_BITSPERLONG_H
> > > >
> > > > -#ifdef __x86_64__
> > > > +#if defined(__x86_64__) && !defined(__ILP32__)
> > > > # define __BITS_PER_LONG 64
> > >
> > > Can we write this as:
> > >
> > > #ifdef __ILP64__
>
> Assuming you meant __LP64__...
>
> > Do all versions of gcc/clang define that, even if x32 isn't
> > supported?
>
> For gcc, it's been defined since 2003 (gcc 3.3):
> https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=0bdab2d89e28ca4dc84f8f0fafed85a4822bca49
>
> For clang, it's been defined since before its first public release:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?r1=38978&r2=38987&pathrev=161685
>
> So gcc 3.1 and 3.2 didn't define it, but everything newer does.
As the kernel itself is supposed to still be compilable with gcc 3.2, I
think this means that my patch has the right condition.
Ben.
--
Ben Hutchings
When in doubt, use brute force. - Ken Thompson
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* [tip:x86/urgent] x86/headers/uapi: Fix __BITS_PER_LONG value for x32 builds
2015-10-01 0:40 [PATCH] x86: uapi: Fix __BITS_PER_LONG for x32 Ben Hutchings
2015-10-01 8:23 ` Ingo Molnar
@ 2015-10-02 7:45 ` tip-bot for Ben Hutchings
1 sibling, 0 replies; 6+ messages in thread
From: tip-bot for Ben Hutchings @ 2015-10-02 7:45 UTC (permalink / raw)
To: linux-tip-commits
Cc: tglx, torvalds, efault, linux-kernel, mingo, hpa, ben, peterz
Commit-ID: f4b4aae1828855db761bf998ce37d3062b1d6446
Gitweb: http://git.kernel.org/tip/f4b4aae1828855db761bf998ce37d3062b1d6446
Author: Ben Hutchings <ben@decadent.org.uk>
AuthorDate: Thu, 1 Oct 2015 01:40:43 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 2 Oct 2015 09:43:21 +0200
x86/headers/uapi: Fix __BITS_PER_LONG value for x32 builds
On x32, gcc predefines __x86_64__ but long is only 32-bit. Use
__ILP32__ to distinguish x32.
Fixes this compiler error in perf:
tools/include/asm-generic/bitops/__ffs.h: In function '__ffs':
tools/include/asm-generic/bitops/__ffs.h:19:8: error: right shift count >= width of type [-Werror=shift-count-overflow]
word >>= 32;
^
This isn't sufficient to build perf for x32, though.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Link: http://lkml.kernel.org/r/1443660043.2730.15.camel@decadent.org.uk
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/include/uapi/asm/bitsperlong.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/include/uapi/asm/bitsperlong.h b/arch/x86/include/uapi/asm/bitsperlong.h
index b0ae1c4..217909b 100644
--- a/arch/x86/include/uapi/asm/bitsperlong.h
+++ b/arch/x86/include/uapi/asm/bitsperlong.h
@@ -1,7 +1,7 @@
#ifndef __ASM_X86_BITSPERLONG_H
#define __ASM_X86_BITSPERLONG_H
-#ifdef __x86_64__
+#if defined(__x86_64__) && !defined(__ILP32__)
# define __BITS_PER_LONG 64
#else
# define __BITS_PER_LONG 32
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-10-02 7:46 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-01 0:40 [PATCH] x86: uapi: Fix __BITS_PER_LONG for x32 Ben Hutchings
2015-10-01 8:23 ` Ingo Molnar
2015-10-01 13:02 ` Brian Gerst
2015-10-01 20:54 ` Ben Hutchings
2015-10-02 1:52 ` Ben Hutchings
2015-10-02 7:45 ` [tip:x86/urgent] x86/headers/uapi: Fix __BITS_PER_LONG value for x32 builds tip-bot for Ben Hutchings
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).