debuggers.hg

view xen/include/xen/lib.h @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children aedb8b90840f
line source
1 #ifndef __LIB_H__
2 #define __LIB_H__
4 #include <xen/inttypes.h>
5 #include <xen/stdarg.h>
6 #include <xen/config.h>
7 #include <xen/types.h>
8 #include <xen/xmalloc.h>
9 #include <xen/string.h>
10 #include <asm/bug.h>
12 void __bug(char *file, int line) __attribute__((noreturn));
13 void __warn(char *file, int line);
15 #define BUG_ON(p) do { if (p) BUG(); } while (0)
16 #define WARN_ON(p) do { if (p) WARN(); } while (0)
18 /* Force a compilation error if condition is true */
19 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2 * !!(condition)]))
21 #ifndef assert_failed
22 #define assert_failed(p) \
23 do { \
24 printk("Assertion '%s' failed, line %d, file %s\n", #p , \
25 __LINE__, __FILE__); \
26 BUG(); \
27 } while (0)
28 #endif
30 #ifndef NDEBUG
31 #define ASSERT(p) \
32 do { if ( unlikely(!(p)) ) assert_failed(p); } while (0)
33 #else
34 #define ASSERT(p) ((void)0)
35 #endif
37 #define SWAP(_a, _b) \
38 do { typeof(_a) _t = (_a); (_a) = (_b); (_b) = _t; } while ( 0 )
40 #define DIV_ROUND(x, y) (((x) + (y) / 2) / (y))
42 #define reserve_bootmem(_p,_l) ((void)0)
44 struct domain;
46 void cmdline_parse(char *cmdline);
48 /*#define DEBUG_TRACE_DUMP*/
49 #ifdef DEBUG_TRACE_DUMP
50 extern void debugtrace_dump(void);
51 extern void debugtrace_printk(const char *fmt, ...);
52 #else
53 #define debugtrace_dump() ((void)0)
54 #define debugtrace_printk(_f, ...) ((void)0)
55 #endif
57 /* Allows us to use '%p' as general-purpose machine-word format char. */
58 #define _p(_x) ((void *)(unsigned long)(_x))
59 extern void printk(const char *format, ...)
60 __attribute__ ((format (printf, 1, 2)));
61 extern void panic(const char *format, ...)
62 __attribute__ ((format (printf, 1, 2)));
63 extern long vm_assist(struct domain *, unsigned int, unsigned int);
64 extern int __printk_ratelimit(int ratelimit_ms, int ratelimit_burst);
65 extern int printk_ratelimit(void);
67 /* vsprintf.c */
68 #define sprintf __xen_has_no_sprintf__
69 #define vsprintf __xen_has_no_vsprintf__
70 extern int snprintf(char * buf, size_t size, const char * fmt, ...)
71 __attribute__ ((format (printf, 3, 4)));
72 extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
73 __attribute__ ((format (printf, 3, 0)));
74 extern int scnprintf(char * buf, size_t size, const char * fmt, ...)
75 __attribute__ ((format (printf, 3, 4)));
76 extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
77 __attribute__ ((format (printf, 3, 0)));
78 extern int sscanf(const char * buf, const char * fmt, ...)
79 __attribute__ ((format (scanf, 2, 3)));
80 extern int vsscanf(const char * buf, const char * fmt, va_list args)
81 __attribute__ ((format (scanf, 2, 0)));
83 long simple_strtol(
84 const char *cp,const char **endp, unsigned int base);
85 unsigned long simple_strtoul(
86 const char *cp,const char **endp, unsigned int base);
87 long long simple_strtoll(
88 const char *cp,const char **endp, unsigned int base);
89 unsigned long long simple_strtoull(
90 const char *cp,const char **endp, unsigned int base);
92 unsigned long long parse_size_and_unit(const char *s, const char **ps);
94 #define TAINT_UNSAFE_SMP (1<<0)
95 #define TAINT_MACHINE_CHECK (1<<1)
96 #define TAINT_BAD_PAGE (1<<2)
97 #define TAINT_SYNC_CONSOLE (1<<3)
98 extern int tainted;
99 #define TAINT_STRING_MAX_LEN 20
100 extern char *print_tainted(char *str);
101 extern void add_taint(unsigned);
103 #endif /* __LIB_H__ */