mirror of
https://github.com/xcat2/xNBA.git
synced 2025-02-17 02:58:14 +00:00
[tables] Add table_index()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
parent
0329673833
commit
da123eada4
@ -308,6 +308,31 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||
( ( unsigned int ) ( table_end ( table ) - \
|
||||
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
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user