sumpfralle commented on PR #12630:
URL: https://github.com/apache/nuttx/pull/12630#issuecomment-2209521659

   OK, I am feeling a bit stupid now.
   
   The change obviously fails to compile for non-ticket spinlock mode due to 
the interface of `spin_is_locked` (insisting on a pointer instead of a value):
   ```
   semaphore/spinlock.c: In function 'spin_lock_wo_note':
   semaphore/spinlock.c:128:25: error: lvalue required as unary '&' operand
     128 |   while (spin_is_locked(&up_testset(lock)))
         |                         ^
   ```
   
   A possible solution would be to change the interface of the macro from 
`spin_is_locked(spinlock_t*)` to `spin_is_locked(spinlock_t)`.
   
   This should work easily, since *every* caller is using the address operator 
for the macro argument:
   ```
   $ grep -r "spin_is_locked([^&]" | wc -l
   2
   $ grep -r "spin_is_locked(&" | wc -l
   71
   ```
   
   Spoiler: the two exceptions above are located in the macro definition itself.
   
   In addition, `spin_is_locked` is not used in the `nuttx-apps` repository:
   ```
   $ grep -r spin_is_locked ../nuttx-apps/ | wc -l
   0
   ```
   
   Changing the interface from a pointer to a value obviously relies on the 
argument being a *small* value (or the evaluation always being implemented as a 
preprocessor macro).
   
   But I am not in the position to judge, whether it would be acceptable to 
change the interface of `spin_is_locked`.
   
   (the obvious alternatives would be to (1) introduce another macro accepting 
a value or (2) adding conditional compilation directives around all comparisons 
related to `spinlock_t`)
   
   What do you think?


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