2 // detail/gcc_x86_fenced_block.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
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)
11 #ifndef BOOST_ASIO_DETAIL_GCC_X86_FENCED_BLOCK_HPP
12 #define BOOST_ASIO_DETAIL_GCC_X86_FENCED_BLOCK_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/config.hpp>
20 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
22 #include <boost/asio/detail/push_options.hpp>
28 class gcc_x86_fenced_block
35 // Constructor for a half fenced block.
36 explicit gcc_x86_fenced_block(half_t)
40 // Constructor for a full fenced block.
41 explicit gcc_x86_fenced_block(full_t)
47 ~gcc_x86_fenced_block()
56 __asm__ __volatile__ (
64 static void lbarrier()
67 # if (__GNUC__ >= 4) && !defined(__INTEL_COMPILER) && !defined(__ICL)
68 __builtin_ia32_lfence();
69 # else // (__GNUC__ >= 4) && !defined(__INTEL_COMPILER) && !defined(__ICL)
70 __asm__ __volatile__ ("lfence" ::: "memory");
71 # endif // (__GNUC__ >= 4) && !defined(__INTEL_COMPILER) && !defined(__ICL)
72 #else // defined(__SSE2__)
74 #endif // defined(__SSE2__)
77 static void sbarrier()
80 # if (__GNUC__ >= 4) && !defined(__INTEL_COMPILER) && !defined(__ICL)
81 __builtin_ia32_sfence();
82 # else // (__GNUC__ >= 4) && !defined(__INTEL_COMPILER) && !defined(__ICL)
83 __asm__ __volatile__ ("sfence" ::: "memory");
84 # endif // (__GNUC__ >= 4) && !defined(__INTEL_COMPILER) && !defined(__ICL)
85 #else // defined(__SSE2__)
87 #endif // defined(__SSE2__)
95 #include <boost/asio/detail/pop_options.hpp>
97 #endif // defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
99 #endif // BOOST_ASIO_DETAIL_GCC_X86_FENCED_BLOCK_HPP