Lines 18-39
Link Here
|
18 |
|
18 |
|
19 |
#ifdef USE_ATOMICS_IA32 |
19 |
#ifdef USE_ATOMICS_IA32 |
20 |
|
20 |
|
|
|
21 |
#ifdef __INTEL_COMPILER |
22 |
# define barrier() __memory_barrier() |
23 |
#else |
24 |
# define barrier() asm volatile ("": : :"memory") |
25 |
#endif |
26 |
|
21 |
APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p) |
27 |
APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p) |
22 |
{ |
28 |
{ |
23 |
return APR_SUCCESS; |
29 |
return APR_SUCCESS; |
24 |
} |
30 |
} |
25 |
|
31 |
|
26 |
APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem) |
32 |
APR_DECLARE(apr_uint32_t) apr_atomic_read32(apr_uint32_t *mem) |
27 |
{ |
33 |
{ |
|
|
34 |
barrier(); |
35 |
|
28 |
return *mem; |
36 |
return *mem; |
29 |
} |
37 |
} |
30 |
|
38 |
|
31 |
APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val) |
39 |
APR_DECLARE(void) apr_atomic_set32(apr_uint32_t *mem, apr_uint32_t val) |
32 |
{ |
40 |
{ |
33 |
*mem = val; |
41 |
*mem = val; |
|
|
42 |
|
43 |
barrier(); |
34 |
} |
44 |
} |
35 |
|
45 |
|
36 |
APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val) |
46 |
APR_DECLARE(apr_uint32_t) apr_atomic_add32(apr_uint32_t *mem, apr_uint32_t val) |
37 |
{ |
47 |
{ |
38 |
asm volatile ("lock; xaddl %0,%1" |
48 |
asm volatile ("lock; xaddl %0,%1" |
39 |
: "=r" (val), "=m" (*mem) |
49 |
: "=r" (val), "=m" (*mem) |
Lines 42-48
APR_DECLARE(apr_uint32_t) apr_atomic_add
Link Here
|
42 |
return val; |
52 |
return val; |
43 |
} |
53 |
} |
44 |
|
54 |
|
45 |
APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val) |
55 |
APR_DECLARE(void) apr_atomic_sub32(apr_uint32_t *mem, apr_uint32_t val) |
46 |
{ |
56 |
{ |
47 |
asm volatile ("lock; subl %1, %0" |
57 |
asm volatile ("lock; subl %1, %0" |
48 |
: /* no output */ |
58 |
: /* no output */ |
Lines 50-61
APR_DECLARE(void) apr_atomic_sub32(volat
Link Here
|
50 |
: "memory", "cc"); |
60 |
: "memory", "cc"); |
51 |
} |
61 |
} |
52 |
|
62 |
|
53 |
APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem) |
63 |
APR_DECLARE(apr_uint32_t) apr_atomic_inc32(apr_uint32_t *mem) |
54 |
{ |
64 |
{ |
55 |
return apr_atomic_add32(mem, 1); |
65 |
return apr_atomic_add32(mem, 1); |
56 |
} |
66 |
} |
57 |
|
67 |
|
58 |
APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem) |
68 |
APR_DECLARE(int) apr_atomic_dec32(apr_uint32_t *mem) |
59 |
{ |
69 |
{ |
60 |
unsigned char prev; |
70 |
unsigned char prev; |
61 |
|
71 |
|
Lines 67-73
APR_DECLARE(int) apr_atomic_dec32(volati
Link Here
|
67 |
return prev; |
77 |
return prev; |
68 |
} |
78 |
} |
69 |
|
79 |
|
70 |
APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with, |
80 |
APR_DECLARE(apr_uint32_t) apr_atomic_cas32(apr_uint32_t *mem, apr_uint32_t with, |
71 |
apr_uint32_t cmp) |
81 |
apr_uint32_t cmp) |
72 |
{ |
82 |
{ |
73 |
apr_uint32_t prev; |
83 |
apr_uint32_t prev; |
Lines 79-85
APR_DECLARE(apr_uint32_t) apr_atomic_cas
Link Here
|
79 |
return prev; |
89 |
return prev; |
80 |
} |
90 |
} |
81 |
|
91 |
|
82 |
APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val) |
92 |
APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(apr_uint32_t *mem, apr_uint32_t val) |
83 |
{ |
93 |
{ |
84 |
apr_uint32_t prev = val; |
94 |
apr_uint32_t prev = val; |
85 |
|
95 |
|
Lines 90-107
APR_DECLARE(apr_uint32_t) apr_atomic_xch
Link Here
|
90 |
return prev; |
100 |
return prev; |
91 |
} |
101 |
} |
92 |
|
102 |
|
93 |
APR_DECLARE(void*) apr_atomic_casptr(volatile void **mem, void *with, const void *cmp) |
103 |
APR_DECLARE(void*) apr_atomic_casptr(void **mem, void *with, void *cmp) |
94 |
{ |
104 |
{ |
95 |
void *prev; |
105 |
void *prev; |
96 |
#if APR_SIZEOF_VOIDP == 4 |
106 |
#if APR_SIZEOF_VOIDP == 4 |
97 |
asm volatile ("lock; cmpxchgl %2, %1" |
107 |
asm volatile ("lock; cmpxchgl %2, %1" |
98 |
: "=a" (prev), "=m" (*mem) |
108 |
: "=a" (prev), "=m" (*mem) |
99 |
: "r" (with), "m" (*mem), "0" (cmp)); |
109 |
: "r" (with), "m" (*mem), "0" (cmp) |
|
|
110 |
: "memory"); |
100 |
#elif APR_SIZEOF_VOIDP == 8 |
111 |
#elif APR_SIZEOF_VOIDP == 8 |
101 |
asm volatile ("lock; cmpxchgq %q2, %1" |
112 |
asm volatile ("lock; cmpxchgq %q2, %1" |
102 |
: "=a" (prev), "=m" (*mem) |
113 |
: "=a" (prev), "=m" (*mem) |
103 |
: "r" ((unsigned long)with), "m" (*mem), |
114 |
: "r" ((unsigned long)with), "m" (*mem), |
104 |
"0" ((unsigned long)cmp)); |
115 |
"0" ((unsigned long)cmp) |
|
|
116 |
: "memory"); |
105 |
#else |
117 |
#else |
106 |
#error APR_SIZEOF_VOIDP value not supported |
118 |
#error APR_SIZEOF_VOIDP value not supported |
107 |
#endif |
119 |
#endif |