Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

win_fenced_block.hpp 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //
  2. // detail/win_fenced_block.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef ASIO_DETAIL_WIN_FENCED_BLOCK_HPP
  11. #define ASIO_DETAIL_WIN_FENCED_BLOCK_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include "asio/detail/config.hpp"
  16. #if defined(ASIO_WINDOWS) && !defined(UNDER_CE)
  17. #include "asio/detail/socket_types.hpp"
  18. #include "asio/detail/noncopyable.hpp"
  19. #include "asio/detail/push_options.hpp"
  20. namespace asio {
  21. namespace detail {
  22. class win_fenced_block
  23. : private noncopyable
  24. {
  25. public:
  26. enum half_t { half };
  27. enum full_t { full };
  28. // Constructor for a half fenced block.
  29. explicit win_fenced_block(half_t)
  30. {
  31. }
  32. // Constructor for a full fenced block.
  33. explicit win_fenced_block(full_t)
  34. {
  35. #if defined(__BORLANDC__)
  36. LONG barrier = 0;
  37. ::InterlockedExchange(&barrier, 1);
  38. #elif defined(ASIO_MSVC) \
  39. && ((ASIO_MSVC < 1400) || !defined(MemoryBarrier))
  40. # if defined(_M_IX86)
  41. # pragma warning(push)
  42. # pragma warning(disable:4793)
  43. LONG barrier;
  44. __asm { xchg barrier, eax }
  45. # pragma warning(pop)
  46. # endif // defined(_M_IX86)
  47. #else
  48. MemoryBarrier();
  49. #endif
  50. }
  51. // Destructor.
  52. ~win_fenced_block()
  53. {
  54. #if defined(__BORLANDC__)
  55. LONG barrier = 0;
  56. ::InterlockedExchange(&barrier, 1);
  57. #elif defined(ASIO_MSVC) \
  58. && ((ASIO_MSVC < 1400) || !defined(MemoryBarrier))
  59. # if defined(_M_IX86)
  60. # pragma warning(push)
  61. # pragma warning(disable:4793)
  62. LONG barrier;
  63. __asm { xchg barrier, eax }
  64. # pragma warning(pop)
  65. # endif // defined(_M_IX86)
  66. #else
  67. MemoryBarrier();
  68. #endif
  69. }
  70. };
  71. } // namespace detail
  72. } // namespace asio
  73. #include "asio/detail/pop_options.hpp"
  74. #endif // defined(ASIO_WINDOWS) && !defined(UNDER_CE)
  75. #endif // ASIO_DETAIL_WIN_FENCED_BLOCK_HPP