]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - share/man/man9/casuword.9
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / share / man / man9 / casuword.9
1 .\" Copyright (c) 2014 The FreeBSD Foundation
2 .\" All rights reserved.
3 .\"
4 .\" Part of this documentation was written by
5 .\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
6 .\" from the FreeBSD Foundation.
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\"    notice, this list of conditions and the following disclaimer in the
15 .\"    documentation and/or other materials provided with the distribution.
16 .\"
17 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
18 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
21 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 .\" SUCH DAMAGE.
28 .\"
29 .\" $FreeBSD$
30 .\"
31 .Dd October 21, 2014
32 .Dt CASU 9
33 .Os
34 .Sh NAME
35 .Nm casueword ,
36 .Nm casueword32 ,
37 .Nm casuword ,
38 .Nm casuword32
39 .Nd fetch, compare and store data from user-space
40 .Sh SYNOPSIS
41 .In sys/types.h
42 .In sys/systm.h
43 .Ft int
44 .Fn casueword "volatile u_long *base" "u_long oldval" "u_long *oldvalp" "u_long newval"
45 .Ft int
46 .Fn casueword32 "volatile uint32_t *base" "uint32_t oldval" "uint32_t *oldvalp" "uint32_t newval"
47 .Ft u_long
48 .Fn casuword "volatile u_long *base" "u_long oldval" "u_long newval"
49 .Ft uint32_t
50 .Fn casuword32 "volatile uint32_t *base" "uint32_t oldval" "uint32_t newval"
51 .Sh DESCRIPTION
52 The
53 .Nm
54 functions are designed to perform atomic compare-and-swap operation on
55 the value in the usermode memory of the current process.
56 .Pp
57 The
58 .Nm
59 routines reads the value from user memory with address
60 .Pa base ,
61 and compare the value read with
62 .Pa oldval .
63 If the values are equal,
64 .Pa newval
65 is written to the
66 .Pa *base .
67 In case of
68 .Fn casueword32
69 and
70 .Fn casueword ,
71 old value is stored into the (kernel-mode) variable pointed by
72 .Pa *oldvalp .
73 The userspace value must be naturally aligned.
74 .Pp
75 The callers of
76 .Fn casuword
77 and
78 .Fn casuword32
79 functions cannot distinguish between -1 read from
80 userspace and function failure.
81 .Sh RETURN VALUES
82 The
83 .Fn casuword
84 and
85 .Fn casuword32
86 functions return the data fetched or -1 on failure.
87 The
88 .Fn casueword
89 and
90 .Fn casueword32
91 functions return 0 on success and -1 on failure.
92 .Sh SEE ALSO
93 .Xr atomic 9 ,
94 .Xr fetch 9 ,
95 .Xr store 9