xkaraman left a comment (kamailio/kamailio#4515)

Hey @n2p-litvinov,

I have some comments on this after some testing with it.

TLDR:

So, 
1. for Make, `CC_GCC_LIKE_ASM` def for `aarch64` should be provided for the 
header to be included at all.
2. def `HAVE_ASM_INLINE_ATOMIC_OPS` and `HAVE_ASM_INLINE_MEMBAR` so 
atomic_unknown is not included if not nessecary

------
As it currently stands, i don't think the `atomic_stdatomic.h` is included 
anywhere as of now (at least on linux aarch64 sever i am testing with).

There is this definition `CC_GCC_LIKE_ASM` missing in the current Makefiles for 
aarch64, so that `atomic_native.h` include anything at all. Therefore the build 
might succeed in the current form but it's not using `atomic_stdatomic` but 
`atomic_unknown.h`.

Even after i modify the makefiles to define the nessecary defintion then the 
build fails with:

```
core/atomic/atomic_unknown.h:260:19: error: redefinition of ‘mb_atomic_get_int’
  260 | inline static int mb_atomic_get_int(volatile int *v)
      |                   ^~~~~~~~~~~~~~~~~
core/parser/../mem/../atomic/atomic_stdatomic.h:263:19: note: previous 
definition of ‘mb_atomic_get_int’ with type ‘int(volatile int *)’
  263 | inline static int mb_atomic_get_int(volatile int *v)
      |                   ^~~~~~~~~~~~~~~~~
core/atomic/atomic_unknown.h:273:20: error: redefinition of ‘mb_atomic_get_long’
  273 | inline static long mb_atomic_get_long(volatile long *v)
      |                    ^~~~~~~~~~~~~~~~~~
core/parser/../mem/../atomic/atomic_stdatomic.h:332:20: note: previous 
definition of ‘mb_atomic_get_long’ with type ‘long int(volatile long int *)’
  332 | inline static long mb_atomic_get_long(volatile long *v)
      |                    ^~~~~~~~~~~~~~~~~~
```

because both stdatomic and unknown are included. this is due to 
 
```
/*! \brief if no native operations, emulate them using locks */
#if !defined HAVE_ASM_INLINE_ATOMIC_OPS || !defined HAVE_ASM_INLINE_MEMBAR
#warning "no native atomic ops, atomic_unknown.h will be used"
#include "atomic/atomic_unknown.h"
 
#endif /* if HAVE_ASM_INLINE_ATOMIC_OPS */
 ```
which requires `HAVE_ASM_INLINE_ATOMIC_OPS`  and `HAVE_ASM_INLINE_MEMBAR` to be 
defined or otherwise it will include the unknown variant.

These two definition are each defined in their respective `atomic_[arch].h` if 
applicable, so i guess `atomic_stdatomic` should too.
 
If you try to compile with cmake you get these errors from the beginning 
because we already provide the `CC_GCC_LIKE_ASM` for aarch64. 

At first try, i tried using `FUTEX` lock method which heavily used atomic, but 
these errors and some other probably related to this, compilation did not 
complete.

Then i tried compiling with `PTHREAD_MUTEX` lock method, with the same errors 
as makefile, redefinition of multiple functions.



-- 
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/4515#issuecomment-3656305946
You are receiving this because you are subscribed to this thread.

Message ID: <kamailio/kamailio/pull/4515/[email protected]>
_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to