diff options
| author | Michael Brown | 2010-07-26 14:26:34 +0200 |
|---|---|---|
| committer | Michael Brown | 2010-09-03 22:25:06 +0200 |
| commit | da123eada44c19a2b4efd2e095b3f90313dffd69 (patch) | |
| tree | 790fb9723475ff2b3753242d1d0e75d54848b6d5 /src | |
| parent | [xfer] Add xfer_deliver_raw_meta() (diff) | |
| download | ipxe-da123eada44c19a2b4efd2e095b3f90313dffd69.tar.gz ipxe-da123eada44c19a2b4efd2e095b3f90313dffd69.tar.xz ipxe-da123eada44c19a2b4efd2e095b3f90313dffd69.zip | |
[tables] Add table_index()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/include/ipxe/tables.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/include/ipxe/tables.h b/src/include/ipxe/tables.h index 130486c67..74d437537 100644 --- a/src/include/ipxe/tables.h +++ b/src/include/ipxe/tables.h @@ -309,6 +309,31 @@ FILE_LICENCE ( GPL2_OR_LATER ); table_start ( table ) ) ) /** + * Get index of entry within linker table + * + * @v table Linker table + * @v entry Table entry + * + * Example usage: + * + * @code + * + * #define FROBNICATORS __table ( struct frobnicator, "frobnicators" ) + * + * #define __frobnicator __table_entry ( FROBNICATORS, 01 ) + * + * struct frobnicator my_frob __frobnicator = { + * ... + * }; + * + * unsigned int my_frob_idx = table_index ( FROBNICATORS, &my_frob ); + * + * @endcode + */ +#define table_index( table, entry ) \ + ( ( unsigned int ) ( (entry) - table_start ( table ) ) ) + +/** * Iterate through all entries within a linker table * * @v pointer Entry pointer |
