Changeset View
Changeset View
Standalone View
Standalone View
sys/i386/i386/copyout.c
Show First 20 Lines • Show All 422 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
return (suword(base, word)); | return (suword(base, word)); | ||||
} | } | ||||
struct casueword_arg0 { | struct casueword_arg0 { | ||||
uint32_t oldval; | uint32_t oldval; | ||||
uint32_t newval; | uint32_t newval; | ||||
int res; | |||||
}; | }; | ||||
static void | static void | ||||
casueword_slow0(vm_offset_t kva, void *arg) | casueword_slow0(vm_offset_t kva, void *arg) | ||||
{ | { | ||||
struct casueword_arg0 *ca; | struct casueword_arg0 *ca; | ||||
ca = arg; | ca = arg; | ||||
atomic_fcmpset_int((u_int *)kva, &ca->oldval, ca->newval); | ca->res = atomic_fcmpset_int((u_int *)kva, &ca->oldval, ca->newval); | ||||
markj: Isn't this inverted? atomic_(f)cmpset returns 1 on success, 0 on failure. | |||||
Done Inline ActionsYes it is, it was reported by Peter earlier. I fixed it in my branch, will upload new patch after pho finishes. kib: Yes it is, it was reported by Peter earlier. I fixed it in my branch, will upload new patch… | |||||
} | } | ||||
int | int | ||||
casueword32(volatile uint32_t *base, uint32_t oldval, uint32_t *oldvalp, | casueword32(volatile uint32_t *base, uint32_t oldval, uint32_t *oldvalp, | ||||
uint32_t newval) | uint32_t newval) | ||||
{ | { | ||||
struct casueword_arg0 ca; | struct casueword_arg0 ca; | ||||
int res; | int res; | ||||
ca.oldval = oldval; | ca.oldval = oldval; | ||||
ca.newval = newval; | ca.newval = newval; | ||||
res = cp_slow0((vm_offset_t)base, sizeof(int32_t), true, | res = cp_slow0((vm_offset_t)base, sizeof(int32_t), true, | ||||
casueword_slow0, &ca); | casueword_slow0, &ca); | ||||
if (res == 0) { | if (res == 0) { | ||||
*oldvalp = ca.oldval; | *oldvalp = ca.oldval; | ||||
return (0); | return (ca.res); | ||||
} | } | ||||
return (-1); | return (-1); | ||||
} | } | ||||
int | int | ||||
casueword(volatile u_long *base, u_long oldval, u_long *oldvalp, u_long newval) | casueword(volatile u_long *base, u_long oldval, u_long *oldvalp, u_long newval) | ||||
{ | { | ||||
struct casueword_arg0 ca; | struct casueword_arg0 ca; | ||||
int res; | int res; | ||||
ca.oldval = oldval; | ca.oldval = oldval; | ||||
ca.newval = newval; | ca.newval = newval; | ||||
res = cp_slow0((vm_offset_t)base, sizeof(int32_t), true, | res = cp_slow0((vm_offset_t)base, sizeof(int32_t), true, | ||||
casueword_slow0, &ca); | casueword_slow0, &ca); | ||||
if (res == 0) { | if (res == 0) { | ||||
*oldvalp = ca.oldval; | *oldvalp = ca.oldval; | ||||
return (0); | return (ca.res); | ||||
} | } | ||||
return (-1); | return (-1); | ||||
} | } |
Isn't this inverted? atomic_(f)cmpset returns 1 on success, 0 on failure.