]> git.itanic.dy.fi Git - scan-pagemap/blob - utils.h
Analyzer: Print detailed kpageflag statistics
[scan-pagemap] / utils.h
1 #ifndef _UTILS_H
2 #define _UTILS_H
3
4 #include <stddef.h>
5
6 #define MAX(a, b) ((a) > (b) ? (a) : (b))
7 #define MIN(a, b) ((a) < (b) ? (a) : (b))
8
9 /**
10  * container_of - cast a member of a structure out to the containing structure
11  * @ptr:        the pointer to the member.
12  * @type:       the type of the container struct this is embedded in.
13  * @member:     the name of the member within the struct.
14  *
15  */
16 #define container_of(ptr, type, member) ({                      \
17         const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
18         (type *)( (char *)__mptr - offsetof(type,member) );})
19
20 #endif