You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Currently atomic_t in atomic.h is set as int. On 32 bit platforms it is then ok to use it with pointers since they are the same size but not on 64 bit platforms. Code like:
int *p = (int *)0x12348985679890;
bool res = atomic_cas((atomic_t *)&p, (atomic_val_t)p, 0);
compiles with warning on qemu_x86_64 and sets to 0 only bottom 32 bits and returns true.
On the other hand using __atomic_compare_exchange_n directly works fine for pointers and integers.
I intend to use atomic_cas with pointers to locklessly control access to a module which has callback (if callback is set module is busy) and it cannot be done right now for 64 bit platforms. Something like:
if (atomic_cas(&obj->callback, NULL, callback) == false) {
return -EBUSY;
}
Describe the solution you'd l`ike
Create atomic_ptr_t type and set of atomic_ptr_cas(), atomic_ptr_set(), atomic_ptr_get() and atomic_ptr_clear() functions.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Currently
atomic_t
inatomic.h
is set asint
. On 32 bit platforms it is then ok to use it with pointers since they are the same size but not on 64 bit platforms. Code like:compiles with warning on qemu_x86_64 and sets to 0 only bottom 32 bits and returns true.
On the other hand using
__atomic_compare_exchange_n
directly works fine for pointers and integers.I intend to use
atomic_cas
with pointers to locklessly control access to a module which has callback (if callback is set module is busy) and it cannot be done right now for 64 bit platforms. Something like:Describe the solution you'd l`ike
Create
atomic_ptr_t
type and set ofatomic_ptr_cas()
,atomic_ptr_set()
,atomic_ptr_get()
andatomic_ptr_clear()
functions.The text was updated successfully, but these errors were encountered: