pussuw commented on code in PR #16226:
URL: https://github.com/apache/nuttx/pull/16226#discussion_r2048637427


##########
include/nuttx/msgq.h:
##########
@@ -0,0 +1,315 @@
+/****************************************************************************
+ * include/nuttx/msgq.h
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * 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 ___INCLUDE_NUTTX_MSGQ_H
+#define ___INCLUDE_NUTTX_MSGQ_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/irq.h>
+#include <nuttx/semaphore.h>
+#include <nuttx/circbuf.h>
+#include <nuttx/spinlock.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: NXMSGQ_INITIALIZER
+ *
+ * Description:
+ *   Statically define and initialize a message queue.
+ *
+ *   The message queue's ring buffer contains space for max_msgs messages,
+ *   each of which is msg_size bytes long.
+ *
+ * Input Parameters:
+ *   buffer   - Ring buffer of Message Queue
+ *   msg_size - Message size (in bytes).
+ *   max_msgs - Maximum number of messages that can be queued.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SMP
+#  define NXMSGQ_INITIALIZER(buffer, msg_size, max_msgs) \
+    { \
+      CIRCBUF_INITIALIZER(buffer, msg_size * max_msgs), \
+      msg_size, \
+      NXSEM_INITIALIZER(0, 0), \
+      NXSEM_INITIALIZER(0, 0), \
+      false, \
+      SP_UNLOCKED, \
+    }
+#else
+#  define NXMSGQ_INITIALIZER(buffer, msg_size, max_msgs) \
+    { \
+      CIRCBUF_INITIALIZER(buffer, msg_size * max_msgs), \
+      msg_size, \
+      NXSEM_INITIALIZER(0, 0), \
+      NXSEM_INITIALIZER(0, 0), \
+      false, \
+    }
+#endif
+
+/****************************************************************************
+ * Public Type Declarations
+ ****************************************************************************/
+
+/* This structure defines a kernel message queue */
+
+typedef struct nxmsgq
+{
+  struct circbuf_s cbuf;

Review Comment:
   Would using a linked list (sq or dq) be an option here? The messages 
themselves would obviously need a bit more space, but it would remove the 
"max_msgs" limit from this implementation ?



-- 
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