rculfhash: document destroy context limitations
[urcu.git] / urcu / arch / generic.h
CommitLineData
e4d1eb09
PB
1#ifndef _URCU_ARCH_GENERIC_H
2#define _URCU_ARCH_GENERIC_H
3
4/*
5 * arch_generic.h: common definitions for multiple architectures.
6 *
7 * Copyright (c) 2010 Paolo Bonzini <pbonzini@redhat.com>
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
05dd4b94 13 *
e4d1eb09
PB
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#include <urcu/compiler.h>
25#include <urcu/config.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
06f22bdb
DG
31#ifndef CAA_CACHE_LINE_SIZE
32#define CAA_CACHE_LINE_SIZE 64
e4d1eb09
PB
33#endif
34
5481ddb3 35#if !defined(cmm_mc) && !defined(cmm_rmc) && !defined(cmm_wmc)
e4d1eb09
PB
36#define CONFIG_HAVE_MEM_COHERENCY
37/*
5481ddb3 38 * Architectures with cache coherency must _not_ define cmm_mc/cmm_rmc/cmm_wmc.
e4d1eb09 39 *
d0bbd9c2
MD
40 * For them, cmm_mc/cmm_rmc/cmm_wmc are implemented with a simple
41 * compiler barrier; in addition, we provide defaults for cmm_mb (using
42 * GCC builtins) as well as cmm_rmb and cmm_wmb (defaulting to cmm_mb).
e4d1eb09
PB
43 */
44
5481ddb3
DG
45#ifndef cmm_mb
46#define cmm_mb() __sync_synchronize()
e4d1eb09
PB
47#endif
48
5481ddb3
DG
49#ifndef cmm_rmb
50#define cmm_rmb() cmm_mb()
e4d1eb09
PB
51#endif
52
5481ddb3
DG
53#ifndef cmm_wmb
54#define cmm_wmb() cmm_mb()
e4d1eb09
PB
55#endif
56
5481ddb3
DG
57#define cmm_mc() cmm_barrier()
58#define cmm_rmc() cmm_barrier()
59#define cmm_wmc() cmm_barrier()
e4d1eb09
PB
60#else
61/*
62 * Architectures without cache coherency need something like the following:
63 *
d0bbd9c2 64 * #define cmm_mc() arch_cache_flush()
5481ddb3
DG
65 * #define cmm_rmc() arch_cache_flush_read()
66 * #define cmm_wmc() arch_cache_flush_write()
e4d1eb09 67 *
d0bbd9c2
MD
68 * Of these, only cmm_mc is mandatory. cmm_rmc and cmm_wmc default to
69 * cmm_mc. cmm_mb/cmm_rmb/cmm_wmb use these definitions by default:
e4d1eb09 70 *
d0bbd9c2 71 * #define cmm_mb() cmm_mc()
5481ddb3
DG
72 * #define cmm_rmb() cmm_rmc()
73 * #define cmm_wmb() cmm_wmc()
e4d1eb09
PB
74 */
75
5481ddb3
DG
76#ifndef cmm_mb
77#define cmm_mb() cmm_mc()
e4d1eb09
PB
78#endif
79
5481ddb3
DG
80#ifndef cmm_rmb
81#define cmm_rmb() cmm_rmc()
e4d1eb09
PB
82#endif
83
5481ddb3
DG
84#ifndef cmm_wmb
85#define cmm_wmb() cmm_wmc()
e4d1eb09
PB
86#endif
87
5481ddb3
DG
88#ifndef cmm_rmc
89#define cmm_rmc() cmm_mc()
e4d1eb09
PB
90#endif
91
5481ddb3
DG
92#ifndef cmm_wmc
93#define cmm_wmc() cmm_mc()
e4d1eb09
PB
94#endif
95#endif
96
97/* Nop everywhere except on alpha. */
5481ddb3
DG
98#ifndef cmm_read_barrier_depends
99#define cmm_read_barrier_depends()
e4d1eb09
PB
100#endif
101
102#ifdef CONFIG_RCU_SMP
0bd48ad3 103#ifndef cmm_smp_mb
5481ddb3 104#define cmm_smp_mb() cmm_mb()
0bd48ad3
PB
105#endif
106#ifndef cmm_smp_rmb
5481ddb3 107#define cmm_smp_rmb() cmm_rmb()
0bd48ad3
PB
108#endif
109#ifndef cmm_smp_wmb
5481ddb3 110#define cmm_smp_wmb() cmm_wmb()
0bd48ad3
PB
111#endif
112#ifndef cmm_smp_mc
5481ddb3 113#define cmm_smp_mc() cmm_mc()
0bd48ad3
PB
114#endif
115#ifndef cmm_smp_rmc
5481ddb3 116#define cmm_smp_rmc() cmm_rmc()
0bd48ad3
PB
117#endif
118#ifndef cmm_smp_wmc
5481ddb3 119#define cmm_smp_wmc() cmm_wmc()
0bd48ad3
PB
120#endif
121#ifndef cmm_smp_read_barrier_depends
5481ddb3 122#define cmm_smp_read_barrier_depends() cmm_read_barrier_depends()
0bd48ad3 123#endif
e4d1eb09 124#else
0bd48ad3 125#ifndef cmm_smp_mb
5481ddb3 126#define cmm_smp_mb() cmm_barrier()
0bd48ad3
PB
127#endif
128#ifndef cmm_smp_rmb
5481ddb3 129#define cmm_smp_rmb() cmm_barrier()
0bd48ad3
PB
130#endif
131#ifndef cmm_smp_wmb
5481ddb3 132#define cmm_smp_wmb() cmm_barrier()
0bd48ad3
PB
133#endif
134#ifndef cmm_smp_mc
5481ddb3 135#define cmm_smp_mc() cmm_barrier()
0bd48ad3
PB
136#endif
137#ifndef cmm_smp_rmc
5481ddb3 138#define cmm_smp_rmc() cmm_barrier()
0bd48ad3
PB
139#endif
140#ifndef cmm_smp_wmc
5481ddb3 141#define cmm_smp_wmc() cmm_barrier()
0bd48ad3
PB
142#endif
143#ifndef cmm_smp_read_barrier_depends
5481ddb3 144#define cmm_smp_read_barrier_depends()
e4d1eb09 145#endif
0bd48ad3 146#endif
e4d1eb09 147
06f22bdb
DG
148#ifndef caa_cpu_relax
149#define caa_cpu_relax() cmm_barrier()
e4d1eb09
PB
150#endif
151
e4d1eb09
PB
152#ifdef __cplusplus
153}
154#endif
155
156#endif /* _URCU_ARCH_GENERIC_H */
This page took 0.052664 seconds and 4 git commands to generate.