anchao commented on code in PR #7088:
URL: https://github.com/apache/incubator-nuttx/pull/7088#discussion_r1000107066


##########
sched/mqueue/msg.h:
##########
@@ -0,0 +1,98 @@
+/********************************************************************************
+ * sched/mqueue/msg.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ 
********************************************************************************/
+
+#ifndef __SCHED_MQUEUE_MSG_H
+#define __SCHED_MQUEUE_MSG_H
+
+/********************************************************************************
+ * Included Files
+ 
********************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+
+#include <nuttx/irq.h>
+#include <nuttx/list.h>
+#include <nuttx/mqueue.h>
+#include <sys/msg.h>
+
+#include <errno.h>
+
+#if defined(CONFIG_MQ_MAXMSGSIZE) && CONFIG_MQ_MAXMSGSIZE > 0
+
+/********************************************************************************
+ * Pre-processor Definitions
+ 
********************************************************************************/
+
+#define MSG_MAX_BYTES   CONFIG_MQ_MAXMSGSIZE
+#define MSG_MAX_MSGS    16
+
+/********************************************************************************
+ * Public Type Definitions
+ 
********************************************************************************/
+
+struct msgq_s
+{
+  struct mqueue_cmn_s  cmn;
+  struct list_node     msglist;       /* Prioritized message list */
+  key_t                key;
+  int16_t              maxmsgs;       /* Maximum number of messages in the 
queue */
+  int16_t              nmsgs;         /* Number of message in the queue */
+  uint16_t             maxmsgsize;    /* Max size of message in message queue 
*/
+};
+
+struct msgbuf_s
+{
+  struct list_node node;
+  uint16_t         msize;                /* Message data length */
+  long             mtype;                /* Message type, must be > 0 */
+  char             mtext[MSG_MAX_BYTES]; /* Message data */
+};
+
+/********************************************************************************
+ * Public Data
+ 
********************************************************************************/
+
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+EXTERN struct list_node g_msgfreelist;
+
+/********************************************************************************

Review Comment:
   Done



##########
sched/mqueue/msgctl.c:
##########
@@ -0,0 +1,124 @@
+/****************************************************************************
+ * sched/mqueue/msgctl.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "mqueue/msg.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: msgctl
+ *
+ * Description:
+ *   System V message control operations.
+ *   msgctl() performs the control operation specified by cmd on the
+ *   System V message queue with identifier msqid.
+ *
+ * Input Parameters:
+ *   msqid    - System V message queue identifier
+ *   cmd      - Command operations
+ *   msqid_ds - Defines a message queue
+ *
+ * Returned Value:
+ *   On success, IPC_STAT, IPC_SET, and IPC_RMID return 0.  A
+ *   successful IPC_INFO or MSG_INFO operation returns the index of
+ *   the highest used entry in the kernel's internal array recording
+ *   information about all message queues.  (This information can be
+ *   used with repeated MSG_STAT or MSG_STAT_ANY operations to obtain
+ *   information about all queues on the system.)  A successful
+ *   MSG_STAT or MSG_STAT_ANY operation returns the identifier of the
+ *   queue whose index was given in msqid.
+ *
+ *   On failure, -1 is returned and errno is set to indicate the error.
+ *
+ ****************************************************************************/
+
+int msgctl(int msqid, int cmd, struct msqid_ds *buf)
+{
+  FAR struct msgq_s *msgq;
+  irqstate_t flags;
+  int ret = OK;
+
+  flags = enter_critical_section();
+
+  msgq = nxmsg_lookup((key_t)msqid);

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to