Updated copyright headers.
[awesomized/libmemcached] / clients / ms_atomic.h
1 /* LibMemcached
2 * Copyright (C) 2006-2009 Brian Aker
3 * All rights reserved.
4 *
5 * Use and distribution licensed under the BSD license. See
6 * the COPYING file in the parent directory for full text.
7 *
8 * Summary:
9 *
10 */
11
12 #ifndef CLIENTS_MS_ATOMIC_H
13 #define CLIENTS_MS_ATOMIC_H
14
15 #if defined(__SUNPRO_C)
16 # define _KERNEL
17 # include <atomic.h>
18 # undef _KERNEL
19 #else
20 # define atomic_add_8(X, Y) __sync_fetch_and_add((X), (Y))
21 # define atomic_add_16(X, Y) __sync_fetch_and_add((X), (Y))
22 # define atomic_add_32(X, Y) __sync_fetch_and_add((X), (Y))
23 # define atomic_add_64(X, Y) __sync_fetch_and_add((X), (Y))
24 # define atomic_dec_8(X) __sync_fetch_and_sub((X), 1)
25 # define atomic_dec_16(X) __sync_fetch_and_sub((X), 1)
26 # define atomic_dec_32(X) __sync_fetch_and_sub((X), 1)
27 # define atomic_dec_64(X) __sync_fetch_and_sub((X), 1)
28 /* The same as above, but these return the new value instead of void */
29 # define atomic_add_8_nv(X, Y) __sync_fetch_and_add((X), (Y))
30 # define atomic_add_16_nv(X, Y) __sync_fetch_and_add((X), (Y))
31 # define atomic_add_32_nv(X, Y) __sync_fetch_and_add((X), (Y))
32 # define atomic_add_64_nv(X, Y) __sync_fetch_and_add((X), (Y))
33 # define atomic_dec_8_nv(X) __sync_fetch_and_sub((X), 1)
34 # define atomic_dec_16_nv(X) __sync_fetch_and_sub((X), 1)
35 # define atomic_dec_32_nv(X) __sync_fetch_and_sub((X), 1)
36 # define atomic_dec_64_nv(X) __sync_fetch_and_sub((X), 1)
37 #endif /* defined(__SUNPRO_C) */
38
39 #endif /* CLIENTS_MS_ATOMIC_H */