.\" $NetBSD: specificdata.9,v 1.7 2018/06/15 22:27:40 pgoyette Exp $ .\" .\" Copyright (c) 2010 The NetBSD Foundation, Inc. .\" All rights reserved. .\" .\" This code is derived from software contributed to The NetBSD Foundation .\" by Jason R. Thorpe .\" .\" 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 June 16, 2018 .Dt SPECIFICDATA 9 .Os .Sh NAME .Nm specificdata , .Nm specificdata_domain_create , .Nm specificdata_domain_delete , .Nm specificdata_key_create , .Nm specificdata_key_delete , .Nm specificdata_init , .Nm specificdata_fini , .Nm specificdata_getspecific , .Nm specificdata_getspecific_unlocked , .Nm specificdata_setspecific , .Nm specificdata_setspecific_nowait .Nd manipulate arbitrary data attached to objects .Sh SYNOPSIS .In sys/specificdata.h .Ft specificdata_domain_t .Fn specificdata_domain_create .Ft void .Fn specificdata_domain_delete "specificdata_domain_t sd" .Ft int .Fn specificdata_key_create "specificdata_domain_t sd" \ "specificdata_key_t *keyp" "specificdata_dtor_t dtor" .Ft void .Fn specificdata_key_delete "specificdata_domain_t sd" "specificdata_key_t key" .Ft int .Fn specificdata_init "specificdata_domain_t sd" "specificdata_reference *ref" .Ft void .Fn specificdata_fini "specificdata_domain_t sd" "specificdata_reference *ref" .Ft "void *" .Fn specificdata_getspecific "specificdata_domain_t sd" \ "specificdata_reference *ref" "specificdata_key_t key" .Ft "void *" .Fn specificdata_getspecific_unlocked "specificdata_domain_t sd" \ "specificdata_reference *ref" "specificdata_key_t key" .Ft void .Fn specificdata_setspecific "specificdata_domain_t sd" \ "specificdata_reference *ref" "specificdata_key_t key" "void *data" .Ft int .Fn specificdata_setspecific_nowait "specificdata_domain_t sd" \ "specificdata_reference *ref" "specificdata_key_t key" "void *data" .Sh DESCRIPTION The .Nm facility provides a mechanism for storing arbitrary data, identified by an index key, within containers which exist within the objects associated with a particular domain. .Sh FUNCTIONS .Bl -tag -width abcd .It Fn specificdata_domain_create Create and initialize a new domain. .It Fn specificdata_domain_delete sd Deletes domain .Fa sd . .It Fn specificdata_key_create sd keyp dtor Create a new key for .Fa sd . If the .Fa dtor argument is not .Dv NULL , it specifies a destructor which will be called when a datum associated with the specified key is deleted from a container within the .Fa sd . The unique identifier of the created key is returned in .Fa keyp . .It Fn specificdata_key_delete sd key Delete a key for .Fa sd , and delete any associated data from all containers within the domain. .It Fn specificdata_init sd ref Initialize the container .Fa ref for use in .Fa sd . .It Fn specificdata_fini sd ref Destroy the container .Fa ref , and destroy all of the data stuffed into the container. .It Fn specificdata_getspecific sd ref key Retrieve the datum from the container .Fa ref associated with .Fa key . .It Fn specificdata_getspecific_unlocked sd ref key Retrieve the datum from the container .Fa ref associated with .Fa key in a lockless manner. Care must be taken to ensure that no other thread could cause .Fa ref to become invalid (i.e. point at the wrong container) by issuing a .Fn setspecific call or by destroying the container. .It Fn specificdata_setspecific sd ref key data Store .Fa data in the container .Fa ref and associate it with .Fa key . If a datum has previously been stored, the new value replaces the original; the original value is not destroyed, i.e. its destructor is not invoked. Note that there is no provision for removing a datum without replacing it. .It Fn specificdata_setspecific_nowait sd ref key data (Unimplemented) .El .Sh CODE REFERENCES The .Nm functionality is implemented in .Pa sys/kern/subr_specificdata.c . .Pp The header file .In sys/sys/specificdata.h describes the public interface. .Sh HISTORY The .Nm subsystem first appeared in .Nx 4.0 . .Sh AUTHORS .An -nosplit The .Nm subsystem was written by .An Jason Thorpe Aq Mt thorpej@NetBSD.org . This manual page was written by .An Paul Goyette Aq Mt pgoyette@NetBSD.org .