anchao commented on code in PR #12802:
URL: https://github.com/apache/nuttx/pull/12802#discussion_r1701767121


##########
sched/event/event_post.c:
##########
@@ -0,0 +1,142 @@
+/****************************************************************************
+ * sched/event/event_post.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 <nuttx/event.h>
+#include <nuttx/sched.h>
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxevent_post_internal
+ ****************************************************************************/
+
+static inline_function int nxevent_post_internal(FAR sem_t *sem)
+{
+  int semcount;
+
+  nxsem_get_value(sem, &semcount);
+  if (semcount < 1)
+    {
+      return nxsem_post(sem);
+    }
+
+  return 0;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxevent_post
+ *
+ * Description:
+ *   Post one or more events to an event object.
+ *
+ *   This routine posts one or more events to an event object. All tasks
+ *   waiting on the event object event whose waiting conditions become
+ *   met by this posting immediately unpend.
+ *
+ *   Posting differs from setting in that posted events are merged together
+ *   with the current set of events tracked by the event object.
+ *
+ * Input Parameters:
+ *   event  - Address of the event object
+ *   events - Set of events to post to event
+ *          - Set events to 0 will be considered as any,
+ *            waking up the waiting thread immediately.
+ *
+ * Returned Value:
+ *   This is an internal OS interface and should not be used by applications.
+ *   It follows the NuttX internal error return policy:  Zero (OK) is
+ *   returned on success.  A negated errno value is returned on failure.
+ *
+ * Assumptions:
+ *   This function may be called from an interrupt handler.
+ *
+ ****************************************************************************/
+
+int nxevent_post(FAR nxevent_t *event, nxevent_mask_t events)
+{
+  FAR struct tcb_s *stcb;
+  irqstate_t flags;
+  int ret = 0;
+
+  if (event == NULL)
+    {
+      return -EINVAL;
+    }
+
+  flags = enter_critical_section();
+
+  /* NOTE: Current implementation does not support multiple waiters. */
+
+  stcb = (FAR struct tcb_s *)dq_peek(SEM_WAITLIST(&event->sem));
+  if (stcb != NULL)
+    {
+      if (events == 0)
+        {
+          events = (stcb->events != 0) ? stcb->events : ~0;
+        }
+
+      /* Specified events */
+
+      if (stcb->events)
+        {
+          events &= stcb->events;

Review Comment:
   Parameter 0 is a special value that means any events,  you could to modify 
the parameters to 0 and get the any event:
   
   ```
   while(true){
     nxevent_wait(&event,0);
    if(event.event&0x000001){A;}
    if(event.event&0x000010){B;}
   }
   ```
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to