Browse Source

[tables] Add for_each_table_entry_continue() and _continue_reverse()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
c04b6ccd75
1 changed files with 58 additions and 0 deletions
  1. 58
    0
      src/include/ipxe/tables.h

+ 58
- 0
src/include/ipxe/tables.h View File

@@ -359,6 +359,35 @@ FILE_LICENCE ( GPL2_OR_LATER );
359 359
 	      pointer < table_end ( table ) ;				\
360 360
 	      pointer++ )
361 361
 
362
+/**
363
+ * Iterate through all remaining entries within a linker table
364
+ *
365
+ * @v pointer		Entry pointer, preset to most recent entry
366
+ * @v table		Linker table
367
+ *
368
+ * Example usage:
369
+ *
370
+ * @code
371
+ *
372
+ *   #define FROBNICATORS __table ( struct frobnicator, "frobnicators" )
373
+ *   #define __frobnicator __table_entry ( FROBNICATORS, 01 )
374
+ *
375
+ *   struct frob my_frobnicator __frobnicator;
376
+ *   struct frobnicator *frob;
377
+ *
378
+ *   frob = &my_frobnicator;
379
+ *   for_each_table_entry_continue ( frob, FROBNICATORS ) {
380
+ *     ...
381
+ *   }
382
+ *
383
+ * @endcode
384
+ *
385
+ */
386
+#define for_each_table_entry_continue( pointer, table )			\
387
+	for ( pointer++ ;						\
388
+	      pointer < table_end ( table ) ;				\
389
+	      pointer++ )
390
+
362 391
 /**
363 392
  * Iterate through all entries within a linker table in reverse order
364 393
  *
@@ -385,6 +414,35 @@ FILE_LICENCE ( GPL2_OR_LATER );
385 414
 	      pointer >= table_start ( table ) ;			\
386 415
 	      pointer-- )
387 416
 
417
+/**
418
+ * Iterate through all remaining entries within a linker table in reverse order
419
+ *
420
+ * @v pointer		Entry pointer, preset to most recent entry
421
+ * @v table		Linker table
422
+ *
423
+ * Example usage:
424
+ *
425
+ * @code
426
+ *
427
+ *   #define FROBNICATORS __table ( struct frobnicator, "frobnicators" )
428
+ *   #define __frobnicator __table_entry ( FROBNICATORS, 01 )
429
+ *
430
+ *   struct frob my_frobnicator __frobnicator;
431
+ *   struct frobnicator *frob;
432
+ *
433
+ *   frob = &my_frobnicator;
434
+ *   for_each_table_entry_continue_reverse ( frob, FROBNICATORS ) {
435
+ *     ...
436
+ *   }
437
+ *
438
+ * @endcode
439
+ *
440
+ */
441
+#define for_each_table_entry_continue_reverse( pointer, table )		\
442
+	for ( pointer-- ;						\
443
+	      pointer >= table_start ( table ) ;			\
444
+	      pointer-- )
445
+
388 446
 /******************************************************************************
389 447
  *
390 448
  * Intel's C compiler chokes on several of the constructs used in this

Loading…
Cancel
Save