common.h 918 B

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef COMMON_H
  2. #define COMMON_H
  3. #include <stdint.h> // uint*_t
  4. #import <Foundation/Foundation.h>
  5. #ifdef __LP64__
  6. # define ADDR "0x%016llx"
  7. typedef uint64_t kptr_t;
  8. #else
  9. # define ADDR "0x%08x"
  10. typedef uint32_t kptr_t;
  11. #endif
  12. #define LOG(str, args...) do { NSLog(@str "\n", ##args); } while(0)
  13. // Re-direct LOG macro to GUI ...
  14. //#include "ViewController.h"
  15. //extern id controller;
  16. //#define LOG(str, args...) do { \
  17. // if (controller && [controller respondsToSelector:@selector(log:)]) { \
  18. // if ([NSThread isMainThread]) { \
  19. // [controller log:[NSString stringWithFormat:@str "\n", ##args]]; \
  20. // } else { \
  21. // [controller performSelectorOnMainThread:@selector(log:) withObject:[NSString stringWithFormat:@str "\n", ##args] waitUntilDone:NO]; \
  22. // } \
  23. // } else { \
  24. // NSLog(@str "\n", ##args); \
  25. // } \
  26. //} while(0)
  27. #endif