Rename all arch primitives with prefix caa_
[urcu.git] / urcu / arch_generic.h
... / ...
CommitLineData
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.
13 *
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
31#ifndef CAA_CACHE_LINE_SIZE
32#define CAA_CACHE_LINE_SIZE 64
33#endif
34
35#if !defined(cmm_mc) && !defined(cmm_rmc) && !defined(cmm_wmc)
36#define CONFIG_HAVE_MEM_COHERENCY
37/*
38 * Architectures with cache coherency must _not_ define cmm_mc/cmm_rmc/cmm_wmc.
39 *
40 * For them, cmm_mc/cmm_rmc/cmm_wmc are implemented with a * simple compiler barrier;
41 * in addition, we provide defaults for cmm_mb (using GCC builtins) as well as
42 * cmm_rmb and cmm_wmb (defaulting to cmm_mb).
43 */
44
45#ifndef cmm_mb
46#define cmm_mb() __sync_synchronize()
47#endif
48
49#ifndef cmm_rmb
50#define cmm_rmb() cmm_mb()
51#endif
52
53#ifndef cmm_wmb
54#define cmm_wmb() cmm_mb()
55#endif
56
57#define cmm_mc() cmm_barrier()
58#define cmm_rmc() cmm_barrier()
59#define cmm_wmc() cmm_barrier()
60#else
61/*
62 * Architectures without cache coherency need something like the following:
63 *
64 * #define cmm_mc() arch_cache_flush()
65 * #define cmm_rmc() arch_cache_flush_read()
66 * #define cmm_wmc() arch_cache_flush_write()
67 *
68 * Of these, only cmm_mc is mandatory. cmm_rmc and cmm_wmc default to cmm_mc.
69 * cmm_mb/cmm_rmb/cmm_wmb use these definitions by default:
70 *
71 * #define cmm_mb() cmm_mc()
72 * #define cmm_rmb() cmm_rmc()
73 * #define cmm_wmb() cmm_wmc()
74 */
75
76#ifndef cmm_mb
77#define cmm_mb() cmm_mc()
78#endif
79
80#ifndef cmm_rmb
81#define cmm_rmb() cmm_rmc()
82#endif
83
84#ifndef cmm_wmb
85#define cmm_wmb() cmm_wmc()
86#endif
87
88#ifndef cmm_rmc
89#define cmm_rmc() cmm_mc()
90#endif
91
92#ifndef cmm_wmc
93#define cmm_wmc() cmm_mc()
94#endif
95#endif
96
97/* Nop everywhere except on alpha. */
98#ifndef cmm_read_barrier_depends
99#define cmm_read_barrier_depends()
100#endif
101
102#ifdef CONFIG_RCU_SMP
103#define cmm_smp_mb() cmm_mb()
104#define cmm_smp_rmb() cmm_rmb()
105#define cmm_smp_wmb() cmm_wmb()
106#define cmm_smp_mc() cmm_mc()
107#define cmm_smp_rmc() cmm_rmc()
108#define cmm_smp_wmc() cmm_wmc()
109#define cmm_smp_read_barrier_depends() cmm_read_barrier_depends()
110#else
111#define cmm_smp_mb() cmm_barrier()
112#define cmm_smp_rmb() cmm_barrier()
113#define cmm_smp_wmb() cmm_barrier()
114#define cmm_smp_mc() cmm_barrier()
115#define cmm_smp_rmc() cmm_barrier()
116#define cmm_smp_wmc() cmm_barrier()
117#define cmm_smp_read_barrier_depends()
118#endif
119
120#ifndef caa_cpu_relax
121#define caa_cpu_relax() cmm_barrier()
122#endif
123
124#ifdef __cplusplus
125}
126#endif
127
128#endif /* _URCU_ARCH_GENERIC_H */
This page took 0.023779 seconds and 4 git commands to generate.