gcc_hppa_fenced_block.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // detail/gcc_hppa_fenced_block.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2018 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 BOOST_ASIO_DETAIL_GCC_HPPA_FENCED_BLOCK_HPP
  11. #define BOOST_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 <boost/asio/detail/config.hpp>
  16. #if defined(__GNUC__) && (defined(__hppa) || defined(__hppa__))
  17. #include <boost/asio/detail/noncopyable.hpp>
  18. #include <boost/asio/detail/push_options.hpp>
  19. namespace boost {
  20. namespace asio {
  21. namespace detail {
  22. class gcc_hppa_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 gcc_hppa_fenced_block(half_t)
  30. {
  31. }
  32. // Constructor for a full fenced block.
  33. explicit gcc_hppa_fenced_block(full_t)
  34. {
  35. barrier();
  36. }
  37. // Destructor.
  38. ~gcc_hppa_fenced_block()
  39. {
  40. barrier();
  41. }
  42. private:
  43. static void barrier()
  44. {
  45. // This is just a placeholder and almost certainly not sufficient.
  46. __asm__ __volatile__ ("" : : : "memory");
  47. }
  48. };
  49. } // namespace detail
  50. } // namespace asio
  51. } // namespace boost
  52. #include <boost/asio/detail/pop_options.hpp>
  53. #endif // defined(__GNUC__) && (defined(__hppa) || defined(__hppa__))
  54. #endif // BOOST_ASIO_DETAIL_GCC_HPPA_FENCED_BLOCK_HPP