Change the userland atomic operations on arm to use memory operands for

the modified memory rather than using register operands that held a pointer
to the memory.  The biggest effect is that we now correctly tell the
compiler that these functions change the memory that these functions
modify.

Reviewed by:	cognet
This commit is contained in:
John Baldwin 2005-10-14 18:07:45 +00:00
parent 6f6b430e2f
commit 43e2ef2bb6

View File

@ -154,16 +154,17 @@ atomic_cmpset_32(volatile u_int32_t *p, volatile u_int32_t cmpval, volatile u_in
"adr %1, 1b\n"
"mov %0, #0xe0000004\n"
"str %1, [%0]\n"
"ldr %1, [%2]\n"
"ldr %1, %2\n"
"cmp %1, %3\n"
"streq %4, [%2]\n"
"streq %4, %2\n"
"2:\n"
"mov %1, #0\n"
"str %1, [%0]\n"
"moveq %1, #1\n"
"movne %1, #0\n"
: "=r" (ras_start), "=r" (done)
,"+r" (p), "+r" (cmpval), "+r" (newval));
,"=m" (*p), "+r" (cmpval), "+r" (newval)
: "m" (*p));
return (done);
}
@ -179,13 +180,14 @@ atomic_add_32(volatile u_int32_t *p, u_int32_t val)
"adr %1, 1b\n"
"mov %0, #0xe0000004\n"
"str %1, [%0]\n"
"ldr %1, [%2]\n"
"ldr %1, %2\n"
"add %1, %1, %3\n"
"str %1, [%2]\n"
"str %1, %2\n"
"2:\n"
"mov %1, #0\n"
"str %1, [%0]\n"
: "=r" (ras_start), "=r" (start), "+r" (p), "+r" (val));
: "=r" (ras_start), "=r" (start), "=m" (*p), "+r" (val)
: "m" (*p));
}
static __inline void
@ -200,14 +202,15 @@ atomic_subtract_32(volatile u_int32_t *p, u_int32_t val)
"adr %1, 1b\n"
"mov %0, #0xe0000004\n"
"str %1, [%0]\n"
"ldr %1, [%2]\n"
"ldr %1, %2\n"
"sub %1, %1, %3\n"
"str %1, [%2]\n"
"str %1, %2\n"
"2:\n"
"mov %1, #0\n"
"str %1, [%0]\n"
: "=r" (ras_start), "=r" (start), "+r" (p), "+r" (val));
: "=r" (ras_start), "=r" (start), "=m" (*p), "+r" (val)
: "m" (*p));
}
static __inline void
@ -222,14 +225,15 @@ atomic_set_32(volatile uint32_t *address, uint32_t setmask)
"adr %1, 1b\n"
"mov %0, #0xe0000004\n"
"str %1, [%0]\n"
"ldr %1, [%2]\n"
"ldr %1, %2\n"
"orr %1, %1, %3\n"
"str %1, [%2]\n"
"str %1, %2\n"
"2:\n"
"mov %1, #0\n"
"str %1, [%0]\n"
: "=r" (ras_start), "=r" (start), "+r" (address), "+r" (setmask));
: "=r" (ras_start), "=r" (start), "=m" (*address), "+r" (setmask)
: "m" (*address));
}
static __inline void
@ -244,13 +248,14 @@ atomic_clear_32(volatile uint32_t *address, uint32_t clearmask)
"adr %1, 1b\n"
"mov %0, #0xe0000004\n"
"str %1, [%0]\n"
"ldr %1, [%2]\n"
"ldr %1, %2\n"
"bic %1, %1, %3\n"
"str %1, [%2]\n"
"str %1, %2\n"
"2:\n"
"mov %1, #0\n"
"str %1, [%0]\n"
: "=r" (ras_start), "=r" (start), "+r" (address), "+r" (clearmask));
: "=r" (ras_start), "=r" (start), "=m" (*address), "+r" (clearmask)
: "m" (*address));
}
@ -272,7 +277,8 @@ atomic_fetchadd_32(volatile uint32_t *p, uint32_t v)
"2:\n"
"mov %3, #0\n"
"str %3, [%0]\n"
: "=r" (ras_start), "=r" (start), "=m" (*p), "+r" (v));
: "=r" (ras_start), "=r" (start), "=m" (*p), "+r" (v)
: "m" (*p));
return (start);
}