2 * Copyright (C) 2006-2009 Brian Aker
5 * Use and distribution licensed under the BSD license. See
6 * the COPYING file in the parent directory for full text.
12 #ifndef CLIENTS_MS_ATOMIC_H
13 #define CLIENTS_MS_ATOMIC_H
15 #if defined(__SUNPRO_C)
18 # if SIZEOF_SIZE_T == 8
19 # define atomic_add_size(X, Y) atomic_add_64((X), (Y))
20 # define atomic_add_size_nv(X, Y) atomic_add_64((X), (Y))
21 # define atomic_dec_size(X, Y) atomic_add_64((X), (Y))
22 # define atomic_dec_size_nv(X, Y) atomic_add_64((X), (Y))
24 # define atomic_add_size(X, Y) atomic_add_32((X), (Y))
25 # define atomic_add_size_nv(X, Y) atomic_add_32((X), (Y))
26 # define atomic_dec_size(X, Y) atomic_add_32((X), (Y))
27 # define atomic_dec_size_nv(X, Y) atomic_add_32((X), (Y))
31 # define atomic_add_8(X, Y) __sync_fetch_and_add((X), (Y))
32 # define atomic_add_16(X, Y) __sync_fetch_and_add((X), (Y))
33 # define atomic_add_32(X, Y) __sync_fetch_and_add((X), (Y))
34 # define atomic_add_size(X, Y) __sync_fetch_and_add((X), (Y))
35 # define atomic_dec_8(X) __sync_fetch_and_sub((X), 1)
36 # define atomic_dec_16(X) __sync_fetch_and_sub((X), 1)
37 # define atomic_dec_32(X) __sync_fetch_and_sub((X), 1)
38 # define atomic_dec_size(X) __sync_fetch_and_sub((X), 1)
39 /* The same as above, but these return the new value instead of void */
40 # define atomic_add_8_nv(X, Y) __sync_fetch_and_add((X), (Y))
41 # define atomic_add_16_nv(X, Y) __sync_fetch_and_add((X), (Y))
42 # define atomic_add_32_nv(X, Y) __sync_fetch_and_add((X), (Y))
43 # define atomic_add_size_nv(X, Y) __sync_fetch_and_add((X), (Y))
44 # define atomic_dec_8_nv(X) __sync_fetch_and_sub((X), 1)
45 # define atomic_dec_16_nv(X) __sync_fetch_and_sub((X), 1)
46 # define atomic_dec_32_nv(X) __sync_fetch_and_sub((X), 1)
47 # define atomic_dec_size_nv(X) __sync_fetch_and_sub((X), 1)
48 #endif /* defined(__SUNPRO_C) */
50 #endif /* CLIENTS_MS_ATOMIC_H */