1 // Copyright (C) 2007, 2008, 2009 Tim Blechmann & Thomas Grill
3 // Distributed under the Boost Software License, Version 1.0. (See
4 // accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
7 // Disclaimer: Not a Boost library.
9 #ifndef BOOST_LOCKFREE_PREFIX_HPP_INCLUDED
10 #define BOOST_LOCKFREE_PREFIX_HPP_INCLUDED
20 #include <libkern/OSAtomic.h>
23 #define BOOST_LOCKFREE_CACHELINE_BYTES 64
26 // \note: Must use /Oi option for VC++ to enable intrinsics
28 void __cdecl
_ReadWriteBarrier();
29 LONG __cdecl
_InterlockedCompareExchange(LONG
volatile* Dest
,LONG Exchange
, LONG Comp
);
32 #define BOOST_LOCKFREE_CACHELINE_ALIGNMENT __declspec(align(BOOST_LOCKFREE_CACHELINE_BYTES))
35 #define BOOST_LOCKFREE_DCAS_ALIGNMENT
36 #elif defined(_M_X64) || defined(_M_IA64)
37 #define BOOST_LOCKFREE_PTR_COMPRESSION 1
38 #define BOOST_LOCKFREE_DCAS_ALIGNMENT __declspec(align(16))
45 #define BOOST_LOCKFREE_CACHELINE_ALIGNMENT __attribute__((aligned(BOOST_LOCKFREE_CACHELINE_BYTES)))
48 #define BOOST_LOCKFREE_DCAS_ALIGNMENT
49 #elif defined(__ppc__)
50 #define BOOST_LOCKFREE_DCAS_ALIGNMENT
51 #elif defined(__x86_64__)
52 #define BOOST_LOCKFREE_PTR_COMPRESSION 1
53 #define BOOST_LOCKFREE_DCAS_ALIGNMENT __attribute__((aligned(16)))
54 #elif defined(__alpha__)
55 #define BOOST_LOCKFREE_PTR_COMPRESSION 1
59 #if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2))
60 #include <ext/atomicity.h>
62 #include <bits/atomicity.h>
70 #define AO_REQUIRE_CAS
71 #define AO_USE_PENTIUM4_INSTRS
74 #include "../libatomic_ops/src/atomic_ops.h"
79 #endif /* BOOST_LOCKFREE_PREFIX_HPP_INCLUDED */