074c9c33fa9e11ece077607a6e8775f3473d4a7e
[libcds.git] / cds / compiler / gcc / x86 / backoff.h
1 //$$CDS-header$$
2
3 #ifndef __CDS_COMPILER_GCC_X86_BACKOFF_H
4 #define __CDS_COMPILER_GCC_X86_BACKOFF_H
5
6 //@cond none
7
8 namespace cds { namespace backoff {
9     namespace gcc { namespace x86 {
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::x86
32
33     namespace platform {
34         using namespace gcc::x86;
35     }
36 }}  // namespace cds::backoff
37
38 //@endcond
39 #endif  // #ifndef __CDS_COMPILER_GCC_X86_BACKOFF_H