summaryrefslogtreecommitdiff
path: root/share/man/man9/SRPL_EMPTY_LOCKED.9
blob: 49403832fee24ff8c352ac77bfa6266d3e063a8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
.\"	$OpenBSD: SRPL_EMPTY_LOCKED.9,v 1.3 2016/11/21 07:11:13 dlg Exp $
.\"
.\" Copyright (c) 2015 David Gwynne <dlg@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: November 21 2016 $
.Dt SRPL_EMPTY_LOCKED 9
.Os
.Sh NAME
.Nm SRPL_EMPTY_LOCKED ,
.Nm SRPL_FIRST_LOCKED ,
.Nm SRPL_NEXT_LOCKED ,
.Nm SRPL_FOREACH_LOCKED ,
.Nm SRPL_FOREACH_SAFE_LOCKED ,
.Nm SRPL_INSERT_HEAD_LOCKED ,
.Nm SRPL_INSERT_AFTER_LOCKED ,
.Nm SRPL_REMOVE_LOCKED
.Nd serialised singly-linked shared reference pointer list operations
.Sh SYNOPSIS
.In sys/srp.h
.Ft int
.Fn "SRPL_EMPTY_LOCKED" "SRPL_HEAD *sl"
.Ft void *
.Fn "SRPL_FIRST_LOCKED" "SRPL_HEAD *sl"
.Ft void *
.Fn "SRPL_NEXT_LOCKED" "struct TYPE *listelm" "FIELDNAME"
.Fn "SRPL_FOREACH_LOCKED" "VARNAME" "SRPL_HEAD *sl" "FIELDNAME"
.Fo "SRPL_FOREACH_SAFE_LOCKED"
.Fa "VARNAME"
.Fa "SRPL_HEAD *sl"
.Fa "FIELDNAME"
.Fa "TEMP_VARNAME"
.Fc
.Ft void
.Fo "SRPL_INSERT_HEAD_LOCKED"
.Fa "struct srpl_rc *rc"
.Fa "SRPL_HEAD *sl"
.Fa "struct TYPE *elm"
.Fa "FIELDNAME"
.Fc
.Ft void
.Fo "SRPL_INSERT_AFTER_LOCKED"
.Fa "struct srpl_rc *rc"
.Fa "struct TYPE *listelm"
.Fa "struct TYPE *elm"
.Fa "FIELDNAME"
.Fc
.Ft void
.Fo "SRPL_REMOVE_LOCKED"
.Fa "struct srpl_rc *rc"
.Fa "SRPL_HEAD *sl"
.Fa "struct TYPE *listelm"
.Fa "TYPE"
.Fa "FIELDNAME"
.Fc
.Sh DESCRIPTION
The SRP list
macros build a linked list on top of shared reference pointers.
These macros allow manipulation and traversal of the linked list while
access to the list is serialised by the caller.
.Pp
.Fn SRPL_EMPTY_LOCKED
tests whether the SRP list
.Fa sl
is empty.
.Pp
.Fn SRPL_FIRST_LOCKED
accesses the first element in the SRP list
.Fa sl .
.Pp
.Fn SRPL_NEXT_LOCKED
accesses the next element in the SRP list after
.Fa listelm .
.Pp
.Fn SRPL_FOREACH_LOCKED
creates a loop for traversing the elements in the SRP list
.Fa sl .
.Pp
.Fn SRPL_FOREACH_SAFE_LOCKED
creates a loop for traversing the elements in the SRP list
.Fa sl ,
permitting it to remove
.Fa VARNAME
as well as freeing it from within the loop safely without interfering with the
traversal.
.Pp
.Fn SRPL_INSERT_HEAD_LOCKED
inserts
.Fa elm
into the SRP list
.Fa sl .
Reference counts are adjusted on the list items using the functions
specified by
.Fa rc .
.Pp
.Fn SRPL_INSERT_AFTER_LOCKED
inserts
.Fa elm
into an SRP list after the element
.Fa listelm .
Reference counts are adjusted on the list items using the functions
specified by
.Fa rc .
.Pp
.Fn SRPL_REMOVE_LOCKED
iterates over the SRP list
.Fa sl
until it finds
.Fa listelm
and then removes it.
Reference counts are adjusted on the list items using the functions
specified by
.Fa rc .
.Sh CONTEXT
.Fn SRPL_EMPTY_LOCKED ,
.Fn SRPL_FIRST_LOCKED ,
.Fn SRPL_NEXT_LOCKED ,
.Fn SRPL_FOREACH_LOCKED ,
.Fn SRPL_INSERT_HEAD_LOCKED ,
.Fn SRPL_INSERT_AFTER_LOCKED ,
and
.Fn SRPL_REMOVE_LOCKED
may be called during autoconf or from process context.
An appropriate lock must be held that prevents concurrent modifications
to the list.
.Sh RETURN VALUES
.Fn SRPL_FIRST_LOCKED ,
and
.Fn SRPL_NEXT_LOCKED
return a pointer to elements in the SRP list, or
.Dv NULL
if there are no more elements.
.Pp
.Fn SRPL_EMPTY_LOCKED
returns non-zero when the list is empty, otherwise 0.
.Sh SEE ALSO
.Xr SRPL_FIRST 9
.Sh HISTORY
The srp API was originally written by
.An Jonathan Matthew Aq Mt jmatthew@openbsd.org
and
.An David Gwynne Aq Mt dlg@openbsd.org .
The SRP list API first appeared in
.Ox 5.9 .