SPECIFICDATA(9)
π SPECIFICDATA(9) β arbitrary data, but make it iconic π
π NAME π
okay bestie, this whole page is about specificdata and its lil crew: specificdata_domain_create, specificdata_domain_delete, specificdata_key_create, specificdata_key_delete, specificdata_init, specificdata_fini, specificdata_getspecific, specificdata_getspecific_unlocked, specificdata_setspecific, and specificdata_setspecific_nowait. Together they manipulate arbitrary data attached to objects. Slay.
β¨ SYNOPSIS β¨
first up, include this exactly:
#include <sys/specificdata.h>
specificdata_domain_t
specificdata_domain_create();
void
specificdata_domain_delete(specificdata_domain_t sd);
int
specificdata_key_create(specificdata_domain_t sd,
specificdata_key_t *keyp, specificdata_dtor_t dtor);
void
specificdata_key_delete(specificdata_domain_t sd,
specificdata_key_t key);
int
specificdata_init(specificdata_domain_t sd,
specificdata_reference *ref);
void
specificdata_fini(specificdata_domain_t sd,
specificdata_reference *ref);
void *
specificdata_getspecific(specificdata_domain_t sd,
specificdata_reference *ref, specificdata_key_t key);
void *
specificdata_getspecific_unlocked(specificdata_domain_t sd,
specificdata_reference *ref, specificdata_key_t key);
void
specificdata_setspecific(specificdata_domain_t sd,
specificdata_reference *ref, specificdata_key_t key, void *data);
int
specificdata_setspecific_nowait(specificdata_domain_t sd,
specificdata_reference *ref, specificdata_key_t key, void *data);
π¦ DESCRIPTION π¦
okay so the specificdata facility is literally a whole mechanism for storing arbitrary data, identified by an index key, inside containers which exist within the objects associated with a particular domain. That's the vibe. It's giving "attach your stuff to objects, but organized."
π FUNCTIONS π
πΈ specificdata_domain_create()
Create and initialize a new domain. New domain era, honestly.
πΈ specificdata_domain_delete(sd)
Deletes domain sd. Bye bestie.
πΈ specificdata_key_create(sd, keyp, dtor)
Create a new key for sd. If the dtor argument is not NULL, it specifies a destructor which will be called when a datum associated with the specified key is deleted from a container within the sd. The unique identifier of the created key is returned in keyp. Cute and functional.
πΈ specificdata_key_delete(sd, key)
Delete a key for sd, and delete any associated data from all containers within the domain. It's a whole cleanup moment.
πΈ specificdata_init(sd, ref)
Initialize the container ref for use in sd. Container is ready for its main character era.
πΈ specificdata_fini(sd, ref)
Destroy the container ref, and destroy all of the data stuffed into the container. Very "closing the group chat" energy.
πΈ specificdata_getspecific(sd, ref, key)
Retrieve the datum from the container ref associated with key. Got it.
πΈ specificdata_getspecific_unlocked(sd, ref, key)
Retrieve the datum from the container ref associated with key in a lockless manner. Care must be taken to ensure that no other thread could cause ref to become invalid (i.e. point at the wrong container) by issuing a setspecific() call or by destroying the container. This is the careful part, bestie β do not skip the vibe check.
πΈ specificdata_setspecific(sd, ref, key, data)
Store data in the container ref and associate it with 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. So yes: replacement is the move, and the old datum does not get a destructor send-off here.
πΈ specificdata_setspecific_nowait(sd, ref, key, data)
(Unimplemented) β that's the whole note, no cap.
π CODE REFERENCES π
The specificdata functionality is implemented in sys/kern/subr_specificdata.c.
The header file <sys/sys/specificdata.h> describes the public interface. Yes, that is the exact path shown here β keep it exactly as written.
β HISTORY β
The specificdata subsystem first appeared in NetBSD 4.0. Vintage, but make it current.
π AUTHORS π
The specificdata subsystem was written by Jason Thorpe <thorpej@NetBSD.org>. This manual page was written by Paul Goyette <pgoyette@NetBSD.org>. Authorship icons only, fr fr.
okay that's the page! footer tea: source/version and date are Debian, June 16, 2018, and SPECIFICDATA(9) β mwah πβ¨
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2010 The NetBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms