ia64/xen-unstable

view tools/xenstore/utils.h @ 19731:01748ccc4da3

Intel VT-d: fix Stoakley boot issue with iommu=1

Signed-off-by: Weidong Han <Weidong.han@intel.com>
Signed-off-by: Allen Kay <allen.m.kay@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jun 05 09:25:50 2009 +0100 (2009-06-05)
parents f343d3c16dcc
children
line source
1 #ifndef _UTILS_H
2 #define _UTILS_H
3 #include <stdbool.h>
4 #include <string.h>
5 #include <stdint.h>
7 /* Is A == B ? */
8 #define streq(a,b) (strcmp((a),(b)) == 0)
10 /* Does A start with B ? */
11 #define strstarts(a,b) (strncmp((a),(b),strlen(b)) == 0)
13 /* Does A end in B ? */
14 static inline bool strends(const char *a, const char *b)
15 {
16 if (strlen(a) < strlen(b))
17 return false;
19 return streq(a + strlen(a) - strlen(b), b);
20 }
22 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
24 void barf(const char *fmt, ...) __attribute__((noreturn));
25 void barf_perror(const char *fmt, ...) __attribute__((noreturn));
27 void (*xprintf)(const char *fmt, ...);
29 #define eprintf(_fmt, _args...) xprintf("[ERR] %s" _fmt, __FUNCTION__, ##_args)
31 /*
32 * Mux errno values onto returned pointers.
33 */
35 static inline void *ERR_PTR(long error)
36 {
37 return (void *)error;
38 }
40 static inline long PTR_ERR(const void *ptr)
41 {
42 return (long)ptr;
43 }
45 static inline long IS_ERR(const void *ptr)
46 {
47 return ((unsigned long)ptr > (unsigned long)-1000L);
48 }
51 #endif /* _UTILS_H */
53 /*
54 * Local variables:
55 * c-file-style: "linux"
56 * indent-tabs-mode: t
57 * c-indent-level: 8
58 * c-basic-offset: 8
59 * tab-width: 8
60 * End:
61 */