michael@0: /* michael@0: * Copyright (c) 2004-2010 Alex Pankratov. All rights reserved. michael@0: * michael@0: * Hierarchical memory allocator, 1.2.1 michael@0: * http://swapped.cc/halloc michael@0: */ michael@0: michael@0: /* michael@0: * The program is distributed under terms of BSD license. michael@0: * You can obtain the copy of the license by visiting: michael@0: * michael@0: * http://www.opensource.org/licenses/bsd-license.php michael@0: */ michael@0: michael@0: #ifndef _LIBP_MACROS_H_ michael@0: #define _LIBP_MACROS_H_ michael@0: michael@0: #include /* offsetof */ michael@0: michael@0: /* michael@0: restore pointer to the structure by a pointer to its field michael@0: */ michael@0: #define structof(p,t,f) ((t*)(- (ptrdiff_t) offsetof(t,f) + (char*)(p))) michael@0: michael@0: /* michael@0: * redefine for the target compiler michael@0: */ michael@0: #ifdef _WIN32 michael@0: #define static_inline static __inline michael@0: #else michael@0: #define static_inline static __inline__ michael@0: #endif michael@0: michael@0: michael@0: #endif michael@0: