3 #ifndef __CDS_COMPILER_VC_X86_BITOP_H
4 #define __CDS_COMPILER_VC_X86_BITOP_H
7 #pragma intrinsic(_BitScanReverse)
8 #pragma intrinsic(_BitScanForward)
12 namespace bitop { namespace platform { namespace vc { namespace x86 {
13 // MSB - return index (1..32) of most significant bit in nArg. If nArg == 0 return 0
14 # define cds_bitop_msb32_DEFINED
15 static inline int msb32( atomic32u_t nArg )
18 if ( _BitScanReverse( &nIndex, nArg ))
19 return (int) nIndex + 1;
23 # define cds_bitop_msb32nz_DEFINED
24 static inline int msb32nz( atomic32u_t nArg )
28 _BitScanReverse( &nIndex, nArg );
32 // LSB - return index (1..32) of least significant bit in nArg. If nArg == 0 return -1U
33 # define cds_bitop_lsb32_DEFINED
34 static inline int lsb32( atomic32u_t nArg )
37 if ( _BitScanForward( &nIndex, nArg ))
38 return (int) nIndex + 1;
42 # define cds_bitop_lsb32nz_DEFINED
43 static inline int lsb32nz( atomic32u_t nArg )
47 _BitScanForward( &nIndex, nArg );
51 // bswap - Reverses the byte order of a 32-bit word
52 # define cds_bitop_bswap32_DEFINED
53 static inline atomic32u_t bswap32( atomic32u_t nArg )
61 # define cds_bitop_complement32_DEFINED
62 static inline bool complement32( atomic32u_t * pArg, unsigned int nBit )
64 return _bittestandcomplement( reinterpret_cast<long *>( pArg ), nBit ) != 0;
67 # define cds_bitop_complement64_DEFINED
68 static inline bool complement64( atomic64u_t * pArg, unsigned int nBit )
71 return _bittestandcomplement( reinterpret_cast<long *>( pArg ), nBit ) != 0;
73 return _bittestandcomplement( reinterpret_cast<long *>( pArg ) + 1, nBit - 32 ) != 0;
76 }} // namespace vc::x86
78 using namespace vc::x86;
80 }}} // namespace cds::bitop::platform
83 #endif // #ifndef __CDS_COMPILER_VC_X86_BITOP_H