xiaoxiang781216 commented on code in PR #10605: URL: https://github.com/apache/nuttx/pull/10605#discussion_r1331350016
########## arch/arm64/include/spinlock.h: ########## @@ -83,6 +83,25 @@ * -- Clear Exclusive access monitor (CLREX) This is used to * clear the state of the Local Exclusive Monitor. */ +#if defined(CONFIG_TICKET_SPINLOCK) +#include <stdatomic.h> + +/* Memory layout is related uint64_t in arm64 little endian + * if uint64 is 0x010203040A0B0C0D, the next is 0A0B0C0D and + * the owner is 01020304. + */ + +struct ticket_spinlock_s +{ + atomic_uint next; Review Comment: it's better to use 16bit count on 32bit machine ########## arch/arm64/include/spinlock.h: ########## @@ -83,6 +83,25 @@ * -- Clear Exclusive access monitor (CLREX) This is used to * clear the state of the Local Exclusive Monitor. */ +#if defined(CONFIG_TICKET_SPINLOCK) Review Comment: let's make the implementation work with other arch too ########## arch/arm64/include/spinlock.h: ########## @@ -83,6 +83,25 @@ * -- Clear Exclusive access monitor (CLREX) This is used to * clear the state of the Local Exclusive Monitor. */ +#if defined(CONFIG_TICKET_SPINLOCK) +#include <stdatomic.h> + +/* Memory layout is related uint64_t in arm64 little endian + * if uint64 is 0x010203040A0B0C0D, the next is 0A0B0C0D and + * the owner is 01020304. + */ + +struct ticket_spinlock_s +{ + atomic_uint next; + atomic_uint owner; +}; +typedef struct ticket_spinlock_s ticket_spinlock_t; + +#define OWNER(l) (((struct ticket_spinlock_s *)l)->owner) +#define NEXT(l) (((struct ticket_spinlock_s *)l)->next) Review Comment: OWNER/NEXT macros are too general and very easy to conflict with others since spinlock.h is included in many header file. -- 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