comparison src/os/unix/ngx_gcc_atomic_ppc.h @ 937:fc1358d3d23a

larx/stcx. should cycle if the reservation was cleared
author Igor Sysoev <igor@sysoev.ru>
date Thu, 21 Dec 2006 15:20:15 +0000
parents db8e718447f1
children c4f120548171
comparison
equal deleted inserted replaced
936:2864303e0ce5 937:fc1358d3d23a
26 ngx_atomic_uint_t res, temp; 26 ngx_atomic_uint_t res, temp;
27 27
28 __asm__ volatile ( 28 __asm__ volatile (
29 29
30 " li %0, 0 \n" /* preset "0" to "res" */ 30 " li %0, 0 \n" /* preset "0" to "res" */
31 "1: \n"
31 " ldarx %1, 0, %2 \n" /* load from [lock] into "temp" */ 32 " ldarx %1, 0, %2 \n" /* load from [lock] into "temp" */
32 /* and store reservation */ 33 /* and store reservation */
33 " cmpd %1, %3 \n" /* compare "temp" and "old" */ 34 " cmpd %1, %3 \n" /* compare "temp" and "old" */
34 " bne- 1f \n" /* not equal */ 35 " bne- 2f \n" /* not equal */
35 " stdcx. %4, 0, %2 \n" /* store "set" into [lock] if reservation */ 36 " stdcx. %4, 0, %2 \n" /* store "set" into [lock] if reservation */
36 /* is not cleared */ 37 /* is not cleared */
37 " bne- 1f \n" /* the reservation was cleared */ 38 " bne- 1b \n" /* the reservation was cleared */
38 " li %0, 1 \n" /* set "1" to "res" */ 39 " li %0, 1 \n" /* set "1" to "res" */
39 "1: \n" 40 "2: \n"
40 41
41 : "=&b" (res), "=&b" (temp) 42 : "=&b" (res), "=&b" (temp)
42 : "b" (lock), "b" (old), "b" (set) 43 : "b" (lock), "b" (old), "b" (set)
43 : "cc", "memory"); 44 : "cc", "memory");
44 45
83 ngx_atomic_uint_t res, temp; 84 ngx_atomic_uint_t res, temp;
84 85
85 __asm__ volatile ( 86 __asm__ volatile (
86 87
87 " li %0, 0 \n" /* preset "0" to "res" */ 88 " li %0, 0 \n" /* preset "0" to "res" */
89 "1: \n"
88 " lwarx %1, 0, %2 \n" /* load from [lock] into "temp" */ 90 " lwarx %1, 0, %2 \n" /* load from [lock] into "temp" */
89 /* and store reservation */ 91 /* and store reservation */
90 " cmpw %1, %3 \n" /* compare "temp" and "old" */ 92 " cmpw %1, %3 \n" /* compare "temp" and "old" */
91 " bne- 1f \n" /* not equal */ 93 " bne- 2f \n" /* not equal */
92 " stwcx. %4, 0, %2 \n" /* store "set" into [lock] if reservation */ 94 " stwcx. %4, 0, %2 \n" /* store "set" into [lock] if reservation */
93 /* is not cleared */ 95 /* is not cleared */
94 " bne- 1f \n" /* the reservation was cleared */ 96 " bne- 1b \n" /* the reservation was cleared */
95 " li %0, 1 \n" /* set "1" to "res" */ 97 " li %0, 1 \n" /* set "1" to "res" */
96 "1: \n" 98 "2: \n"
97 99
98 : "=&b" (res), "=&b" (temp) 100 : "=&b" (res), "=&b" (temp)
99 : "b" (lock), "b" (old), "b" (set) 101 : "b" (lock), "b" (old), "b" (set)
100 : "cc", "memory"); 102 : "cc", "memory");
101 103