man-pages futex(2) example program using _Atomic

Alejandro Colomar alx.manpages@gmail.com
Wed Aug 17 13:37:13 GMT 2022


Hi,

The man-pages example program for the futex(2) page uses 
atomic_compare_exchange_strong(), but it seems to use it incorrectly, 
according to clang-tidy(1) (see below).  I've neved used _Atomic, and so 
I'm not confident in fixing the program.  Would you mind having a look 
at it and possibly sending a patch?

Thanks,

Alex

===

alx@asus5775:~/src/linux/man-pages/man-pages$ make 
tmp/src/man2/futex.2.d/futex.lint-c.clang-tidy.touch
LINT (clang-tidy)	tmp/src/man2/futex.2.d/futex.lint-c.clang-tidy.touch
Error while processing 
/home/alx/src/linux/man-pages/man-pages/tmp/src/man2/futex.2.d/futex.c.
/home/alx/src/linux/man-pages/man-pages/tmp/src/man2/futex.2.d/futex.c:60:13: 
error: address argument to atomic operation must be a pointer to _Atomic 
type ('uint32_t *' (aka 'unsigned int *') invalid) [clang-diagnostic-error]
         if (atomic_compare_exchange_strong(futexp, &one, 0))
             ^
/usr/lib/llvm-14/lib/clang/14.0.6/include/stdatomic.h:135:67: note: 
expanded from macro 'atomic_compare_exchange_strong'
#define atomic_compare_exchange_strong(object, expected, desired) 
__c11_atomic_compare_exchange_strong(object, expected, desired, 
__ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
                                                                   ^ 
                                ~~~~~~
/home/alx/src/linux/man-pages/man-pages/tmp/src/man2/futex.2.d/futex.c:84:9: 
error: address argument to atomic operation must be a pointer to _Atomic 
type ('uint32_t *' (aka 'unsigned int *') invalid) [clang-diagnostic-error]
     if (atomic_compare_exchange_strong(futexp, &zero, 1)) {
         ^
/usr/lib/llvm-14/lib/clang/14.0.6/include/stdatomic.h:135:67: note: 
expanded from macro 'atomic_compare_exchange_strong'
#define atomic_compare_exchange_strong(object, expected, desired) 
__c11_atomic_compare_exchange_strong(object, expected, desired, 
__ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
                                                                   ^ 
                                ~~~~~~
make: *** [lib/lint-c.mk:58: 
tmp/src/man2/futex.2.d/futex.lint-c.clang-tidy.touch] Error 1



-- 
Alejandro Colomar
<http://www.alejandro-colomar.es/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20220817/edf63771/attachment.sig>


More information about the Gcc mailing list