Go to main content

man pages section 3: Extended Library Functions, Volume 2

Exit Print View

Updated: Wednesday, July 27, 2022
 
 

kstat2_map_get_userdata (3KSTAT2)

Name

kstat2_map_set_userdata, kstat2_map_get_userdata - set/retrieve user data for a kstat2 map

Synopsis

cc [ flag... ] file... -lkstat2 [ library...]
     #include <kstat2.h>
kstat2_status_t kstat2_map_set_userdata(kstat2_map_t map,
         void *data);
kstat2_status_t kstat2_map_get_userdata(kstat2_map_t map,
         void **data)

Description

The kstat2_map_set_userdata() function allows arbitrary user data to be associated with a kstat2 map. To remove user data, pass NULL as the data parameter.

The kstat2_map_get_userdata() function retrieves the user data for a map and returns a reference in data, or NULL if no data has been associated with the map.

The memory occupied by any user data associated with a map is not managed by the kstat2 library. If user data cleanup actions are required when a map is deleted, the kstat2_map_set_destroy_cb() function should be used to establish a handler which will be called when the map is deleted, see kstat2_map_set_destroy_cb(3KSTAT2).

Return Values

Upon successful completion the functions will return KSTAT2_S_OK.

Errors

The kstat2_map_set_userdata() function will fail if:

KSTAT2_S_INVAL_ARG

The map parameter is NULL

The kstat2_map_get_userdata() function will fail if:

KSTAT2_S_INVAL_ARG

The map parameter is NULL or the map has no associated user data

Files

/dev/kstat

kernel statistics driver

/usr/include/kstat2.h

header

Examples

See the kstat2(3KSTAT2) manpage.

Attributes

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Interface Stability
Committed
MT-Level
MT-Safe with exceptions

See Also

kstat2_close(3KSTAT2), kstat2_close(3KSTAT2), kstat2_map_get(3KSTAT2), kstat2_map_meta(3KSTAT2), kstat2_map_parent(3KSTAT2), kstat2_map_put_integer(3KSTAT2), kstat2_map_put_integers(3KSTAT2), kstat2_map_put_string(3KSTAT2), kstat2_map_put_strings(3KSTAT2), kstat2_map_remove(3KSTAT2), kstat2_map_set_data_cb(3KSTAT2), kstat2_map_set_destroy_cb(3KSTAT2), kstat2_map_set_tree_cb(3KSTAT2), kstat2_map_size(3KSTAT2), kstat2_map_to_array(3KSTAT2), kstat2_map_uri(3KSTAT2), kstat2_mapiter_end(3KSTAT2), kstat2_mapiter_hasnext(3KSTAT2), kstat2_mapiter_next(3KSTAT2), kstat2_mapiter_remove(3KSTAT2), kstat2_mapiter_start(3KSTAT2), kstat2_mapref_alloc(3KSTAT2), kstat2_mapref_deref(3KSTAT2), kstat2_mapref_free(3KSTAT2), kstat2_nv_meta(3KSTAT2), kstat2_open(3KSTAT2), kstat2_status_string(3KSTAT2), kstat2_update(3KSTAT2), kstat2_uri_decode(3KSTAT2), kstat2_uri_encode(3KSTAT2), libkstat2(3LIB)

Notes

The kstat2 functions are MT-Safe with the exception that only one thread may actively use a kstat2_handle_t, or any object obtained through it, at any one time. Synchronization is required if multiple threads intend to share a kstat2_handle_t or any object obtained through it. Synchronization is left to the application.