Xenomai API  2.6.5
map.h
Go to the documentation of this file.
1 
23 #ifndef _XENO_NUCLEUS_MAP_H
24 #define _XENO_NUCLEUS_MAP_H
25 
29 #include <nucleus/types.h>
30 
31 #define XNMAP_MAX_KEYS (BITS_PER_LONG * BITS_PER_LONG)
32 
33 typedef struct xnmap {
34 
35  int nkeys;
36  int ukeys;
37  int offset;
38  unsigned long himask;
39  unsigned long himap;
40 #define __IDMAP_LONGS ((XNMAP_MAX_KEYS+BITS_PER_LONG-1)/BITS_PER_LONG)
41  unsigned long lomap[__IDMAP_LONGS];
42 #undef __IDMAP_LONGS
43  void *objarray[1];
44 
45 } xnmap_t;
46 
47 xnmap_t *xnmap_create(int nkeys,
48  int reserve,
49  int offset);
50 
51 void xnmap_delete(xnmap_t *map);
52 
53 int xnmap_enter(xnmap_t *map,
54  int key,
55  void *objaddr);
56 
57 int xnmap_remove(xnmap_t *map,
58  int key);
59 
60 static inline void *xnmap_fetch_nocheck(xnmap_t *map, int key)
61 {
62  int ofkey = key - map->offset;
63  return map->objarray[ofkey];
64 }
65 
66 static inline void *xnmap_fetch(xnmap_t *map, int key)
67 {
68  int ofkey = key - map->offset;
69 
70  if (ofkey < 0 || ofkey >= map->nkeys)
71  return NULL;
72 
73  return map->objarray[ofkey];
74 }
75 
78 #endif /* !_XENO_NUCLEUS_MAP_H */
int xnmap_remove(xnmap_t *map, int key)
Remove an object reference from a map.
Definition: map.c:250
int xnmap_enter(xnmap_t *map, int key, void *objaddr)
Index an object into a map.
Definition: map.c:180
xnmap_t * xnmap_create(int nkeys, int reserve, int offset)
Create a map.
Definition: map.c:91
static void * xnmap_fetch_nocheck(xnmap_t *map, int key)
Search an object into a map - unchecked form.
Definition: map.h:60
void xnmap_delete(xnmap_t *map)
Delete a map.
Definition: map.c:137
static void * xnmap_fetch(xnmap_t *map, int key)
Search an object into a map.
Definition: map.h:66