next up previous contents index
Next: 16.8.15 amm_join_func: Join two Up: 16.8 API reference Previous: 16.8.13 amm_iterate_func: Function to

16.8.14 amm_iterate_gen: Call a user-defined function for select entries in an AMM

 

SYNOPSIS

#include <oskit/amm.h>

int amm_iterate_gen(amm_t *amm, int (*amm_iterate_func)(), void *arg, oskit_addr_t addr, oskit_size_t size, int flags, int flagmask);

DESCRIPTION

Calls a user-provided function amm_iterate_func for every entry of amm which falls partially or completely in the range [addr - addr+size-1] and matches the given attribute criteria.

Arg is an opaque value which is passed to every instance of amm_iterate_func (along with amm and the entry itself).

Flags and flagmask specify the attributes that an entry in the range must match for amm_iterate_func to be invoked. Only entries with ((entry->flags & flagmask) == flags) are considered.

amm_iterate_gen continues until the function has been called for all appropriate entries in the range or until one instance of the function returns non-zero. In the latter case, that non-zero value will be returned from amm_iterate_gen.

Since the iteration function may modify or even destroy the entry passed in, amm_iterate_gen uses the following technique for locating the ``next'' entry. At the beginning of each iteration, amm_iterate_gen records the last address covered by the current entry. After the specified iteration function returns, amm_find_addr is called with this address to ``relocate'' the current entry. From this entry, amm_iterate_gen derives the next entry.

PARAMETERS

amm
A pointer to the amm_t structure representing the address map.
amm_iterate_func
Function to be called for every matching entry.
arg
Argument to be passed to every instance of the iteration function.
addr
Address at which to start iterating.
size
Size of the desired range over which to iterate.
flags
Attribute flags that an entry must possess after masking with flagmask.
flagmask
Attribute mask to bitwise-AND with when matching an entry.

RETURNS

Returns zero if amm_iterate_func returned zero for all entries. Returns the first non-zero value returned from any amm_iterate_func call.

RELATED INFORMATION

amm_iterate_func


next up previous contents index
Next: 16.8.15 amm_join_func: Join two Up: 16.8 API reference Previous: 16.8.13 amm_iterate_func: Function to

University of Utah Flux Research Group