fc_atomic.h: add FC_ATOMIC_SET

storage_pool
YuQing 2021-01-11 16:22:07 +08:00
parent 3b2b9d6176
commit 1f126476bc
3 changed files with 16 additions and 1 deletions

View File

@ -1,4 +1,7 @@
Version 1.47 2021-01-11
* fc_atomic.h: add FC_ATOMIC_SET
Version 1.46 2020-12-29
* add function get_time_item_from_conf_ex
* INI_FIND_ITEM just break instead of return

View File

@ -62,5 +62,5 @@ rm -rf %{buildroot}
/usr/include/fastcommon/*
%changelog
* Mon Jun 23 2014 Zaixue Liao <liaozaixue@yongche.com>
* Mon Jun 23 2014 Zaixue Liao
- first RPM release (1.0)

View File

@ -28,6 +28,18 @@ extern "C" {
old_value = __sync_add_and_fetch(&var, 0); \
} while (new_value != old_value)
#define FC_ATOMIC_SET(var, new_value) \
do { \
typeof(var) _old_value; \
_old_value = var; \
do { \
if (__sync_bool_compare_and_swap(&var, _old_value, new_value)) { \
break; \
} \
_old_value = __sync_add_and_fetch(&var, 0); \
} while (new_value != _old_value); \
} while (0)
#ifdef __cplusplus
}
#endif