opal/class: add additional object helper functions
This commit adds two additional helpers to opal/class: - OPAL_HASH_TABLE_FOREACH_PTR: Same as OPAL_HASH_TABLE_FOREACH but operating on ptr hash tables. This is needed because the _ptr iterator functions take an additional argument. - OPAL_LIST_FOREACH_DECL: Same as OPAL_LIST_FOREACH but declares the variable specified in the first argument. Signed-off-by: Nathan Hjelm <hjelmn@google.com>
Этот коммит содержится в:
родитель
1b6622f5d9
Коммит
3a036f8486
@ -486,6 +486,13 @@ OPAL_DECLSPEC int opal_proc_table_get_next_key(opal_proc_table_t *pt, opal_proce
|
|||||||
for (void *_nptr=NULL; \
|
for (void *_nptr=NULL; \
|
||||||
OPAL_SUCCESS == opal_hash_table_get_next_key_##type(ht, &key, (void **)&value, _nptr, &_nptr);)
|
OPAL_SUCCESS == opal_hash_table_get_next_key_##type(ht, &key, (void **)&value, _nptr, &_nptr);)
|
||||||
|
|
||||||
|
#define OPAL_HASH_TABLE_FOREACH_PTR(key, value, ht, body) \
|
||||||
|
{ \
|
||||||
|
size_t key_size_; \
|
||||||
|
for (void *_nptr=NULL; \
|
||||||
|
OPAL_SUCCESS == opal_hash_table_get_next_key_ptr (ht, &key, &key_size_, (void **)&value, _nptr, &_nptr);) \
|
||||||
|
body \
|
||||||
|
}
|
||||||
END_C_DECLS
|
END_C_DECLS
|
||||||
|
|
||||||
#endif /* OPAL_HASH_TABLE_H */
|
#endif /* OPAL_HASH_TABLE_H */
|
||||||
|
@ -215,6 +215,11 @@ typedef struct opal_list_t opal_list_t;
|
|||||||
item != (type *) &(list)->opal_list_sentinel ; \
|
item != (type *) &(list)->opal_list_sentinel ; \
|
||||||
item = (type *) ((opal_list_item_t *) (item))->opal_list_next)
|
item = (type *) ((opal_list_item_t *) (item))->opal_list_next)
|
||||||
|
|
||||||
|
#define OPAL_LIST_FOREACH_DECL(item, list, type) \
|
||||||
|
for (type *item = (type *) (list)->opal_list_sentinel.opal_list_next ; \
|
||||||
|
item != (type *) &(list)->opal_list_sentinel ; \
|
||||||
|
item = (type *) ((opal_list_item_t *) (item))->opal_list_next)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loop over a list in reverse.
|
* Loop over a list in reverse.
|
||||||
*
|
*
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user