1
/* Copyright (C) 2006 MySQL AB
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#ifndef my_atomic_rwlock_init
20
#ifndef MY_ATOMIC_MODE_RWLOCKS
21
#include "atomic/nolock.h"
24
#ifndef make_atomic_cas_body
25
#include "atomic/rwlock.h"
28
#ifndef make_atomic_add_body
29
#define make_atomic_add_body(S) \
31
while (!my_atomic_cas ## S(a, &tmp, tmp+v)); \
37
#define make_atomic_add(S) \
38
STATIC_INLINE int ## S my_atomic_add ## S( \
39
int ## S volatile *a, int ## S v) \
41
make_atomic_add_body(S); \
45
#define make_atomic_swap(S) \
46
STATIC_INLINE int ## S my_atomic_swap ## S( \
47
int ## S volatile *a, int ## S v) \
49
make_atomic_swap_body(S); \
53
#define make_atomic_cas(S) \
54
STATIC_INLINE int my_atomic_cas ## S(int ## S volatile *a, \
55
int ## S *cmp, int ## S set) \
58
make_atomic_cas_body(S); \
62
#define make_atomic_load(S) \
63
STATIC_INLINE int ## S my_atomic_load ## S(int ## S volatile *a) \
66
make_atomic_load_body(S); \
70
#define make_atomic_store(S) \
71
STATIC_INLINE void my_atomic_store ## S( \
72
int ## S volatile *a, int ## S v) \
74
make_atomic_store_body(S); \
77
#else /* no inline functions */
79
#define make_atomic_add(S) \
80
extern int ## S my_atomic_add ## S(int ## S volatile *a, int ## S v);
82
#define make_atomic_swap(S) \
83
extern int ## S my_atomic_swap ## S(int ## S volatile *a, int ## S v);
85
#define make_atomic_cas(S) \
86
extern int my_atomic_cas ## S(int ## S volatile *a, int ## S *cmp, int ## S set);
88
#define make_atomic_load(S) \
89
extern int ## S my_atomic_load ## S(int ## S volatile *a);
91
#define make_atomic_store(S) \
92
extern void my_atomic_store ## S(int ## S volatile *a, int ## S v);
108
make_atomic_load(ptr)
110
make_atomic_store( 8)
111
make_atomic_store(16)
112
make_atomic_store(32)
113
make_atomic_store(ptr)
118
make_atomic_swap(ptr)
120
#undef make_atomic_add
121
#undef make_atomic_cas
122
#undef make_atomic_load
123
#undef make_atomic_store
124
#undef make_atomic_swap
125
#undef make_atomic_add_body
126
#undef make_atomic_cas_body
127
#undef make_atomic_load_body
128
#undef make_atomic_store_body
129
#undef make_atomic_swap_body
132
#ifdef _atomic_h_cleanup_
133
#include _atomic_h_cleanup_
134
#undef _atomic_h_cleanup_
137
#define MY_ATOMIC_OK 0
138
#define MY_ATOMIC_NOT_1CPU 1
139
extern int my_atomic_initialize();