3 #ifndef __CDS_COMPILER_VC_AMD64_BITOP_H
4 #define __CDS_COMPILER_VC_AMD64_BITOP_H
9 math.h(136) : warning C4985: 'ceil': attributes not present on previous declaration.
10 intrin.h(142) : see declaration of 'ceil'
12 See http://connect.microsoft.com/VisualStudio/feedback/details/381422/warning-of-attributes-not-present-on-previous-declaration-on-ceil-using-both-math-h-and-intrin-h
14 # pragma warning(push)
15 # pragma warning(disable: 4985)
22 #pragma intrinsic(_BitScanReverse)
23 #pragma intrinsic(_BitScanForward)
24 #pragma intrinsic(_BitScanReverse64)
25 #pragma intrinsic(_BitScanForward64)
29 namespace bitop { namespace platform { namespace vc { namespace amd64 {
31 // MSB - return index (1..32) of most significant bit in nArg. If nArg == 0 return 0
32 # define cds_bitop_msb32_DEFINED
33 static inline int msb32( uint32_t nArg )
36 if ( _BitScanReverse( &nIndex, nArg ))
37 return (int) nIndex + 1;
41 # define cds_bitop_msb32nz_DEFINED
42 static inline int msb32nz( uint32_t nArg )
46 _BitScanReverse( &nIndex, nArg );
50 // LSB - return index (1..32) of least significant bit in nArg. If nArg == 0 return -1U
51 # define cds_bitop_lsb32_DEFINED
52 static inline int lsb32( uint32_t nArg )
55 if ( _BitScanForward( &nIndex, nArg ))
56 return (int) nIndex + 1;
60 # define cds_bitop_lsb32nz_DEFINED
61 static inline int lsb32nz( uint32_t nArg )
65 _BitScanForward( &nIndex, nArg );
70 # define cds_bitop_msb64_DEFINED
71 static inline int msb64( atomic64u_unaligned nArg )
74 if ( _BitScanReverse64( &nIndex, nArg ))
75 return (int) nIndex + 1;
79 # define cds_bitop_msb64nz_DEFINED
80 static inline int msb64nz( atomic64u_unaligned nArg )
84 _BitScanReverse64( &nIndex, nArg );
88 # define cds_bitop_lsb64_DEFINED
89 static inline int lsb64( atomic64u_unaligned nArg )
92 if ( _BitScanForward64( &nIndex, nArg ))
93 return (int) nIndex + 1;
97 # define cds_bitop_lsb64nz_DEFINED
98 static inline int lsb64nz( atomic64u_unaligned nArg )
101 unsigned long nIndex;
102 _BitScanForward64( &nIndex, nArg );
106 # define cds_bitop_complement32_DEFINED
107 static inline bool complement32( uint32_t * pArg, unsigned int nBit )
109 return _bittestandcomplement( reinterpret_cast<long *>( pArg ), nBit ) != 0;
112 # define cds_bitop_complement64_DEFINED
113 static inline bool complement64( atomic64u_t * pArg, unsigned int nBit )
115 return _bittestandcomplement64( reinterpret_cast<__int64 *>( pArg ), nBit ) != 0;
119 }} // namespace vc::amd64
121 using namespace vc::amd64;
123 }}} // namespace cds::bitop::platform
126 #endif // #ifndef __CDS_COMPILER_VC_AMD64_BITOP_H