ia64/xen-unstable

annotate xen/include/xen/lib.h @ 14590:070cf119a7ec

Add WARN() and generic WARN_ON().

Based on a patch by Jan Beulich <jbeulich@novell.com>

Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Mar 27 15:53:45 2007 +0100 (2007-03-27)
parents 43e9952b07ea
children 6c8c934b235c
rev   line source
kaf24@1210 1 #ifndef __LIB_H__
kaf24@1210 2 #define __LIB_H__
kaf24@1210 3
kaf24@4809 4 #include <xen/inttypes.h>
kfraser@11879 5 #include <xen/stdarg.h>
kaf24@3827 6 #include <xen/config.h>
kaf24@1210 7 #include <xen/types.h>
cl349@5285 8 #include <xen/xmalloc.h>
kaf24@1486 9 #include <xen/string.h>
kfraser@14021 10 #include <asm/bug.h>
kaf24@1210 11
kfraser@14021 12 void __bug(char *file, int line) __attribute__((noreturn));
kfraser@14590 13 void __warn(char *file, int line);
kfraser@14021 14
kfraser@14590 15 #define BUG_ON(p) do { if (p) BUG(); } while (0)
kfraser@14590 16 #define WARN_ON(p) do { if (p) WARN(); } while (0)
kaf24@3848 17
kaf24@9878 18 /* Force a compilation error if condition is true */
kaf24@9878 19 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2 * !!(condition)]))
kaf24@9878 20
kfraser@14054 21 #ifndef assert_failed
kfraser@14054 22 #define assert_failed(p) \
kfraser@14054 23 do { \
kfraser@14054 24 printk("Assertion '%s' failed, line %d, file %s\n", #p , \
kfraser@14054 25 __LINE__, __FILE__); \
kfraser@14054 26 BUG(); \
kfraser@14054 27 } while (0)
kfraser@14054 28 #endif
kfraser@14054 29
kaf24@1210 30 #ifndef NDEBUG
kfraser@14054 31 #define ASSERT(p) \
kfraser@14054 32 do { if ( unlikely(!(p)) ) assert_failed(p); } while (0)
kaf24@1210 33 #else
kfraser@14054 34 #define ASSERT(p) ((void)0)
kaf24@1210 35 #endif
kaf24@1210 36
kaf24@2635 37 #define SWAP(_a, _b) \
kaf24@2635 38 do { typeof(_a) _t = (_a); (_a) = (_b); (_b) = _t; } while ( 0 )
kaf24@2635 39
iap10@4606 40 #define DIV_ROUND(x, y) (((x) + (y) / 2) / (y))
arun@3920 41
kaf24@3354 42 #define reserve_bootmem(_p,_l) ((void)0)
kaf24@1210 43
cl349@2448 44 struct domain;
cl349@2448 45
kaf24@3338 46 void cmdline_parse(char *cmdline);
kaf24@3338 47
kfraser@11212 48 /*#define DEBUG_TRACE_DUMP*/
kfraser@11212 49 #ifdef DEBUG_TRACE_DUMP
kaf24@3875 50 extern void debugtrace_dump(void);
kaf24@3827 51 extern void debugtrace_printk(const char *fmt, ...);
kaf24@3827 52 #else
kaf24@3875 53 #define debugtrace_dump() ((void)0)
kaf24@3875 54 #define debugtrace_printk(_f, ...) ((void)0)
kaf24@3827 55 #endif
kaf24@3827 56
kaf24@4654 57 /* Allows us to use '%p' as general-purpose machine-word format char. */
kaf24@4654 58 #define _p(_x) ((void *)(unsigned long)(_x))
kfraser@11947 59 extern void printk(const char *format, ...)
kaf24@4654 60 __attribute__ ((format (printf, 1, 2)));
kaf24@9454 61 extern void panic(const char *format, ...)
kaf24@9454 62 __attribute__ ((format (printf, 1, 2)));
kaf24@4654 63 extern long vm_assist(struct domain *, unsigned int, unsigned int);
kaf24@12030 64 extern int __printk_ratelimit(int ratelimit_ms, int ratelimit_burst);
kaf24@12030 65 extern int printk_ratelimit(void);
kaf24@1210 66
kaf24@1210 67 /* vsprintf.c */
keir@13756 68 #define sprintf __xen_has_no_sprintf__
kfraser@13697 69 #define vsprintf __xen_has_no_vsprintf__
kaf24@1210 70 extern int snprintf(char * buf, size_t size, const char * fmt, ...)
kaf24@4654 71 __attribute__ ((format (printf, 3, 4)));
kaf24@8520 72 extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
kaf24@8520 73 __attribute__ ((format (printf, 3, 0)));
kaf24@8520 74 extern int scnprintf(char * buf, size_t size, const char * fmt, ...)
kaf24@8520 75 __attribute__ ((format (printf, 3, 4)));
kaf24@8520 76 extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
kaf24@8520 77 __attribute__ ((format (printf, 3, 0)));
kaf24@1210 78
kaf24@4850 79 long simple_strtol(
kfraser@13156 80 const char *cp,const char **endp, unsigned int base);
kaf24@4850 81 unsigned long simple_strtoul(
kfraser@13156 82 const char *cp,const char **endp, unsigned int base);
kaf24@4850 83 long long simple_strtoll(
kfraser@13156 84 const char *cp,const char **endp, unsigned int base);
kaf24@4850 85 unsigned long long simple_strtoull(
kfraser@13156 86 const char *cp,const char **endp, unsigned int base);
kaf24@4850 87
kfraser@13156 88 unsigned long long parse_size_and_unit(const char *s, const char **ps);
kaf24@1210 89
kaf24@8846 90 #define TAINT_UNSAFE_SMP (1<<0)
kaf24@8846 91 #define TAINT_MACHINE_CHECK (1<<1)
kaf24@8846 92 #define TAINT_BAD_PAGE (1<<2)
kaf24@10500 93 #define TAINT_SYNC_CONSOLE (1<<3)
kaf24@8846 94 extern int tainted;
kaf24@8846 95 #define TAINT_STRING_MAX_LEN 20
kaf24@8846 96 extern char *print_tainted(char *str);
kaf24@8846 97 extern void add_taint(unsigned);
kaf24@8846 98
kaf24@1210 99 #endif /* __LIB_H__ */