2
0

jemalloc_preamble.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. #ifndef JEMALLOC_PREAMBLE_H
  2. #define JEMALLOC_PREAMBLE_H
  3. #include "jemalloc_internal_defs.h"
  4. #include "jemalloc/internal/jemalloc_internal_decls.h"
  5. #if defined(JEMALLOC_UTRACE) || defined(JEMALLOC_UTRACE_LABEL)
  6. #include <sys/ktrace.h>
  7. # if defined(JEMALLOC_UTRACE)
  8. # define UTRACE_CALL(p, l) utrace(p, l)
  9. # else
  10. # define UTRACE_CALL(p, l) utrace("jemalloc_process", p, l)
  11. # define JEMALLOC_UTRACE
  12. # endif
  13. #endif
  14. #define JEMALLOC_NO_DEMANGLE
  15. #ifdef JEMALLOC_JET
  16. # undef JEMALLOC_IS_MALLOC
  17. # define JEMALLOC_N(n) jet_##n
  18. # include "jemalloc/internal/public_namespace.h"
  19. # define JEMALLOC_NO_RENAME
  20. # include "../jemalloc.h"
  21. # undef JEMALLOC_NO_RENAME
  22. #else
  23. # define JEMALLOC_N(n) je_##n
  24. # include "../jemalloc.h"
  25. #endif
  26. #if defined(JEMALLOC_OSATOMIC)
  27. #include <libkern/OSAtomic.h>
  28. #endif
  29. #ifdef JEMALLOC_ZONE
  30. #include <mach/mach_error.h>
  31. #include <mach/mach_init.h>
  32. #include <mach/vm_map.h>
  33. #endif
  34. #include "jemalloc/internal/jemalloc_internal_macros.h"
  35. /*
  36. * Note that the ordering matters here; the hook itself is name-mangled. We
  37. * want the inclusion of hooks to happen early, so that we hook as much as
  38. * possible.
  39. */
  40. #ifndef JEMALLOC_NO_PRIVATE_NAMESPACE
  41. # ifndef JEMALLOC_JET
  42. # include "jemalloc/internal/private_namespace.h"
  43. # else
  44. # include "jemalloc/internal/private_namespace_jet.h"
  45. # endif
  46. #endif
  47. #include "jemalloc/internal/test_hooks.h"
  48. #ifdef JEMALLOC_DEFINE_MADVISE_FREE
  49. # define JEMALLOC_MADV_FREE 8
  50. #endif
  51. static const bool config_debug =
  52. #ifdef JEMALLOC_DEBUG
  53. true
  54. #else
  55. false
  56. #endif
  57. ;
  58. static const bool have_dss =
  59. #ifdef JEMALLOC_DSS
  60. true
  61. #else
  62. false
  63. #endif
  64. ;
  65. static const bool have_madvise_huge =
  66. #ifdef JEMALLOC_HAVE_MADVISE_HUGE
  67. true
  68. #else
  69. false
  70. #endif
  71. ;
  72. static const bool config_fill =
  73. #ifdef JEMALLOC_FILL
  74. true
  75. #else
  76. false
  77. #endif
  78. ;
  79. static const bool config_lazy_lock =
  80. #ifdef JEMALLOC_LAZY_LOCK
  81. true
  82. #else
  83. false
  84. #endif
  85. ;
  86. static const char * const config_malloc_conf = JEMALLOC_CONFIG_MALLOC_CONF;
  87. static const bool config_prof =
  88. #ifdef JEMALLOC_PROF
  89. true
  90. #else
  91. false
  92. #endif
  93. ;
  94. static const bool config_prof_libgcc =
  95. #ifdef JEMALLOC_PROF_LIBGCC
  96. true
  97. #else
  98. false
  99. #endif
  100. ;
  101. static const bool config_prof_libunwind =
  102. #ifdef JEMALLOC_PROF_LIBUNWIND
  103. true
  104. #else
  105. false
  106. #endif
  107. ;
  108. static const bool maps_coalesce =
  109. #ifdef JEMALLOC_MAPS_COALESCE
  110. true
  111. #else
  112. false
  113. #endif
  114. ;
  115. static const bool config_stats =
  116. #ifdef JEMALLOC_STATS
  117. true
  118. #else
  119. false
  120. #endif
  121. ;
  122. static const bool config_tls =
  123. #ifdef JEMALLOC_TLS
  124. true
  125. #else
  126. false
  127. #endif
  128. ;
  129. static const bool config_utrace =
  130. #ifdef JEMALLOC_UTRACE
  131. true
  132. #else
  133. false
  134. #endif
  135. ;
  136. static const bool config_xmalloc =
  137. #ifdef JEMALLOC_XMALLOC
  138. true
  139. #else
  140. false
  141. #endif
  142. ;
  143. static const bool config_cache_oblivious =
  144. #ifdef JEMALLOC_CACHE_OBLIVIOUS
  145. true
  146. #else
  147. false
  148. #endif
  149. ;
  150. /*
  151. * Undocumented, for jemalloc development use only at the moment. See the note
  152. * in jemalloc/internal/log.h.
  153. */
  154. static const bool config_log =
  155. #ifdef JEMALLOC_LOG
  156. true
  157. #else
  158. false
  159. #endif
  160. ;
  161. /*
  162. * Are extra safety checks enabled; things like checking the size of sized
  163. * deallocations, double-frees, etc.
  164. */
  165. static const bool config_opt_safety_checks =
  166. #ifdef JEMALLOC_OPT_SAFETY_CHECKS
  167. true
  168. #elif defined(JEMALLOC_DEBUG)
  169. /*
  170. * This lets us only guard safety checks by one flag instead of two; fast
  171. * checks can guard solely by config_opt_safety_checks and run in debug mode
  172. * too.
  173. */
  174. true
  175. #else
  176. false
  177. #endif
  178. ;
  179. /*
  180. * Extra debugging of sized deallocations too onerous to be included in the
  181. * general safety checks.
  182. */
  183. static const bool config_opt_size_checks =
  184. #if defined(JEMALLOC_OPT_SIZE_CHECKS) || defined(JEMALLOC_DEBUG)
  185. true
  186. #else
  187. false
  188. #endif
  189. ;
  190. static const bool config_uaf_detection =
  191. #if defined(JEMALLOC_UAF_DETECTION) || defined(JEMALLOC_DEBUG)
  192. true
  193. #else
  194. false
  195. #endif
  196. ;
  197. /* Whether or not the C++ extensions are enabled. */
  198. static const bool config_enable_cxx =
  199. #ifdef JEMALLOC_ENABLE_CXX
  200. true
  201. #else
  202. false
  203. #endif
  204. ;
  205. #if defined(_WIN32) || defined(JEMALLOC_HAVE_SCHED_GETCPU)
  206. /* Currently percpu_arena depends on sched_getcpu. */
  207. #define JEMALLOC_PERCPU_ARENA
  208. #endif
  209. static const bool have_percpu_arena =
  210. #ifdef JEMALLOC_PERCPU_ARENA
  211. true
  212. #else
  213. false
  214. #endif
  215. ;
  216. /*
  217. * Undocumented, and not recommended; the application should take full
  218. * responsibility for tracking provenance.
  219. */
  220. static const bool force_ivsalloc =
  221. #ifdef JEMALLOC_FORCE_IVSALLOC
  222. true
  223. #else
  224. false
  225. #endif
  226. ;
  227. static const bool have_background_thread =
  228. #ifdef JEMALLOC_BACKGROUND_THREAD
  229. true
  230. #else
  231. false
  232. #endif
  233. ;
  234. static const bool config_high_res_timer =
  235. #ifdef JEMALLOC_HAVE_CLOCK_REALTIME
  236. true
  237. #else
  238. false
  239. #endif
  240. ;
  241. static const bool have_memcntl =
  242. #ifdef JEMALLOC_HAVE_MEMCNTL
  243. true
  244. #else
  245. false
  246. #endif
  247. ;
  248. #endif /* JEMALLOC_PREAMBLE_H */