public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH] 2/6 POSIX message queues
@ 2004-02-19 14:28 Krzysztof Benedyczak
  2004-02-19 14:53 ` Christoph Hellwig
  0 siblings, 1 reply; 8+ messages in thread
From: Krzysztof Benedyczak @ 2004-02-19 14:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: Manfred Spraul, Michal Wronski

// $Header$
// Kernel Version:
//  VERSION = 2
//  PATCHLEVEL = 6
//  SUBLEVEL = 2
//  EXTRAVERSION =
--- 2.6/ipc/util.c	2004-02-14 18:47:10.000000000 +0100
+++ build-2.6/ipc/util.c	2004-02-14 18:44:34.000000000 +0100
@@ -24,6 +24,7 @@
 #include <linux/security.h>
 #include <linux/rcupdate.h>
 #include <linux/workqueue.h>
+#include <linux/mqueue.h>

 #if defined(CONFIG_SYSVIPC)

--- 2.6/arch/i386/kernel/entry.S	2004-02-14 18:47:10.000000000 +0100
+++ build-2.6/arch/i386/kernel/entry.S	2004-02-14 18:43:43.000000000 +0100
@@ -882,5 +882,11 @@
 	.long sys_utimes
  	.long sys_fadvise64_64
 	.long sys_ni_syscall	/* sys_vserver */
+	.long sys_mq_open
+	.long sys_mq_unlink	/* 275 */
+	.long sys_mq_timedsend
+	.long sys_mq_timedreceive
+	.long sys_mq_notify
+	.long sys_mq_getsetattr

 syscall_table_size=(.-sys_call_table)
--- 2.6/include/asm-i386/unistd.h	2004-02-14 18:47:10.000000000 +0100
+++ build-2.6/include/asm-i386/unistd.h	2004-02-14 18:43:43.000000000 +0100
@@ -279,8 +279,14 @@
 #define __NR_utimes		271
 #define __NR_fadvise64_64	272
 #define __NR_vserver		273
+#define __NR_mq_open 		274
+#define __NR_mq_unlink		(__NR_mq_open+1)
+#define __NR_mq_timedsend	(__NR_mq_open+2)
+#define __NR_mq_timedreceive	(__NR_mq_open+3)
+#define __NR_mq_notify		(__NR_mq_open+4)
+#define __NR_mq_getsetattr	(__NR_mq_open+5)

-#define NR_syscalls 274
+#define NR_syscalls 280

 /* user-visible error numbers are in the range -1 - -124: see <asm-i386/errno.h> */

--- 2.6/include/linux/mqueue.h	1970-01-01 01:00:00.000000000 +0100
+++ build-2.6/include/linux/mqueue.h	2004-02-14 18:50:50.000000000 +0100
@@ -0,0 +1,50 @@
+/* Copyright (C) 2003 Krzysztof Benedyczak & Michal Wronski
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   It is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this software; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _LINUX_MQUEUE_H
+#define _LINUX_MQUEUE_H
+
+#define MQ_PRIO_MAX 	32768
+
+typedef int mqd_t;
+
+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	*/
+};
+
+#define NOTIFY_NONE	0
+#define NOTIFY_WOKENUP	1
+#define NOTIFY_REMOVED	2
+
+#ifdef __KERNEL__
+#include <linux/types.h>
+#include <linux/time.h>
+#include <linux/signal.h>
+#include <linux/linkage.h>
+
+asmlinkage long sys_mq_open(const char __user *name, int oflag, mode_t mode, struct mq_attr __user *attr);
+asmlinkage long sys_mq_unlink(const char __user *name);
+asmlinkage long mq_timedsend(mqd_t mqdes, const char __user *msg_ptr, size_t msg_len, unsigned int msg_prio, const struct timespec __user *abs_timeout);
+asmlinkage ssize_t mq_timedreceive(mqd_t mqdes, char __user *msg_ptr, size_t msg_len, unsigned int __user *msg_prio, const struct timespec __user *abs_timeout);
+asmlinkage long mq_notify(mqd_t mqdes, const struct sigevent __user *notification);
+asmlinkage long mq_getsetattr(mqd_t mqdes, const struct mq_attr __user *mqstat, struct mq_attr __user *omqstat);
+#endif
+
+#endif
--- 2.6/kernel/sys.c	2004-02-14 17:19:39.000000000 +0100
+++ build-2.6/kernel/sys.c	2004-02-14 18:45:23.000000000 +0100
@@ -249,6 +249,12 @@
 cond_syscall(sys_epoll_create)
 cond_syscall(sys_epoll_ctl)
 cond_syscall(sys_epoll_wait)
+cond_syscall(sys_mq_open)
+cond_syscall(sys_mq_unlink)
+cond_syscall(sys_mq_timedsend)
+cond_syscall(sys_mq_timedreceive)
+cond_syscall(sys_mq_notify)
+cond_syscall(sys_mq_getsetattr)

 /* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read)

^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: [RFC][PATCH] 2/6 POSIX message queues
@ 2004-02-20 13:55 Arnd Bergmann
  2004-02-20 18:11 ` Krzysztof Benedyczak
  0 siblings, 1 reply; 8+ messages in thread
From: Arnd Bergmann @ 2004-02-20 13:55 UTC (permalink / raw)
  To: Krzysztof Benedyczak; +Cc: linux-kernel

Krzysztof Benedyczak wrote:

> +
> +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	*/
> +};
> +

Does POSIX mandate that these have to be 'long'? If you can change them
all to any of 'int', '__s32' or '__s64', the handlers for 32 bit system
call emulation on 64 bit machines will get a lot simpler because the
32 bit user structures are then identical to the 64 bit ones.

	Arnd <><


^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: [RFC][PATCH] 2/6 POSIX message queues
@ 2004-02-22 15:12 Manfred Spraul
  0 siblings, 0 replies; 8+ messages in thread
From: Manfred Spraul @ 2004-02-22 15:12 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-kernel, Krzysztof Benedyczak

Arnd wrote:

>Nothing difficult here, but slow and avoidable if you have the
>structures laid out properly.
>
I thought about using s32 for the kernel mq_attr structure, and didn't 
like it: It would mean that 64-bit archs running native 64-bit apps must 
do a conversion - glibc must expose a structure with long values.
Additionally, the posix message queue API uses 3 structures with long 
values, and only one of them is new - we'll need wrappers anyway.
The actual values in the mq_attr structure would fit into s32:
- mq_flags is 0 or O_NONBLOCK
- mq_maxmsg is less than 32k (kmalloc'ed array of pointers)
- mq_msgsize is theoretically unlimited, but the current implementation 
arbitrarily limits the value to 1 MB.

--
    Manfred



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

end of thread, other threads:[~2004-02-22 15:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-19 14:28 [RFC][PATCH] 2/6 POSIX message queues Krzysztof Benedyczak
2004-02-19 14:53 ` Christoph Hellwig
2004-02-19 19:07   ` Sam Ravnborg
2004-02-19 19:44     ` Manfred Spraul
  -- strict thread matches above, loose matches on Subject: below --
2004-02-20 13:55 Arnd Bergmann
2004-02-20 18:11 ` Krzysztof Benedyczak
2004-02-22 12:23   ` Arnd Bergmann
2004-02-22 15:12 Manfred Spraul

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