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


##########
include/nuttx/semaphore.h:
##########
@@ -59,6 +59,54 @@
      {(c), (f), SEM_WAITLIST_INITIALIZER}
 #endif /* CONFIG_PRIORITY_INHERITANCE */
 
+/* Fast mutex lock/unlock path */
+
+#ifndef CONFIG_LIBC_ARCH_ATOMIC
+
+#  if defined(CONFIG_PRIORITY_PROTECT) || defined(CONFIG_PRIORITY_INHERITANCE)
+#    define NXSEM_IS_FASTMUTEX(sem)                                       \
+      (((sem)->flags & (SEM_TYPE_MUTEX | SEM_PRIO_MASK)) ==               \
+       (SEM_TYPE_MUTEX | SEM_PRIO_NONE))
+#  else
+#    define NXSEM_IS_FASTMUTEX(sem) ((sem)->flags & SEM_TYPE_MUTEX)
+#  endif
+
+/* Try wait; sets ret to OK or -EAGAIN when success,
+ * -EPERM when fast locking can't be performed
+ */
+
+#  define NXSEM_TRYWAIT_FAST(sem, ret)                                    \

Review Comment:
   I also prefer inline functions. This makes the code more readable, and the 
inline implementation has already been widely used in the NuttX kernel and 
other popular RTOS, Moreover, the current code base is no longer fully 
compatible with C89 or ANSI and this issue also exists in other RTOS, and also 
the current CI/CD without related checks, I think which will be better to be 
developer-friendly.
   
   Zephyr:
   
https://github.com/zephyrproject-rtos/zephyr/blob/main/include/zephyr/kernel.h#L3342-L3345
   
   Linux:
   
https://github.com/torvalds/linux/blob/master/include/linux/semaphore.h#L37-L42
   



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