342 // Find the item preceding or following the given location. May return NULL.
343 #define DefineFindItemAtPos(Type,Item,LocationSuffix) \
344 Type *Find##Item##AtPos (const SECTION *Section, OFFSET Location, BOOLEAN Following) \
345 { \
346 /* Find the place so that Item->Location is always less than Location */ \
347 /* and Next##Item->Location is always greater or equal. */ \
348 Type *Item = NULL, *Next##Item = NULL; \
349 if (Location > Section->Size >> 1) \
350 { \
351 Item = GetLast (Section->Item##s); \
352 while (Item && (Item->Location LocationSuffix >= Location)) \
353 { \
354 Next##Item = Item; \
355 Item = GetPrev (Item); \
356 } \
357 } \
358 else \
359 { \
360 Next##Item = GetFirst (Section->Item##s); \
361 while (Next##Item && (Next##Item->Location LocationSuffix < Location)) \
362 { \
363 Item = Next##Item; \
364 Next##Item = GetNext (Next##Item); \
365 } \
366 } \
367 /* If we are looking for something that follows, the case is clear. */ \
368 /* Otherwise, we need to check whether the next item is also OK. */ \
369 if (Following || (Next##Item && (Next##Item->Location LocationSuffix <= Location))) \
370 return Next##Item; \
371 else \
372 return Item; \
373 }
374
375 DefineFindItemAtPos (SYMBOL, Symbol, );
376 DefineFindItemAtPos (RELOC, Reloc, );
377 DefineFindItemAtPos (ROM_CALL, ROMCall, );
378 DefineFindItemAtPos (RAM_CALL, RAMCall, );
379 DefineFindItemAtPos (LIB_CALL, LibCall, );
380 DefineFindItemAtPos (SEGMENT, Segment, .Start->Location);
381
382 #undef DefineFindItemAtPos
?
edit : ça me rend malade tout ça, pas envie d'en lire plus