From 1266d7902bf7f2534ee279671d48613ef9b2434c Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 12 Mar 2009 19:41:40 +0000 Subject: [tables] Redefine methods for accessing linker tables Intel's C compiler (icc) chokes on the zero-length arrays that we currently use as part of the mechanism for accessing linker table entries. Abstract away the zero-length arrays, to make a port to icc easier. Introduce macros such as for_each_table_entry() to simplify the common case of iterating over all entries in a linker table. Represent table names as #defined string constants rather than unquoted literals; this avoids visual confusion between table names and C variable or type names, and also allows us to force a compilation error in the event of incorrect table names. --- src/interface/efi/efi_init.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'src/interface') diff --git a/src/interface/efi/efi_init.c b/src/interface/efi/efi_init.c index 6e54cf7e1..43a3ca805 100644 --- a/src/interface/efi/efi_init.c +++ b/src/interface/efi/efi_init.c @@ -26,18 +26,6 @@ EFI_HANDLE efi_image_handle; /** System table passed to entry point */ EFI_SYSTEM_TABLE *efi_systab; -/** Declared used EFI protocols */ -static struct efi_protocol efi_protocols[0] \ - __table_start ( struct efi_protocol, efi_protocols ); -static struct efi_protocol efi_protocols_end[0] \ - __table_end ( struct efi_protocol, efi_protocols ); - -/** Declared used EFI configuration tables */ -static struct efi_config_table efi_config_tables[0] \ - __table_start ( struct efi_config_table, efi_config_tables ); -static struct efi_config_table efi_config_tables_end[0] \ - __table_end ( struct efi_config_table, efi_config_tables ); - /** * Look up EFI configuration table * @@ -92,7 +80,7 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle, /* Look up used protocols */ bs = systab->BootServices; - for ( prot = efi_protocols ; prot < efi_protocols_end ; prot++ ) { + for_each_table_entry ( prot, EFI_PROTOCOLS ) { if ( ( efirc = bs->LocateProtocol ( &prot->u.guid, NULL, prot->protocol ) ) == 0 ) { DBGC ( systab, "EFI protocol %s is at %p\n", @@ -106,7 +94,7 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle, } /* Look up used configuration tables */ - for ( tab = efi_config_tables ; tab < efi_config_tables_end ; tab++ ) { + for_each_table_entry ( tab, EFI_CONFIG_TABLES ) { if ( ( *(tab->table) = efi_find_table ( &tab->u.guid ) ) ) { DBGC ( systab, "EFI configuration table %s is at %p\n", uuid_ntoa ( &tab->u.uuid ), *(tab->table) ); -- cgit v1.2.3-55-g7522