Changes to config-file structure.
5 // Created by Jens Alfke on 1/5/08.
6 // Copyright 2008 Jens Alfke. All rights reserved.
9 #import <Foundation/Foundation.h>
12 NSString* LOC( NSString *key ); // Localized string lookup
15 // To enable IN_SEGMENT (which breaks rarely-called logging code out of your main code segment,
16 // improving locality of reference) you must define MY_USE_NESTED_FNS in your prefix file or
17 // target settings, and add the GCC flag "-fnested-functions" to your target's C flags.
18 #if defined(MY_USE_NESTED_FNS) && ! defined(__cplusplus)
19 #define IN_SEGMENT(SEG) auto __attribute__ ((section ("__TEXT, "#SEG))) __attribute__ ((noinline)) void _outofband_(void);\
21 void _outofband_(void)
22 #define IN_SEGMENT_NORETURN(SEG) auto __attribute__ ((section ("__TEXT, "#SEG))) __attribute__ ((noinline)) __attribute__((noreturn)) void _assertfailure_(void);\
24 void _assertfailure_(void)
26 #define IN_SEGMENT(SEG)
27 #define IN_SEGMENT_NORETURN(SEG)
30 #define Log(FMT,ARGS...) do{if(__builtin_expect(_gShouldLog,0)) {\
31 IN_SEGMENT(Logging){_Log(FMT,##ARGS);}\
33 #define LogTo(DOMAIN,FMT,ARGS...) do{if(__builtin_expect(_gShouldLog,0)) {\
34 IN_SEGMENT(Logging) {if(_WillLogTo(@""#DOMAIN)) _LogTo(@""#DOMAIN,FMT,##ARGS);}\
38 void AlwaysLog( NSString *msg, ... ) __attribute__((format(__NSString__, 1, 2)));
39 BOOL EnableLog( BOOL enable );
40 #define EnableLogTo( DOMAIN, VALUE ) _EnableLogTo(@""#DOMAIN, VALUE)
41 #define WillLog() _WillLogTo(nil)
42 #define WillLogTo( DOMAIN ) _WillLogTo(@""#DOMAIN)
45 // internals; don't use directly
46 extern int _gShouldLog;
47 void _Log( NSString *msg, ... ) __attribute__((format(__NSString__, 1, 2)));
48 void Warn( NSString *msg, ... ) __attribute__((format(__NSString__, 1, 2)));
49 void _LogTo( NSString *domain, NSString *msg, ... ) __attribute__((format(__NSString__, 2, 3)));
50 BOOL _WillLogTo( NSString *domain );
51 BOOL _EnableLogTo( NSString *domain, BOOL enable );