jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2040890461
########## include/nuttx/semaphore.h: ########## @@ -45,23 +45,43 @@ /* semcount, flags, waitlist, hhead */ # define NXSEM_INITIALIZER(c, f) \ - {(c), (f), SEM_WAITLIST_INITIALIZER, NULL} + {{c}, (f), SEM_WAITLIST_INITIALIZER, NULL} # else /* semcount, flags, waitlist, holder[2] */ # define NXSEM_INITIALIZER(c, f) \ - {(c), (f), SEM_WAITLIST_INITIALIZER, SEMHOLDER_INITIALIZER} + {{(c)}, (f), SEM_WAITLIST_INITIALIZER, SEMHOLDER_INITIALIZER} # endif #else /* CONFIG_PRIORITY_INHERITANCE */ /* semcount, flags, waitlist */ # define NXSEM_INITIALIZER(c, f) \ - {(c), (f), SEM_WAITLIST_INITIALIZER} + {{(c)}, (f), SEM_WAITLIST_INITIALIZER} #endif /* CONFIG_PRIORITY_INHERITANCE */ -/* Macro to retrieve sem count */ +/* Macros to retrieve sem count and to check if nxsem is mutex */ -#define NXSEM_COUNT(s) ((FAR atomic_t *)&(s)->semcount) +#define NXSEM_COUNT(s) ((FAR atomic_t *)&(s)->val.semcount) +#define NXSEM_IS_MUTEX(s) (((s)->flags & SEM_TYPE_MUTEX) != 0) + +/* Mutex related helper macros */ + +#define NXMUTEX_BLOCKS_BIT (((uint32_t)1) << 31) + +#define NXMUTEX_NO_HOLDER ((uint32_t)0x7ffffffe) +#define NXMUTEX_RESET ((uint32_t)0x7fffffff) + +/* Macro to retrieve mutex's atomic holder's ptr */ + +#define NXMUTEX_HOLDER(s) ((FAR atomic_t *)&(s)->val.mholder) + +/* Check if holder value (TID) is not NO_HOLDER or RESET */ + +#define NXMUTEX_ACQUIRED(h) (!(((h) & NXMUTEX_NO_HOLDER) == NXMUTEX_NO_HOLDER)) + +/* Check if mutex is acquired and blocks some other task */ + +#define NXMUTEX_BLOCKS(h) (NXMUTEX_ACQUIRED(h) && ((h) & NXMUTEX_BLOCKS_BIT)) Review Comment: no need. this was leftover from some earlier version, thanks -- 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