2 * Copyright (c) 2008-2009
3 * The Linux Box Corporation
6 * Permission is granted to use, copy, create derivative works
7 * and redistribute this software and such derivative works
8 * for any purpose, so long as the name of the Linux Box
9 * Corporation is not used in any advertising or publicity
10 * pertaining to the use or distribution of this software
11 * without specific, written prior authorization. If the
12 * above copyright notice or any other identification of the
13 * Linux Box Corporation is included in any copy of any
14 * portion of this software, then the disclaimer below must
17 * This software is provided as is, without representation
18 * from the Linux Box Corporation as to its fitness for any
19 * purpose, and without warranty by the Linux Box Corporation
20 * of any kind, either express or implied, including
21 * without limitation the implied warranties of
22 * merchantability and fitness for a particular purpose. The
23 * regents of the Linux Box Corporation shall not be liable
24 * for any damages, including special, indirect, incidental, or
25 * consequential damages, with respect to any claim arising
26 * out of or in connection with the use of the software, even
27 * if it has been or is hereafter advised of the possibility of
31 #ifndef OSI_MCAS_ATOMIC_H
32 #define OSI_MCAS_ATOMIC_H
34 #include "portable_defns.h" /* FASPO, CASIO, etc. */
36 #define CASIO_ATOMICS 1
38 typedef unsigned long osi_atomic_t
;
43 #warning Compiling with new CASIO atomic inc/dec
45 /* these update in place, discarding the result */
46 #define osi_atomic_inc(x) ADD_TO((x), 1UL)
47 #define osi_atomic_dec(x) SUB_FROM((x), 1UL)
48 #define osi_atomic_dec_n(x, n) SUB_FROM((x), (n))
50 /* these return the old value of x when the update succeeds */
51 #define osi_atomic_add_n_r(x, n, r) ADD_TO_RETURNING_OLD((x), (n), (r))
52 #define osi_atomic_sub_n_r(x, n, r) SUB_FROM_RETURNING_OLD((x), (n), (r))
53 #define osi_atomic_inc_r(x, r) ADD_TO_RETURNING_OLD((x), 1UL, (r))
54 #define osi_atomic_dec_r(x, r) SUB_FROM_RETURNING_OLD((x), 1UL, (r))
58 #warning Compiling with FASPO and RMB() atomic inc/dec
60 #define osi_atomic_inc(x) \
66 #define osi_atomic_dec(x) \
72 #define osi_atomic_dec_n(x, n) \
78 #endif /* old atomics */
80 #endif /* OSI_MCAS_ATOMIC_H */