diff options
author | Michael Brown | 2009-03-12 20:41:40 +0100 |
---|---|---|
committer | Michael Brown | 2009-03-13 03:06:30 +0100 |
commit | 1266d7902bf7f2534ee279671d48613ef9b2434c (patch) | |
tree | a1a5b188148d983fa962a887476259768f1751d4 /src/core/settings.c | |
parent | [tcp] Avoid setting PSH flag when SYN flag is set (diff) | |
download | ipxe-1266d7902bf7f2534ee279671d48613ef9b2434c.tar.gz ipxe-1266d7902bf7f2534ee279671d48613ef9b2434c.tar.xz ipxe-1266d7902bf7f2534ee279671d48613ef9b2434c.zip |
[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.
Diffstat (limited to 'src/core/settings.c')
-rw-r--r-- | src/core/settings.c | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/src/core/settings.c b/src/core/settings.c index bb5a382b..55f96383 100644 --- a/src/core/settings.c +++ b/src/core/settings.c @@ -37,24 +37,6 @@ * */ -/** Registered settings */ -static struct setting settings[0] - __table_start ( struct setting, settings ); -static struct setting settings_end[0] - __table_end ( struct setting, settings ); - -/** Registered setting types */ -static struct setting_type setting_types[0] - __table_start ( struct setting_type, setting_types ); -static struct setting_type setting_types_end[0] - __table_end ( struct setting_type, setting_types ); - -/** Registered settings applicators */ -static struct settings_applicator settings_applicators[0] - __table_start ( struct settings_applicator, settings_applicators ); -static struct settings_applicator settings_applicators_end[0] - __table_end ( struct settings_applicator, settings_applicators ); - /****************************************************************************** * * Registered settings blocks @@ -229,8 +211,7 @@ static int apply_settings ( void ) { int rc; /* Call all settings applicators */ - for ( applicator = settings_applicators ; - applicator < settings_applicators_end ; applicator++ ) { + for_each_table_entry ( applicator, SETTINGS_APPLICATORS ) { if ( ( rc = applicator->apply() ) != 0 ) { DBG ( "Could not apply settings using applicator " "%p: %s\n", applicator, strerror ( rc ) ); @@ -670,7 +651,7 @@ int storef_setting ( struct settings *settings, struct setting *setting, static struct setting * find_setting ( const char *name ) { struct setting *setting; - for ( setting = settings ; setting < settings_end ; setting++ ) { + for_each_table_entry ( setting, SETTINGS ) { if ( strcmp ( name, setting->name ) == 0 ) return setting; } @@ -686,7 +667,7 @@ static struct setting * find_setting ( const char *name ) { static struct setting_type * find_setting_type ( const char *name ) { struct setting_type *type; - for ( type = setting_types ; type < setting_types_end ; type++ ) { + for_each_table_entry ( type, SETTING_TYPES ) { if ( strcmp ( name, type->name ) == 0 ) return type; } |