1 #include <linux/stringify.h>
6 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
9 * Some bits are stolen from perf tool :)
21 #include <sys/param.h>
22 #include <sys/types.h>
25 #define NORETURN __attribute__((__noreturn__))
29 #define __attribute__(x)
33 extern bool do_debug_print;
35 #define PROT_RW (PROT_READ|PROT_WRITE)
36 #define MAP_ANON_NORESERVE (MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE)
38 extern void die(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2)));
39 extern void die_perror(const char *s) NORETURN;
40 extern int pr_error(const char *err, ...) __attribute__((format (printf, 1, 2)));
41 extern void pr_warning(const char *err, ...) __attribute__((format (printf, 1, 2)));
42 extern void pr_info(const char *err, ...) __attribute__((format (printf, 1, 2)));
43 extern void set_die_routine(void (*routine)(const char *err, va_list params) NORETURN);
45 #define pr_debug(fmt, ...) \
48 pr_info("(%s) %s:%d: " fmt, __FILE__, \
49 __func__, __LINE__, ##__VA_ARGS__); \
52 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
57 die(" at (" __FILE__ ":" __stringify(__LINE__) "): " \
58 __stringify(cnd) "\n"); \
61 extern size_t strlcat(char *dest, const char *src, size_t count);
63 /* some inline functions */
65 static inline const char *skip_prefix(const char *str, const char *prefix)
67 size_t len = strlen(prefix);
68 return strncmp(str, prefix, len) ? NULL : str + len;
71 #endif /* KVM__UTIL_H */