@shd101wyy/yo 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (339) hide show
  1. package/LICENSE.md +17 -0
  2. package/README.md +80 -0
  3. package/out/cjs/index.cjs +51 -0
  4. package/out/cjs/yo-cli.cjs +2158 -0
  5. package/out/esm/index.mjs +51 -0
  6. package/out/types/src/codegen/async/runtime.d.ts +2 -0
  7. package/out/types/src/codegen/async/state-code-gen.d.ts +10 -0
  8. package/out/types/src/codegen/async/state-machine.d.ts +13 -0
  9. package/out/types/src/codegen/c/collection.d.ts +3 -0
  10. package/out/types/src/codegen/codegen-c.d.ts +12 -0
  11. package/out/types/src/codegen/constants.d.ts +3 -0
  12. package/out/types/src/codegen/expressions/array.d.ts +4 -0
  13. package/out/types/src/codegen/expressions/generation.d.ts +11 -0
  14. package/out/types/src/codegen/expressions/index.d.ts +2 -0
  15. package/out/types/src/codegen/functions/collection.d.ts +5 -0
  16. package/out/types/src/codegen/functions/context.d.ts +57 -0
  17. package/out/types/src/codegen/functions/generation.d.ts +25 -0
  18. package/out/types/src/codegen/functions/index.d.ts +2 -0
  19. package/out/types/src/codegen/index.d.ts +20 -0
  20. package/out/types/src/codegen/parallelism/runtime.d.ts +2 -0
  21. package/out/types/src/codegen/types/collection.d.ts +8 -0
  22. package/out/types/src/codegen/types/generation.d.ts +13 -0
  23. package/out/types/src/codegen/types/index.d.ts +2 -0
  24. package/out/types/src/codegen/utils/fixup.d.ts +2 -0
  25. package/out/types/src/codegen/utils/index.d.ts +77 -0
  26. package/out/types/src/codegen/values/index.d.ts +1 -0
  27. package/out/types/src/emitter.d.ts +11 -0
  28. package/out/types/src/env.d.ts +85 -0
  29. package/out/types/src/error.d.ts +45 -0
  30. package/out/types/src/evaluator/async/await-analysis-types.d.ts +23 -0
  31. package/out/types/src/evaluator/async/await-analysis.d.ts +5 -0
  32. package/out/types/src/evaluator/builtins/alignof.d.ts +8 -0
  33. package/out/types/src/evaluator/builtins/and_or.d.ts +8 -0
  34. package/out/types/src/evaluator/builtins/arc_fns.d.ts +58 -0
  35. package/out/types/src/evaluator/builtins/array_fns.d.ts +0 -0
  36. package/out/types/src/evaluator/builtins/as.d.ts +8 -0
  37. package/out/types/src/evaluator/builtins/async_fns.d.ts +8 -0
  38. package/out/types/src/evaluator/builtins/compt_assert.d.ts +8 -0
  39. package/out/types/src/evaluator/builtins/compt_boolean_fns.d.ts +8 -0
  40. package/out/types/src/evaluator/builtins/compt_expect_error.d.ts +8 -0
  41. package/out/types/src/evaluator/builtins/compt_list_fns.d.ts +33 -0
  42. package/out/types/src/evaluator/builtins/compt_print.d.ts +8 -0
  43. package/out/types/src/evaluator/builtins/compt_string_fns.d.ts +8 -0
  44. package/out/types/src/evaluator/builtins/consume.d.ts +8 -0
  45. package/out/types/src/evaluator/builtins/drop.d.ts +8 -0
  46. package/out/types/src/evaluator/builtins/dup.d.ts +8 -0
  47. package/out/types/src/evaluator/builtins/expr_fns.d.ts +33 -0
  48. package/out/types/src/evaluator/builtins/future_fns.d.ts +8 -0
  49. package/out/types/src/evaluator/builtins/gc.d.ts +8 -0
  50. package/out/types/src/evaluator/builtins/gensym.d.ts +8 -0
  51. package/out/types/src/evaluator/builtins/impl_constraint.d.ts +8 -0
  52. package/out/types/src/evaluator/builtins/macro_expand.d.ts +8 -0
  53. package/out/types/src/evaluator/builtins/numeric_fns.d.ts +8 -0
  54. package/out/types/src/evaluator/builtins/panic.d.ts +8 -0
  55. package/out/types/src/evaluator/builtins/ptr_fns.d.ts +8 -0
  56. package/out/types/src/evaluator/builtins/quote.d.ts +13 -0
  57. package/out/types/src/evaluator/builtins/rc.d.ts +8 -0
  58. package/out/types/src/evaluator/builtins/sizeof.d.ts +8 -0
  59. package/out/types/src/evaluator/builtins/the.d.ts +8 -0
  60. package/out/types/src/evaluator/builtins/type_fns.d.ts +28 -0
  61. package/out/types/src/evaluator/builtins/va_start.d.ts +8 -0
  62. package/out/types/src/evaluator/builtins/var_fns.d.ts +18 -0
  63. package/out/types/src/evaluator/calls/array.d.ts +13 -0
  64. package/out/types/src/evaluator/calls/array_type.d.ts +11 -0
  65. package/out/types/src/evaluator/calls/closure_type.d.ts +11 -0
  66. package/out/types/src/evaluator/calls/compt_function.d.ts +19 -0
  67. package/out/types/src/evaluator/calls/compt_list_type.d.ts +11 -0
  68. package/out/types/src/evaluator/calls/function.d.ts +16 -0
  69. package/out/types/src/evaluator/calls/function_type.d.ts +15 -0
  70. package/out/types/src/evaluator/calls/helper.d.ts +42 -0
  71. package/out/types/src/evaluator/calls/iso.d.ts +15 -0
  72. package/out/types/src/evaluator/calls/module_type.d.ts +11 -0
  73. package/out/types/src/evaluator/calls/numeric_type.d.ts +15 -0
  74. package/out/types/src/evaluator/calls/pointer.d.ts +8 -0
  75. package/out/types/src/evaluator/calls/pointer_type.d.ts +14 -0
  76. package/out/types/src/evaluator/calls/type.d.ts +12 -0
  77. package/out/types/src/evaluator/context.d.ts +169 -0
  78. package/out/types/src/evaluator/exprs/_expr.d.ts +8 -0
  79. package/out/types/src/evaluator/exprs/assignment.d.ts +9 -0
  80. package/out/types/src/evaluator/exprs/begin.d.ts +10 -0
  81. package/out/types/src/evaluator/exprs/binding.d.ts +12 -0
  82. package/out/types/src/evaluator/exprs/c_include.d.ts +8 -0
  83. package/out/types/src/evaluator/exprs/cond.d.ts +8 -0
  84. package/out/types/src/evaluator/exprs/destructuring_assignment.d.ts +33 -0
  85. package/out/types/src/evaluator/exprs/exists.d.ts +0 -0
  86. package/out/types/src/evaluator/exprs/expr.d.ts +9 -0
  87. package/out/types/src/evaluator/exprs/extern.d.ts +8 -0
  88. package/out/types/src/evaluator/exprs/identifer_and_operator.d.ts +9 -0
  89. package/out/types/src/evaluator/exprs/import.d.ts +9 -0
  90. package/out/types/src/evaluator/exprs/initialization_assignment.d.ts +8 -0
  91. package/out/types/src/evaluator/exprs/match.d.ts +8 -0
  92. package/out/types/src/evaluator/exprs/open.d.ts +8 -0
  93. package/out/types/src/evaluator/exprs/property_access.d.ts +8 -0
  94. package/out/types/src/evaluator/exprs/recur.d.ts +8 -0
  95. package/out/types/src/evaluator/exprs/subtype_of.d.ts +21 -0
  96. package/out/types/src/evaluator/exprs/test.d.ts +8 -0
  97. package/out/types/src/evaluator/exprs/typeof.d.ts +8 -0
  98. package/out/types/src/evaluator/exprs/while.d.ts +8 -0
  99. package/out/types/src/evaluator/index.d.ts +26 -0
  100. package/out/types/src/evaluator/types/array.d.ts +8 -0
  101. package/out/types/src/evaluator/types/closure.d.ts +8 -0
  102. package/out/types/src/evaluator/types/compt_list.d.ts +8 -0
  103. package/out/types/src/evaluator/types/concrete_module.d.ts +8 -0
  104. package/out/types/src/evaluator/types/dyn.d.ts +8 -0
  105. package/out/types/src/evaluator/types/enum.d.ts +8 -0
  106. package/out/types/src/evaluator/types/expr_synthesizer.d.ts +14 -0
  107. package/out/types/src/evaluator/types/field.d.ts +14 -0
  108. package/out/types/src/evaluator/types/fn_module.d.ts +8 -0
  109. package/out/types/src/evaluator/types/function.d.ts +58 -0
  110. package/out/types/src/evaluator/types/future_module.d.ts +8 -0
  111. package/out/types/src/evaluator/types/module.d.ts +19 -0
  112. package/out/types/src/evaluator/types/newtype.d.ts +8 -0
  113. package/out/types/src/evaluator/types/object.d.ts +8 -0
  114. package/out/types/src/evaluator/types/proofs.d.ts +0 -0
  115. package/out/types/src/evaluator/types/slice.d.ts +8 -0
  116. package/out/types/src/evaluator/types/struct.d.ts +8 -0
  117. package/out/types/src/evaluator/types/synthesizer.d.ts +16 -0
  118. package/out/types/src/evaluator/types/tuple.d.ts +18 -0
  119. package/out/types/src/evaluator/types/union.d.ts +8 -0
  120. package/out/types/src/evaluator/types/utils.d.ts +71 -0
  121. package/out/types/src/evaluator/types/validation.d.ts +3 -0
  122. package/out/types/src/evaluator/utils/array-utils.d.ts +15 -0
  123. package/out/types/src/evaluator/utils/closure.d.ts +35 -0
  124. package/out/types/src/evaluator/utils.d.ts +4 -0
  125. package/out/types/src/evaluator/values/anonymous_function.d.ts +8 -0
  126. package/out/types/src/evaluator/values/anonymous_module.d.ts +17 -0
  127. package/out/types/src/evaluator/values/anonymous_struct.d.ts +8 -0
  128. package/out/types/src/evaluator/values/array.d.ts +8 -0
  129. package/out/types/src/evaluator/values/boolean.d.ts +3 -0
  130. package/out/types/src/evaluator/values/char.d.ts +3 -0
  131. package/out/types/src/evaluator/values/compt_list.d.ts +8 -0
  132. package/out/types/src/evaluator/values/dyn.d.ts +8 -0
  133. package/out/types/src/evaluator/values/float.d.ts +4 -0
  134. package/out/types/src/evaluator/values/integer.d.ts +4 -0
  135. package/out/types/src/evaluator/values/module.d.ts +58 -0
  136. package/out/types/src/evaluator/values/string.d.ts +3 -0
  137. package/out/types/src/evaluator/values/tuple.d.ts +32 -0
  138. package/out/types/src/expr.d.ts +456 -0
  139. package/out/types/src/function-value.d.ts +42 -0
  140. package/out/types/src/index.d.ts +4 -0
  141. package/out/types/src/lexer.d.ts +2 -0
  142. package/out/types/src/logger.d.ts +1 -0
  143. package/out/types/src/module-manager.d.ts +30 -0
  144. package/out/types/src/naming-checker.d.ts +4 -0
  145. package/out/types/src/parser.d.ts +33 -0
  146. package/out/types/src/test-runner.d.ts +30 -0
  147. package/out/types/src/tests/codegen.test.d.ts +1 -0
  148. package/out/types/src/tests/fixme.test.d.ts +1 -0
  149. package/out/types/src/tests/module-manager.test.d.ts +1 -0
  150. package/out/types/src/tests/parser.test.d.ts +1 -0
  151. package/out/types/src/tests/sample.test.d.ts +0 -0
  152. package/out/types/src/tests/std.test.d.ts +1 -0
  153. package/out/types/src/token.d.ts +40 -0
  154. package/out/types/src/type-value.d.ts +7 -0
  155. package/out/types/src/types/compatibility.d.ts +16 -0
  156. package/out/types/src/types/creators.d.ts +73 -0
  157. package/out/types/src/types/definitions.d.ts +218 -0
  158. package/out/types/src/types/guards.d.ts +70 -0
  159. package/out/types/src/types/hierarchy.d.ts +4 -0
  160. package/out/types/src/types/index.d.ts +7 -0
  161. package/out/types/src/types/module_field.d.ts +2 -0
  162. package/out/types/src/types/tags.d.ts +45 -0
  163. package/out/types/src/types/utils.d.ts +50 -0
  164. package/out/types/src/unit-value.d.ts +7 -0
  165. package/out/types/src/utils.d.ts +6 -0
  166. package/out/types/src/value-tag.d.ts +29 -0
  167. package/out/types/src/value.d.ts +110 -0
  168. package/out/types/src/yo-cli.d.ts +1 -0
  169. package/out/types/tsconfig.tsbuildinfo +1 -0
  170. package/package.json +57 -0
  171. package/scripts/check-liburing.js +76 -0
  172. package/std/alg/hash.yo +50 -0
  173. package/std/allocator.yo +113 -0
  174. package/std/allocators/c_allocator.yo +118 -0
  175. package/std/async.yo +13 -0
  176. package/std/collections/array_list.yo +415 -0
  177. package/std/collections/hash_map.yo +482 -0
  178. package/std/collections/hash_set.yo +706 -0
  179. package/std/collections/index.yo +11 -0
  180. package/std/collections/linked_list.yo +439 -0
  181. package/std/error.yo +0 -0
  182. package/std/gc.yo +10 -0
  183. package/std/index.yo +12 -0
  184. package/std/io/file.yo +191 -0
  185. package/std/io/index.yo +5 -0
  186. package/std/libc/assert.yo +39 -0
  187. package/std/libc/ctype.yo +57 -0
  188. package/std/libc/errno.yo +182 -0
  189. package/std/libc/float.yo +87 -0
  190. package/std/libc/index.yo +29 -0
  191. package/std/libc/limits.yo +65 -0
  192. package/std/libc/math.yo +679 -0
  193. package/std/libc/signal.yo +101 -0
  194. package/std/libc/stdatomic.yo +213 -0
  195. package/std/libc/stdint.yo +214 -0
  196. package/std/libc/stdio.yo +225 -0
  197. package/std/libc/stdlib.yo +204 -0
  198. package/std/libc/string.yo +151 -0
  199. package/std/libc/time.yo +92 -0
  200. package/std/libc/unistd.yo +130 -0
  201. package/std/monad.yo +152 -0
  202. package/std/prelude.yo +3094 -0
  203. package/std/string/index.yo +8 -0
  204. package/std/string/rune.yo +82 -0
  205. package/std/string/string.yo +288 -0
  206. package/std/sync.yo +95 -0
  207. package/std/thread.yo +36 -0
  208. package/std/time.yo +13 -0
  209. package/std/worker.yo +36 -0
  210. package/vendor/mimalloc/.gitattributes +12 -0
  211. package/vendor/mimalloc/CMakeLists.txt +763 -0
  212. package/vendor/mimalloc/LICENSE +21 -0
  213. package/vendor/mimalloc/SECURITY.md +41 -0
  214. package/vendor/mimalloc/azure-pipelines.yml +251 -0
  215. package/vendor/mimalloc/bin/mimalloc-redirect-arm64.dll +0 -0
  216. package/vendor/mimalloc/bin/mimalloc-redirect-arm64.lib +0 -0
  217. package/vendor/mimalloc/bin/mimalloc-redirect-arm64ec.dll +0 -0
  218. package/vendor/mimalloc/bin/mimalloc-redirect-arm64ec.lib +0 -0
  219. package/vendor/mimalloc/bin/mimalloc-redirect.dll +0 -0
  220. package/vendor/mimalloc/bin/mimalloc-redirect.lib +0 -0
  221. package/vendor/mimalloc/bin/mimalloc-redirect32.dll +0 -0
  222. package/vendor/mimalloc/bin/mimalloc-redirect32.lib +0 -0
  223. package/vendor/mimalloc/bin/minject-arm64.exe +0 -0
  224. package/vendor/mimalloc/bin/minject.exe +0 -0
  225. package/vendor/mimalloc/bin/minject32.exe +0 -0
  226. package/vendor/mimalloc/bin/readme.md +118 -0
  227. package/vendor/mimalloc/cmake/JoinPaths.cmake +23 -0
  228. package/vendor/mimalloc/cmake/mimalloc-config-version.cmake +19 -0
  229. package/vendor/mimalloc/cmake/mimalloc-config.cmake +14 -0
  230. package/vendor/mimalloc/contrib/docker/alpine/Dockerfile +23 -0
  231. package/vendor/mimalloc/contrib/docker/alpine-arm32v7/Dockerfile +28 -0
  232. package/vendor/mimalloc/contrib/docker/alpine-x86/Dockerfile +28 -0
  233. package/vendor/mimalloc/contrib/docker/manylinux-x64/Dockerfile +23 -0
  234. package/vendor/mimalloc/contrib/docker/readme.md +10 -0
  235. package/vendor/mimalloc/contrib/vcpkg/portfile.cmake +64 -0
  236. package/vendor/mimalloc/contrib/vcpkg/readme.md +40 -0
  237. package/vendor/mimalloc/contrib/vcpkg/usage +20 -0
  238. package/vendor/mimalloc/contrib/vcpkg/vcpkg-cmake-wrapper.cmake +20 -0
  239. package/vendor/mimalloc/contrib/vcpkg/vcpkg.json +48 -0
  240. package/vendor/mimalloc/doc/bench-2020/bench-c5-18xlarge-2020-01-20-a.svg +887 -0
  241. package/vendor/mimalloc/doc/bench-2020/bench-c5-18xlarge-2020-01-20-b.svg +1185 -0
  242. package/vendor/mimalloc/doc/bench-2020/bench-c5-18xlarge-2020-01-20-rss-a.svg +757 -0
  243. package/vendor/mimalloc/doc/bench-2020/bench-c5-18xlarge-2020-01-20-rss-b.svg +1028 -0
  244. package/vendor/mimalloc/doc/bench-2020/bench-r5a-1.svg +769 -0
  245. package/vendor/mimalloc/doc/bench-2020/bench-r5a-12xlarge-2020-01-16-a.svg +868 -0
  246. package/vendor/mimalloc/doc/bench-2020/bench-r5a-12xlarge-2020-01-16-b.svg +1157 -0
  247. package/vendor/mimalloc/doc/bench-2020/bench-r5a-2.svg +983 -0
  248. package/vendor/mimalloc/doc/bench-2020/bench-r5a-rss-1.svg +683 -0
  249. package/vendor/mimalloc/doc/bench-2020/bench-r5a-rss-2.svg +854 -0
  250. package/vendor/mimalloc/doc/bench-2020/bench-spec-rss.svg +713 -0
  251. package/vendor/mimalloc/doc/bench-2020/bench-spec.svg +713 -0
  252. package/vendor/mimalloc/doc/bench-2020/bench-z4-1.svg +890 -0
  253. package/vendor/mimalloc/doc/bench-2020/bench-z4-2.svg +1146 -0
  254. package/vendor/mimalloc/doc/bench-2020/bench-z4-rss-1.svg +796 -0
  255. package/vendor/mimalloc/doc/bench-2020/bench-z4-rss-2.svg +974 -0
  256. package/vendor/mimalloc/doc/bench-2021/bench-amd5950x-2021-01-30-a.svg +952 -0
  257. package/vendor/mimalloc/doc/bench-2021/bench-amd5950x-2021-01-30-b.svg +1255 -0
  258. package/vendor/mimalloc/doc/bench-2021/bench-c5-18xlarge-2021-01-30-a.svg +955 -0
  259. package/vendor/mimalloc/doc/bench-2021/bench-c5-18xlarge-2021-01-30-b.svg +1269 -0
  260. package/vendor/mimalloc/doc/bench-2021/bench-c5-18xlarge-2021-01-30-rss-a.svg +836 -0
  261. package/vendor/mimalloc/doc/bench-2021/bench-c5-18xlarge-2021-01-30-rss-b.svg +1131 -0
  262. package/vendor/mimalloc/doc/bench-2021/bench-macmini-2021-01-30.svg +766 -0
  263. package/vendor/mimalloc/doc/doxyfile +2895 -0
  264. package/vendor/mimalloc/doc/ds-logo.jpg +0 -0
  265. package/vendor/mimalloc/doc/ds-logo.png +0 -0
  266. package/vendor/mimalloc/doc/mimalloc-doc.h +1452 -0
  267. package/vendor/mimalloc/doc/mimalloc-doxygen.css +60 -0
  268. package/vendor/mimalloc/doc/mimalloc-logo-100.png +0 -0
  269. package/vendor/mimalloc/doc/mimalloc-logo.png +0 -0
  270. package/vendor/mimalloc/doc/mimalloc-logo.svg +161 -0
  271. package/vendor/mimalloc/doc/spades-logo.png +0 -0
  272. package/vendor/mimalloc/doc/unreal-logo.svg +43 -0
  273. package/vendor/mimalloc/ide/vs2022/mimalloc-lib.vcxproj +500 -0
  274. package/vendor/mimalloc/ide/vs2022/mimalloc-lib.vcxproj.filters +108 -0
  275. package/vendor/mimalloc/ide/vs2022/mimalloc-override-dll.vcxproj +508 -0
  276. package/vendor/mimalloc/ide/vs2022/mimalloc-override-dll.vcxproj.filters +111 -0
  277. package/vendor/mimalloc/ide/vs2022/mimalloc-override-test-dep.vcxproj +355 -0
  278. package/vendor/mimalloc/ide/vs2022/mimalloc-override-test.vcxproj +360 -0
  279. package/vendor/mimalloc/ide/vs2022/mimalloc-test-api.vcxproj +295 -0
  280. package/vendor/mimalloc/ide/vs2022/mimalloc-test-stress.vcxproj +292 -0
  281. package/vendor/mimalloc/ide/vs2022/mimalloc-test.vcxproj +289 -0
  282. package/vendor/mimalloc/ide/vs2022/mimalloc.sln +151 -0
  283. package/vendor/mimalloc/include/mimalloc/atomic.h +557 -0
  284. package/vendor/mimalloc/include/mimalloc/internal.h +1153 -0
  285. package/vendor/mimalloc/include/mimalloc/prim.h +421 -0
  286. package/vendor/mimalloc/include/mimalloc/track.h +145 -0
  287. package/vendor/mimalloc/include/mimalloc/types.h +685 -0
  288. package/vendor/mimalloc/include/mimalloc-new-delete.h +66 -0
  289. package/vendor/mimalloc/include/mimalloc-override.h +68 -0
  290. package/vendor/mimalloc/include/mimalloc-stats.h +103 -0
  291. package/vendor/mimalloc/include/mimalloc.h +612 -0
  292. package/vendor/mimalloc/mimalloc.pc.in +11 -0
  293. package/vendor/mimalloc/readme.md +946 -0
  294. package/vendor/mimalloc/src/alloc-aligned.c +360 -0
  295. package/vendor/mimalloc/src/alloc-override.c +316 -0
  296. package/vendor/mimalloc/src/alloc-posix.c +185 -0
  297. package/vendor/mimalloc/src/alloc.c +692 -0
  298. package/vendor/mimalloc/src/arena-abandon.c +346 -0
  299. package/vendor/mimalloc/src/arena.c +1043 -0
  300. package/vendor/mimalloc/src/bitmap.c +441 -0
  301. package/vendor/mimalloc/src/bitmap.h +119 -0
  302. package/vendor/mimalloc/src/free.c +572 -0
  303. package/vendor/mimalloc/src/heap.c +733 -0
  304. package/vendor/mimalloc/src/init.c +714 -0
  305. package/vendor/mimalloc/src/libc.c +334 -0
  306. package/vendor/mimalloc/src/options.c +663 -0
  307. package/vendor/mimalloc/src/os.c +770 -0
  308. package/vendor/mimalloc/src/page-queue.c +390 -0
  309. package/vendor/mimalloc/src/page.c +1049 -0
  310. package/vendor/mimalloc/src/prim/emscripten/prim.c +249 -0
  311. package/vendor/mimalloc/src/prim/osx/alloc-override-zone.c +461 -0
  312. package/vendor/mimalloc/src/prim/osx/prim.c +9 -0
  313. package/vendor/mimalloc/src/prim/prim.c +76 -0
  314. package/vendor/mimalloc/src/prim/readme.md +9 -0
  315. package/vendor/mimalloc/src/prim/unix/prim.c +934 -0
  316. package/vendor/mimalloc/src/prim/wasi/prim.c +284 -0
  317. package/vendor/mimalloc/src/prim/windows/etw-mimalloc.wprp +61 -0
  318. package/vendor/mimalloc/src/prim/windows/etw.h +905 -0
  319. package/vendor/mimalloc/src/prim/windows/etw.man +0 -0
  320. package/vendor/mimalloc/src/prim/windows/prim.c +878 -0
  321. package/vendor/mimalloc/src/prim/windows/readme.md +17 -0
  322. package/vendor/mimalloc/src/random.c +258 -0
  323. package/vendor/mimalloc/src/segment-map.c +142 -0
  324. package/vendor/mimalloc/src/segment.c +1702 -0
  325. package/vendor/mimalloc/src/static.c +41 -0
  326. package/vendor/mimalloc/src/stats.c +635 -0
  327. package/vendor/mimalloc/test/CMakeLists.txt +56 -0
  328. package/vendor/mimalloc/test/main-override-dep.cpp +51 -0
  329. package/vendor/mimalloc/test/main-override-dep.h +11 -0
  330. package/vendor/mimalloc/test/main-override-static.c +539 -0
  331. package/vendor/mimalloc/test/main-override.c +36 -0
  332. package/vendor/mimalloc/test/main-override.cpp +497 -0
  333. package/vendor/mimalloc/test/main.c +46 -0
  334. package/vendor/mimalloc/test/readme.md +16 -0
  335. package/vendor/mimalloc/test/test-api-fill.c +343 -0
  336. package/vendor/mimalloc/test/test-api.c +466 -0
  337. package/vendor/mimalloc/test/test-stress.c +428 -0
  338. package/vendor/mimalloc/test/test-wrong.c +92 -0
  339. package/vendor/mimalloc/test/testhelper.h +49 -0
