From: Lucas De Marchi Date: Mon, 5 Dec 2011 13:33:15 +0000 (-0200) Subject: Inline foreach macro for internal usage X-Git-Tag: v1~103 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf91579b8df997db6af369417d4e439238fb9589;p=thirdparty%2Fkmod.git Inline foreach macro for internal usage Avoid calling _next() function because it's an exported function and linker can not optimize it. Thanks to "Gustavo Sverzut Barbieri " for suggestion. --- diff --git a/libkmod/libkmod-private.h b/libkmod/libkmod-private.h index 660a85c6..85963562 100644 --- a/libkmod/libkmod-private.h +++ b/libkmod/libkmod-private.h @@ -53,6 +53,12 @@ struct kmod_list *kmod_list_remove_data(struct kmod_list *list, const void *data) __must_check __attribute__((nonnull(2))); struct kmod_list *kmod_list_remove_n_latest(struct kmod_list *list, unsigned int n) __must_check; +#undef kmod_list_foreach +#define kmod_list_foreach(list_entry, first_entry) \ + for (list_entry = ((first_entry) == NULL) ? NULL : first_entry; \ + list_entry != NULL; \ + list_entry = (list_entry->node.next == &first_entry->node) ? NULL : \ + container_of(list_entry->node.next, struct kmod_list, node)) /* libkmod.c */ const char *kmod_get_dirname(const struct kmod_ctx *ctx) __attribute__((nonnull(1)));