summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/tables.h
diff options
context:
space:
mode:
authorMichael Brown2010-09-05 00:29:00 +0200
committerMichael Brown2010-09-05 03:49:06 +0200
commitc04b6ccd75cc87b55b74bcc6a9798ad038b3e744 (patch)
treeb69fbd1907b73be976086f3aa97326ecfa46574f /src/include/ipxe/tables.h
parent[rtl8139] Strip CRC from received packets (diff)
downloadipxe-c04b6ccd75cc87b55b74bcc6a9798ad038b3e744.tar.gz
ipxe-c04b6ccd75cc87b55b74bcc6a9798ad038b3e744.tar.xz
ipxe-c04b6ccd75cc87b55b74bcc6a9798ad038b3e744.zip
[tables] Add for_each_table_entry_continue() and _continue_reverse()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe/tables.h')
-rw-r--r--src/include/ipxe/tables.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/include/ipxe/tables.h b/src/include/ipxe/tables.h
index 74d43753..583ba51b 100644
--- a/src/include/ipxe/tables.h
+++ b/src/include/ipxe/tables.h
@@ -360,6 +360,35 @@ FILE_LICENCE ( GPL2_OR_LATER );
pointer++ )
/**
+ * Iterate through all remaining entries within a linker table
+ *
+ * @v pointer Entry pointer, preset to most recent entry
+ * @v table Linker table
+ *
+ * Example usage:
+ *
+ * @code
+ *
+ * #define FROBNICATORS __table ( struct frobnicator, "frobnicators" )
+ * #define __frobnicator __table_entry ( FROBNICATORS, 01 )
+ *
+ * struct frob my_frobnicator __frobnicator;
+ * struct frobnicator *frob;
+ *
+ * frob = &my_frobnicator;
+ * for_each_table_entry_continue ( frob, FROBNICATORS ) {
+ * ...
+ * }
+ *
+ * @endcode
+ *
+ */
+#define for_each_table_entry_continue( pointer, table ) \
+ for ( pointer++ ; \
+ pointer < table_end ( table ) ; \
+ pointer++ )
+
+/**
* Iterate through all entries within a linker table in reverse order
*
* @v pointer Entry pointer
@@ -385,6 +414,35 @@ FILE_LICENCE ( GPL2_OR_LATER );
pointer >= table_start ( table ) ; \
pointer-- )
+/**
+ * Iterate through all remaining entries within a linker table in reverse order
+ *
+ * @v pointer Entry pointer, preset to most recent entry
+ * @v table Linker table
+ *
+ * Example usage:
+ *
+ * @code
+ *
+ * #define FROBNICATORS __table ( struct frobnicator, "frobnicators" )
+ * #define __frobnicator __table_entry ( FROBNICATORS, 01 )
+ *
+ * struct frob my_frobnicator __frobnicator;
+ * struct frobnicator *frob;
+ *
+ * frob = &my_frobnicator;
+ * for_each_table_entry_continue_reverse ( frob, FROBNICATORS ) {
+ * ...
+ * }
+ *
+ * @endcode
+ *
+ */
+#define for_each_table_entry_continue_reverse( pointer, table ) \
+ for ( pointer-- ; \
+ pointer >= table_start ( table ) ; \
+ pointer-- )
+
/******************************************************************************
*
* Intel's C compiler chokes on several of the constructs used in this