pion-net  4.0.9
common/include/boost/lockfree/detail/prefix.hpp
00001 //  Copyright (C) 2007, 2008, 2009 Tim Blechmann & Thomas Grill
00002 //
00003 //  Distributed under the Boost Software License, Version 1.0. (See
00004 //  accompanying file LICENSE_1_0.txt or copy at
00005 //  http://www.boost.org/LICENSE_1_0.txt)
00006 
00007 //  Disclaimer: Not a Boost library.
00008 
00009 #ifndef BOOST_LOCKFREE_PREFIX_HPP_INCLUDED
00010 #define BOOST_LOCKFREE_PREFIX_HPP_INCLUDED
00011 
00012 #include <cassert>
00013 
00014 
00015 #ifdef _WIN32
00016     #include <windows.h>
00017 #endif
00018 
00019 #ifdef __APPLE__
00020     #include <libkern/OSAtomic.h>
00021 
00022 //    #include <bits/atomicity.h>
00023 #endif
00024 
00025 #define BOOST_LOCKFREE_CACHELINE_BYTES 64
00026 
00027 #ifdef _MSC_VER
00028 // \note: Must use /Oi option for VC++ to enable intrinsics
00029     extern "C" {
00030         void __cdecl _ReadWriteBarrier();
00031         LONG __cdecl _InterlockedCompareExchange(LONG volatile* Dest,LONG Exchange, LONG Comp);
00032     }
00033 
00034 #define BOOST_LOCKFREE_CACHELINE_ALIGNMENT __declspec(align(BOOST_LOCKFREE_CACHELINE_BYTES))
00035 
00036 #if defined(_M_IX86)
00037     #define BOOST_LOCKFREE_DCAS_ALIGNMENT
00038 #elif defined(_M_X64) || defined(_M_IA64)
00039     #define BOOST_LOCKFREE_PTR_COMPRESSION 1
00040     #define BOOST_LOCKFREE_DCAS_ALIGNMENT __declspec(align(16))
00041 #endif
00042 
00043 #endif /* _MSC_VER */
00044 
00045 #ifdef __GNUC__
00046 
00047 //#define BOOST_LOCKFREE_CACHELINE_ALIGNMENT __attribute__((aligned(BOOST_LOCKFREE_CACHELINE_ALIGNMENT)))
00048 #define BOOST_LOCKFREE_CACHELINE_ALIGNMENT __attribute__((aligned(64)))
00049 
00050 #ifdef __i386__
00051     #define BOOST_LOCKFREE_DCAS_ALIGNMENT
00052 #elif defined(__ppc__)
00053     #define BOOST_LOCKFREE_DCAS_ALIGNMENT
00054 #elif defined(__x86_64__)
00055 
00056     #if !(defined (__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16))
00057         #define BOOST_LOCKFREE_PTR_COMPRESSION 1
00058     #endif
00059     #define BOOST_LOCKFREE_DCAS_ALIGNMENT __attribute__((aligned(16)))
00060 #endif
00061 
00062 #endif /* __GNUC__ */
00063 
00064 
00065 #ifdef USE_ATOMIC_OPS
00066     #define AO_REQUIRE_CAS
00067     #define AO_USE_PENTIUM4_INSTRS
00068 
00069     extern "C" {
00070         #include "../libatomic_ops/src/atomic_ops.h"
00071     }
00072 #endif
00073 
00074 
00075 #endif /* BOOST_LOCKFREE_PREFIX_HPP_INCLUDED */