#ifndef CCAN_JMAP_H
#define CCAN_JMAP_H
#include <stddef.h>
-#define _WORD_T
-typedef size_t Word_t, *PWord_t;
#include <Judy.h>
#include <stdbool.h>
#include <string.h>
/* Used if !NDEBUG */
int num_accesses;
/* Used if DEBUG */
- size_t *acc_value;
- size_t acc_index;
+ unsigned long *acc_value;
+ unsigned long acc_index;
const char *funcname;
};
const char *COLD_ATTRIBUTE jmap_error_(struct jmap *map);
/* Debugging checks. */
static inline void jmap_debug_add_access(const struct jmap *map,
- size_t index, size_t *val,
+ unsigned long index,
+ unsigned long *val,
const char *funcname)
{
#ifdef DEBUG
assert(++((struct jmap *)map)->num_accesses);
}
-static inline void jmap_debug_del_access(struct jmap *map, size_t **val)
+static inline void jmap_debug_del_access(struct jmap *map, unsigned long **val)
{
assert(--map->num_accesses >= 0);
#ifdef DEBUG
#ifdef DEBUG
if (map->num_accesses && map->acc_value)
fprintf(stderr,
- "jmap: still got index %zu, val %zu (%p) from %s\n",
+ "jmap: still got index %lu, val %lu (%p) from %s\n",
map->acc_index, *map->acc_value, map->acc_value,
map->funcname);
#endif
* if (!jmap_add(map, 0, 1))
* err(1, "jmap_add failed!");
*/
-static inline bool jmap_add(struct jmap *map, size_t index, size_t value)
+static inline bool jmap_add(struct jmap *map,
+ unsigned long index, unsigned long value)
{
- size_t *val;
+ unsigned long *val;
jmap_debug_access(map);
- val = (size_t *)JudyLIns(&map->judy, index, &map->err);
+ val = (unsigned long *)JudyLIns(&map->judy, index, &map->err);
if (val == PJERR)
return false;
*val = value;
* if (!jmap_set(map, 0, 2))
* err(1, "jmap_set: index 0 not found");
*/
-static inline bool jmap_set(const struct jmap *map, size_t index, size_t value)
+static inline bool jmap_set(const struct jmap *map,
+ unsigned long index, unsigned long value)
{
- size_t *val;
- val = (size_t *)JudyLGet(map->judy, index, (JError_t *)&map->err);
+ unsigned long *val;
+ val = (unsigned long *)JudyLGet(map->judy, index,
+ (JError_t *)&map->err);
if (val && val != PJERR) {
*val = value;
return true;
* if (!jmap_del(map, 0))
* err(1, "jmap_del failed!");
*/
-static inline bool jmap_del(struct jmap *map, size_t index)
+static inline bool jmap_del(struct jmap *map, unsigned long index)
{
jmap_debug_access(map);
return JudyLDel(&map->judy, index, &map->err) == 1;
* jmap_add(map, 0, 1);
* assert(jmap_test(map, 0));
*/
-static inline bool jmap_test(const struct jmap *map, size_t index)
+static inline bool jmap_test(const struct jmap *map, unsigned long index)
{
return JudyLGet(map->judy, index, (JError_t *)&map->err) != NULL;
}
* See Also:
* jmap_getval()
*/
-static inline size_t jmap_get(const struct jmap *map, size_t index,
- size_t invalid)
+static inline unsigned long jmap_get(const struct jmap *map,
+ unsigned long index,
+ unsigned long invalid)
{
- size_t *val;
- val = (size_t *)JudyLGet(map->judy, index, (JError_t *)&map->err);
+ unsigned long *val;
+ val = (unsigned long *)JudyLGet(map->judy, index,
+ (JError_t *)&map->err);
if (!val || val == PJERR)
return invalid;
return *val;
* Example:
* assert(jmap_popcount(map, 0, 1000) <= jmap_popcount(map, 0, 2000));
*/
-static inline size_t jmap_popcount(const struct jmap *map,
- size_t start, size_t end_incl)
+static inline unsigned long jmap_popcount(const struct jmap *map,
+ unsigned long start,
+ unsigned long end_incl)
{
return JudyLCount(map->judy, start, end_incl, (JError_t *)&map->err);
}
* map). Otherwise you can use jmap_nthval().
*
* Example:
- * size_t i, index;
+ * unsigned long i, index;
*
* // We know 0 isn't in map.
* assert(!jmap_test(map, 0));
* for (i = 0; (index = jmap_nth(map, i, 0)) != 0; i++) {
* assert(jmap_popcount(map, 0, index) == i);
- * printf("Index %zu = %zu\n", i, index);
+ * printf("Index %lu = %lu\n", i, index);
* }
*
* See Also:
* jmap_nthval();
*/
-static inline size_t jmap_nth(const struct jmap *map,
- size_t n, size_t invalid)
+static inline unsigned long jmap_nth(const struct jmap *map,
+ unsigned long n, unsigned long invalid)
{
- size_t index;
+ unsigned long index;
if (!JudyLByCount(map->judy, n+1, &index, (JError_t *)&map->err))
index = invalid;
return index;
* assert(!jmap_test(map, 0));
* printf("Map indices (increasing order):");
* for (i = jmap_first(map, 0); i; i = jmap_next(map, i, 0))
- * printf(" %zu", i);
+ * printf(" %lu", i);
* printf("\n");
*
* See Also:
* jmap_firstval()
*/
-static inline size_t jmap_first(const struct jmap *map, size_t invalid)
+static inline unsigned long jmap_first(const struct jmap *map,
+ unsigned long invalid)
{
- size_t index = 0;
+ unsigned long index = 0;
if (!JudyLFirst(map->judy, &index, (JError_t *)&map->err))
index = invalid;
else
* See Also:
* jmap_nextval()
*/
-static inline size_t jmap_next(const struct jmap *map, size_t prev,
- size_t invalid)
+static inline unsigned long jmap_next(const struct jmap *map,
+ unsigned long prev,
+ unsigned long invalid)
{
if (!JudyLNext(map->judy, &prev, (JError_t *)&map->err))
prev = invalid;
* assert(!jmap_test(map, 0));
* printf("Map indices (increasing order):");
* for (i = jmap_last(map, 0); i; i = jmap_prev(map, i, 0))
- * printf(" %zu", i);
+ * printf(" %lu", i);
* printf("\n");
* See Also:
* jmap_lastval()
*/
-static inline size_t jmap_last(const struct jmap *map, size_t invalid)
+static inline unsigned long jmap_last(const struct jmap *map,
+ unsigned long invalid)
{
- size_t index = -1;
+ unsigned long index = -1;
if (!JudyLLast(map->judy, &index, (JError_t *)&map->err))
index = invalid;
else
* See Also:
* jmap_prevval()
*/
-static inline size_t jmap_prev(const struct jmap *map, size_t prev,
- size_t invalid)
+static inline unsigned long jmap_prev(const struct jmap *map,
+ unsigned long prev,
+ unsigned long invalid)
{
if (!JudyLPrev(map->judy, &prev, (JError_t *)&map->err))
prev = invalid;
* have called jmap_putval().
*
* Example:
- * size_t *p;
+ * unsigned long *p;
* jmap_add(map, 0, 1);
* p = jmap_getval(map, 0);
* if (!p)
* See Also:
* jmap_putval(), jmap_firstval()
*/
-static inline size_t *jmap_getval(struct jmap *map, size_t index)
+static inline unsigned long *jmap_getval(struct jmap *map, unsigned long index)
{
- size_t *val;
- val = (size_t *)JudyLGet(map->judy, index, (JError_t *)&map->err);
+ unsigned long *val;
+ val = (unsigned long *)JudyLGet(map->judy, index,
+ (JError_t *)&map->err);
jmap_debug_add_access(map, index, val, "jmap_getval");
return val;
}
* jmap_getval(), jmap_nthval(), jmap_firstval(), jmap_nextval(),
* jmap_lastval(), jmap_prevval().
*/
-static inline void jmap_putval(struct jmap *map, size_t **p)
+static inline void jmap_putval(struct jmap *map, unsigned long **p)
{
jmap_debug_del_access(map, p);
}
* You must use jmap_putval() on the pointer once you are done with it.
*
* Example:
- * size_t *val;
+ * unsigned long *val;
*
* // We know 0 isn't in map.
* assert(!jmap_test(map, 0));
* for (i = 0; (val = jmap_nthval(map, i, &index)) != NULL; i++) {
* assert(jmap_popcount(map, 0, index) == i);
- * printf("Index %zu = %zu, value = %zu\n", i, index, *val);
+ * printf("Index %lu = %lu, value = %lu\n", i, index, *val);
* jmap_putval(map, &val);
* }
*
* See Also:
* jmap_nth();
*/
-static inline size_t *jmap_nthval(const struct jmap *map,
- size_t n, size_t *index)
+static inline unsigned long *jmap_nthval(const struct jmap *map,
+ unsigned long n, unsigned long *index)
{
- size_t *val;
- val = (size_t *)JudyLByCount(map->judy, n+1, index,
+ unsigned long *val;
+ val = (unsigned long *)JudyLByCount(map->judy, n+1, index,
(JError_t *)&map->err);
jmap_debug_add_access(map, *index, val, "jmap_nthval");
return val;
* See Also:
* jmap_first, jmap_nextval()
*/
-static inline size_t *jmap_firstval(const struct jmap *map, size_t *index)
+static inline unsigned long *jmap_firstval(const struct jmap *map,
+ unsigned long *index)
{
- size_t *val;
+ unsigned long *val;
*index = 0;
- val = (size_t *)JudyLFirst(map->judy, index, (JError_t *)&map->err);
+ val = (unsigned long *)JudyLFirst(map->judy, index,
+ (JError_t *)&map->err);
jmap_debug_add_access(map, *index, val, "jmap_firstval");
return val;
}
* See Also:
* jmap_firstval(), jmap_putval()
*/
-static inline size_t *jmap_nextval(const struct jmap *map, size_t *index)
+static inline unsigned long *jmap_nextval(const struct jmap *map,
+ unsigned long *index)
{
- size_t *val;
- val = (size_t *)JudyLNext(map->judy, index, (JError_t *)&map->err);
+ unsigned long *val;
+ val = (unsigned long *)JudyLNext(map->judy, index,
+ (JError_t *)&map->err);
jmap_debug_add_access(map, *index, val, "jmap_nextval");
return val;
}
* See Also:
* jmap_last(), jmap_putval()
*/
-static inline size_t *jmap_lastval(const struct jmap *map, size_t *index)
+static inline unsigned long *jmap_lastval(const struct jmap *map,
+ unsigned long *index)
{
- size_t *val;
+ unsigned long *val;
*index = -1;
- val = (size_t *)JudyLLast(map->judy, index, (JError_t *)&map->err);
+ val = (unsigned long *)JudyLLast(map->judy, index,
+ (JError_t *)&map->err);
jmap_debug_add_access(map, *index, val, "jmap_lastval");
return val;
}
* See Also:
* jmap_lastval(), jmap_putval()
*/
-static inline size_t *jmap_prevval(const struct jmap *map, size_t *index)
+static inline unsigned long *jmap_prevval(const struct jmap *map,
+ unsigned long *index)
{
- size_t *val;
- val = (size_t *)JudyLPrev(map->judy, index, (JError_t *)&map->err);
+ unsigned long *val;
+ val = (unsigned long *)JudyLPrev(map->judy, index,
+ (JError_t *)&map->err);
jmap_debug_add_access(map, *index, val, "jmap_prevval");
return val;
}
* The following wrapper functions are defined; each one is the same as
* the jmap.h generic equivalent except where noted:
*
+ * // Creating, errors and freeing.
* struct jmap_@name *jmap_@name_new(void);
* void jmap_@name_free(const struct jmap_@name *map);
* const char *jmap_@name_error(struct jmap_@name *map);
*
+ * // Add, set, delete, test and get.
* bool jmap_@name_add(const struct jmap_@name *map,
- * size_t index, const type *value);
+ * unsigned long idx, const type *value);
* bool jmap_@name_set(const struct jmap_@name *map,
- * size_t index, const type *value);
- * bool jmap_@name_del(struct jmap_@name *map, size_t index);
- * bool jmap_@name_test(const struct jmap_@name *map, size_t index);
+ * unsigned long idx, const type *value);
+ * bool jmap_@name_del(struct jmap_@name *map, unsigned long idx);
+ * bool jmap_@name_test(const struct jmap_@name *map, unsigned long idx);
+ * type *jmap_@name_get(const struct jmap_@name *map, unsigned long idx);
*
- * type *jmap_@name_get(const struct jmap_@name *map, size_t index);
- * size_t jmap_@name_popcount(const struct jmap_@name *map,
- * size_t start, size_t end_incl);
- * size_t jmap_@name_nth(const struct jmap_@name *map,
- * size_t n, size_t invalid);
- * size_t jmap_@name_first(const struct jmap_@name *map,
- * size_t invalid);
- * size_t jmap_@name_next(const struct jmap_@name *map,
- * size_t prev, size_t invalid);
- * size_t jmap_@name_last(const struct jmap_@name *map,
- * size_t invalid);
- * size_t jmap_@name_prev(const struct jmap_@name *map,
- * size_t prev, size_t invalid);
+ * // Counting and iteration.
+ * unsigned long jmap_@name_popcount(const struct jmap_@name *map,
+ * unsigned long start,
+ * unsigned long end_incl);
+ * unsigned long jmap_@name_nth(const struct jmap_@name *map,
+ * unsigned long n, unsigned long invalid);
+ * unsigned long jmap_@name_first(const struct jmap_@name *map,
+ * unsigned long invalid);
+ * unsigned long jmap_@name_next(const struct jmap_@name *map,
+ * unsigned long prev,
+ * unsigned long invalid);
+ * unsigned long jmap_@name_last(const struct jmap_@name *map,
+ * unsigned long invalid);
+ * unsigned long jmap_@name_prev(const struct jmap_@name *map,
+ * unsigned long prev,
+ * unsigned long invalid);
*
- * type **jmap_@name_getval(const struct jmap_@name *map, size_t index);
+ * // Get pointers to values to use.
+ * type **jmap_@name_getval(const struct jmap_@name *map,
+ * unsigned long idx);
* void jmap_@name_putval(struct jmap_@name *map, type ***p);
* type **jmap_@name_nthval(struct jmap_@name *map,
- * size_t n, size_t *index);
+ * unsigned long n, unsigned long *idx);
* type **jmap_@name_firstval(const struct jmap_@name *map,
- * size_t *index);
- * type **jmap_@name_nextval(const struct jmap_@name *map, size_t *index);
- * type **jmap_@name_lastval(const struct jmap_@name *map, size_t *index);
- * type **jmap_@name_prevval(const struct jmap_@name *map, size_t *index);
+ * unsigned long *idx);
+ * type **jmap_@name_nextval(const struct jmap_@name *map,
+ * unsigned long *idx);
+ * type **jmap_@name_lastval(const struct jmap_@name *map,
+ * unsigned long *idx);
+ * type **jmap_@name_prevval(const struct jmap_@name *map,
+ * unsigned long *idx);
*/
#define JMAP_DEFINE_UINTIDX_TYPE(type, name) \
struct jmap_##name; \
return jmap_error((struct jmap *)map); \
} \
static inline bool jmap_##name##_add(struct jmap_##name *map, \
- size_t index, const type *value) \
+ unsigned long idx, const type *value) \
{ \
- return jmap_add((struct jmap *)map, index, (size_t)value); \
+ return jmap_add((struct jmap *)map, idx, (unsigned long)value); \
} \
static inline bool jmap_##name##_set(const struct jmap_##name *map, \
- size_t index, const type *value) \
+ unsigned long idx, const type *value) \
{ \
- return jmap_set((const struct jmap *)map, index, (size_t)value); \
+ return jmap_set((const struct jmap *)map, idx, (unsigned long)value); \
} \
-static inline bool jmap_##name##_del(struct jmap_##name *map, size_t index) \
+static inline bool jmap_##name##_del(struct jmap_##name *map, \
+ unsigned long idx) \
{ \
- return jmap_del((struct jmap *)map, index); \
+ return jmap_del((struct jmap *)map, idx); \
} \
-static inline bool jmap_##name##_test(const struct jmap_##name *map, \
- size_t index) \
+static inline bool jmap_##name##_test(const struct jmap_##name *map, \
+ unsigned long idx) \
{ \
- return jmap_test((const struct jmap *)map, (size_t)index); \
+ return jmap_test((const struct jmap *)map, (unsigned long)idx); \
} \
static inline type *jmap_##name##_get(const struct jmap_##name *map, \
- size_t index) \
+ unsigned long idx) \
{ \
- return (type *)jmap_get((const struct jmap *)map, index, 0); \
+ return (type *)jmap_get((const struct jmap *)map, idx, 0); \
} \
-static inline size_t jmap_##name##_popcount(const struct jmap_##name *map, \
- size_t start, size_t end_incl) \
+static inline unsigned long \
+jmap_##name##_popcount(const struct jmap_##name *map, \
+ unsigned long start, unsigned long end_incl) \
{ \
return jmap_popcount((const struct jmap *)map, start, end_incl); \
} \
-static inline size_t jmap_##name##_nth(const struct jmap_##name *map, \
- size_t n, size_t invalid) \
+static inline unsigned long jmap_##name##_nth(const struct jmap_##name *map, \
+ unsigned long n, \
+ unsigned long invalid) \
{ \
return jmap_nth((const struct jmap *)map, n, invalid); \
} \
-static inline size_t jmap_##name##_first(const struct jmap_##name *map, \
- size_t invalid) \
+static inline unsigned long \
+jmap_##name##_first(const struct jmap_##name *map, \
+ unsigned long invalid) \
{ \
return jmap_first((const struct jmap *)map, invalid); \
} \
-static inline size_t jmap_##name##_next(const struct jmap_##name *map, \
- size_t prev, size_t invalid) \
+static inline unsigned long \
+jmap_##name##_next(const struct jmap_##name *map, \
+ unsigned long prev, unsigned long invalid) \
{ \
return jmap_next((const struct jmap *)map, prev, invalid); \
} \
-static inline size_t jmap_##name##_last(const struct jmap_##name *map, \
- size_t invalid) \
+static inline unsigned long \
+jmap_##name##_last(const struct jmap_##name *map, \
+ unsigned long invalid) \
{ \
return jmap_last((const struct jmap *)map, invalid); \
} \
-static inline size_t jmap_##name##_prev(const struct jmap_##name *map, \
- size_t prev, size_t invalid) \
+static inline unsigned long \
+jmap_##name##_prev(const struct jmap_##name *map, \
+ unsigned long prev, unsigned long invalid) \
{ \
return jmap_prev((const struct jmap *)map, prev, invalid); \
} \
static inline type **jmap_##name##_getval(const struct jmap_##name *map, \
- size_t index) \
+ unsigned long idx) \
{ \
- return (type **)jmap_getval((struct jmap *)map, index); \
+ return (type **)jmap_getval((struct jmap *)map, idx); \
} \
static inline void jmap_##name##_putval(struct jmap_##name *map, \
type ***p) \
{ \
- return jmap_putval((struct jmap *)map, (size_t **)p); \
+ return jmap_putval((struct jmap *)map, (unsigned long **)p); \
} \
static inline type **jmap_##name##_nthval(struct jmap_##name *map, \
- size_t n, size_t *index) \
+ unsigned long n, \
+ unsigned long *idx) \
{ \
- return (type **)jmap_nthval((struct jmap *)map, n, index); \
+ return (type **)jmap_nthval((struct jmap *)map, n, idx); \
} \
static inline type **jmap_##name##_firstval(const struct jmap_##name *map, \
- size_t *index) \
+ unsigned long *idx) \
{ \
- return (type **)jmap_firstval((const struct jmap *)map, index); \
+ return (type **)jmap_firstval((const struct jmap *)map, idx); \
} \
static inline type **jmap_##name##_nextval(const struct jmap_##name *map, \
- size_t *index) \
+ unsigned long *idx) \
{ \
- return (type **)jmap_nextval((const struct jmap *)map, index); \
+ return (type **)jmap_nextval((const struct jmap *)map, idx); \
} \
static inline type **jmap_##name##_lastval(const struct jmap_##name *map, \
- size_t *index) \
+ unsigned long *idx) \
{ \
- return (type **)jmap_lastval((const struct jmap *)map, index); \
+ return (type **)jmap_lastval((const struct jmap *)map, idx); \
} \
static inline type **jmap_##name##_prevval(const struct jmap_##name *map, \
- size_t *index) \
+ unsigned long *idx) \
{ \
- return (type **)jmap_prevval((const struct jmap *)map, index); \
+ return (type **)jmap_prevval((const struct jmap *)map, idx); \
}
/**
* JMAP_DEFINE_PTRIDX_TYPE - create a map of jmap ops for ptr->ptr map
- * @itype: a type whose pointers will index into the map.
+ * @itype: a type whose pointers will idx into the map.
* @type: a type whose pointers will be values in the map.
* @name: a name for all the functions to define (of form jmap_<name>_*)
*
* This macro defines a map of inline functions for typesafe and
- * convenient usage of a pointer-indexed Judy map of pointers. It is
- * assumed that a NULL pointer is never an index in the map, as
- * various functions return NULL for "invalid index". Similarly,
- * jmap_@name_get will return NULL if an index isn't valid, so NULL indices
+ * convenient usage of a pointer-idxed Judy map of pointers. It is
+ * assumed that a NULL pointer is never an idx in the map, as
+ * various functions return NULL for "invalid idx". Similarly,
+ * jmap_@name_get will return NULL if an idx isn't valid, so NULL indices
* are not recommended (though you can tell using jmap_@name_test).
*
- * Since the ordering is by index pointer value, it's generally quite useless.
+ * Since the ordering is by idx pointer value, it's generally quite useless.
* Thus we don't define order-specific functions, except first/next for
* traversal.
*
* const char *jmap_@name_error(struct jmap_@name *map);
*
* bool jmap_@name_add(const struct jmap_@name *map,
- * const itype *index, const type *value);
+ * const itype *idx, const type *value);
* bool jmap_@name_set(const struct jmap_@name *map,
- * const itype *index, const type *value);
- * bool jmap_@name_del(struct jmap_@name *map, const itype *index);
- * bool jmap_@name_test(const struct jmap_@name *map, const itype *index);
+ * const itype *idx, const type *value);
+ * bool jmap_@name_del(struct jmap_@name *map, const itype *idx);
+ * bool jmap_@name_test(const struct jmap_@name *map, const itype *idx);
*
- * type *jmap_@name_get(const struct jmap_@name *map, const itype *index);
+ * type *jmap_@name_get(const struct jmap_@name *map, const itype *idx);
* itype *jmap_@name_count(const struct jmap_@name *map);
* itype *jmap_@name_first(const struct jmap_@name *map);
* itype *jmap_@name_next(const struct jmap_@name *map,
* const itype *prev);
*
* type **jmap_@name_getval(const struct jmap_@name *map,
- * const itype *index);
+ * const itype *idx);
* void jmap_@name_putval(struct jmap_@name *map, type ***p);
* type **jmap_@name_firstval(const struct jmap_@name *map,
- * const itype **index);
+ * const itype **idx);
* type **jmap_@name_nextval(const struct jmap_@name *map,
- * const itype **index);
+ * const itype **idx);
*/
#define JMAP_DEFINE_PTRIDX_TYPE(itype, type, name) \
struct jmap_##name; \
return jmap_error((struct jmap *)map); \
} \
static inline bool jmap_##name##_add(struct jmap_##name *map, \
- const itype *index, const type *value) \
+ const itype *idx, const type *value) \
{ \
- return jmap_add((struct jmap *)map, (size_t)index, \
- (size_t)value); \
+ return jmap_add((struct jmap *)map, (unsigned long)idx, \
+ (unsigned long)value); \
} \
static inline bool jmap_##name##_set(const struct jmap_##name *map, \
- const itype *index, const type *value) \
+ const itype *idx, const type *value) \
{ \
- return jmap_set((const struct jmap *)map, (size_t)index, \
- (size_t)value); \
+ return jmap_set((const struct jmap *)map, (unsigned long)idx, \
+ (unsigned long)value); \
} \
static inline bool jmap_##name##_del(struct jmap_##name *map, \
- const itype *index) \
+ const itype *idx) \
{ \
- return jmap_del((struct jmap *)map, (size_t)index); \
+ return jmap_del((struct jmap *)map, (unsigned long)idx); \
} \
static inline bool jmap_##name##_test(const struct jmap_##name *map, \
- const itype *index) \
+ const itype *idx) \
{ \
- return jmap_test((const struct jmap *)map, (size_t)index); \
+ return jmap_test((const struct jmap *)map, (unsigned long)idx); \
} \
static inline type *jmap_##name##_get(const struct jmap_##name *map, \
- const itype *index) \
+ const itype *idx) \
{ \
- return (type *)jmap_get((const struct jmap *)map, (size_t)index, 0); \
+ return (type *)jmap_get((const struct jmap *)map, \
+ (unsigned long)idx, 0); \
} \
-static inline size_t jmap_##name##_count(const struct jmap_##name *map) \
+static inline unsigned long \
+jmap_##name##_count(const struct jmap_##name *map) \
{ \
return jmap_popcount((const struct jmap *)map, 0, -1); \
} \
static inline itype *jmap_##name##_next(const struct jmap_##name *map, \
const itype *prev) \
{ \
- return (itype *)jmap_next((const struct jmap *)map, (size_t)prev, 0); \
+ return (itype *)jmap_next((const struct jmap *)map, \
+ (unsigned long)prev, 0); \
} \
static inline type **jmap_##name##_getval(const struct jmap_##name *map, \
- const itype *index) \
+ const itype *idx) \
{ \
- return (type **)jmap_getval((struct jmap *)map, (size_t)index); \
+ return (type **)jmap_getval((struct jmap *)map, \
+ (unsigned long)idx); \
} \
static inline void jmap_##name##_putval(struct jmap_##name *map, \
type ***p) \
{ \
- return jmap_putval((struct jmap *)map, (size_t **)p); \
+ return jmap_putval((struct jmap *)map, (unsigned long **)p); \
} \
static inline type **jmap_##name##_firstval(const struct jmap_##name *map, \
- itype **index) \
+ itype **idx) \
{ \
- size_t idx; \
+ unsigned long i; \
type **ret; \
- ret = (type **)jmap_firstval((const struct jmap *)map, &idx); \
- *index = (void *)idx; \
+ ret = (type **)jmap_firstval((const struct jmap *)map, &i); \
+ *idx = (void *)i; \
return ret; \
} \
static inline type **jmap_##name##_nextval(const struct jmap_##name *map, \
- itype **index) \
+ itype **idx) \
{ \
return (type **)jmap_nextval((const struct jmap *)map, \
- (size_t *)index); \
+ (unsigned long *)idx); \
}
#endif /* CCAN_JMAP_TYPE_H */