Initial community commit
This commit is contained in:
25
Src/replicant/nu/lfitem.c
Normal file
25
Src/replicant/nu/lfitem.c
Normal file
@ -0,0 +1,25 @@
|
||||
#include "nu/lfitem.h"
|
||||
#include "foundation/atomics.h"
|
||||
|
||||
void lfitem_init(lfitem_t item)
|
||||
{
|
||||
item->item=0;
|
||||
}
|
||||
|
||||
void *lfitem_get(lfitem_t item)
|
||||
{
|
||||
return nx_atomic_swap_pointer(0, &(item->item));
|
||||
}
|
||||
|
||||
void *lfitem_set(lfitem_t item, const void *value)
|
||||
{
|
||||
return nx_atomic_swap_pointer((void *)value, &(item->item));
|
||||
}
|
||||
|
||||
void *lfitem_set_if_zero(lfitem_t item, void *value)
|
||||
{
|
||||
if (nx_atomic_cmpxchg_pointer(0, value, &(item->item)) == 0)
|
||||
return 0;
|
||||
else
|
||||
return (void *)value;
|
||||
}
|
Reference in New Issue
Block a user