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


##########
libs/libc/semaphore/sem_wait.c:
##########
@@ -98,3 +98,43 @@ int sem_wait(FAR sem_t *sem)
   leave_cancellation_point();
   return ERROR;
 }
+
+/****************************************************************************
+ * Name: nxsem_wait
+ *
+ * Description:
+ *   This function attempts to lock the semaphore referenced by 'sem'.  If
+ *   the semaphore value is (<=) zero, then the calling task will not return
+ *   until it successfully acquires the lock.
+ *
+ *   This is an internal OS interface.  It is functionally equivalent to
+ *   sem_wait except that:
+ *
+ *   - It is not a cancellation point, and
+ *   - It does not modify the errno value.
+ *
+ * Input Parameters:
+ *   sem - Semaphore descriptor.
+ *
+ * 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.
+ *   Possible returned errors:
+ *
+ *   - EINVAL:  Invalid attempt to get the semaphore
+ *   - EINTR:   The wait was interrupted by the receipt of a signal.
+ *
+ ****************************************************************************/
+
+#if !defined(CONFIG_BUILD_FLAT) && !defined(__KERNEL__)
+int nxsem_wait(FAR sem_t *sem)

Review Comment:
   So now the kernel has to link libc into itself ? Isn't libc a userspace API 
? I'm very confused.
   Also the prefix "nxsomething_" seems to be reserved for kernel APIs, so the 
naming is confusing as well.
   
   Is all of this necessary just because all of libc used to call the nxsem_ 
system calls and we don't want to touch those calls ?



##########
libs/libc/semaphore/sem_wait.c:
##########
@@ -98,3 +103,67 @@ int sem_wait(FAR sem_t *sem)
   leave_cancellation_point();
   return ERROR;
 }
+
+/****************************************************************************
+ * Name: nxsem_wait
+ *
+ * Description:
+ *   This function attempts to lock the semaphore referenced by 'sem'.  If
+ *   the semaphore value is (<=) zero, then the calling task will not return
+ *   until it successfully acquires the lock.
+ *
+ *   This is an internal OS interface.  It is functionally equivalent to
+ *   sem_wait except that:
+ *
+ *   - It is not a cancellation point, and
+ *   - It does not modify the errno value.
+ *
+ * Input Parameters:
+ *   sem - Semaphore descriptor.
+ *
+ * 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.
+ *   Possible returned errors:
+ *
+ *   - EINVAL:  Invalid attempt to get the semaphore
+ *   - EINTR:   The wait was interrupted by the receipt of a signal.
+ *
+ ****************************************************************************/
+
+int nxsem_wait(FAR sem_t *sem)
+{
+  DEBUGASSERT(sem != NULL);
+
+  /* This API should not be called from the idleloop or interrupt */
+
+#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
+  DEBUGASSERT(!OSINIT_IDLELOOP() || !sched_idletask() ||

Review Comment:
   What is this doing in libc



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