ZestCode
 
Loading...
Searching...
No Matches
gid.h
Go to the documentation of this file.
1
15
16#pragma once
17
18#include <stdint.h>
19#include "api.h"
20
22 uint32_t* const bitmap; // a constant pointer to a bitmap
23 const size_t max; // Maximum gid value
24 const size_t reserved; // first n GIDs may be reserved, at most 32, but at least 1
25 const size_t bitmap_size; // Cached number of uint32_t's used to map gid_max.
26 // Use gid_size_to_words to compute
27
28 // internal usage to ensure that GIDs get delegated linearly before wrapping
29 // around back to 0
30 size_t _cur_val;
31 mutex_t _lock;
32};
33
34#ifndef UINT32_WIDTH
35#define UINT32_WIDTH 32
36#endif
37
42#define gid_size_to_words(size) (((size) + UINT32_WIDTH - 1) / UINT32_WIDTH)
43
50void gid_init(struct gid_metadata* const metadata);
51
60uint32_t gid_alloc(struct gid_metadata* const metadata);
61
70void gid_free(struct gid_metadata* const metadata, uint32_t id);
71
83bool gid_check(struct gid_metadata* metadata, uint32_t id);
bool gid_check(struct gid_metadata *metadata, uint32_t id)
void gid_free(struct gid_metadata *const metadata, uint32_t id)
uint32_t gid_alloc(struct gid_metadata *const metadata)
void gid_init(struct gid_metadata *const metadata)
void * mutex_t
Definition rtos.h:184
Definition gid.h:21