diff --git a/include/nuttx/mqueue.h b/include/nuttx/mqueue.h index fd5ab3164f..7aa60ed52b 100644 --- a/include/nuttx/mqueue.h +++ b/include/nuttx/mqueue.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/nuttx/mqueue.h * - * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2011, 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -64,13 +64,11 @@ struct mq_des; /* forward reference */ -struct msgq_s +struct mqueue_inode_s { - FAR struct msgq_s *flink; /* Forward link to next message queue */ sq_queue_t msglist; /* Prioritized message list */ int16_t maxmsgs; /* Maximum number of messages in the queue */ int16_t nmsgs; /* Number of message in the queue */ - int16_t nconnect; /* Number of connections to message queue */ int16_t nwaitnotfull; /* Number tasks waiting for not full */ int16_t nwaitnotempty; /* Number tasks waiting for not empty */ #if CONFIG_MQ_MAXMSGSIZE < 256 @@ -78,19 +76,15 @@ struct msgq_s #else uint16_t maxmsgsize; /* Max size of message in message queue */ #endif - bool unlinked; /* true if the msg queue has been unlinked */ #ifndef CONFIG_DISABLE_SIGNALS FAR struct mq_des *ntmqdes; /* Notification: Owning mqdes (NULL if none) */ pid_t ntpid; /* Notification: Receiving Task's PID */ int ntsigno; /* Notification: Signal number */ union sigval ntvalue; /* Notification: Signal value */ #endif - char name[1]; /* Start of the queue name */ }; -typedef struct msgq_s msgq_t; - -#define SIZEOF_MQ_HEADER ((int)(((msgq_t*)NULL)->name)) +#define SIZEOF_MQ_HEADER ((int)(((struct mqueue_inode_s*)NULL)->name)) /* This describes the message queue descriptor that is held in the * task's TCB @@ -98,9 +92,9 @@ typedef struct msgq_s msgq_t; struct mq_des { - FAR struct mq_des *flink; /* Forward link to next message descriptor */ - FAR msgq_t *msgq; /* Pointer to associated message queue */ - int oflags; /* Flags set when message queue was opened */ + FAR struct mq_des *flink; /* Forward link to next message descriptor */ + FAR struct mqueue_inode_s *msgq; /* Pointer to associated message queue */ + int oflags; /* Flags set when message queue was opened */ }; /**************************************************************************** diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h index 28f157f3ce..3509d34564 100644 --- a/include/nuttx/sched.h +++ b/include/nuttx/sched.h @@ -224,10 +224,6 @@ typedef CODE void (*atexitfunc_t)(void); typedef CODE void (*onexitfunc_t)(int exitcode, FAR void *arg); #endif -/* POSIX Message queue */ - -typedef struct msgq_s msgq_t; - /* struct child_status_s *********************************************************/ /* This structure is used to maintin information about child tasks. * pthreads work differently, they have join information. This is @@ -523,7 +519,7 @@ struct tcb_s /* POSIX Named Message Queue Fields *******************************************/ #ifndef CONFIG_DISABLE_MQUEUE - FAR msgq_t *msgwaitq; /* Waiting for this message queue */ + FAR struct mqueue_inode_s *msgwaitq; /* Waiting for this message queue */ #endif /* Library related fields *****************************************************/ diff --git a/sched/mqueue/Make.defs b/sched/mqueue/Make.defs index 1dc67e3567..e83cd56d4b 100644 --- a/sched/mqueue/Make.defs +++ b/sched/mqueue/Make.defs @@ -37,7 +37,7 @@ ifneq ($(CONFIG_DISABLE_MQUEUE),y) MQUEUE_SRCS = mq_open.c mq_close.c mq_unlink.c mq_send.c mq_timedsend.c MQUEUE_SRCS += mq_sndinternal.c mq_receive.c mq_timedreceive.c mq_rcvinternal.c -MQUEUE_SRCS += mq_initialize.c mq_descreate.c mq_findnamed.c mq_msgfree.c +MQUEUE_SRCS += mq_initialize.c mq_descreate.c mq_msgfree.c MQUEUE_SRCS += mq_msgqfree.c mq_release.c mq_recover.c ifneq ($(CONFIG_DISABLE_SIGNALS),y) @@ -49,4 +49,5 @@ endif DEPPATH += --dep-path mqueue VPATH += :mqueue -endif \ No newline at end of file +endif + diff --git a/sched/mqueue/mq_close.c b/sched/mqueue/mq_close.c index 36caf05ebd..0a26cc8d3b 100644 --- a/sched/mqueue/mq_close.c +++ b/sched/mqueue/mq_close.c @@ -115,7 +115,7 @@ int mq_close(mqd_t mqdes) { FAR struct tcb_s *rtcb = (FAR struct tcb_s*)g_readytorun.head; FAR struct task_group_s *group = rtcb->group; - FAR msgq_t *msgq; + FAR struct mqueue_inode_s *msgq; irqstate_t saved_state; int ret = ERROR; diff --git a/sched/mqueue/mq_descreate.c b/sched/mqueue/mq_descreate.c index e4af89e429..237085d71a 100644 --- a/sched/mqueue/mq_descreate.c +++ b/sched/mqueue/mq_descreate.c @@ -134,7 +134,8 @@ static mqd_t mq_desalloc(void) * ****************************************************************************/ -mqd_t mq_descreate(FAR struct tcb_s* mtcb, FAR msgq_t* msgq, int oflags) +mqd_t mq_descreate(FAR struct tcb_s* mtcb, FAR struct mqueue_inode_s* msgq, + int oflags) { FAR struct task_group_s *group = mtcb->group; mqd_t mqdes; diff --git a/sched/mqueue/mq_findnamed.c b/sched/mqueue/mq_findnamed.c deleted file mode 100644 index 0ef4f221da..0000000000 --- a/sched/mqueue/mq_findnamed.c +++ /dev/null @@ -1,105 +0,0 @@ -/************************************************************************ - * sched/mqueue/mq_findnamed.c - * - * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ************************************************************************/ - -/************************************************************************ - * Included Files - ************************************************************************/ - -#include - -#include - -#include "mqueue/mqueue.h" - -/************************************************************************ - * Definitions - ************************************************************************/ - -/************************************************************************ - * Private Type Declarations - ************************************************************************/ - -/************************************************************************ - * Global Variables - ************************************************************************/ - -/************************************************************************ - * Private Variables - ************************************************************************/ - -/************************************************************************ - * Private Functions - ************************************************************************/ - -/************************************************************************ - * Public Functions - ************************************************************************/ - -/************************************************************************ - * Name: mq_findnamed - * - * Description: - * This function finds the named message queue with the specified name - * in the list of message queues. - * - * Inputs: - * mq_name - the name of the message queue to find - * - * Return Value: - * A reference to the matching named message queue structure (or NULL - * if none was found). - * - ************************************************************************/ - -FAR msgq_t *mq_findnamed(const char *mq_name) -{ - FAR msgq_t *msgq; - - /* Search the list of named message queues */ - - for (msgq = (FAR msgq_t*)g_msgqueues.head; (msgq); msgq = msgq->flink) - { - /* Break out of the lloop with a non-NULL msgq if the - * name matches. - */ - - if (!strcmp(mq_name, msgq->name)) - { - break; - } - } - - return msgq; -} diff --git a/sched/mqueue/mq_initialize.c b/sched/mqueue/mq_initialize.c index 99e4d5c0a0..1d06b9c13b 100644 --- a/sched/mqueue/mq_initialize.c +++ b/sched/mqueue/mq_initialize.c @@ -65,10 +65,6 @@ struct mq_des_block_s * Global Variables ************************************************************************/ -/* This is a list of all opened message queues */ - -sq_queue_t g_msgqueues; - /* The g_msgfree is a list of messages that are available for general * use. The number of messages in this list is a system configuration * item. @@ -171,10 +167,6 @@ static mqmsg_t *mq_msgblockalloc(sq_queue_t *queue, uint16_t nmsgs, void mq_initialize(void) { - /* Initialize the list of message queues */ - - sq_init(&g_msgqueues); - /* Initialize the message free lists */ sq_init(&g_msgfree); diff --git a/sched/mqueue/mq_msgqfree.c b/sched/mqueue/mq_msgqfree.c index 808e021e32..ba54453f06 100644 --- a/sched/mqueue/mq_msgqfree.c +++ b/sched/mqueue/mq_msgqfree.c @@ -85,7 +85,7 @@ * ************************************************************************/ -void mq_msgqfree(FAR msgq_t *msgq) +void mq_msgqfree(FAR struct mqueue_inode_s *msgq) { FAR mqmsg_t *curr; FAR mqmsg_t *next; diff --git a/sched/mqueue/mq_notify.c b/sched/mqueue/mq_notify.c index 891cb46f4d..8224050694 100644 --- a/sched/mqueue/mq_notify.c +++ b/sched/mqueue/mq_notify.c @@ -127,7 +127,7 @@ int mq_notify(mqd_t mqdes, const struct sigevent *notification) { struct tcb_s *rtcb; - msgq_t *msgq; + struct mqueue_inode_s *msgq; int errval; /* Was a valid message queue descriptor provided? */ diff --git a/sched/mqueue/mq_open.c b/sched/mqueue/mq_open.c index db1012788f..b70582c250 100644 --- a/sched/mqueue/mq_open.c +++ b/sched/mqueue/mq_open.c @@ -110,7 +110,7 @@ mqd_t mq_open(const char *mq_name, int oflags, ...) { FAR struct tcb_s *rtcb = (FAR struct tcb_s*)g_readytorun.head; - FAR msgq_t *msgq; + FAR struct mqueue_inode_s *msgq; mqd_t mqdes = NULL; va_list arg; /* Points to each un-named argument */ struct mq_attr *attr; /* MQ creation attributes */ @@ -152,11 +152,11 @@ mqd_t mq_open(const char *mq_name, int oflags, ...) else if ((oflags & O_CREAT) != 0) { /* Allocate memory for the new message queue. The size to - * allocate is the size of the msgq_t header plus the size - * of the message queue name+1. + * allocate is the size of the struct mqueue_inode_s header + * plus the size of the message queue name+1. */ - msgq = (FAR msgq_t*)kmm_zalloc(SIZEOF_MQ_HEADER + namelen + 1); + msgq = (FAR struct mqueue_inode_s*)kmm_zalloc(SIZEOF_MQ_HEADER + namelen + 1); if (msgq) { /* Create a message queue descriptor for the TCB */ diff --git a/sched/mqueue/mq_rcvinternal.c b/sched/mqueue/mq_rcvinternal.c index 9a355aa0b9..33b2441bd4 100644 --- a/sched/mqueue/mq_rcvinternal.c +++ b/sched/mqueue/mq_rcvinternal.c @@ -157,7 +157,7 @@ int mq_verifyreceive(mqd_t mqdes, void *msg, size_t msglen) FAR mqmsg_t *mq_waitreceive(mqd_t mqdes) { FAR struct tcb_s *rtcb; - FAR msgq_t *msgq; + FAR struct mqueue_inode_s *msgq; FAR mqmsg_t *rcvmsg; /* Get a pointer to the message queue */ @@ -249,7 +249,7 @@ ssize_t mq_doreceive(mqd_t mqdes, mqmsg_t *mqmsg, void *ubuffer, int *prio) { FAR struct tcb_s *btcb; irqstate_t saved_state; - FAR msgq_t *msgq; + FAR struct mqueue_inode_s *msgq; ssize_t rcvmsglen; /* Get the length of the message (also the return value) */ diff --git a/sched/mqueue/mq_send.c b/sched/mqueue/mq_send.c index a365c6eba5..17a92975f9 100644 --- a/sched/mqueue/mq_send.c +++ b/sched/mqueue/mq_send.c @@ -117,7 +117,7 @@ int mq_send(mqd_t mqdes, const void *msg, size_t msglen, int prio) { - FAR msgq_t *msgq; + FAR struct mqueue_inode_s *msgq; FAR mqmsg_t *mqmsg = NULL; irqstate_t saved_state; int ret = ERROR; diff --git a/sched/mqueue/mq_sndinternal.c b/sched/mqueue/mq_sndinternal.c index c499ff1f8d..91fa164928 100644 --- a/sched/mqueue/mq_sndinternal.c +++ b/sched/mqueue/mq_sndinternal.c @@ -240,7 +240,7 @@ FAR mqmsg_t *mq_msgalloc(void) int mq_waitsend(mqd_t mqdes) { FAR struct tcb_s *rtcb; - FAR msgq_t *msgq; + FAR struct mqueue_inode_s *msgq; /* Get a pointer to the message queue */ @@ -327,7 +327,7 @@ int mq_waitsend(mqd_t mqdes) int mq_dosend(mqd_t mqdes, FAR mqmsg_t *mqmsg, const void *msg, size_t msglen, int prio) { FAR struct tcb_s *btcb; - FAR msgq_t *msgq; + FAR struct mqueue_inode_s *msgq; FAR mqmsg_t *next; FAR mqmsg_t *prev; irqstate_t saved_state; diff --git a/sched/mqueue/mq_timedsend.c b/sched/mqueue/mq_timedsend.c index 84d05db06f..46879b1352 100644 --- a/sched/mqueue/mq_timedsend.c +++ b/sched/mqueue/mq_timedsend.c @@ -184,7 +184,7 @@ int mq_timedsend(mqd_t mqdes, const char *msg, size_t msglen, int prio, const struct timespec *abstime) { FAR struct tcb_s *rtcb = (FAR struct tcb_s *)g_readytorun.head; - FAR msgq_t *msgq; + FAR struct mqueue_inode_s *msgq; FAR mqmsg_t *mqmsg = NULL; irqstate_t saved_state; int ret = ERROR; diff --git a/sched/mqueue/mq_unlink.c b/sched/mqueue/mq_unlink.c index 5481ded832..5b33a4314a 100644 --- a/sched/mqueue/mq_unlink.c +++ b/sched/mqueue/mq_unlink.c @@ -90,9 +90,9 @@ int mq_unlink(const char *mq_name) { - FAR msgq_t *msgq; - irqstate_t saved_state; - int ret = ERROR; + FAR struct mqueue_inode_s *msgq; + irqstate_t saved_state; + int ret = ERROR; /* Verify the input values */ diff --git a/sched/mqueue/mq_waitirq.c b/sched/mqueue/mq_waitirq.c index f801bb1c93..c5afdb0547 100644 --- a/sched/mqueue/mq_waitirq.c +++ b/sched/mqueue/mq_waitirq.c @@ -92,7 +92,7 @@ void mq_waitirq(FAR struct tcb_s *wtcb, int errcode) { - FAR msgq_t *msgq; + FAR struct mqueue_inode_s *msgq; irqstate_t saved_state; /* Disable interrupts. This is necessary because an interrupt handler may diff --git a/sched/mqueue/mqueue.h b/sched/mqueue/mqueue.h index 240bc26e6a..1de2866b4a 100644 --- a/sched/mqueue/mqueue.h +++ b/sched/mqueue/mqueue.h @@ -56,7 +56,7 @@ #if CONFIG_MQ_MAXMSGSIZE > 0 /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #define MQ_MAX_BYTES CONFIG_MQ_MAXMSGSIZE @@ -86,8 +86,6 @@ enum mqalloc_e MQ_ALLOC_IRQ /* Preallocated, reserved for interrupt handling */ }; -typedef enum mqalloc_e mqalloc_t; - /* This structure describes one buffered POSIX message. */ struct mqmsg @@ -117,10 +115,6 @@ extern "C" #define EXTERN extern #endif -/* This is a list of all opened message queues */ - -EXTERN sq_queue_t g_msgqueues; - /* The g_msgfree is a list of messages that are available for general use. * The number of messages in this list is a system configuration item. */