Move libcds 1.6.0 from SVN
[libcds.git] / cds / compiler / gcc / amd64 / backoff.h
1 //$$CDS-header$$
2
3 #ifndef __CDS_COMPILER_GCC_AMD64_BACKOFF_H
4 #define __CDS_COMPILER_GCC_AMD64_BACKOFF_H
5
6 //@cond none
7
8 namespace cds { namespace backoff {
9     namespace gcc { namespace amd64 {
10
11 #       define CDS_backoff_pause_defined
12         static inline void backoff_pause( unsigned int nLoop = 0x000003FF )
13         {
14             asm volatile (
15                 "andl %[nLoop], %%ecx;      \n\t"
16                 "cmovzl %[nLoop], %%ecx;    \n\t"
17                 "rep; "
18                 "nop;   \n\t"
19                 : /*no output*/
20                 : [nLoop] "r" (nLoop)
21                 : "ecx", "cc"
22                 );
23         }
24
25 #       define CDS_backoff_nop_defined
26         static inline void backoff_nop()
27         {
28             asm volatile ( "nop;" );
29         }
30
31     }} // namespace gcc::amd64
32
33     namespace platform {
34         using namespace gcc::amd64;
35     }
36 }}  // namespace cds::backoff
37
38 //@endcond
39 #endif  // #ifndef __CDS_COMPILER_GCC_AMD64_BACKOFF_H