public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Use __kernel_long_t in struct mq_attr
@ 2013-12-25 16:58 H.J. Lu
  2013-12-26 15:54 ` H.J. Lu
  0 siblings, 1 reply; 6+ messages in thread
From: H.J. Lu @ 2013-12-25 16:58 UTC (permalink / raw)
  To: H. Peter Anvin, LKML

Both x32 and x86-64 use the same struct mq_attr for system calls.  But
x32 long is 32-bit. This patch replaces long with __kernel_long_t in
struct mq_attr.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
 include/uapi/linux/mqueue.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/uapi/linux/mqueue.h b/include/uapi/linux/mqueue.h
index 8b5a796..d0a2b8e 100644
--- a/include/uapi/linux/mqueue.h
+++ b/include/uapi/linux/mqueue.h
@@ -23,11 +23,11 @@
 #define MQ_BYTES_MAX	819200
 
 struct mq_attr {
-	long	mq_flags;	/* message queue flags			*/
-	long	mq_maxmsg;	/* maximum number of messages		*/
-	long	mq_msgsize;	/* maximum message size			*/
-	long	mq_curmsgs;	/* number of messages currently queued	*/
-	long	__reserved[4];	/* ignored for input, zeroed for output */
+	__kernel_long_t	mq_flags;	/* message queue flags			*/
+	__kernel_long_t	mq_maxmsg;	/* maximum number of messages		*/
+	__kernel_long_t	mq_msgsize;	/* maximum message size			*/
+	__kernel_long_t	mq_curmsgs;	/* number of messages currently queued	*/
+	__kernel_long_t	__reserved[4];	/* ignored for input, zeroed for output */
 };
 
 /*
-- 
1.8.4.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Use __kernel_long_t in struct mq_attr
  2013-12-25 16:58 [PATCH] Use __kernel_long_t in struct mq_attr H.J. Lu
@ 2013-12-26 15:54 ` H.J. Lu
  2013-12-26 17:53   ` H. Peter Anvin
  0 siblings, 1 reply; 6+ messages in thread
From: H.J. Lu @ 2013-12-26 15:54 UTC (permalink / raw)
  To: H. Peter Anvin, LKML

[-- Attachment #1: Type: text/plain, Size: 315 bytes --]

On Wed, Dec 25, 2013 at 08:58:34AM -0800, H.J. Lu wrote:
> Both x32 and x86-64 use the same struct mq_attr for system calls.  But
> x32 long is 32-bit. This patch replaces long with __kernel_long_t in
> struct mq_attr.
> 

Here is the updated patch which uses __kernel_long_t only if
__BITS_PER_LONG == 64. 
 
H.J.

[-- Attachment #2: 0008-Use-__kernel_long_t-in-struct-mq_attr.patch --]
[-- Type: text/plain, Size: 1715 bytes --]

>From fc117a05dd0a4a9ec7e6ae286aac9433609ce155 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Wed, 25 Dec 2013 08:56:22 -0800
Subject: [PATCH] Use __kernel_long_t in struct mq_attr

Both x32 and x86-64 use the same struct mq_attr for system calls.  But
x32 long is 32-bit. This patch replaces long with __kernel_long_t in
struct mq_attr if __BITS_PER_LONG == 64.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
 include/uapi/linux/mqueue.h | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/include/uapi/linux/mqueue.h b/include/uapi/linux/mqueue.h
index 8b5a796..03bf30e 100644
--- a/include/uapi/linux/mqueue.h
+++ b/include/uapi/linux/mqueue.h
@@ -23,11 +23,19 @@
 #define MQ_BYTES_MAX	819200
 
 struct mq_attr {
-	long	mq_flags;	/* message queue flags			*/
-	long	mq_maxmsg;	/* maximum number of messages		*/
-	long	mq_msgsize;	/* maximum message size			*/
-	long	mq_curmsgs;	/* number of messages currently queued	*/
-	long	__reserved[4];	/* ignored for input, zeroed for output */
+#if __BITS_PER_LONG == 64
+	__kernel_long_t	mq_flags;	/* message queue flags			*/
+	__kernel_long_t	mq_maxmsg;	/* maximum number of messages		*/
+	__kernel_long_t	mq_msgsize;	/* maximum message size			*/
+	__kernel_long_t	mq_curmsgs;	/* number of messages currently queued	*/
+	__kernel_long_t	__reserved[4];	/* ignored for input, zeroed for output */
+#else
+	long	mq_flags;		/* message queue flags			*/
+	long	mq_maxmsg;		/* maximum number of messages		*/
+	long	mq_msgsize;		/* maximum message size			*/
+	long	mq_curmsgs;		/* number of messages currently queued	*/
+	long	__reserved[4];		/* ignored for input, zeroed for output */
+#endif
 };
 
 /*
-- 
1.8.4.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Use __kernel_long_t in struct mq_attr
  2013-12-26 15:54 ` H.J. Lu
@ 2013-12-26 17:53   ` H. Peter Anvin
  2013-12-26 17:59     ` H.J. Lu
  0 siblings, 1 reply; 6+ messages in thread
