]> git.itanic.dy.fi Git - scan-pagemap/blob - utils.h
Show full process argument list instead only executable name
[scan-pagemap] / utils.h
1 /*
2  * Copyright (C) 2010 Timo Kokkonen <timo.t.kokkonen@iki.fi>
3  *
4  * Some of the code is taken from other GPLv2 sources, such as the
5  * Linux kernel.
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20
21 #ifndef _UTILS_H
22 #define _UTILS_H
23
24 #include <stddef.h>
25
26 #define MAX(a, b) ((a) > (b) ? (a) : (b))
27 #define MIN(a, b) ((a) < (b) ? (a) : (b))
28
29 /**
30  * container_of - cast a member of a structure out to the containing structure
31  * @ptr:        the pointer to the member.
32  * @type:       the type of the container struct this is embedded in.
33  * @member:     the name of the member within the struct.
34  *
35  */
36 #define container_of(ptr, type, member) ({                      \
37         const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
38         (type *)( (char *)__mptr - offsetof(type,member) );})
39
40 #endif