macros.h
1 /*
2  * This file is a part of Hierarchical Allocator library.
3  * Copyright (c) 2004-2011 Alex Pankratov. All rights reserved.
4  *
5  * http://swapped.cc/halloc
6  */
7 
8 /*
9  * The program is distributed under terms of BSD license.
10  * You can obtain the copy of the license by visiting:
11  *
12  * http://www.opensource.org/licenses/bsd-license.php
13  */
14 
15 #ifndef _LIBP_MACROS_H_
16 #define _LIBP_MACROS_H_
17 
18 #include <stddef.h> /* offsetof */
19 
20 /*
21  restore pointer to the structure by a pointer to its field
22  */
23 #define structof(p,t,f) ((t*)(- offsetof(t,f) + (void*)(p)))
24 
25 /*
26  * redefine for the target compiler
27  */
28 #define static_inline static __inline__
29 
30 
31 #endif
32