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


##########
include/nuttx/spinlock_type.h:
##########
@@ -64,22 +58,46 @@ typedef struct spinlock_s
 
 #  define SP_UNLOCKED (spinlock_t){0, 0}
 #  define SP_LOCKED   (spinlock_t){0, 1}
-
-#else
+#elif defined(CONFIG_SPINLOCK) || !defined(CONFIG_HAVE_ZERO_SIZE_ARRAY)
+#  if defined(CONFIG_ARCH_HAVE_TESTSET)
 
 /* The architecture specific spinlock.h header file must also provide the
  * following:
  *
- *   SP_LOCKED   - A definition of the locked state value (usually 1)
- *   SP_UNLOCKED - A definition of the unlocked state value (usually 0)
- *   spinlock_t  - The type of a spinlock memory object.
+ *   UP_SP_LOCKED   - A definition of the locked state value (usually 1)
+ *   UP_SP_UNLOCKED - A definition of the unlocked state value (usually 0)
+ *   _spinlock_t     - The type of a spinlock memory object.
  *
- * SP_LOCKED and SP_UNLOCKED must be constants of type spinlock_t.
+ * UP_SP_LOCKED and UP_SP_UNLOCKED must be constants of type spinlock_t.
  */
 
-#include <arch/spinlock.h>
+#  include <arch/spinlock.h>
+#  else
+typedef uint8_t _spinlock_t;
+
+#    define UP_SP_UNLOCKED 0  /* The Un-locked state */
+#    define UP_SP_LOCKED   1  /* The Locked state */
+#  endif
 
-#endif /* CONFIG_SPINLOCK */
+typedef _spinlock_t spinlock_t;
+
+#  define SP_UNLOCKED UP_SP_UNLOCKED
+#  define SP_LOCKED   UP_SP_LOCKED
+#else
+#  define SP_LOCKED      SP_UNLOCKED
+#  define SP_UNLOCKED    \
+     (struct spinlock_s) \
+     {                   \
+       .lock = {}        \
+     }
+
+struct spinlock_s
+{
+  uint8_t lock[0];

Review Comment:
   do we have the size diff in AMP mode if apply this change or not?



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