From: H. Peter Anvin @ 2013-12-26 17:53 UTC (permalink / raw)
  To: H.J. Lu, LKML

On 12/26/2013 07:54 AM, H.J. Lu wrote:
> On Wed, Dec 25, 2013 at 08:58:34AM -0800, H.J. Lu wrote:
>> Both x32 and x86-64 use the same struct mq_attr for system calls.  But
>> x32 long is 32-bit. This patch replaces long with __kernel_long_t in
>> struct mq_attr.
>>
> 
> Here is the updated patch which uses __kernel_long_t only if
> __BITS_PER_LONG == 64. 
>  

That seems wrong in multiple ways... not only does it add more clutter,
but it would seem to give the wrong types when __BITS_PER_LONG in
userspace is 32.

	-hpa


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Use __kernel_long_t in struct mq_attr
  2013-12-26 17:53   ` H. Peter Anvin
@ 2013-12-26 17:59     ` H.J. Lu
  2013-12-26 18:03       ` H. Peter Anvin
  0 siblings, 1 reply; 6+ messages in thread
From: H.J. Lu @ 2013-12-26 17:59 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: LKML

On Thu, Dec 26, 2013 at 9:53 AM, H. Peter Anvin <hpa@zytor.com> wrote:
> On 12/26/2013 07:54 AM, H.J. Lu wrote:
>> On Wed, Dec 25, 2013 at 08:58:34AM -0800, H.J. Lu wrote:
>>> Both x32 and x86-64 use the same struct mq_attr for system calls.  But
>>> x32 long is 32-bit. This patch replaces long with __kernel_long_t in
>>> struct mq_attr.
>>>
>>
>> Here is the updated patch which uses __kernel_long_t only if
>> __BITS_PER_LONG == 64.
>>
>
> That seems wrong in multiple ways... not only does it add more clutter,

It is true for more clutter.

> but it would seem to give the wrong types when __BITS_PER_LONG in
> userspace is 32.
>

For x32,  __BITS_PER_LONG is 64, not 32. If __BITS_PER_LONG
 is 32, my patch doesn't change anything.  If it works before,
it still works.  If it is broken before, it remains broken.

I prefer my first patch, which is less clutter.  But I can't guarantee
it is correct for all x3-like ABIs.  My second patch has more
clutter, but it has no impact on other ABIs.

-- 
H.J.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Use __kernel_long_t in struct mq_attr
  2013-12-26 17:59     ` H.J. Lu
@ 2013-12-26 18:03       ` H. Peter Anvin
  2013-12-26 18:10         ` H.J. Lu
  0 siblings, 1 reply; 6+ messages in thread
From: H. Peter Anvin @ 2013-12-26 18:03 UTC (permalink / raw)
  To: H.J. Lu; +Cc: LKML

On 12/26/2013 09:59 AM, H.J. Lu wrote:
> 
>> but it would seem to give the wrong types when __BITS_PER_LONG in
>> userspace is 32.
>>
> 
> For x32,  __BITS_PER_LONG is 64, not 32. If __BITS_PER_LONG
>  is 32, my patch doesn't change anything.  If it works before,
> it still works.  If it is broken before, it remains broken.
> 
> I prefer my first patch, which is less clutter.  But I can't guarantee
> it is correct for all x3-like ABIs.  My second patch has more
> clutter, but it has no impact on other ABIs.
> 

It's rather simple to prove, which is to consider the generic definition
of __kernel_[u]long_t.

	-hpa


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Use __kernel_long_t in struct mq_attr
  2013-12-26 18:03       ` H. Peter Anvin
@ 2013-12-26 18:10         ` H.J. Lu
  0 siblings, 0 replies; 6+ messages in thread
From: H.J. Lu @ 2013-12-26 18:10 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: LKML

On Thu, Dec 26, 2013 at 10:03 AM, H. Peter Anvin <hpa@zytor.com> wrote:
> On 12/26/2013 09:59 AM, H.J. Lu wrote:
>>
>>> but it would seem to give the wrong types when __BITS_PER_LONG in
>>> userspace is 32.
>>>
>>
>> For x32,  __BITS_PER_LONG is 64, not 32. If __BITS_PER_LONG
>>  is 32, my patch doesn't change anything.  If it works before,
>> it still works.  If it is broken before, it remains broken.
>>
>> I prefer my first patch, which is less clutter.  But I can't guarantee
>> it is correct for all x3-like ABIs.  My second patch has more
>> clutter, but it has no impact on other ABIs.
>>
>
> It's rather simple to prove, which is to consider the generic definition
> of __kernel_[u]long_t.
>

Then. I withdrew my second alternative with  __BITS_PER_LONG == 64
check..  Please use my first alternative for all my kernel_long_t and
kernel_ulong_t patches.

Thanks.

-- 
H.J.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-12-26 18:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-25 16:58 [PATCH] Use __kernel_long_t in struct mq_attr H.J. Lu
2013-12-26 15:54 ` H.J. Lu
2013-12-26 17:53   ` H. Peter Anvin
2013-12-26 17:59     ` H.J. Lu
2013-12-26 18:03       ` H. Peter Anvin
2013-12-26 18:10         ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox