casaroli commented on code in PR #21693:
URL: https://github.com/apache/nuttx/pull/21693#discussion_r4536935359


##########
include/pthread.h:
##########
@@ -435,9 +421,7 @@ typedef struct pthread_rwlock_s pthread_rwlock_t;
 
 struct pthread_spinlock_s
 {
-  volatile spinlock_t sp_lock;  /* Indicates if the spinlock is locked or
-                                 * not.  See the values SP_LOCKED and
-                                 * SP_UNLOCKED. */
+  int32_t sp_lock;              /* 1 if locked, 0 if not (atomic) */

Review Comment:
   Done.



##########
libs/libc/pthread/pthread_spinlock.c:
##########
@@ -26,24 +26,32 @@
 
 #include <nuttx/config.h>
 
-#include <sys/types.h>
-#include <sys/boardctl.h>
-#include <nuttx/spinlock.h>
-
-#include <assert.h>
 #include <errno.h>
-#include <nuttx/debug.h>
 #include <pthread.h>
 #include <sched.h>
 
-#ifdef CONFIG_PTHREAD_SPINLOCKS
+#include <nuttx/atomic.h>
 
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
 
 #define IMPOSSIBLE_THREAD ((pthread_t)-1)
 
+/* The lock word, used as an atomic variable */
+
+#define SPIN_WORD(l)      ((FAR atomic_t *)&(l)->sp_lock)

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

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

Reply via email to