@@ -0,0 +1,612 @@
1
+ /* ----------------------------------------------------------------------------
2
+ Copyright (c) 2018-2025, Microsoft Research, Daan Leijen
3
+ This is free software; you can redistribute it and/or modify it under the
4
+ terms of the MIT license. A copy of the license can be found in the file
5
+ "LICENSE" at the root of this distribution.
6
+ -----------------------------------------------------------------------------*/
7
+ #pragma once
8
+ #ifndef MIMALLOC_H
9
+ #define MIMALLOC_H
10
+
11
+ #define MI_MALLOC_VERSION 225 // major + 2 digits minor
12
+
13
+ // ------------------------------------------------------
14
+ // Compiler specific attributes
15
+ // ------------------------------------------------------
16
+
17
+ #ifdef __cplusplus
18
+ #if (__cplusplus >= 201103L) || (_MSC_VER > 1900) // C++11
19
+ #define mi_attr_noexcept noexcept
20
+ #else
21
+ #define mi_attr_noexcept throw()
22
+ #endif
23
+ #else
24
+ #define mi_attr_noexcept
25
+ #endif
26
+
27
+ #if defined(__cplusplus) && (__cplusplus >= 201703)
28
+ #define mi_decl_nodiscard [[nodiscard]]
29
+ #elif (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) // includes clang, icc, and clang-cl
30
+ #define mi_decl_nodiscard __attribute__((warn_unused_result))
31
+ #elif defined(_HAS_NODISCARD)
32
+ #define mi_decl_nodiscard _NODISCARD
33
+ #elif (_MSC_VER >= 1700)
34
+ #define mi_decl_nodiscard _Check_return_
35
+ #else
36
+ #define mi_decl_nodiscard
37
+ #endif
38
+
39
+ #if defined(_MSC_VER) || defined(__MINGW32__)
40
+ #if !defined(MI_SHARED_LIB)
41
+ #define mi_decl_export
42
+ #elif defined(MI_SHARED_LIB_EXPORT)
43
+ #define mi_decl_export __declspec(dllexport)
44
+ #else
45
+ #define mi_decl_export __declspec(dllimport)
46
+ #endif
47
+ #if defined(__MINGW32__)
48
+ #define mi_decl_restrict
49
+ #define mi_attr_malloc __attribute__((malloc))
50
+ #else
51
+ #if (_MSC_VER >= 1900) && !defined(__EDG__)
52
+ #define mi_decl_restrict __declspec(allocator) __declspec(restrict)
53
+ #else
54
+ #define mi_decl_restrict __declspec(restrict)
55
+ #endif
56
+ #define mi_attr_malloc
57
+ #endif
58
+ #define mi_cdecl __cdecl
59
+ #define mi_attr_alloc_size(s)
60
+ #define mi_attr_alloc_size2(s1,s2)
61
+ #define mi_attr_alloc_align(p)
62
+ #elif defined(__GNUC__) // includes clang and icc
63
+ #if defined(MI_SHARED_LIB) && defined(MI_SHARED_LIB_EXPORT)
64
+ #define mi_decl_export __attribute__((visibility("default")))
65
+ #else
66
+ #define mi_decl_export
67
+ #endif
68
+ #define mi_cdecl // leads to warnings... __attribute__((cdecl))
69
+ #define mi_decl_restrict
70
+ #define mi_attr_malloc __attribute__((malloc))
71
+ #if (defined(__clang_major__) && (__clang_major__ < 4)) || (__GNUC__ < 5)
72
+ #define mi_attr_alloc_size(s)
73
+ #define mi_attr_alloc_size2(s1,s2)
74
+ #define mi_attr_alloc_align(p)
75
+ #elif defined(__INTEL_COMPILER)
76
+ #define mi_attr_alloc_size(s) __attribute__((alloc_size(s)))
77
+ #define mi_attr_alloc_size2(s1,s2) __attribute__((alloc_size(s1,s2)))
78
+ #define mi_attr_alloc_align(p)
79
+ #else
80
+ #define mi_attr_alloc_size(s) __attribute__((alloc_size(s)))
81
+ #define mi_attr_alloc_size2(s1,s2) __attribute__((alloc_size(s1,s2)))
82
+ #define mi_attr_alloc_align(p) __attribute__((alloc_align(p)))
83
+ #endif
84
+ #else
85
+ #define mi_cdecl
86
+ #define mi_decl_export
87
+ #define mi_decl_restrict
88
+ #define mi_attr_malloc
89
+ #define mi_attr_alloc_size(s)
90
+ #define mi_attr_alloc_size2(s1,s2)
91
+ #define mi_attr_alloc_align(p)
92
+ #endif
93
+
94
+ // ------------------------------------------------------
95
+ // Includes
96
+ // ------------------------------------------------------
97
+
98
+ #include <stddef.h> // size_t
99
+ #include <stdbool.h> // bool
100
+ #include <stdint.h> // INTPTR_MAX
101
+
102
+ #ifdef __cplusplus
103
+ extern "C" {
104
+ #endif
105
+
106
+ // ------------------------------------------------------
107
+ // Standard malloc interface
108
+ // ------------------------------------------------------
109
+
110
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_malloc(size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1);
111
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_calloc(size_t count, size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size2(1,2);
112
+ mi_decl_nodiscard mi_decl_export void* mi_realloc(void* p, size_t newsize) mi_attr_noexcept mi_attr_alloc_size(2);
113
+ mi_decl_export void* mi_expand(void* p, size_t newsize) mi_attr_noexcept mi_attr_alloc_size(2);
114
+
115
+ mi_decl_export void mi_free(void* p) mi_attr_noexcept;
116
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict char* mi_strdup(const char* s) mi_attr_noexcept mi_attr_malloc;
117
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict char* mi_strndup(const char* s, size_t n) mi_attr_noexcept mi_attr_malloc;
118
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict char* mi_realpath(const char* fname, char* resolved_name) mi_attr_noexcept mi_attr_malloc;
119
+
120
+ // ------------------------------------------------------
121
+ // Extended functionality
122
+ // ------------------------------------------------------
123
+ #define MI_SMALL_WSIZE_MAX (128)
124
+ #define MI_SMALL_SIZE_MAX (MI_SMALL_WSIZE_MAX*sizeof(void*))
125
+
126
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_malloc_small(size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1);
127
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_zalloc_small(size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1);
128
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_zalloc(size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1);
129
+
130
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_mallocn(size_t count, size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size2(1,2);
131
+ mi_decl_nodiscard mi_decl_export void* mi_reallocn(void* p, size_t count, size_t size) mi_attr_noexcept mi_attr_alloc_size2(2,3);
132
+ mi_decl_nodiscard mi_decl_export void* mi_reallocf(void* p, size_t newsize) mi_attr_noexcept mi_attr_alloc_size(2);
133
+
134
+ mi_decl_nodiscard mi_decl_export size_t mi_usable_size(const void* p) mi_attr_noexcept;
135
+ mi_decl_nodiscard mi_decl_export size_t mi_good_size(size_t size) mi_attr_noexcept;
136
+
137
+
138
+ // ------------------------------------------------------
139
+ // Internals
140
+ // ------------------------------------------------------
141
+
142
+ typedef void (mi_cdecl mi_deferred_free_fun)(bool force, unsigned long long heartbeat, void* arg);
143
+ mi_decl_export void mi_register_deferred_free(mi_deferred_free_fun* deferred_free, void* arg) mi_attr_noexcept;
144
+
145
+ typedef void (mi_cdecl mi_output_fun)(const char* msg, void* arg);
146
+ mi_decl_export void mi_register_output(mi_output_fun* out, void* arg) mi_attr_noexcept;
147
+
148
+ typedef void (mi_cdecl mi_error_fun)(int err, void* arg);
149
+ mi_decl_export void mi_register_error(mi_error_fun* fun, void* arg);
150
+
151
+ mi_decl_export void mi_collect(bool force) mi_attr_noexcept;
152
+ mi_decl_export int mi_version(void) mi_attr_noexcept;
153
+ mi_decl_export void mi_stats_reset(void) mi_attr_noexcept;
154
+ mi_decl_export void mi_stats_merge(void) mi_attr_noexcept;
155
+ mi_decl_export void mi_stats_print(void* out) mi_attr_noexcept; // backward compatibility: `out` is ignored and should be NULL
156
+ mi_decl_export void mi_stats_print_out(mi_output_fun* out, void* arg) mi_attr_noexcept;
157
+ mi_decl_export void mi_thread_stats_print_out(mi_output_fun* out, void* arg) mi_attr_noexcept;
158
+ mi_decl_export void mi_options_print(void) mi_attr_noexcept;
159
+
160
+ mi_decl_export void mi_process_info(size_t* elapsed_msecs, size_t* user_msecs, size_t* system_msecs,
161
+ size_t* current_rss, size_t* peak_rss,
162
+ size_t* current_commit, size_t* peak_commit, size_t* page_faults) mi_attr_noexcept;
163
+
164
+
165
+ // Generally do not use the following as these are usually called automatically
166
+ mi_decl_export void mi_process_init(void) mi_attr_noexcept;
167
+ mi_decl_export void mi_cdecl mi_process_done(void) mi_attr_noexcept;
168
+ mi_decl_export void mi_thread_init(void) mi_attr_noexcept;
169
+ mi_decl_export void mi_thread_done(void) mi_attr_noexcept;
170
+
171
+
172
+ // -------------------------------------------------------------------------------------
173
+ // Aligned allocation
174
+ // Note that `alignment` always follows `size` for consistency with unaligned
175
+ // allocation, but unfortunately this differs from `posix_memalign` and `aligned_alloc`.
176
+ // -------------------------------------------------------------------------------------
177
+
178
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_malloc_aligned(size_t size, size_t alignment) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1) mi_attr_alloc_align(2);
179
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_malloc_aligned_at(size_t size, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1);
180
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_zalloc_aligned(size_t size, size_t alignment) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1) mi_attr_alloc_align(2);
181
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_zalloc_aligned_at(size_t size, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1);
182
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_calloc_aligned(size_t count, size_t size, size_t alignment) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size2(1,2) mi_attr_alloc_align(3);
183
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_calloc_aligned_at(size_t count, size_t size, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size2(1,2);
184
+ mi_decl_nodiscard mi_decl_export void* mi_realloc_aligned(void* p, size_t newsize, size_t alignment) mi_attr_noexcept mi_attr_alloc_size(2) mi_attr_alloc_align(3);
185
+ mi_decl_nodiscard mi_decl_export void* mi_realloc_aligned_at(void* p, size_t newsize, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_alloc_size(2);
186
+
187
+
188
+ // -------------------------------------------------------------------------------------
189
+ // Heaps: first-class, but can only allocate from the same thread that created it.
190
+ // -------------------------------------------------------------------------------------
191
+
192
+ struct mi_heap_s;
193
+ typedef struct mi_heap_s mi_heap_t;
194
+
195
+ mi_decl_nodiscard mi_decl_export mi_heap_t* mi_heap_new(void);
196
+ mi_decl_export void mi_heap_delete(mi_heap_t* heap);
197
+ mi_decl_export void mi_heap_destroy(mi_heap_t* heap);
198
+ mi_decl_export mi_heap_t* mi_heap_set_default(mi_heap_t* heap);
199
+ mi_decl_export mi_heap_t* mi_heap_get_default(void);
200
+ mi_decl_export mi_heap_t* mi_heap_get_backing(void);
201
+ mi_decl_export void mi_heap_collect(mi_heap_t* heap, bool force) mi_attr_noexcept;
202
+
203
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_malloc(mi_heap_t* heap, size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(2);
204
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_zalloc(mi_heap_t* heap, size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(2);
205
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_calloc(mi_heap_t* heap, size_t count, size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size2(2, 3);
206
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_mallocn(mi_heap_t* heap, size_t count, size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size2(2, 3);
207
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_malloc_small(mi_heap_t* heap, size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(2);
208
+
209
+ mi_decl_nodiscard mi_decl_export void* mi_heap_realloc(mi_heap_t* heap, void* p, size_t newsize) mi_attr_noexcept mi_attr_alloc_size(3);
210
+ mi_decl_nodiscard mi_decl_export void* mi_heap_reallocn(mi_heap_t* heap, void* p, size_t count, size_t size) mi_attr_noexcept mi_attr_alloc_size2(3,4);
211
+ mi_decl_nodiscard mi_decl_export void* mi_heap_reallocf(mi_heap_t* heap, void* p, size_t newsize) mi_attr_noexcept mi_attr_alloc_size(3);
212
+
213
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict char* mi_heap_strdup(mi_heap_t* heap, const char* s) mi_attr_noexcept mi_attr_malloc;
214
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict char* mi_heap_strndup(mi_heap_t* heap, const char* s, size_t n) mi_attr_noexcept mi_attr_malloc;
215
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict char* mi_heap_realpath(mi_heap_t* heap, const char* fname, char* resolved_name) mi_attr_noexcept mi_attr_malloc;
216
+
217
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_malloc_aligned(mi_heap_t* heap, size_t size, size_t alignment) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(2) mi_attr_alloc_align(3);
218
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_malloc_aligned_at(mi_heap_t* heap, size_t size, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(2);
219
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_zalloc_aligned(mi_heap_t* heap, size_t size, size_t alignment) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(2) mi_attr_alloc_align(3);
220
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_zalloc_aligned_at(mi_heap_t* heap, size_t size, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(2);
221
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_calloc_aligned(mi_heap_t* heap, size_t count, size_t size, size_t alignment) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size2(2, 3) mi_attr_alloc_align(4);
222
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_calloc_aligned_at(mi_heap_t* heap, size_t count, size_t size, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size2(2, 3);
223
+ mi_decl_nodiscard mi_decl_export void* mi_heap_realloc_aligned(mi_heap_t* heap, void* p, size_t newsize, size_t alignment) mi_attr_noexcept mi_attr_alloc_size(3) mi_attr_alloc_align(4);
224
+ mi_decl_nodiscard mi_decl_export void* mi_heap_realloc_aligned_at(mi_heap_t* heap, void* p, size_t newsize, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_alloc_size(3);
225
+
226
+
227
+ // --------------------------------------------------------------------------------
228
+ // Zero initialized re-allocation.
229
+ // Only valid on memory that was originally allocated with zero initialization too.
230
+ // e.g. `mi_calloc`, `mi_zalloc`, `mi_zalloc_aligned` etc.
231
+ // see <https://github.com/microsoft/mimalloc/issues/63#issuecomment-508272992>
232
+ // --------------------------------------------------------------------------------
233
+
234
+ mi_decl_nodiscard mi_decl_export void* mi_rezalloc(void* p, size_t newsize) mi_attr_noexcept mi_attr_alloc_size(2);
235
+ mi_decl_nodiscard mi_decl_export void* mi_recalloc(void* p, size_t newcount, size_t size) mi_attr_noexcept mi_attr_alloc_size2(2,3);
236
+
237
+ mi_decl_nodiscard mi_decl_export void* mi_rezalloc_aligned(void* p, size_t newsize, size_t alignment) mi_attr_noexcept mi_attr_alloc_size(2) mi_attr_alloc_align(3);
238
+ mi_decl_nodiscard mi_decl_export void* mi_rezalloc_aligned_at(void* p, size_t newsize, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_alloc_size(2);
239
+ mi_decl_nodiscard mi_decl_export void* mi_recalloc_aligned(void* p, size_t newcount, size_t size, size_t alignment) mi_attr_noexcept mi_attr_alloc_size2(2,3) mi_attr_alloc_align(4);
240
+ mi_decl_nodiscard mi_decl_export void* mi_recalloc_aligned_at(void* p, size_t newcount, size_t size, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_alloc_size2(2,3);
241
+
242
+ mi_decl_nodiscard mi_decl_export void* mi_heap_rezalloc(mi_heap_t* heap, void* p, size_t newsize) mi_attr_noexcept mi_attr_alloc_size(3);
243
+ mi_decl_nodiscard mi_decl_export void* mi_heap_recalloc(mi_heap_t* heap, void* p, size_t newcount, size_t size) mi_attr_noexcept mi_attr_alloc_size2(3,4);
244
+
245
+ mi_decl_nodiscard mi_decl_export void* mi_heap_rezalloc_aligned(mi_heap_t* heap, void* p, size_t newsize, size_t alignment) mi_attr_noexcept mi_attr_alloc_size(3) mi_attr_alloc_align(4);
246
+ mi_decl_nodiscard mi_decl_export void* mi_heap_rezalloc_aligned_at(mi_heap_t* heap, void* p, size_t newsize, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_alloc_size(3);
247
+ mi_decl_nodiscard mi_decl_export void* mi_heap_recalloc_aligned(mi_heap_t* heap, void* p, size_t newcount, size_t size, size_t alignment) mi_attr_noexcept mi_attr_alloc_size2(3,4) mi_attr_alloc_align(5);
248
+ mi_decl_nodiscard mi_decl_export void* mi_heap_recalloc_aligned_at(mi_heap_t* heap, void* p, size_t newcount, size_t size, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_alloc_size2(3,4);
249
+
250
+
251
+ // ------------------------------------------------------
252
+ // Analysis
253
+ // ------------------------------------------------------
254
+
255
+ mi_decl_export bool mi_heap_contains_block(mi_heap_t* heap, const void* p);
256
+ mi_decl_export bool mi_heap_check_owned(mi_heap_t* heap, const void* p);
257
+ mi_decl_export bool mi_check_owned(const void* p);
258
+
259
+ // An area of heap space contains blocks of a single size.
260
+ typedef struct mi_heap_area_s {
261
+ void* blocks; // start of the area containing heap blocks
262
+ size_t reserved; // bytes reserved for this area (virtual)
263
+ size_t committed; // current available bytes for this area
264
+ size_t used; // number of allocated blocks
265
+ size_t block_size; // size in bytes of each block
266
+ size_t full_block_size; // size in bytes of a full block including padding and metadata.
267
+ int heap_tag; // heap tag associated with this area
268
+ } mi_heap_area_t;
269
+
270
+ typedef bool (mi_cdecl mi_block_visit_fun)(const mi_heap_t* heap, const mi_heap_area_t* area, void* block, size_t block_size, void* arg);
271
+
272
+ mi_decl_export bool mi_heap_visit_blocks(const mi_heap_t* heap, bool visit_blocks, mi_block_visit_fun* visitor, void* arg);
273
+
274
+ // Experimental
275
+ mi_decl_nodiscard mi_decl_export bool mi_is_in_heap_region(const void* p) mi_attr_noexcept;
276
+ mi_decl_nodiscard mi_decl_export bool mi_is_redirected(void) mi_attr_noexcept;
277
+
278
+ mi_decl_export int mi_reserve_huge_os_pages_interleave(size_t pages, size_t numa_nodes, size_t timeout_msecs) mi_attr_noexcept;
279
+ mi_decl_export int mi_reserve_huge_os_pages_at(size_t pages, int numa_node, size_t timeout_msecs) mi_attr_noexcept;
280
+
281
+ mi_decl_export int mi_reserve_os_memory(size_t size, bool commit, bool allow_large) mi_attr_noexcept;
282
+ mi_decl_export bool mi_manage_os_memory(void* start, size_t size, bool is_committed, bool is_large, bool is_zero, int numa_node) mi_attr_noexcept;
283
+
284
+ mi_decl_export void mi_debug_show_arenas(void) mi_attr_noexcept;
285
+ mi_decl_export void mi_arenas_print(void) mi_attr_noexcept;
286
+
287
+ // Experimental: heaps associated with specific memory arena's
288
+ typedef int mi_arena_id_t;
289
+ mi_decl_export void* mi_arena_area(mi_arena_id_t arena_id, size_t* size);
290
+ mi_decl_export int mi_reserve_huge_os_pages_at_ex(size_t pages, int numa_node, size_t timeout_msecs, bool exclusive, mi_arena_id_t* arena_id) mi_attr_noexcept;
291
+ mi_decl_export int mi_reserve_os_memory_ex(size_t size, bool commit, bool allow_large, bool exclusive, mi_arena_id_t* arena_id) mi_attr_noexcept;
292
+ mi_decl_export bool mi_manage_os_memory_ex(void* start, size_t size, bool is_committed, bool is_large, bool is_zero, int numa_node, bool exclusive, mi_arena_id_t* arena_id) mi_attr_noexcept;
293
+
294
+ #if MI_MALLOC_VERSION >= 182
295
+ // Create a heap that only allocates in the specified arena
296
+ mi_decl_nodiscard mi_decl_export mi_heap_t* mi_heap_new_in_arena(mi_arena_id_t arena_id);
297
+ #endif
298
+
299
+
300
+ // Experimental: allow sub-processes whose memory areas stay separated (and no reclamation between them)
301
+ // Used for example for separate interpreters in one process.
302
+ typedef void* mi_subproc_id_t;
303
+ mi_decl_export mi_subproc_id_t mi_subproc_main(void);
304
+ mi_decl_export mi_subproc_id_t mi_subproc_new(void);
305
+ mi_decl_export void mi_subproc_delete(mi_subproc_id_t subproc);
306
+ mi_decl_export void mi_subproc_add_current_thread(mi_subproc_id_t subproc); // this should be called right after a thread is created (and no allocation has taken place yet)
307
+
308
+ // Experimental: visit abandoned heap areas (that are not owned by a specific heap)
309
+ mi_decl_export bool mi_abandoned_visit_blocks(mi_subproc_id_t subproc_id, int heap_tag, bool visit_blocks, mi_block_visit_fun* visitor, void* arg);
310
+
311
+ // Experimental: objects followed by a guard page.
312
+ // A sample rate of 0 disables guarded objects, while 1 uses a guard page for every object.
313
+ // A seed of 0 uses a random start point. Only objects within the size bound are eligable for guard pages.
314
+ mi_decl_export void mi_heap_guarded_set_sample_rate(mi_heap_t* heap, size_t sample_rate, size_t seed);
315
+ mi_decl_export void mi_heap_guarded_set_size_bound(mi_heap_t* heap, size_t min, size_t max);
316
+
317
+ // Experimental: communicate that the thread is part of a threadpool
318
+ mi_decl_export void mi_thread_set_in_threadpool(void) mi_attr_noexcept;
319
+
320
+ // Experimental: create a new heap with a specified heap tag. Set `allow_destroy` to false to allow the thread
321
+ // to reclaim abandoned memory (with a compatible heap_tag and arena_id) but in that case `mi_heap_destroy` will
322
+ // fall back to `mi_heap_delete`.
323
+ mi_decl_nodiscard mi_decl_export mi_heap_t* mi_heap_new_ex(int heap_tag, bool allow_destroy, mi_arena_id_t arena_id);
324
+
325
+ // deprecated
326
+ mi_decl_export int mi_reserve_huge_os_pages(size_t pages, double max_secs, size_t* pages_reserved) mi_attr_noexcept;
327
+ mi_decl_export void mi_collect_reduce(size_t target_thread_owned) mi_attr_noexcept;
328
+
329
+
330
+
331
+ // ------------------------------------------------------
332
+ // Convenience
333
+ // ------------------------------------------------------
334
+
335
+ #define mi_malloc_tp(tp) ((tp*)mi_malloc(sizeof(tp)))
336
+ #define mi_zalloc_tp(tp) ((tp*)mi_zalloc(sizeof(tp)))
337
+ #define mi_calloc_tp(tp,n) ((tp*)mi_calloc(n,sizeof(tp)))
338
+ #define mi_mallocn_tp(tp,n) ((tp*)mi_mallocn(n,sizeof(tp)))
339
+ #define mi_reallocn_tp(p,tp,n) ((tp*)mi_reallocn(p,n,sizeof(tp)))
340
+ #define mi_recalloc_tp(p,tp,n) ((tp*)mi_recalloc(p,n,sizeof(tp)))
341
+
342
+ #define mi_heap_malloc_tp(hp,tp) ((tp*)mi_heap_malloc(hp,sizeof(tp)))
343
+ #define mi_heap_zalloc_tp(hp,tp) ((tp*)mi_heap_zalloc(hp,sizeof(tp)))
344
+ #define mi_heap_calloc_tp(hp,tp,n) ((tp*)mi_heap_calloc(hp,n,sizeof(tp)))
345
+ #define mi_heap_mallocn_tp(hp,tp,n) ((tp*)mi_heap_mallocn(hp,n,sizeof(tp)))
346
+ #define mi_heap_reallocn_tp(hp,p,tp,n) ((tp*)mi_heap_reallocn(hp,p,n,sizeof(tp)))
347
+ #define mi_heap_recalloc_tp(hp,p,tp,n) ((tp*)mi_heap_recalloc(hp,p,n,sizeof(tp)))
348
+
349
+
350
+ // ------------------------------------------------------
351
+ // Options
352
+ // ------------------------------------------------------
353
+
354
+ typedef enum mi_option_e {
355
+ // stable options
356
+ mi_option_show_errors, // print error messages
357
+ mi_option_show_stats, // print statistics on termination
358
+ mi_option_verbose, // print verbose messages
359
+ // advanced options
360
+ mi_option_eager_commit, // eager commit segments? (after `eager_commit_delay` segments) (=1)
361
+ mi_option_arena_eager_commit, // eager commit arenas? Use 2 to enable just on overcommit systems (=2)
362
+ mi_option_purge_decommits, // should a memory purge decommit? (=1). Set to 0 to use memory reset on a purge (instead of decommit)
363
+ mi_option_allow_large_os_pages, // allow large (2 or 4 MiB) OS pages, implies eager commit. If false, also disables THP for the process.
364
+ mi_option_reserve_huge_os_pages, // reserve N huge OS pages (1GiB pages) at startup
365
+ mi_option_reserve_huge_os_pages_at, // reserve huge OS pages at a specific NUMA node
366
+ mi_option_reserve_os_memory, // reserve specified amount of OS memory in an arena at startup (internally, this value is in KiB; use `mi_option_get_size`)
367
+ mi_option_deprecated_segment_cache,
368
+ mi_option_deprecated_page_reset,
369
+ mi_option_abandoned_page_purge, // immediately purge delayed purges on thread termination
370
+ mi_option_deprecated_segment_reset,
371
+ mi_option_eager_commit_delay, // the first N segments per thread are not eagerly committed (but per page in the segment on demand)
372
+ mi_option_purge_delay, // memory purging is delayed by N milli seconds; use 0 for immediate purging or -1 for no purging at all. (=10)
373
+ mi_option_use_numa_nodes, // 0 = use all available numa nodes, otherwise use at most N nodes.
374
+ mi_option_disallow_os_alloc, // 1 = do not use OS memory for allocation (but only programmatically reserved arenas)
375
+ mi_option_os_tag, // tag used for OS logging (macOS only for now) (=100)
376
+ mi_option_max_errors, // issue at most N error messages
377
+ mi_option_max_warnings, // issue at most N warning messages
378
+ mi_option_max_segment_reclaim, // max. percentage of the abandoned segments can be reclaimed per try (=10%)
379
+ mi_option_destroy_on_exit, // if set, release all memory on exit; sometimes used for dynamic unloading but can be unsafe
380
+ mi_option_arena_reserve, // initial memory size for arena reservation (= 1 GiB on 64-bit) (internally, this value is in KiB; use `mi_option_get_size`)
381
+ mi_option_arena_purge_mult, // multiplier for `purge_delay` for the purging delay for arenas (=10)
382
+ mi_option_purge_extend_delay,
383
+ mi_option_abandoned_reclaim_on_free, // allow to reclaim an abandoned segment on a free (=1)
384
+ mi_option_disallow_arena_alloc, // 1 = do not use arena's for allocation (except if using specific arena id's)
385
+ mi_option_retry_on_oom, // retry on out-of-memory for N milli seconds (=400), set to 0 to disable retries. (only on windows)
386
+ mi_option_visit_abandoned, // allow visiting heap blocks from abandoned threads (=0)
387
+ mi_option_guarded_min, // only used when building with MI_GUARDED: minimal rounded object size for guarded objects (=0)
388
+ mi_option_guarded_max, // only used when building with MI_GUARDED: maximal rounded object size for guarded objects (=0)
389
+ mi_option_guarded_precise, // disregard minimal alignment requirement to always place guarded blocks exactly in front of a guard page (=0)
390
+ mi_option_guarded_sample_rate, // 1 out of N allocations in the min/max range will be guarded (=1000)
391
+ mi_option_guarded_sample_seed, // can be set to allow for a (more) deterministic re-execution when a guard page is triggered (=0)
392
+ mi_option_target_segments_per_thread, // experimental (=0)
393
+ mi_option_generic_collect, // collect heaps every N (=10000) generic allocation calls
394
+ _mi_option_last,
395
+ // legacy option names
396
+ mi_option_large_os_pages = mi_option_allow_large_os_pages,
397
+ mi_option_eager_region_commit = mi_option_arena_eager_commit,
398
+ mi_option_reset_decommits = mi_option_purge_decommits,
399
+ mi_option_reset_delay = mi_option_purge_delay,
400
+ mi_option_abandoned_page_reset = mi_option_abandoned_page_purge,
401
+ mi_option_limit_os_alloc = mi_option_disallow_os_alloc
402
+ } mi_option_t;
403
+
404
+
405
+ mi_decl_nodiscard mi_decl_export bool mi_option_is_enabled(mi_option_t option);
406
+ mi_decl_export void mi_option_enable(mi_option_t option);
407
+ mi_decl_export void mi_option_disable(mi_option_t option);
408
+ mi_decl_export void mi_option_set_enabled(mi_option_t option, bool enable);
409
+ mi_decl_export void mi_option_set_enabled_default(mi_option_t option, bool enable);
410
+
411
+ mi_decl_nodiscard mi_decl_export long mi_option_get(mi_option_t option);
412
+ mi_decl_nodiscard mi_decl_export long mi_option_get_clamp(mi_option_t option, long min, long max);
413
+ mi_decl_nodiscard mi_decl_export size_t mi_option_get_size(mi_option_t option);
414
+ mi_decl_export void mi_option_set(mi_option_t option, long value);
415
+ mi_decl_export void mi_option_set_default(mi_option_t option, long value);
416
+
417
+
418
+ // -------------------------------------------------------------------------------------------------------
419
+ // "mi" prefixed implementations of various posix, Unix, Windows, and C++ allocation functions.
420
+ // (This can be convenient when providing overrides of these functions as done in `mimalloc-override.h`.)
421
+ // note: we use `mi_cfree` as "checked free" and it checks if the pointer is in our heap before free-ing.
422
+ // -------------------------------------------------------------------------------------------------------
423
+
424
+ mi_decl_export void mi_cfree(void* p) mi_attr_noexcept;
425
+ mi_decl_export void* mi__expand(void* p, size_t newsize) mi_attr_noexcept;
426
+ mi_decl_nodiscard mi_decl_export size_t mi_malloc_size(const void* p) mi_attr_noexcept;
427
+ mi_decl_nodiscard mi_decl_export size_t mi_malloc_good_size(size_t size) mi_attr_noexcept;
428
+ mi_decl_nodiscard mi_decl_export size_t mi_malloc_usable_size(const void *p) mi_attr_noexcept;
429
+
430
+ mi_decl_export int mi_posix_memalign(void** p, size_t alignment, size_t size) mi_attr_noexcept;
431
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_memalign(size_t alignment, size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(2) mi_attr_alloc_align(1);
432
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_valloc(size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1);
433
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_pvalloc(size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1);
434
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_aligned_alloc(size_t alignment, size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(2) mi_attr_alloc_align(1);
435
+
436
+ mi_decl_nodiscard mi_decl_export void* mi_reallocarray(void* p, size_t count, size_t size) mi_attr_noexcept mi_attr_alloc_size2(2,3);
437
+ mi_decl_nodiscard mi_decl_export int mi_reallocarr(void* p, size_t count, size_t size) mi_attr_noexcept;
438
+ mi_decl_nodiscard mi_decl_export void* mi_aligned_recalloc(void* p, size_t newcount, size_t size, size_t alignment) mi_attr_noexcept;
439
+ mi_decl_nodiscard mi_decl_export void* mi_aligned_offset_recalloc(void* p, size_t newcount, size_t size, size_t alignment, size_t offset) mi_attr_noexcept;
440
+
441
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict unsigned short* mi_wcsdup(const unsigned short* s) mi_attr_noexcept mi_attr_malloc;
442
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict unsigned char* mi_mbsdup(const unsigned char* s) mi_attr_noexcept mi_attr_malloc;
443
+ mi_decl_export int mi_dupenv_s(char** buf, size_t* size, const char* name) mi_attr_noexcept;
444
+ mi_decl_export int mi_wdupenv_s(unsigned short** buf, size_t* size, const unsigned short* name) mi_attr_noexcept;
445
+
446
+ mi_decl_export void mi_free_size(void* p, size_t size) mi_attr_noexcept;
447
+ mi_decl_export void mi_free_size_aligned(void* p, size_t size, size_t alignment) mi_attr_noexcept;
448
+ mi_decl_export void mi_free_aligned(void* p, size_t alignment) mi_attr_noexcept;
449
+
450
+ // The `mi_new` wrappers implement C++ semantics on out-of-memory instead of directly returning `NULL`.
451
+ // (and call `std::get_new_handler` and potentially raise a `std::bad_alloc` exception).
452
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_new(size_t size) mi_attr_malloc mi_attr_alloc_size(1);
453
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_new_aligned(size_t size, size_t alignment) mi_attr_malloc mi_attr_alloc_size(1) mi_attr_alloc_align(2);
454
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_new_nothrow(size_t size) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1);
455
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_new_aligned_nothrow(size_t size, size_t alignment) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1) mi_attr_alloc_align(2);
456
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_new_n(size_t count, size_t size) mi_attr_malloc mi_attr_alloc_size2(1, 2);
457
+ mi_decl_nodiscard mi_decl_export void* mi_new_realloc(void* p, size_t newsize) mi_attr_alloc_size(2);
458
+ mi_decl_nodiscard mi_decl_export void* mi_new_reallocn(void* p, size_t newcount, size_t size) mi_attr_alloc_size2(2, 3);
459
+
460
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_alloc_new(mi_heap_t* heap, size_t size) mi_attr_malloc mi_attr_alloc_size(2);
461
+ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_alloc_new_n(mi_heap_t* heap, size_t count, size_t size) mi_attr_malloc mi_attr_alloc_size2(2, 3);
462
+
463
+ #ifdef __cplusplus
464
+ }
465
+ #endif
466
+
467
+ // ---------------------------------------------------------------------------------------------
468
+ // Implement the C++ std::allocator interface for use in STL containers.
469
+ // (note: see `mimalloc-new-delete.h` for overriding the new/delete operators globally)
470
+ // ---------------------------------------------------------------------------------------------
471
+ #ifdef __cplusplus
472
+
473
+ #include <cstddef> // std::size_t
474
+ #include <cstdint> // PTRDIFF_MAX
475
+ #if (__cplusplus >= 201103L) || (_MSC_VER > 1900) // C++11
476
+ #include <type_traits> // std::true_type
477
+ #include <utility> // std::forward
478
+ #endif
479
+
480
+ template<class T> struct _mi_stl_allocator_common {
481
+ typedef T value_type;
482
+ typedef std::size_t size_type;
483
+ typedef std::ptrdiff_t difference_type;
484
+ typedef value_type& reference;
485
+ typedef value_type const& const_reference;
486
+ typedef value_type* pointer;
487
+ typedef value_type const* const_pointer;
488
+
489
+ #if ((__cplusplus >= 201103L) || (_MSC_VER > 1900)) // C++11
490
+ using propagate_on_container_copy_assignment = std::true_type;
491
+ using propagate_on_container_move_assignment = std::true_type;
492
+ using propagate_on_container_swap = std::true_type;
493
+ template <class U, class ...Args> void construct(U* p, Args&& ...args) { ::new(p) U(std::forward<Args>(args)...); }
494
+ template <class U> void destroy(U* p) mi_attr_noexcept { p->~U(); }
495
+ #else
496
+ void construct(pointer p, value_type const& val) { ::new(p) value_type(val); }
497
+ void destroy(pointer p) { p->~value_type(); }
498
+ #endif
499
+
500
+ size_type max_size() const mi_attr_noexcept { return (PTRDIFF_MAX/sizeof(value_type)); }
501
+ pointer address(reference x) const { return &x; }
502
+ const_pointer address(const_reference x) const { return &x; }
503
+ };
504
+
505
+ template<class T> struct mi_stl_allocator : public _mi_stl_allocator_common<T> {
506
+ using typename _mi_stl_allocator_common<T>::size_type;
507
+ using typename _mi_stl_allocator_common<T>::value_type;
508
+ using typename _mi_stl_allocator_common<T>::pointer;
509
+ template <class U> struct rebind { typedef mi_stl_allocator<U> other; };
510
+
511
+ mi_stl_allocator() mi_attr_noexcept = default;
512
+ mi_stl_allocator(const mi_stl_allocator&) mi_attr_noexcept = default;
513
+ template<class U> mi_stl_allocator(const mi_stl_allocator<U>&) mi_attr_noexcept { }
514
+ mi_stl_allocator select_on_container_copy_construction() const { return *this; }
515
+ void deallocate(T* p, size_type) { mi_free(p); }
516
+
517
+ #if (__cplusplus >= 201703L) // C++17
518
+ mi_decl_nodiscard T* allocate(size_type count) { return static_cast<T*>(mi_new_n(count, sizeof(T))); }
519
+ mi_decl_nodiscard T* allocate(size_type count, const void*) { return allocate(count); }
520
+ #else
521
+ mi_decl_nodiscard pointer allocate(size_type count, const void* = 0) { return static_cast<pointer>(mi_new_n(count, sizeof(value_type))); }
522
+ #endif
523
+
524
+ #if ((__cplusplus >= 201103L) || (_MSC_VER > 1900)) // C++11
525
+ using is_always_equal = std::true_type;
526
+ #endif
527
+ };
528
+
529
+ template<class T1,class T2> bool operator==(const mi_stl_allocator<T1>& , const mi_stl_allocator<T2>& ) mi_attr_noexcept { return true; }
530
+ template<class T1,class T2> bool operator!=(const mi_stl_allocator<T1>& , const mi_stl_allocator<T2>& ) mi_attr_noexcept { return false; }
531
+
532
+
533
+ #if (__cplusplus >= 201103L) || (_MSC_VER >= 1900) // C++11
534
+ #define MI_HAS_HEAP_STL_ALLOCATOR 1
535
+
536
+ #include <memory> // std::shared_ptr
537
+
538
+ // Common base class for STL allocators in a specific heap
539
+ template<class T, bool _mi_destroy> struct _mi_heap_stl_allocator_common : public _mi_stl_allocator_common<T> {
540
+ using typename _mi_stl_allocator_common<T>::size_type;
541
+ using typename _mi_stl_allocator_common<T>::value_type;
542
+ using typename _mi_stl_allocator_common<T>::pointer;
543
+
544
+ _mi_heap_stl_allocator_common(mi_heap_t* hp) : heap(hp, [](mi_heap_t*) {}) {} /* will not delete nor destroy the passed in heap */
545
+
546
+ #if (__cplusplus >= 201703L) // C++17
547
+ mi_decl_nodiscard T* allocate(size_type count) { return static_cast<T*>(mi_heap_alloc_new_n(this->heap.get(), count, sizeof(T))); }
548
+ mi_decl_nodiscard T* allocate(size_type count, const void*) { return allocate(count); }
549
+ #else
550
+ mi_decl_nodiscard pointer allocate(size_type count, const void* = 0) { return static_cast<pointer>(mi_heap_alloc_new_n(this->heap.get(), count, sizeof(value_type))); }
551
+ #endif
552
+
553
+ #if ((__cplusplus >= 201103L) || (_MSC_VER > 1900)) // C++11
554
+ using is_always_equal = std::false_type;
555
+ #endif
556
+
557
+ void collect(bool force) { mi_heap_collect(this->heap.get(), force); }
558
+ template<class U> bool is_equal(const _mi_heap_stl_allocator_common<U, _mi_destroy>& x) const { return (this->heap == x.heap); }
559
+
560
+ protected:
561
+ std::shared_ptr<mi_heap_t> heap;
562
+ template<class U, bool D> friend struct _mi_heap_stl_allocator_common;
563
+
564
+ _mi_heap_stl_allocator_common() {
565
+ mi_heap_t* hp = mi_heap_new();
566
+ this->heap.reset(hp, (_mi_destroy ? &heap_destroy : &heap_delete)); /* calls heap_delete/destroy when the refcount drops to zero */
567
+ }
568
+ _mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common& x) mi_attr_noexcept : heap(x.heap) { }
569
+ template<class U> _mi_heap_stl_allocator_common(const _mi_heap_stl_allocator_common<U, _mi_destroy>& x) mi_attr_noexcept : heap(x.heap) { }
570
+
571
+ private:
572
+ static void heap_delete(mi_heap_t* hp) { if (hp != NULL) { mi_heap_delete(hp); } }
573
+ static void heap_destroy(mi_heap_t* hp) { if (hp != NULL) { mi_heap_destroy(hp); } }
574
+ };
575
+
576
+ // STL allocator allocation in a specific heap
577
+ template<class T> struct mi_heap_stl_allocator : public _mi_heap_stl_allocator_common<T, false> {
578
+ using typename _mi_heap_stl_allocator_common<T, false>::size_type;
579
+ mi_heap_stl_allocator() : _mi_heap_stl_allocator_common<T, false>() { } // creates fresh heap that is deleted when the destructor is called
580
+ mi_heap_stl_allocator(mi_heap_t* hp) : _mi_heap_stl_allocator_common<T, false>(hp) { } // no delete nor destroy on the passed in heap
581
+ template<class U> mi_heap_stl_allocator(const mi_heap_stl_allocator<U>& x) mi_attr_noexcept : _mi_heap_stl_allocator_common<T, false>(x) { }
582
+
583
+ mi_heap_stl_allocator select_on_container_copy_construction() const { return *this; }
584
+ void deallocate(T* p, size_type) { mi_free(p); }
585
+ template<class U> struct rebind { typedef mi_heap_stl_allocator<U> other; };
586
+ };
587
+
588
+ template<class T1, class T2> bool operator==(const mi_heap_stl_allocator<T1>& x, const mi_heap_stl_allocator<T2>& y) mi_attr_noexcept { return (x.is_equal(y)); }
589
+ template<class T1, class T2> bool operator!=(const mi_heap_stl_allocator<T1>& x, const mi_heap_stl_allocator<T2>& y) mi_attr_noexcept { return (!x.is_equal(y)); }
590
+
591
+
592
+ // STL allocator allocation in a specific heap, where `free` does nothing and
593
+ // the heap is destroyed in one go on destruction -- use with care!
594
+ template<class T> struct mi_heap_destroy_stl_allocator : public _mi_heap_stl_allocator_common<T, true> {
595
+ using typename _mi_heap_stl_allocator_common<T, true>::size_type;
596
+ mi_heap_destroy_stl_allocator() : _mi_heap_stl_allocator_common<T, true>() { } // creates fresh heap that is destroyed when the destructor is called
597
+ mi_heap_destroy_stl_allocator(mi_heap_t* hp) : _mi_heap_stl_allocator_common<T, true>(hp) { } // no delete nor destroy on the passed in heap
598
+ template<class U> mi_heap_destroy_stl_allocator(const mi_heap_destroy_stl_allocator<U>& x) mi_attr_noexcept : _mi_heap_stl_allocator_common<T, true>(x) { }
599
+
600
+ mi_heap_destroy_stl_allocator select_on_container_copy_construction() const { return *this; }
601
+ void deallocate(T*, size_type) { /* do nothing as we destroy the heap on destruct. */ }
602
+ template<class U> struct rebind { typedef mi_heap_destroy_stl_allocator<U> other; };
603
+ };
604
+
605
+ template<class T1, class T2> bool operator==(const mi_heap_destroy_stl_allocator<T1>& x, const mi_heap_destroy_stl_allocator<T2>& y) mi_attr_noexcept { return (x.is_equal(y)); }
606
+ template<class T1, class T2> bool operator!=(const mi_heap_destroy_stl_allocator<T1>& x, const mi_heap_destroy_stl_allocator<T2>& y) mi_attr_noexcept { return (!x.is_equal(y)); }
607
+
608
+ #endif // C++11
609
+
610
+ #endif // __cplusplus
611
+
612
+ #endif
@@ -0,0 +1,11 @@
1
+ prefix=@CMAKE_INSTALL_PREFIX@
2
+ libdir=@mi_pc_libdir@
3
+ includedir=@mi_pc_includedir@
4
+
5
+ Name: @PROJECT_NAME@
6
+ Description: A compact general purpose allocator with excellent performance
7
+ Version: @PACKAGE_VERSION@
8
+ URL: https://github.com/microsoft/mimalloc/
9
+ Libs: -L${libdir} -l@mi_libname@
10
+ Libs.private: @mi_pc_libraries@
11
+ Cflags: -I${includedir}