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