ia64/xen-unstable

annotate xen/include/xen/lib.h @ 13756:d96b346cab5d

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