debuggers.hg

view xen/include/xen/config.h @ 19667:5369133d772c

Introduce __must_be_array

Cloning the similar construct from Linux, allowing to detect improper
uses of ARRAY_SIZE() at build time.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed May 20 15:29:25 2009 +0100 (2009-05-20)
parents 0d7d6804af22
children f210a633571c
line source
1 /******************************************************************************
2 * config.h
3 *
4 * A Linux-style configuration list.
5 */
7 #ifndef __XEN_CONFIG_H__
8 #define __XEN_CONFIG_H__
10 #include <asm/config.h>
12 #define EXPORT_SYMBOL(var)
13 #define EXPORT_SYMBOL_GPL(var)
14 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]) + __must_be_array(x))
16 /*
17 * The following log levels are as follows:
18 *
19 * XENLOG_ERR: Fatal errors, either Xen, Guest or Dom0
20 * is about to crash.
21 *
22 * XENLOG_WARNING: Something bad happened, but we can recover.
23 *
24 * XENLOG_INFO: Interesting stuff, but not too noisy.
25 *
26 * XENLOG_DEBUG: Use where ever you like. Lots of noise.
27 *
28 *
29 * Since we don't trust the guest operating system, we don't want
30 * it to allow for DoS by causing the HV to print out a lot of
31 * info, so where ever the guest has control of what is printed
32 * we use the XENLOG_GUEST to distinguish that the output is
33 * controlled by the guest.
34 *
35 * To make it easier on the typing, the above log levels all
36 * have a corresponding _G_ equivalent that appends the
37 * XENLOG_GUEST. (see the defines below).
38 *
39 */
40 #define XENLOG_ERR "<0>"
41 #define XENLOG_WARNING "<1>"
42 #define XENLOG_INFO "<2>"
43 #define XENLOG_DEBUG "<3>"
45 #define XENLOG_GUEST "<G>"
47 #define XENLOG_G_ERR XENLOG_GUEST XENLOG_ERR
48 #define XENLOG_G_WARNING XENLOG_GUEST XENLOG_WARNING
49 #define XENLOG_G_INFO XENLOG_GUEST XENLOG_INFO
50 #define XENLOG_G_DEBUG XENLOG_GUEST XENLOG_DEBUG
52 /*
53 * Some code is copied directly from Linux.
54 * Match some of the Linux log levels to Xen.
55 */
56 #define KERN_ERR XENLOG_ERR
57 #define KERN_CRIT XENLOG_ERR
58 #define KERN_EMERG XENLOG_ERR
59 #define KERN_WARNING XENLOG_WARNING
60 #define KERN_NOTICE XENLOG_INFO
61 #define KERN_INFO XENLOG_INFO
62 #define KERN_DEBUG XENLOG_DEBUG
64 /* Linux 'checker' project. */
65 #define __iomem
66 #define __user
67 #define __force
68 #define __bitwise
70 #ifndef __ASSEMBLY__
72 int current_domain_id(void);
73 #define dprintk(_l, _f, _a...) \
74 printk(_l "%s:%d: " _f, __FILE__ , __LINE__ , ## _a )
75 #define gdprintk(_l, _f, _a...) \
76 printk(XENLOG_GUEST _l "%s:%d:d%d " _f, __FILE__, \
77 __LINE__, current_domain_id() , ## _a )
79 #include <xen/compiler.h>
81 #endif /* !__ASSEMBLY__ */
83 #define __STR(...) #__VA_ARGS__
84 #define STR(...) __STR(__VA_ARGS__)
86 #ifndef __ASSEMBLY__
87 /* Turn a plain number into a C unsigned long constant. */
88 #define __mk_unsigned_long(x) x ## UL
89 #define mk_unsigned_long(x) __mk_unsigned_long(x)
90 #else /* __ASSEMBLY__ */
91 /* In assembly code we cannot use C numeric constant suffixes. */
92 #define mk_unsigned_long(x) x
93 #endif /* !__ASSEMBLY__ */
95 #define fastcall
96 #define __cpuinitdata
97 #define __cpuinit
99 #endif /* __XEN_CONFIG_H__ */