aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2022-02-14 13:13:37 +0000
committerMichael Brown <mcb30@ipxe.org>2022-02-14 13:21:09 +0000
commit1150321595c44acfac2b2c56590d4d7f1d2ad70c (patch)
treec190091c416437feb53247945a47ae71695812d7
parent0bbd8967830097b9141945ba960e90339c230ccb (diff)
downloadipxe-1150321595c44acfac2b2c56590d4d7f1d2ad70c.zip
ipxe-1150321595c44acfac2b2c56590d4d7f1d2ad70c.tar.gz
ipxe-1150321595c44acfac2b2c56590d4d7f1d2ad70c.tar.bz2
[tables] Add ability to declare static table start and end markers
The compound statement expression within __table_entries() prevents the use of top-level declarations such as static struct thing *things = table_start ( THINGS ); Define TABLE_START() and TABLE_END() macros that can be used as: static TABLE_START ( things_start, THINGS ); static struct thing *things = things_start; Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/include/ipxe/tables.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/include/ipxe/tables.h b/src/include/ipxe/tables.h
index 28a87da..de5b1f2 100644
--- a/src/include/ipxe/tables.h
+++ b/src/include/ipxe/tables.h
@@ -253,6 +253,17 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
__table_entries; } )
/**
+ * Declare start of linker table entries
+ *
+ * @v entries Start of entries
+ * @v table Linker table
+ * @v idx Sub-table index
+ */
+#define __TABLE_ENTRIES( entries, table, idx ) \
+ __table_type ( table ) entries[0] \
+ __table_entry ( table, idx )
+
+/**
* Get start of linker table
*
* @v table Linker table
@@ -271,6 +282,14 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define table_start( table ) __table_entries ( table, 00 )
/**
+ * Declare start of linker table
+ *
+ * @v start Start of linker table
+ * @v table Linker table
+ */
+#define TABLE_START( start, table ) __TABLE_ENTRIES ( start, table, 00 )
+
+/**
* Get end of linker table
*
* @v table Linker table
@@ -289,6 +308,14 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define table_end( table ) __table_entries ( table, 99 )
/**
+ * Declare end of linker table
+ *
+ * @v end End of linker table
+ * @v table Linker table
+ */
+#define TABLE_END( end, table ) __TABLE_ENTRIES ( end, table, 99 )
+
+/**
* Get number of entries in linker table
*
* @v table Linker table