objc-config.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. * Copyright (c) 1999-2002, 2005-2008 Apple Inc. All Rights Reserved.
  3. *
  4. * @APPLE_LICENSE_HEADER_START@
  5. *
  6. * This file contains Original Code and/or Modifications of Original Code
  7. * as defined in and that are subject to the Apple Public Source License
  8. * Version 2.0 (the 'License'). You may not use this file except in
  9. * compliance with the License. Please obtain a copy of the License at
  10. * http://www.opensource.apple.com/apsl/ and read it before using this
  11. * file.
  12. *
  13. * The Original Code and all software distributed under the License are
  14. * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  15. * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  16. * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
  18. * Please see the License for the specific language governing rights and
  19. * limitations under the License.
  20. *
  21. * @APPLE_LICENSE_HEADER_END@
  22. */
  23. #ifndef _OBJC_CONFIG_H_
  24. #define _OBJC_CONFIG_H_
  25. #include <TargetConditionals.h>
  26. // Define __OBJC2__ for the benefit of our asm files.
  27. #ifndef __OBJC2__
  28. # if TARGET_OS_OSX && !TARGET_OS_IOSMAC && __i386__
  29. // old ABI
  30. # else
  31. # define __OBJC2__ 1
  32. # endif
  33. #endif
  34. // Avoid the !NDEBUG double negative.
  35. #if !NDEBUG
  36. # define DEBUG 1
  37. #else
  38. # define DEBUG 0
  39. #endif
  40. // Define SUPPORT_GC_COMPAT=1 to enable compatibility where GC once was.
  41. // OBJC_NO_GC and OBJC_NO_GC_API in objc-api.h mean something else.
  42. #if !TARGET_OS_OSX
  43. # define SUPPORT_GC_COMPAT 0
  44. #else
  45. # define SUPPORT_GC_COMPAT 1
  46. #endif
  47. // Define SUPPORT_ZONES=1 to enable malloc zone support in NXHashTable.
  48. #if !(TARGET_OS_OSX || TARGET_OS_IOSMAC)
  49. # define SUPPORT_ZONES 0
  50. #else
  51. # define SUPPORT_ZONES 1
  52. #endif
  53. // Define SUPPORT_MOD=1 to use the mod operator in NXHashTable and objc-sel-set
  54. #if defined(__arm__)
  55. # define SUPPORT_MOD 0
  56. #else
  57. # define SUPPORT_MOD 1
  58. #endif
  59. // Define SUPPORT_PREOPT=1 to enable dyld shared cache optimizations
  60. #if TARGET_OS_WIN32 || TARGET_OS_SIMULATOR
  61. # define SUPPORT_PREOPT 0
  62. #else
  63. # define SUPPORT_PREOPT 1
  64. #endif
  65. // Define SUPPORT_TAGGED_POINTERS=1 to enable tagged pointer objects
  66. // Be sure to edit tagged pointer SPI in objc-internal.h as well.
  67. #if !(__OBJC2__ && __LP64__)
  68. # define SUPPORT_TAGGED_POINTERS 0
  69. #else
  70. # define SUPPORT_TAGGED_POINTERS 1
  71. #endif
  72. // Define SUPPORT_MSB_TAGGED_POINTERS to use the MSB
  73. // as the tagged pointer marker instead of the LSB.
  74. // Be sure to edit tagged pointer SPI in objc-internal.h as well.
  75. #if !SUPPORT_TAGGED_POINTERS || (TARGET_OS_OSX || TARGET_OS_IOSMAC)
  76. # define SUPPORT_MSB_TAGGED_POINTERS 0
  77. #else
  78. # define SUPPORT_MSB_TAGGED_POINTERS 1
  79. #endif
  80. // Define SUPPORT_INDEXED_ISA=1 on platforms that store the class in the isa
  81. // field as an index into a class table.
  82. // Note, keep this in sync with any .s files which also define it.
  83. // Be sure to edit objc-abi.h as well.
  84. #if __ARM_ARCH_7K__ >= 2 || (__arm64__ && !__LP64__)
  85. # define SUPPORT_INDEXED_ISA 1
  86. #else
  87. # define SUPPORT_INDEXED_ISA 0
  88. #endif
  89. // Define SUPPORT_PACKED_ISA=1 on platforms that store the class in the isa
  90. // field as a maskable pointer with other data around it.
  91. #if (!__LP64__ || TARGET_OS_WIN32 || \
  92. (TARGET_OS_SIMULATOR && !TARGET_OS_IOSMAC))
  93. # define SUPPORT_PACKED_ISA 0
  94. #else
  95. # define SUPPORT_PACKED_ISA 1
  96. #endif
  97. // Define SUPPORT_NONPOINTER_ISA=1 on any platform that may store something
  98. // in the isa field that is not a raw pointer.
  99. #if !SUPPORT_INDEXED_ISA && !SUPPORT_PACKED_ISA
  100. # define SUPPORT_NONPOINTER_ISA 0
  101. #else
  102. # define SUPPORT_NONPOINTER_ISA 1
  103. #endif
  104. // Define SUPPORT_FIXUP=1 to repair calls sites for fixup dispatch.
  105. // Fixup messaging itself is no longer supported.
  106. // Be sure to edit objc-abi.h as well (objc_msgSend*_fixup)
  107. #if !(defined(__x86_64__) && (TARGET_OS_OSX || TARGET_OS_SIMULATOR))
  108. # define SUPPORT_FIXUP 0
  109. #else
  110. # define SUPPORT_FIXUP 1
  111. #endif
  112. // Define SUPPORT_ZEROCOST_EXCEPTIONS to use "zero-cost" exceptions for OBJC2.
  113. // Be sure to edit objc-exception.h as well (objc_add/removeExceptionHandler)
  114. #if !__OBJC2__ || (defined(__arm__) && __USING_SJLJ_EXCEPTIONS__)
  115. # define SUPPORT_ZEROCOST_EXCEPTIONS 0
  116. #else
  117. # define SUPPORT_ZEROCOST_EXCEPTIONS 1
  118. #endif
  119. // Define SUPPORT_ALT_HANDLERS if you're using zero-cost exceptions
  120. // but also need to support AppKit's alt-handler scheme
  121. // Be sure to edit objc-exception.h as well (objc_add/removeExceptionHandler)
  122. #if !SUPPORT_ZEROCOST_EXCEPTIONS || !TARGET_OS_OSX
  123. # define SUPPORT_ALT_HANDLERS 0
  124. #else
  125. # define SUPPORT_ALT_HANDLERS 1
  126. #endif
  127. // Define SUPPORT_RETURN_AUTORELEASE to optimize autoreleased return values
  128. #if TARGET_OS_WIN32
  129. # define SUPPORT_RETURN_AUTORELEASE 0
  130. #else
  131. # define SUPPORT_RETURN_AUTORELEASE 1
  132. #endif
  133. // Define SUPPORT_STRET on architectures that need separate struct-return ABI.
  134. #if defined(__arm64__)
  135. # define SUPPORT_STRET 0
  136. #else
  137. # define SUPPORT_STRET 1
  138. #endif
  139. // Define SUPPORT_MESSAGE_LOGGING to enable NSObjCMessageLoggingEnabled
  140. #if !TARGET_OS_OSX
  141. # define SUPPORT_MESSAGE_LOGGING 0
  142. #else
  143. # define SUPPORT_MESSAGE_LOGGING 1
  144. #endif
  145. // OBJC_INSTRUMENTED controls whether message dispatching is dynamically
  146. // monitored. Monitoring introduces substantial overhead.
  147. // NOTE: To define this condition, do so in the build command, NOT by
  148. // uncommenting the line here. This is because objc-class.h heeds this
  149. // condition, but objc-class.h can not #include this file (objc-config.h)
  150. // because objc-class.h is public and objc-config.h is not.
  151. //#define OBJC_INSTRUMENTED
  152. #endif