ia64/xen-unstable

annotate xen/include/xen/lib.h @ 9878:ef0a56c0784d

Add BUILD_BUG_ON() and a handful of users.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Apr 27 15:55:09 2006 +0100 (2006-04-27)
parents 38c170be0e63
children 06b10ad218f4
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>
kaf24@1210 5 #include <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>
kaf24@1210 10
kaf24@3827 11 #define BUG() do { \
kaf24@3875 12 debugtrace_dump(); \
kaf24@3827 13 printk("BUG at %s:%d\n", __FILE__, __LINE__); \
kaf24@3827 14 FORCE_CRASH(); \
kaf24@3827 15 } while ( 0 )
kaf24@3827 16
kaf24@3848 17 #define BUG_ON(_p) do { if (_p) BUG(); } while ( 0 )
kaf24@3848 18
kaf24@9878 19 /* Force a compilation error if condition is true */
kaf24@9878 20 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2 * !!(condition)]))
kaf24@9878 21
kaf24@1210 22 #ifndef NDEBUG
mafetter@4799 23 #define ASSERT(_p) { if ( !(_p) ) { printk("Assertion '%s' failed, line %d, file %s\n", #_p , __LINE__, __FILE__); BUG(); } }
kaf24@1210 24 #else
kaf24@1210 25 #define ASSERT(_p) ((void)0)
kaf24@1210 26 #endif
kaf24@1210 27
kaf24@2635 28 #define SWAP(_a, _b) \
kaf24@2635 29 do { typeof(_a) _t = (_a); (_a) = (_b); (_b) = _t; } while ( 0 )
kaf24@2635 30
iap10@4606 31 #define DIV_ROUND(x, y) (((x) + (y) / 2) / (y))
arun@3920 32
kaf24@3354 33 #define reserve_bootmem(_p,_l) ((void)0)
kaf24@1210 34
cl349@2448 35 struct domain;
cl349@2448 36
kaf24@3338 37 void cmdline_parse(char *cmdline);
kaf24@3338 38
kaf24@3827 39 #ifndef NDEBUG
kaf24@3875 40 extern int debugtrace_send_to_console;
kaf24@3875 41 extern void debugtrace_dump(void);
kaf24@3827 42 extern void debugtrace_printk(const char *fmt, ...);
kaf24@3827 43 #else
kaf24@3875 44 #define debugtrace_dump() ((void)0)
kaf24@3875 45 #define debugtrace_printk(_f, ...) ((void)0)
kaf24@3827 46 #endif
kaf24@3827 47
kaf24@4654 48 /* Allows us to use '%p' as general-purpose machine-word format char. */
kaf24@4654 49 #define _p(_x) ((void *)(unsigned long)(_x))
kaf24@4654 50 #define printk(_f , _a...) printf( _f , ## _a )
kaf24@4654 51 extern void printf(const char *format, ...)
kaf24@4654 52 __attribute__ ((format (printf, 1, 2)));
kaf24@9454 53 extern void panic(const char *format, ...)
kaf24@9454 54 __attribute__ ((format (printf, 1, 2)));
kaf24@4654 55 extern long vm_assist(struct domain *, unsigned int, unsigned int);
kaf24@1210 56
kaf24@1210 57 /* vsprintf.c */
kaf24@1210 58 extern int sprintf(char * buf, const char * fmt, ...)
kaf24@4654 59 __attribute__ ((format (printf, 2, 3)));
kaf24@8520 60 extern int vsprintf(char *buf, const char *, va_list)
kaf24@8520 61 __attribute__ ((format (printf, 2, 0)));
kaf24@1210 62 extern int snprintf(char * buf, size_t size, const char * fmt, ...)
kaf24@4654 63 __attribute__ ((format (printf, 3, 4)));
kaf24@8520 64 extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
kaf24@8520 65 __attribute__ ((format (printf, 3, 0)));
kaf24@8520 66 extern int scnprintf(char * buf, size_t size, const char * fmt, ...)
kaf24@8520 67 __attribute__ ((format (printf, 3, 4)));
kaf24@8520 68 extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
kaf24@8520 69 __attribute__ ((format (printf, 3, 0)));
kaf24@1210 70
kaf24@4850 71 long simple_strtol(
kaf24@4850 72 const char *cp,char **endp, unsigned int base);
kaf24@4850 73 unsigned long simple_strtoul(
kaf24@4850 74 const char *cp,char **endp, unsigned int base);
kaf24@4850 75 long long simple_strtoll(
kaf24@4850 76 const char *cp,char **endp, unsigned int base);
kaf24@4850 77 unsigned long long simple_strtoull(
kaf24@4850 78 const char *cp,char **endp, unsigned int base);
kaf24@4850 79
kaf24@5018 80 unsigned long long parse_size_and_unit(char *s);
kaf24@1210 81
kaf24@8846 82 #define TAINT_UNSAFE_SMP (1<<0)
kaf24@8846 83 #define TAINT_MACHINE_CHECK (1<<1)
kaf24@8846 84 #define TAINT_BAD_PAGE (1<<2)
kaf24@8846 85 extern int tainted;
kaf24@8846 86 #define TAINT_STRING_MAX_LEN 20
kaf24@8846 87 extern char *print_tainted(char *str);
kaf24@8846 88 extern void add_taint(unsigned);
kaf24@8846 89
kaf24@1210 90 #endif /* __LIB_H__ */