strongswan.org
Wiki/Project Management
Downloads
Gitweb
projects
/
strongswan.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ref_get()/ref_put() use atomic gcc operations if supported, thanks to Thomas Jarosch...
[strongswan.git]
/
src
/
libstrongswan
/
utils.h
diff --git
a/src/libstrongswan/utils.h
b/src/libstrongswan/utils.h
index
af619ea
..
298253f
100644
(file)
--- a/
src/libstrongswan/utils.h
+++ b/
src/libstrongswan/utils.h
@@
-248,6
+248,14
@@
void nop();
*/
typedef volatile u_int refcount_t;
*/
typedef volatile u_int refcount_t;
+
+#ifdef HAVE_GCC_ATOMIC_OPERATIONS
+
+#define ref_get(ref) {__sync_fetch_and_add(ref, 1); }
+#define ref_put(ref) (!__sync_sub_and_fetch(ref, 1))
+
+#else /* !HAVE_GCC_ATOMIC_OPERATIONS */
+
/**
* Get a new reference.
*
/**
* Get a new reference.
*
@@
-268,6
+276,8
@@
void ref_get(refcount_t *ref);
*/
bool ref_put(refcount_t *ref);
*/
bool ref_put(refcount_t *ref);
+#endif /* HAVE_GCC_ATOMIC_OPERATIONS */
+
/**
* Get printf hooks for time.
*
/**
* Get printf hooks for time.
*