diff options
Diffstat (limited to 'src/atomic_ops.c')
| -rw-r--r-- | src/atomic_ops.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/atomic_ops.c b/src/atomic_ops.c index da45eb5..e0f7ae2 100644 --- a/src/atomic_ops.c +++ b/src/atomic_ops.c @@ -101,19 +101,17 @@ AO_TS_t AO_locks[AO_HASH_SIZE] = { AO_TS_INITIALIZER, AO_TS_INITIALIZER, AO_TS_INITIALIZER, AO_TS_INITIALIZER, }; -static AO_T dummy = 1; +static AO_t dummy = 1; /* Spin for 2**n units. */ -void AO_spin(int n) +static void AO_spin(int n) { - int i; - AO_T j = AO_load(&dummy); + AO_t j = AO_load(&dummy); + int i = 2 << n; - for (i = 0; i < (2 << n); ++i) - { - j *= 5; - j -= 4; - } + while (i-- > 0) + j += (j - 1) << 2; + /* Given 'dummy' is initialized to 1, j is 1 after the loop. */ AO_store(&dummy, j); } |
