X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=kitten%2Finclude%2Flwk%2Fidspace.h;fp=kitten%2Finclude%2Flwk%2Fidspace.h;h=e70de8060970cb0b5fc43748634af85597e3b92b;hb=66a1a4c7a9edcd7d8bc207aca093d694a6e6b5b2;hp=0000000000000000000000000000000000000000;hpb=f7cf9c19ecb0a589dd45ae0d2c91814bd3c2acc2;p=palacios.git diff --git a/kitten/include/lwk/idspace.h b/kitten/include/lwk/idspace.h new file mode 100644 index 0000000..e70de80 --- /dev/null +++ b/kitten/include/lwk/idspace.h @@ -0,0 +1,31 @@ +/* Copyright (c) 2008, Sandia National Laboratories */ + +#ifndef _LWK_IDSPACE_H +#define _LWK_IDSPACE_H + +/** + * ID space object. + * An ID space consists of a range of IDs and keeps track of which are + * allocated and which are available for allocation. + */ +typedef void * idspace_t; + +/** + * Numeric identifier type. + */ +typedef unsigned int id_t; + +/** + * Used to request any available ID... pass as 'request' arg to id_alloc(). + */ +#define ANY_ID (-1) + +/** + * ID space API. + */ +int idspace_create(id_t min_id, id_t max_id, idspace_t *idspace); +int idspace_destroy(idspace_t idspace); +int idspace_alloc_id(idspace_t idspace, id_t request, id_t *id); +int idspace_free_id(idspace_t idspace, id_t id); + +#endif