CNDP  22.08.0
uid.h File Reference
#include <stdio.h>
#include <stdint.h>
#include <cne_common.h>

Go to the source code of this file.

Macros

#define DEFAULT_MAX_THREADS   512
 

Typedefs

typedef void * u_id_t
 

Functions

CNDP_API u_id_t uid_find_by_name (const char *name)
 
CNDP_API uint16_t uid_max_ids (u_id_t _e)
 
CNDP_API uint16_t uid_allocated (u_id_t _e)
 
CNDP_API u_id_t uid_register (const char *name, uint16_t cnt)
 
CNDP_API int uid_unregister (u_id_t _e)
 
CNDP_API int uid_alloc (u_id_t _e)
 
CNDP_API void uid_free (u_id_t _e, int idx)
 
CNDP_API int uid_test (u_id_t *e, int uid)
 
CNDP_API void uid_dump (FILE *f)
 

Detailed Description

API for User Index allocation

Definition in file uid.h.

Macro Definition Documentation

◆ DEFAULT_MAX_THREADS

#define DEFAULT_MAX_THREADS   512

Max Number of threads to support

Definition at line 24 of file uid.h.

Typedef Documentation

◆ u_id_t

typedef void* u_id_t

User opaque value handler

Definition at line 26 of file uid.h.

Function Documentation

◆ uid_find_by_name()

CNDP_API u_id_t uid_find_by_name ( const char *  name)

Find a UID entry given the name of the UID

Parameters
nameString used to locate the UID structure
Returns
NULL if not found or the u_id_t opaque pointer

◆ uid_max_ids()

CNDP_API uint16_t uid_max_ids ( u_id_t  _e)

Return the max size of the UID pool.

Parameters
_eThe pointer to the uid_entry structure
Returns
Max number of UID entries in the UID pool.

◆ uid_allocated()

CNDP_API uint16_t uid_allocated ( u_id_t  _e)

Return the current number of allocated UIDs

Parameters
_eThe pointer to the uid_entry structure
Returns
The number of allocated entries in the UID structure

◆ uid_register()

CNDP_API u_id_t uid_register ( const char *  name,
uint16_t  cnt 
)

Add a new UID set of IDs based on the total count

Parameters
nameThe name of the UID entry
cntThe max number of IDs from 0 - cnt possible.
Returns
The opaque pointer value or NULL if error

◆ uid_unregister()

CNDP_API int uid_unregister ( u_id_t  _e)

Delete a UID entry created by uid_register()

Parameters
_eThe opaque pointer value to delete
Returns
0 on success or -1 on error

◆ uid_alloc()

CNDP_API int uid_alloc ( u_id_t  _e)

Allocate a unique ID value from a UID entry

Parameters
_eThe opaque pointer value to allocate from
Returns
-1 on error or 0 >= cnt value index

◆ uid_free()

CNDP_API void uid_free ( u_id_t  _e,
int  idx 
)

Release a index value back to the UID entry (free)

Parameters
_eThe UID to free the index value to
idxThe index value to free or release

◆ uid_test()

CNDP_API int uid_test ( u_id_t e,
int  uid 
)

Test to see if a bit is set in the bitmap (or cleared in this case)

Parameters
eThe u_id_t structure pointer to be tested using the uid bit index.
uidThe uid bit to test, if the bit is cleared then it is allocated.
Returns
0 on not set and 1 on set.

◆ uid_dump()

CNDP_API void uid_dump ( FILE *  f)

Dump out all of the UID structures.

Parameters
fFile descriptor pointer to write the output, if NULL use stdout