.\" $NetBSD: ucas.9,v 1.2 2011/10/27 07:23:23 wiz Exp $ .\" .\" Copyright (c)2011 YAMAMOTO Takashi, .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" ------------------------------------------------------------ .Dd October 24, 2011 .Dt UCAS 9 .Os .\" ------------------------------------------------------------ .Sh NAME .Nm ucas .Nd atomic memory operations on user-space address .\" ------------------------------------------------------------ .Sh SYNOPSIS .In sys/systm.h .\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - .Ft int .Fn ucas_ptr \ "volatile void *uptr" "void *old" "void *new" "void *retp" .\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - .Ft int .Fn ucas_int \ "volatile int *uptr" "int old" "int new" "int *retp" .\" ------------------------------------------------------------ .Sh DESCRIPTION These functions provide compare-and-swap (CAS) functionality on user-space address. .Pp Except that they can be safely used for the kernel to access user-space address, they are semantically equivalents of .Xr atomic_cas 3 . .Pp .Bl -tag -width uptr .It Fa uptr The pointer to the variable. This should be a user-space pointer. .It Fa old The value to compare with the variable. .It Fa new The value to store to the variable. .It Fa retp The pointer to the memory to store the old value of the variable. .El .\" ------------------------------------------------------------ .Sh RETURN VALUES On success, these functions return 0. In that case, the caller can consult the value returned via .Fa retp to check the result of the CAS operation. Otherwise, these functions return an appropriate .Xr errno 9 error code, typically .Dv EFAULT . .\" ------------------------------------------------------------ .Sh SEE ALSO .Xr atomic_cas 3 , .Xr intro 9 .\" ------------------------------------------------------------ .Sh BUGS Conceptually, the .Fa retp argument of .Fn ucas_ptr would be of .Dv void ** . The current prototype is a compromise for usability.