1b117cfe7ec09a901391befdae895b6f3acca25b
[ust.git] / libust / immediate.h
1 #ifndef _LINUX_IMMEDIATE_H
2 #define _LINUX_IMMEDIATE_H
3
4 /*
5 * Immediate values, can be updated at runtime and save cache lines.
6 *
7 * (C) Copyright 2007 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
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 #ifdef USE_IMMEDIATE
25
26 #include <asm/immediate.h>
27
28 /**
29 * imv_set - set immediate variable (with locking)
30 * @name: immediate value name
31 * @i: required value
32 *
33 * Sets the value of @name, taking the module_mutex if required by
34 * the architecture.
35 */
36 #define imv_set(name, i) \
37 do { \
38 name##__imv = (i); \
39 core_imv_update(); \
40 module_imv_update(); \
41 } while (0)
42
43 /*
44 * Internal update functions.
45 */
46 extern void core_imv_update(void);
47 extern void imv_update_range(const struct __imv *begin,
48 const struct __imv *end);
49 extern void imv_unref_core_init(void);
50 extern void imv_unref(struct __imv *begin, struct __imv *end, void *start,
51 unsigned long size);
52
53 #else
54
55 /*
56 * Generic immediate values: a simple, standard, memory load.
57 */
58
59 /**
60 * imv_read - read immediate variable
61 * @name: immediate value name
62 *
63 * Reads the value of @name.
64 */
65 #define imv_read(name) _imv_read(name)
66
67 /**
68 * imv_set - set immediate variable (with locking)
69 * @name: immediate value name
70 * @i: required value
71 *
72 * Sets the value of @name, taking the module_mutex if required by
73 * the architecture.
74 */
75 #define imv_set(name, i) (name##__imv = (i))
76
77 static inline void core_imv_update(void) { }
78 static inline void imv_unref_core_init(void) { }
79
80 #endif
81
82 #define DECLARE_IMV(type, name) extern __typeof__(type) name##__imv
83 #define DEFINE_IMV(type, name) __typeof__(type) name##__imv
84
85 #define EXPORT_IMV_SYMBOL(name) EXPORT_SYMBOL(name##__imv)
86 #define EXPORT_IMV_SYMBOL_GPL(name) EXPORT_SYMBOL_GPL(name##__imv)
87
88 /**
89 * _imv_read - Read immediate value with standard memory load.
90 * @name: immediate value name
91 *
92 * Force a data read of the immediate value instead of the immediate value
93 * based mechanism. Useful for __init and __exit section data read.
94 */
95 #define _imv_read(name) (name##__imv)
96
97 #endif
This page took 0.02977 seconds and 3 git commands to generate.