Commit bb36fce6 authored by Rich Prohaska's avatar Rich Prohaska

add the gcc atomic builtin fetch_and_add

git-svn-id: file:///svn/tokudb@5501 c7de825b-a66e-492c-adef-691d508d4ae1
parent 58498c74
...@@ -62,6 +62,12 @@ fetch_and_add_i (volatile int *p, int incr) ...@@ -62,6 +62,12 @@ fetch_and_add_i (volatile int *p, int incr)
return result; return result;
} }
static inline int
gcc_fetch_and_add_i (volatile int *p, int incr)
{
return __sync_fetch_and_add(p, incr);
}
// Something wrong with the compiler for longs // Something wrong with the compiler for longs
/* Returns nonzero if the comparison succeeded. */ /* Returns nonzero if the comparison succeeded. */
static inline long static inline long
...@@ -139,6 +145,12 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un ...@@ -139,6 +145,12 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un
TIME("fetchadd", i, TIME("fetchadd", i,
(void)0, (void)0,
fetch_and_add_i(&fa, i)); fetch_and_add_i(&fa, i));
// printf("fa=%d\n", fa);
fa=0;
TIME("gcc_fetchadd", i,
(void)0,
gcc_fetch_and_add_i(&fa, i));
// printf("fa=%d\n", fa);
TIME("compare_and_swap", i, TIME("compare_and_swap", i,
ivals[i]=0, ivals[i]=0,
({ int r=compare_and_swap_full_i(&ivals[i], 0, 1); assert(r==1); })); ({ int r=compare_and_swap_full_i(&ivals[i], 0, 1); assert(r==1); }));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment