diff -r 5588347dfcbd -r ce9c83f7ec14 Logging.h --- a/Logging.h Wed May 07 16:47:44 2008 -0700 +++ b/Logging.h Sun Jul 13 10:45:42 2008 -0700 @@ -6,25 +6,32 @@ // Copyright 2008 Jens Alfke. All rights reserved. // -#import +#import NSString* LOC( NSString *key ); // Localized string lookup -#ifdef __cplusplus - #define IN_SEGMENT(SEG) -#else +// To enable IN_SEGMENT (which breaks rarely-called logging code out of your main code segment, +// improving locality of reference) you must define MY_USE_NESTED_FNS in your prefix file or +// target settings, and add the GCC flag "-fnested-functions" to your target's C flags. +#if defined(MY_USE_NESTED_FNS) && ! defined(__cplusplus) #define IN_SEGMENT(SEG) auto __attribute__ ((section ("__TEXT, "#SEG))) __attribute__ ((noinline)) void _outofband_(void);\ _outofband_();\ void _outofband_(void) + #define IN_SEGMENT_NORETURN(SEG) auto __attribute__ ((section ("__TEXT, "#SEG))) __attribute__ ((noinline)) __attribute__((noreturn)) void _assertfailure_(void);\ + _assertfailure_();\ + void _assertfailure_(void) +#else + #define IN_SEGMENT(SEG) + #define IN_SEGMENT_NORETURN(SEG) #endif #define Log(FMT,ARGS...) do{if(__builtin_expect(_gShouldLog,0)) {\ IN_SEGMENT(Logging){_Log(FMT,##ARGS);}\ } }while(0) #define LogTo(DOMAIN,FMT,ARGS...) do{if(__builtin_expect(_gShouldLog,0)) {\ - IN_SEGMENT(Logging) {_LogTo(@""#DOMAIN,FMT,##ARGS);}\ + IN_SEGMENT(Logging) {if(_WillLogTo(@""#DOMAIN)) _LogTo(@""#DOMAIN,FMT,##ARGS);}\ } }while(0) #define Warn Warn