MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
solaris.h
1 /* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation; version 2 of the License.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software
14  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15 
16 #ifndef _atomic_h_cleanup_
17 #define _atomic_h_cleanup_ "atomic/solaris.h"
18 
19 #include <atomic.h>
20 
21 #define MY_ATOMIC_MODE "solaris-atomic"
22 
23 #if defined(__GNUC__)
24 #define atomic_typeof(T,V) __typeof__(V)
25 #else
26 #define atomic_typeof(T,V) T
27 #endif
28 
29 #define uintptr_t void *
30 #define atomic_or_ptr_nv(X,Y) (void *)atomic_or_ulong_nv((volatile ulong_t *)X, Y)
31 
32 #define make_atomic_cas_body(S) \
33  atomic_typeof(uint ## S ## _t, *cmp) sav; \
34  sav = atomic_cas_ ## S( \
35  (volatile uint ## S ## _t *)a, \
36  (uint ## S ## _t)*cmp, \
37  (uint ## S ## _t)set); \
38  if (! (ret= (sav == *cmp))) \
39  *cmp= sav;
40 
41 #define make_atomic_add_body(S) \
42  int ## S nv; /* new value */ \
43  nv= atomic_add_ ## S ## _nv((volatile uint ## S ## _t *)a, v); \
44  v= nv - v
45 
46 /* ------------------------------------------------------------------------ */
47 
48 #ifdef MY_ATOMIC_MODE_DUMMY
49 
50 #define make_atomic_load_body(S) ret= *a
51 #define make_atomic_store_body(S) *a= v
52 
53 #else /* MY_ATOMIC_MODE_DUMMY */
54 
55 #define make_atomic_load_body(S) \
56  ret= atomic_or_ ## S ## _nv((volatile uint ## S ## _t *)a, 0)
57 
58 #define make_atomic_store_body(S) \
59  (void) atomic_swap_ ## S((volatile uint ## S ## _t *)a, (uint ## S ## _t)v)
60 
61 #endif
62 
63 #define make_atomic_fas_body(S) \
64  v= atomic_swap_ ## S((volatile uint ## S ## _t *)a, (uint ## S ## _t)v)
65 
66 #else /* cleanup */
67 
68 #undef uintptr_t
69 #undef atomic_or_ptr_nv
70 
71 #endif
72