debuggers.hg

view xen/include/xen/kernel.h @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children
line source
1 #ifndef _LINUX_KERNEL_H
2 #define _LINUX_KERNEL_H
4 /*
5 * 'kernel.h' contains some often-used function prototypes etc
6 */
8 /*
9 * min()/max() macros that also do
10 * strict type-checking.. See the
11 * "unnecessary" pointer comparison.
12 */
13 #define min(x,y) ({ \
14 const typeof(x) _x = (x); \
15 const typeof(y) _y = (y); \
16 (void) (&_x == &_y); \
17 _x < _y ? _x : _y; })
19 #define max(x,y) ({ \
20 const typeof(x) _x = (x); \
21 const typeof(y) _y = (y); \
22 (void) (&_x == &_y); \
23 _x > _y ? _x : _y; })
25 /*
26 * ..and if you can't take the strict
27 * types, you can specify one yourself.
28 *
29 * Or not use min/max at all, of course.
30 */
31 #define min_t(type,x,y) \
32 ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
33 #define max_t(type,x,y) \
34 ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
36 /**
37 * container_of - cast a member of a structure out to the containing structure
38 *
39 * @ptr: the pointer to the member.
40 * @type: the type of the container struct this is embedded in.
41 * @member: the name of the member within the struct.
42 *
43 */
44 #define container_of(ptr, type, member) ({ \
45 typeof( ((type *)0)->member ) *__mptr = (ptr); \
46 (type *)( (char *)__mptr - offsetof(type,member) );})
48 /*
49 * Check at compile time that something is of a particular type.
50 * Always evaluates to 1 so you may use it easily in comparisons.
51 */
52 #define typecheck(type,x) \
53 ({ type __dummy; \
54 typeof(x) __dummy2; \
55 (void)(&__dummy == &__dummy2); \
56 1; \
57 })
59 extern char _start[], _end[];
60 #define is_kernel(p) ({ \
61 char *__p = (char *)(unsigned long)(p); \
62 (__p >= _start) && (__p <= _end); \
63 })
65 extern char _stext[], _etext[];
66 #define is_kernel_text(p) ({ \
67 char *__p = (char *)(unsigned long)(p); \
68 (__p >= _stext) && (__p <= _etext); \
69 })
71 extern char _sinittext[], _einittext[];
72 #define is_kernel_inittext(p) ({ \
73 char *__p = (char *)(unsigned long)(p); \
74 (__p >= _sinittext) && (__p <= _einittext); \
75 })
77 #endif /* _LINUX_KERNEL_H */