prefix.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright (C) 2009 Tim Blechmann
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See
  4. // accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_LOCKFREE_PREFIX_HPP_INCLUDED
  7. #define BOOST_LOCKFREE_PREFIX_HPP_INCLUDED
  8. /* this file defines the following macros:
  9. BOOST_LOCKFREE_CACHELINE_BYTES: size of a cache line
  10. BOOST_LOCKFREE_PTR_COMPRESSION: use tag/pointer compression to utilize parts
  11. of the virtual address space as tag (at least 16bit)
  12. BOOST_LOCKFREE_DCAS_ALIGNMENT: symbol used for aligning structs at cache line
  13. boundaries
  14. */
  15. #define BOOST_LOCKFREE_CACHELINE_BYTES 64
  16. #ifdef _MSC_VER
  17. #define BOOST_LOCKFREE_CACHELINE_ALIGNMENT __declspec(align(BOOST_LOCKFREE_CACHELINE_BYTES))
  18. #if defined(_M_IX86)
  19. #define BOOST_LOCKFREE_DCAS_ALIGNMENT
  20. #elif defined(_M_X64) || defined(_M_IA64)
  21. #define BOOST_LOCKFREE_PTR_COMPRESSION 1
  22. #define BOOST_LOCKFREE_DCAS_ALIGNMENT __declspec(align(16))
  23. #endif
  24. #endif /* _MSC_VER */
  25. #ifdef __GNUC__
  26. #define BOOST_LOCKFREE_CACHELINE_ALIGNMENT __attribute__((aligned(BOOST_LOCKFREE_CACHELINE_BYTES)))
  27. #if defined(__i386__) || defined(__ppc__)
  28. #define BOOST_LOCKFREE_DCAS_ALIGNMENT
  29. #elif defined(__x86_64__)
  30. #define BOOST_LOCKFREE_PTR_COMPRESSION 1
  31. #define BOOST_LOCKFREE_DCAS_ALIGNMENT __attribute__((aligned(16)))
  32. #elif defined(__alpha__)
  33. // LATER: alpha may benefit from pointer compression. but what is the maximum size of the address space?
  34. #define BOOST_LOCKFREE_DCAS_ALIGNMENT
  35. #endif
  36. #endif /* __GNUC__ */
  37. #ifndef BOOST_LOCKFREE_DCAS_ALIGNMENT
  38. #define BOOST_LOCKFREE_DCAS_ALIGNMENT /*BOOST_LOCKFREE_DCAS_ALIGNMENT*/
  39. #endif
  40. #ifndef BOOST_LOCKFREE_CACHELINE_ALIGNMENT
  41. #define BOOST_LOCKFREE_CACHELINE_ALIGNMENT /*BOOST_LOCKFREE_CACHELINE_ALIGNMENT*/
  42. #endif
  43. #endif /* BOOST_LOCKFREE_PREFIX_HPP_INCLUDED */