OpenBSD manual page server

Manual Page Search Parameters

SRPL_EMPTY_LOCKED(9) Kernel Developer's Manual SRPL_EMPTY_LOCKED(9)

SRPL_EMPTY_LOCKED, SRPL_FIRST_LOCKED, SRPL_NEXT_LOCKED, SRPL_FOREACH_LOCKED, SRPL_FOREACH_SAFE_LOCKED, SRPL_INSERT_HEAD_LOCKED, SRPL_INSERT_AFTER_LOCKED, SRPL_REMOVE_LOCKEDserialised singly-linked shared reference pointer list operations

#include <sys/srp.h>

int
SRPL_EMPTY_LOCKED(SRPL_HEAD *sl);

void *
SRPL_FIRST_LOCKED(SRPL_HEAD *sl);

void *
SRPL_NEXT_LOCKED(struct TYPE *listelm, FIELDNAME);

SRPL_FOREACH_LOCKED(VARNAME, SRPL_HEAD *sl, FIELDNAME);

SRPL_FOREACH_SAFE_LOCKED(VARNAME, SRPL_HEAD *sl, FIELDNAME, TEMP_VARNAME);

void
SRPL_INSERT_HEAD_LOCKED(struct srpl_rc *rc, SRPL_HEAD *sl, struct TYPE *elm, FIELDNAME);

void
SRPL_INSERT_AFTER_LOCKED(struct srpl_rc *rc, struct TYPE *listelm, struct TYPE *elm, FIELDNAME);

void
SRPL_REMOVE_LOCKED(struct srpl_rc *rc, SRPL_HEAD *sl, struct TYPE *listelm, TYPE, FIELDNAME);

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.

() tests whether the SRP list sl is empty.

() accesses the first element in the SRP list sl.

() accesses the next element in the SRP list after listelm.

() creates a loop for traversing the elements in the SRP list sl.

() creates a loop for traversing the elements in the SRP list sl, permitting it to remove VARNAME as well as freeing it from within the loop safely without interfering with the traversal.

() inserts elm into the SRP list sl. Reference counts are adjusted on the list items using the functions specified by rc.

() inserts elm into an SRP list after the element listelm. Reference counts are adjusted on the list items using the functions specified by rc.

() iterates over the SRP list sl until it finds listelm and then removes it. Reference counts are adjusted on the list items using the functions specified by rc.

SRPL_EMPTY_LOCKED(), SRPL_FIRST_LOCKED(), SRPL_NEXT_LOCKED(), SRPL_FOREACH_LOCKED(), SRPL_INSERT_HEAD_LOCKED(), SRPL_INSERT_AFTER_LOCKED(), and 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.

SRPL_FIRST_LOCKED(), and SRPL_NEXT_LOCKED() return a pointer to elements in the SRP list, or NULL if there are no more elements.

SRPL_EMPTY_LOCKED() returns non-zero when the list is empty, otherwise 0.

SRPL_FIRST(9)

The srp API was originally written by Jonathan Matthew <jmatthew@openbsd.org> and David Gwynne <dlg@openbsd.org>. The SRP list API first appeared in OpenBSD 5.9.

November 21, 2016 OpenBSD-current