ia64/xen-unstable

view xen/include/xen/lib.h @ 11212:ca9f3a7b1b03

[XEN] Remove shadow2 dependencies from common code.
Disable debugtrace functionality even in debug builds:
it's currently only used by shadow2 maintainers.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Fri Aug 18 17:59:26 2006 +0100 (2006-08-18)
parents 0f917d63e960
children 3409c35a0b0e
line source
1 #ifndef __LIB_H__
2 #define __LIB_H__
4 #include <xen/inttypes.h>
5 #include <stdarg.h>
6 #include <xen/config.h>
7 #include <xen/types.h>
8 #include <xen/xmalloc.h>
9 #include <xen/string.h>
11 extern void __bug(char *file, int line) __attribute__((noreturn));
12 #define BUG() __bug(__FILE__, __LINE__)
13 #define BUG_ON(_p) do { if (_p) BUG(); } while ( 0 )
15 /* Force a compilation error if condition is true */
16 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2 * !!(condition)]))
18 #ifndef NDEBUG
19 #define ASSERT(_p) \
20 do { \
21 if ( unlikely(!(_p)) ) \
22 { \
23 printk("Assertion '%s' failed, line %d, file %s\n", #_p , \
24 __LINE__, __FILE__); \
25 BUG(); \
26 } \
27 } while ( 0 )
28 #else
29 #define ASSERT(_p) ((void)0)
30 #endif
32 #define SWAP(_a, _b) \
33 do { typeof(_a) _t = (_a); (_a) = (_b); (_b) = _t; } while ( 0 )
35 #define DIV_ROUND(x, y) (((x) + (y) / 2) / (y))
37 #define reserve_bootmem(_p,_l) ((void)0)
39 struct domain;
41 void cmdline_parse(char *cmdline);
43 /*#define DEBUG_TRACE_DUMP*/
44 #ifdef DEBUG_TRACE_DUMP
45 extern void debugtrace_dump(void);
46 extern void debugtrace_printk(const char *fmt, ...);
47 #else
48 #define debugtrace_dump() ((void)0)
49 #define debugtrace_printk(_f, ...) ((void)0)
50 #endif
52 /* Allows us to use '%p' as general-purpose machine-word format char. */
53 #define _p(_x) ((void *)(unsigned long)(_x))
54 #define printk(_f , _a...) printf( _f , ## _a )
55 extern void printf(const char *format, ...)
56 __attribute__ ((format (printf, 1, 2)));
57 extern void panic(const char *format, ...)
58 __attribute__ ((format (printf, 1, 2)));
59 extern long vm_assist(struct domain *, unsigned int, unsigned int);
61 /* vsprintf.c */
62 extern int sprintf(char * buf, const char * fmt, ...)
63 __attribute__ ((format (printf, 2, 3)));
64 extern int vsprintf(char *buf, const char *, va_list)
65 __attribute__ ((format (printf, 2, 0)));
66 extern int snprintf(char * buf, size_t size, const char * fmt, ...)
67 __attribute__ ((format (printf, 3, 4)));
68 extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
69 __attribute__ ((format (printf, 3, 0)));
70 extern int scnprintf(char * buf, size_t size, const char * fmt, ...)
71 __attribute__ ((format (printf, 3, 4)));
72 extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
73 __attribute__ ((format (printf, 3, 0)));
75 long simple_strtol(
76 const char *cp,char **endp, unsigned int base);
77 unsigned long simple_strtoul(
78 const char *cp,char **endp, unsigned int base);
79 long long simple_strtoll(
80 const char *cp,char **endp, unsigned int base);
81 unsigned long long simple_strtoull(
82 const char *cp,char **endp, unsigned int base);
84 unsigned long long parse_size_and_unit(char *s);
86 #define TAINT_UNSAFE_SMP (1<<0)
87 #define TAINT_MACHINE_CHECK (1<<1)
88 #define TAINT_BAD_PAGE (1<<2)
89 #define TAINT_SYNC_CONSOLE (1<<3)
90 extern int tainted;
91 #define TAINT_STRING_MAX_LEN 20
92 extern char *print_tainted(char *str);
93 extern void add_taint(unsigned);
95 #endif /* __LIB_H__ */