diff options
| author | Garrett D'Amore <garrett@damore.org> | 2021-12-06 21:09:55 -0500 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2021-12-06 21:09:55 -0500 |
| commit | 037d26a902a3cd5016052c76a6747e40c1a0df50 (patch) | |
| tree | f76ed1eabcffa862d93ffe6ee3d53c6a0ae472c4 /src/core/idhash.h | |
| parent | 21528dfe0998d056222191a4abe53d8d9f1286e3 (diff) | |
| download | nng-037d26a902a3cd5016052c76a6747e40c1a0df50.tar.gz nng-037d26a902a3cd5016052c76a6747e40c1a0df50.tar.bz2 nng-037d26a902a3cd5016052c76a6747e40c1a0df50.zip | |
ID map static initialization support.
This also arranges to clean up the maps at nng_fini time.
Diffstat (limited to 'src/core/idhash.h')
| -rw-r--r-- | src/core/idhash.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/core/idhash.h b/src/core/idhash.h index b2259853..e8894dfb 100644 --- a/src/core/idhash.h +++ b/src/core/idhash.h @@ -37,14 +37,26 @@ struct nni_id_map { uint32_t id_min_val; uint32_t id_max_val; uint32_t id_dyn_val; + uint32_t id_flags; nni_id_entry *id_entries; }; +#define NNI_ID_FLAG_STATIC 1 // allocated statically +#define NNI_ID_FLAG_RANDOM 2 // start at a random value +#define NNI_ID_FLAG_REGISTER 4 // map is registered for finalization + extern void nni_id_map_init(nni_id_map *, uint32_t, uint32_t, bool); extern void nni_id_map_fini(nni_id_map *); extern void *nni_id_get(nni_id_map *, uint32_t); extern int nni_id_set(nni_id_map *, uint32_t, void *); extern int nni_id_alloc(nni_id_map *, uint32_t *, void *); extern int nni_id_remove(nni_id_map *, uint32_t); +extern void nni_id_map_sys_fini(void); + +#define NNI_ID_MAP_INITIALIZER(min, max, flags) \ + { \ + .id_min_val = (min), .id_max_val = (max), \ + .id_flags = ((flags) | NNI_ID_FLAG_STATIC) \ + } #endif // CORE_IDHASH_H |
