gcc_hppa_fenced_block.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // detail/gcc_hppa_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_GCC_HPPA_FENCED_BLOCK_HPP
  11. #define ASIO_DETAIL_GCC_HPPA_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(__GNUC__) && (defined(__hppa) || defined(__hppa__))
  17. #include "asio/detail/push_options.hpp"
  18. namespace asio {
  19. namespace detail {
  20. class gcc_hppa_fenced_block
  21. : private noncopyable
  22. {
  23. public:
  24. enum half_t { half };
  25. enum full_t { full };
  26. // Constructor for a half fenced block.
  27. explicit gcc_hppa_fenced_block(half_t)
  28. {
  29. }
  30. // Constructor for a full fenced block.
  31. explicit gcc_hppa_fenced_block(full_t)
  32. {
  33. barrier();
  34. }
  35. // Destructor.
  36. ~gcc_hppa_fenced_block()
  37. {
  38. barrier();
  39. }
  40. private:
  41. static void barrier()
  42. {
  43. // This is just a placeholder and almost certainly not sufficient.
  44. __asm__ __volatile__ ("" : : : "memory");
  45. }
  46. };
  47. } // namespace detail
  48. } // namespace asio
  49. #include "asio/detail/pop_options.hpp"
  50. #endif // defined(__GNUC__) && (defined(__hppa) || defined(__hppa__))
  51. #endif // ASIO_DETAIL_GCC_HPPA_FENCED_BLOCK_HPP