/media/libnestegg/src/macros.h

http://github.com/zpao/v8monkey · C Header · 36 lines · 10 code · 8 blank · 18 comment · 0 complexity · a8d91dfb4163ecb8bc67b78d7efc60db MD5 · raw file

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