/Src/Dependencies/Boost/boost/thread/win32/interlocked_read.hpp

http://hadesmem.googlecode.com/ · C++ Header · 80 lines · 61 code · 12 blank · 7 comment · 0 complexity · a0c1e4d0e6653bde3b538da5ff97472b MD5 · raw file

  1. #ifndef BOOST_THREAD_DETAIL_INTERLOCKED_READ_WIN32_HPP
  2. #define BOOST_THREAD_DETAIL_INTERLOCKED_READ_WIN32_HPP
  3. // interlocked_read_win32.hpp
  4. //
  5. // (C) Copyright 2005-8 Anthony Williams
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See
  8. // accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. #include <boost/detail/interlocked.hpp>
  11. #include <boost/config/abi_prefix.hpp>
  12. #ifdef BOOST_MSVC
  13. extern "C" void _ReadWriteBarrier(void);
  14. #pragma intrinsic(_ReadWriteBarrier)
  15. namespace boost
  16. {
  17. namespace detail
  18. {
  19. inline long interlocked_read_acquire(long volatile* x)
  20. {
  21. long const res=*x;
  22. _ReadWriteBarrier();
  23. return res;
  24. }
  25. inline void* interlocked_read_acquire(void* volatile* x)
  26. {
  27. void* const res=*x;
  28. _ReadWriteBarrier();
  29. return res;
  30. }
  31. inline void interlocked_write_release(long volatile* x,long value)
  32. {
  33. _ReadWriteBarrier();
  34. *x=value;
  35. }
  36. inline void interlocked_write_release(void* volatile* x,void* value)
  37. {
  38. _ReadWriteBarrier();
  39. *x=value;
  40. }
  41. }
  42. }
  43. #else
  44. namespace boost
  45. {
  46. namespace detail
  47. {
  48. inline long interlocked_read_acquire(long volatile* x)
  49. {
  50. return BOOST_INTERLOCKED_COMPARE_EXCHANGE(x,0,0);
  51. }
  52. inline void* interlocked_read_acquire(void* volatile* x)
  53. {
  54. return BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(x,0,0);
  55. }
  56. inline void interlocked_write_release(long volatile* x,long value)
  57. {
  58. BOOST_INTERLOCKED_EXCHANGE(x,value);
  59. }
  60. inline void interlocked_write_release(void* volatile* x,void* value)
  61. {
  62. BOOST_INTERLOCKED_EXCHANGE_POINTER(x,value);
  63. }
  64. }
  65. }
  66. #endif
  67. #include <boost/config/abi_suffix.hpp>
  68. #endif