pytron-kit 0.3.12__py3-none-macosx_11_0_universal2.whl

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 (419) hide show
  1. pytron/__init__.py +112 -0
  2. pytron/application.py +562 -0
  3. pytron/apputils/__init__.py +0 -0
  4. pytron/apputils/chrome_ipc.py +203 -0
  5. pytron/apputils/codegen.py +261 -0
  6. pytron/apputils/config.py +303 -0
  7. pytron/apputils/deadmansswitch.py +47 -0
  8. pytron/apputils/extras.py +76 -0
  9. pytron/apputils/native.py +148 -0
  10. pytron/apputils/shell.py +73 -0
  11. pytron/apputils/windows.py +286 -0
  12. pytron/cli.py +384 -0
  13. pytron/commands/__init__.py +0 -0
  14. pytron/commands/android.py +28 -0
  15. pytron/commands/build.py +26 -0
  16. pytron/commands/doctor.py +221 -0
  17. pytron/commands/engine.py +23 -0
  18. pytron/commands/frontend.py +60 -0
  19. pytron/commands/harvest.py +112 -0
  20. pytron/commands/helpers.py +239 -0
  21. pytron/commands/info.py +50 -0
  22. pytron/commands/init.py +521 -0
  23. pytron/commands/install.py +294 -0
  24. pytron/commands/login.py +130 -0
  25. pytron/commands/package.py +228 -0
  26. pytron/commands/plugin.py +442 -0
  27. pytron/commands/run.py +312 -0
  28. pytron/commands/scan.py +210 -0
  29. pytron/commands/show.py +23 -0
  30. pytron/commands/uninstall.py +150 -0
  31. pytron/commands/utils.py +42 -0
  32. pytron/commands/workflow.py +95 -0
  33. pytron/console.py +133 -0
  34. pytron/core.py +18 -0
  35. pytron/dependencies/WebView2Loader.dll +0 -0
  36. pytron/dependencies/__init__.py +1 -0
  37. pytron/dependencies/pytron_native.so +0 -0
  38. pytron/engines/chrome/adapter.py +445 -0
  39. pytron/engines/chrome/engine.py +576 -0
  40. pytron/engines/chrome/forge.py +147 -0
  41. pytron/engines/chrome/shell/package.json +8 -0
  42. pytron/engines/chrome/shell/preload.js +12 -0
  43. pytron/engines/chrome/shell/shell.js +534 -0
  44. pytron/exceptions.py +36 -0
  45. pytron/inspector.py +201 -0
  46. pytron/inspector_ui.py +512 -0
  47. pytron/installer/Installation.nsi +236 -0
  48. pytron/installer/header.bmp +0 -0
  49. pytron/installer/pytron.ico +0 -0
  50. pytron/installer/sidebar.bmp +0 -0
  51. pytron/llms.md +98 -0
  52. pytron/manifests/README.md +29 -0
  53. pytron/manifests/windows-utf8.manifest +44 -0
  54. pytron/menu.py +128 -0
  55. pytron/nsis-setup.exe +0 -0
  56. pytron/pack/__init__.py +0 -0
  57. pytron/pack/assets.py +131 -0
  58. pytron/pack/compilers.py +289 -0
  59. pytron/pack/crystal.py +297 -0
  60. pytron/pack/graph.py +377 -0
  61. pytron/pack/inference.py +157 -0
  62. pytron/pack/installers.py +402 -0
  63. pytron/pack/introspect.py +357 -0
  64. pytron/pack/metadata.py +213 -0
  65. pytron/pack/modules.py +618 -0
  66. pytron/pack/nuitka.py +108 -0
  67. pytron/pack/pipeline.py +107 -0
  68. pytron/pack/pyinstaller.py +176 -0
  69. pytron/pack/rust_engine.py +273 -0
  70. pytron/pack/secure.py +309 -0
  71. pytron/pack/secure_loader/bin/pytron_rust_bootloader +0 -0
  72. pytron/pack/secure_loader/icon.ico +0 -0
  73. pytron/pack/utils.py +110 -0
  74. pytron/pack/virtual_root.py +124 -0
  75. pytron/platforms/__init__.py +0 -0
  76. pytron/platforms/android/__init__.py +3 -0
  77. pytron/platforms/android/android.py +103 -0
  78. pytron/platforms/android/builder.py +736 -0
  79. pytron/platforms/android/ops/build.py +79 -0
  80. pytron/platforms/android/ops/init.py +63 -0
  81. pytron/platforms/android/ops/run.py +79 -0
  82. pytron/platforms/android/ops/sync.py +770 -0
  83. pytron/platforms/android/ops/utils.py +8 -0
  84. pytron/platforms/android/shell/README.md +30 -0
  85. pytron/platforms/android/shell/app/build.gradle +64 -0
  86. pytron/platforms/android/shell/app/src/main/AndroidManifest.xml +29 -0
  87. pytron/platforms/android/shell/app/src/main/assets/python/main.py +86 -0
  88. pytron/platforms/android/shell/app/src/main/assets/python/python314.zip +0 -0
  89. pytron/platforms/android/shell/app/src/main/cpp/CMakeLists.txt +25 -0
  90. pytron/platforms/android/shell/app/src/main/cpp/include/Python.h +155 -0
  91. pytron/platforms/android/shell/app/src/main/cpp/include/abstract.h +915 -0
  92. pytron/platforms/android/shell/app/src/main/cpp/include/audit.h +30 -0
  93. pytron/platforms/android/shell/app/src/main/cpp/include/bltinmodule.h +14 -0
  94. pytron/platforms/android/shell/app/src/main/cpp/include/boolobject.h +54 -0
  95. pytron/platforms/android/shell/app/src/main/cpp/include/bytearrayobject.h +44 -0
  96. pytron/platforms/android/shell/app/src/main/cpp/include/bytesobject.h +66 -0
  97. pytron/platforms/android/shell/app/src/main/cpp/include/ceval.h +145 -0
  98. pytron/platforms/android/shell/app/src/main/cpp/include/codecs.h +176 -0
  99. pytron/platforms/android/shell/app/src/main/cpp/include/compile.h +22 -0
  100. pytron/platforms/android/shell/app/src/main/cpp/include/complexobject.h +30 -0
  101. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/abstract.h +104 -0
  102. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/audit.h +8 -0
  103. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/bytearrayobject.h +38 -0
  104. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/bytesobject.h +42 -0
  105. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/cellobject.h +50 -0
  106. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/ceval.h +43 -0
  107. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/classobject.h +71 -0
  108. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/code.h +340 -0
  109. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/compile.h +50 -0
  110. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/complexobject.h +33 -0
  111. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/context.h +107 -0
  112. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/critical_section.h +154 -0
  113. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/descrobject.h +62 -0
  114. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/dictobject.h +105 -0
  115. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/fileobject.h +16 -0
  116. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/fileutils.h +16 -0
  117. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/floatobject.h +27 -0
  118. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/frameobject.h +35 -0
  119. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/funcobject.h +185 -0
  120. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/genobject.h +56 -0
  121. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/import.h +30 -0
  122. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/initconfig.h +334 -0
  123. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/listobject.h +53 -0
  124. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/lock.h +74 -0
  125. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/longintrepr.h +184 -0
  126. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/longobject.h +89 -0
  127. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/memoryobject.h +50 -0
  128. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/methodobject.h +66 -0
  129. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/modsupport.h +26 -0
  130. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/monitoring.h +269 -0
  131. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/object.h +493 -0
  132. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/objimpl.h +104 -0
  133. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/odictobject.h +43 -0
  134. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/picklebufobject.h +31 -0
  135. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pthread_stubs.h +105 -0
  136. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic.h +614 -0
  137. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_gcc.h +615 -0
  138. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_msc.h +1197 -0
  139. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_std.h +1112 -0
  140. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyctype.h +39 -0
  141. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pydebug.h +38 -0
  142. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyerrors.h +132 -0
  143. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyfpe.h +15 -0
  144. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyframe.h +45 -0
  145. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyhash.h +54 -0
  146. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pylifecycle.h +89 -0
  147. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pymem.h +84 -0
  148. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pystate.h +275 -0
  149. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pystats.h +194 -0
  150. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pythonrun.h +96 -0
  151. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pythread.h +43 -0
  152. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pytime.h +27 -0
  153. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/setobject.h +71 -0
  154. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/traceback.h +13 -0
  155. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/tracemalloc.h +32 -0
  156. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/tupleobject.h +40 -0
  157. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/unicodeobject.h +773 -0
  158. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/warnings.h +20 -0
  159. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/weakrefobject.h +66 -0
  160. pytron/platforms/android/shell/app/src/main/cpp/include/critical_section.h +16 -0
  161. pytron/platforms/android/shell/app/src/main/cpp/include/datetime.h +267 -0
  162. pytron/platforms/android/shell/app/src/main/cpp/include/descrobject.h +100 -0
  163. pytron/platforms/android/shell/app/src/main/cpp/include/dictobject.h +108 -0
  164. pytron/platforms/android/shell/app/src/main/cpp/include/dynamic_annotations.h +499 -0
  165. pytron/platforms/android/shell/app/src/main/cpp/include/enumobject.h +17 -0
  166. pytron/platforms/android/shell/app/src/main/cpp/include/errcode.h +45 -0
  167. pytron/platforms/android/shell/app/src/main/cpp/include/exports.h +105 -0
  168. pytron/platforms/android/shell/app/src/main/cpp/include/fileobject.h +41 -0
  169. pytron/platforms/android/shell/app/src/main/cpp/include/fileutils.h +62 -0
  170. pytron/platforms/android/shell/app/src/main/cpp/include/floatobject.h +54 -0
  171. pytron/platforms/android/shell/app/src/main/cpp/include/frameobject.h +20 -0
  172. pytron/platforms/android/shell/app/src/main/cpp/include/genericaliasobject.h +14 -0
  173. pytron/platforms/android/shell/app/src/main/cpp/include/import.h +103 -0
  174. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/atomic.h +392 -0
  175. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/internal.h +969 -0
  176. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/prim.h +329 -0
  177. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/track.h +147 -0
  178. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/types.h +721 -0
  179. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc.h +565 -0
  180. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_abstract.h +61 -0
  181. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_asdl.h +112 -0
  182. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ast.h +945 -0
  183. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ast_state.h +271 -0
  184. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_atexit.h +31 -0
  185. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_audit.h +35 -0
  186. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_backoff.h +133 -0
  187. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bitutils.h +186 -0
  188. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_blocks_output_buffer.h +321 -0
  189. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_brc.h +73 -0
  190. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bytes_methods.h +82 -0
  191. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bytesobject.h +149 -0
  192. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_c_array.h +39 -0
  193. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_call.h +206 -0
  194. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_capsule.h +17 -0
  195. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_cell.h +75 -0
  196. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ceval.h +390 -0
  197. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ceval_state.h +48 -0
  198. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_code.h +671 -0
  199. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_codecs.h +76 -0
  200. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_compile.h +230 -0
  201. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_complexobject.h +34 -0
  202. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_condvar.h +93 -0
  203. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_context.h +59 -0
  204. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_critical_section.h +237 -0
  205. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_crossinterp.h +406 -0
  206. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_crossinterp_data_registry.h +41 -0
  207. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_debug_offsets.h +379 -0
  208. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_descrobject.h +28 -0
  209. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dict.h +410 -0
  210. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dict_state.h +28 -0
  211. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dtoa.h +40 -0
  212. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_emscripten_signal.h +30 -0
  213. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_emscripten_trampoline.h +70 -0
  214. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_exceptions.h +40 -0
  215. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_faulthandler.h +100 -0
  216. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_fileutils.h +320 -0
  217. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_fileutils_windows.h +98 -0
  218. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_floatobject.h +49 -0
  219. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_flowgraph.h +47 -0
  220. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_format.h +27 -0
  221. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_frame.h +61 -0
  222. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_freelist.h +111 -0
  223. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_freelist_state.h +70 -0
  224. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_function.h +53 -0
  225. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_gc.h +378 -0
  226. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_genobject.h +43 -0
  227. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_getopt.h +22 -0
  228. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_gil.h +66 -0
  229. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_objects.h +34 -0
  230. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_objects_fini_generated.h +1592 -0
  231. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_strings.h +854 -0
  232. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_hamt.h +113 -0
  233. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_hashtable.h +150 -0
  234. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_import.h +141 -0
  235. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_importdl.h +139 -0
  236. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_index_pool.h +36 -0
  237. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_initconfig.h +197 -0
  238. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_instruction_sequence.h +83 -0
  239. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_instruments.h +127 -0
  240. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interp.h +109 -0
  241. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interp_structs.h +977 -0
  242. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpframe.h +401 -0
  243. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpframe_structs.h +95 -0
  244. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpolation.h +26 -0
  245. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_intrinsics.h +51 -0
  246. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_jit.h +29 -0
  247. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_list.h +81 -0
  248. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_llist.h +106 -0
  249. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_lock.h +236 -0
  250. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_long.h +319 -0
  251. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_magic_number.h +305 -0
  252. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_memoryobject.h +20 -0
  253. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_mimalloc.h +69 -0
  254. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_modsupport.h +99 -0
  255. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_moduleobject.h +62 -0
  256. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_namespace.h +21 -0
  257. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object.h +1029 -0
  258. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_alloc.h +71 -0
  259. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_deferred.h +32 -0
  260. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_stack.h +95 -0
  261. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_state.h +49 -0
  262. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_obmalloc.h +702 -0
  263. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_obmalloc_init.h +66 -0
  264. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_opcode_metadata.h +2117 -0
  265. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_opcode_utils.h +90 -0
  266. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_optimizer.h +318 -0
  267. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_parking_lot.h +97 -0
  268. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_parser.h +78 -0
  269. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pathconfig.h +26 -0
  270. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyarena.h +68 -0
  271. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyatomic_ft_wrappers.h +174 -0
  272. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pybuffer.h +21 -0
  273. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyerrors.h +213 -0
  274. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyhash.h +91 -0
  275. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pylifecycle.h +136 -0
  276. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymath.h +205 -0
  277. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymem.h +145 -0
  278. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymem_init.h +103 -0
  279. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pystate.h +339 -0
  280. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pystats.h +21 -0
  281. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pythonrun.h +68 -0
  282. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pythread.h +172 -0
  283. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_qsbr.h +172 -0
  284. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_range.h +21 -0
  285. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime.h +63 -0
  286. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_init.h +239 -0
  287. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_init_generated.h +1589 -0
  288. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_structs.h +310 -0
  289. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_semaphore.h +67 -0
  290. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_setobject.h +41 -0
  291. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_signal.h +108 -0
  292. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_sliceobject.h +20 -0
  293. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_stackref.h +791 -0
  294. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_stats.h +97 -0
  295. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_strhex.h +39 -0
  296. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_structs.h +88 -0
  297. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_structseq.h +40 -0
  298. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_symtable.h +201 -0
  299. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_sysmodule.h +32 -0
  300. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_template.h +26 -0
  301. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_time.h +334 -0
  302. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_token.h +110 -0
  303. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_traceback.h +111 -0
  304. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tracemalloc.h +164 -0
  305. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tstate.h +88 -0
  306. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tuple.h +75 -0
  307. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typedefs.h +18 -0
  308. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typeobject.h +155 -0
  309. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typevarobject.h +28 -0
  310. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ucnhash.h +36 -0
  311. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unicodeobject.h +308 -0
  312. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unicodeobject_generated.h +3132 -0
  313. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unionobject.h +26 -0
  314. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uniqueid.h +57 -0
  315. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uop_ids.h +335 -0
  316. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uop_metadata.h +1204 -0
  317. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_warnings.h +21 -0
  318. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_weakref.h +133 -0
  319. pytron/platforms/android/shell/app/src/main/cpp/include/intrcheck.h +23 -0
  320. pytron/platforms/android/shell/app/src/main/cpp/include/iterobject.h +24 -0
  321. pytron/platforms/android/shell/app/src/main/cpp/include/listobject.h +55 -0
  322. pytron/platforms/android/shell/app/src/main/cpp/include/lock.h +16 -0
  323. pytron/platforms/android/shell/app/src/main/cpp/include/longobject.h +178 -0
  324. pytron/platforms/android/shell/app/src/main/cpp/include/marshal.h +31 -0
  325. pytron/platforms/android/shell/app/src/main/cpp/include/memoryobject.h +34 -0
  326. pytron/platforms/android/shell/app/src/main/cpp/include/methodobject.h +146 -0
  327. pytron/platforms/android/shell/app/src/main/cpp/include/modsupport.h +146 -0
  328. pytron/platforms/android/shell/app/src/main/cpp/include/moduleobject.h +122 -0
  329. pytron/platforms/android/shell/app/src/main/cpp/include/monitoring.h +18 -0
  330. pytron/platforms/android/shell/app/src/main/cpp/include/object.h +828 -0
  331. pytron/platforms/android/shell/app/src/main/cpp/include/objimpl.h +211 -0
  332. pytron/platforms/android/shell/app/src/main/cpp/include/opcode.h +43 -0
  333. pytron/platforms/android/shell/app/src/main/cpp/include/opcode_ids.h +259 -0
  334. pytron/platforms/android/shell/app/src/main/cpp/include/osdefs.h +57 -0
  335. pytron/platforms/android/shell/app/src/main/cpp/include/osmodule.h +17 -0
  336. pytron/platforms/android/shell/app/src/main/cpp/include/patchlevel.h +49 -0
  337. pytron/platforms/android/shell/app/src/main/cpp/include/py_curses.h +117 -0
  338. pytron/platforms/android/shell/app/src/main/cpp/include/pyatomic.h +16 -0
  339. pytron/platforms/android/shell/app/src/main/cpp/include/pybuffer.h +145 -0
  340. pytron/platforms/android/shell/app/src/main/cpp/include/pycapsule.h +58 -0
  341. pytron/platforms/android/shell/app/src/main/cpp/include/pyconfig.h +2088 -0
  342. pytron/platforms/android/shell/app/src/main/cpp/include/pydtrace.h +59 -0
  343. pytron/platforms/android/shell/app/src/main/cpp/include/pyerrors.h +335 -0
  344. pytron/platforms/android/shell/app/src/main/cpp/include/pyexpat.h +62 -0
  345. pytron/platforms/android/shell/app/src/main/cpp/include/pyframe.h +26 -0
  346. pytron/platforms/android/shell/app/src/main/cpp/include/pyhash.h +59 -0
  347. pytron/platforms/android/shell/app/src/main/cpp/include/pylifecycle.h +80 -0
  348. pytron/platforms/android/shell/app/src/main/cpp/include/pymacconfig.h +91 -0
  349. pytron/platforms/android/shell/app/src/main/cpp/include/pymacro.h +243 -0
  350. pytron/platforms/android/shell/app/src/main/cpp/include/pymath.h +65 -0
  351. pytron/platforms/android/shell/app/src/main/cpp/include/pymem.h +110 -0
  352. pytron/platforms/android/shell/app/src/main/cpp/include/pyport.h +710 -0
  353. pytron/platforms/android/shell/app/src/main/cpp/include/pystate.h +132 -0
  354. pytron/platforms/android/shell/app/src/main/cpp/include/pystats.h +28 -0
  355. pytron/platforms/android/shell/app/src/main/cpp/include/pystrcmp.h +23 -0
  356. pytron/platforms/android/shell/app/src/main/cpp/include/pystrtod.h +37 -0
  357. pytron/platforms/android/shell/app/src/main/cpp/include/pythonrun.h +42 -0
  358. pytron/platforms/android/shell/app/src/main/cpp/include/pythread.h +131 -0
  359. pytron/platforms/android/shell/app/src/main/cpp/include/pytypedefs.h +30 -0
  360. pytron/platforms/android/shell/app/src/main/cpp/include/rangeobject.h +27 -0
  361. pytron/platforms/android/shell/app/src/main/cpp/include/refcount.h +555 -0
  362. pytron/platforms/android/shell/app/src/main/cpp/include/setobject.h +49 -0
  363. pytron/platforms/android/shell/app/src/main/cpp/include/sliceobject.h +69 -0
  364. pytron/platforms/android/shell/app/src/main/cpp/include/structmember.h +56 -0
  365. pytron/platforms/android/shell/app/src/main/cpp/include/structseq.h +46 -0
  366. pytron/platforms/android/shell/app/src/main/cpp/include/sysmodule.h +27 -0
  367. pytron/platforms/android/shell/app/src/main/cpp/include/traceback.h +26 -0
  368. pytron/platforms/android/shell/app/src/main/cpp/include/tupleobject.h +46 -0
  369. pytron/platforms/android/shell/app/src/main/cpp/include/typeslots.h +96 -0
  370. pytron/platforms/android/shell/app/src/main/cpp/include/unicodeobject.h +1029 -0
  371. pytron/platforms/android/shell/app/src/main/cpp/include/warnings.h +45 -0
  372. pytron/platforms/android/shell/app/src/main/cpp/include/weakrefobject.h +46 -0
  373. pytron/platforms/android/shell/app/src/main/cpp/pytron_bridge.cpp +224 -0
  374. pytron/platforms/android/shell/app/src/main/java/com/pytron/shell/MainActivity.kt +208 -0
  375. pytron/platforms/android/shell/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  376. pytron/platforms/android/shell/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  377. pytron/platforms/android/shell/build.gradle +11 -0
  378. pytron/platforms/android/shell/gradle/wrapper/gradle-wrapper.jar +0 -0
  379. pytron/platforms/android/shell/gradle/wrapper/gradle-wrapper.properties +5 -0
  380. pytron/platforms/android/shell/gradle.properties +2 -0
  381. pytron/platforms/android/shell/gradlew.bat +85 -0
  382. pytron/platforms/android/shell/settings.gradle +16 -0
  383. pytron/platforms/darwin.py +82 -0
  384. pytron/platforms/darwin_ops/libs.py +31 -0
  385. pytron/platforms/darwin_ops/system.py +182 -0
  386. pytron/platforms/darwin_ops/utils.py +85 -0
  387. pytron/platforms/darwin_ops/webview.py +5 -0
  388. pytron/platforms/darwin_ops/window.py +102 -0
  389. pytron/platforms/interface.py +152 -0
  390. pytron/platforms/linux.py +82 -0
  391. pytron/platforms/linux_ops/libs.py +49 -0
  392. pytron/platforms/linux_ops/system.py +316 -0
  393. pytron/platforms/linux_ops/utils.py +19 -0
  394. pytron/platforms/linux_ops/webview.py +5 -0
  395. pytron/platforms/linux_ops/window.py +115 -0
  396. pytron/platforms/windows.py +136 -0
  397. pytron/platforms/windows_ops/__init__.py +0 -0
  398. pytron/platforms/windows_ops/constants.py +126 -0
  399. pytron/platforms/windows_ops/system.py +518 -0
  400. pytron/platforms/windows_ops/utils.py +3 -0
  401. pytron/platforms/windows_ops/webview.py +5 -0
  402. pytron/platforms/windows_ops/window.py +361 -0
  403. pytron/plugin.py +467 -0
  404. pytron/rcedit-x64.exe +0 -0
  405. pytron/router.py +146 -0
  406. pytron/serializer.py +240 -0
  407. pytron/shortcuts.py +279 -0
  408. pytron/state.py +76 -0
  409. pytron/tray.py +399 -0
  410. pytron/updater.py +181 -0
  411. pytron/utf8_hook.py +112 -0
  412. pytron/utils.py +44 -0
  413. pytron/webview.py +722 -0
  414. pytron_kit-0.3.12.dist-info/METADATA +131 -0
  415. pytron_kit-0.3.12.dist-info/RECORD +419 -0
  416. pytron_kit-0.3.12.dist-info/WHEEL +5 -0
  417. pytron_kit-0.3.12.dist-info/entry_points.txt +2 -0
  418. pytron_kit-0.3.12.dist-info/licenses/LICENSE +201 -0
  419. pytron_kit-0.3.12.dist-info/top_level.txt +1 -0
@@ -0,0 +1,329 @@
1
+ /* ----------------------------------------------------------------------------
2
+ Copyright (c) 2018-2023, 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_PRIM_H
9
+ #define MIMALLOC_PRIM_H
10
+
11
+
12
+ // --------------------------------------------------------------------------
13
+ // This file specifies the primitive portability API.
14
+ // Each OS/host needs to implement these primitives, see `src/prim`
15
+ // for implementations on Window, macOS, WASI, and Linux/Unix.
16
+ //
17
+ // note: on all primitive functions, we always have result parameters != NUL, and:
18
+ // addr != NULL and page aligned
19
+ // size > 0 and page aligned
20
+ // return value is an error code an int where 0 is success.
21
+ // --------------------------------------------------------------------------
22
+
23
+ // OS memory configuration
24
+ typedef struct mi_os_mem_config_s {
25
+ size_t page_size; // 4KiB
26
+ size_t large_page_size; // 2MiB
27
+ size_t alloc_granularity; // smallest allocation size (on Windows 64KiB)
28
+ bool has_overcommit; // can we reserve more memory than can be actually committed?
29
+ bool must_free_whole; // must allocated blocks be freed as a whole (false for mmap, true for VirtualAlloc)
30
+ bool has_virtual_reserve; // supports virtual address space reservation? (if true we can reserve virtual address space without using commit or physical memory)
31
+ } mi_os_mem_config_t;
32
+
33
+ // Initialize
34
+ void _mi_prim_mem_init( mi_os_mem_config_t* config );
35
+
36
+ // Free OS memory
37
+ int _mi_prim_free(void* addr, size_t size );
38
+
39
+ // Allocate OS memory. Return NULL on error.
40
+ // The `try_alignment` is just a hint and the returned pointer does not have to be aligned.
41
+ // If `commit` is false, the virtual memory range only needs to be reserved (with no access)
42
+ // which will later be committed explicitly using `_mi_prim_commit`.
43
+ // `is_zero` is set to true if the memory was zero initialized (as on most OS's)
44
+ // pre: !commit => !allow_large
45
+ // try_alignment >= _mi_os_page_size() and a power of 2
46
+ int _mi_prim_alloc(size_t size, size_t try_alignment, bool commit, bool allow_large, bool* is_large, bool* is_zero, void** addr);
47
+
48
+ // Commit memory. Returns error code or 0 on success.
49
+ // For example, on Linux this would make the memory PROT_READ|PROT_WRITE.
50
+ // `is_zero` is set to true if the memory was zero initialized (e.g. on Windows)
51
+ int _mi_prim_commit(void* addr, size_t size, bool* is_zero);
52
+
53
+ // Decommit memory. Returns error code or 0 on success. The `needs_recommit` result is true
54
+ // if the memory would need to be re-committed. For example, on Windows this is always true,
55
+ // but on Linux we could use MADV_DONTNEED to decommit which does not need a recommit.
56
+ // pre: needs_recommit != NULL
57
+ int _mi_prim_decommit(void* addr, size_t size, bool* needs_recommit);
58
+
59
+ // Reset memory. The range keeps being accessible but the content might be reset.
60
+ // Returns error code or 0 on success.
61
+ int _mi_prim_reset(void* addr, size_t size);
62
+
63
+ // Protect memory. Returns error code or 0 on success.
64
+ int _mi_prim_protect(void* addr, size_t size, bool protect);
65
+
66
+ // Allocate huge (1GiB) pages possibly associated with a NUMA node.
67
+ // `is_zero` is set to true if the memory was zero initialized (as on most OS's)
68
+ // pre: size > 0 and a multiple of 1GiB.
69
+ // numa_node is either negative (don't care), or a numa node number.
70
+ int _mi_prim_alloc_huge_os_pages(void* hint_addr, size_t size, int numa_node, bool* is_zero, void** addr);
71
+
72
+ // Return the current NUMA node
73
+ size_t _mi_prim_numa_node(void);
74
+
75
+ // Return the number of logical NUMA nodes
76
+ size_t _mi_prim_numa_node_count(void);
77
+
78
+ // Clock ticks
79
+ mi_msecs_t _mi_prim_clock_now(void);
80
+
81
+ // Return process information (only for statistics)
82
+ typedef struct mi_process_info_s {
83
+ mi_msecs_t elapsed;
84
+ mi_msecs_t utime;
85
+ mi_msecs_t stime;
86
+ size_t current_rss;
87
+ size_t peak_rss;
88
+ size_t current_commit;
89
+ size_t peak_commit;
90
+ size_t page_faults;
91
+ } mi_process_info_t;
92
+
93
+ void _mi_prim_process_info(mi_process_info_t* pinfo);
94
+
95
+ // Default stderr output. (only for warnings etc. with verbose enabled)
96
+ // msg != NULL && _mi_strlen(msg) > 0
97
+ void _mi_prim_out_stderr( const char* msg );
98
+
99
+ // Get an environment variable. (only for options)
100
+ // name != NULL, result != NULL, result_size >= 64
101
+ bool _mi_prim_getenv(const char* name, char* result, size_t result_size);
102
+
103
+
104
+ // Fill a buffer with strong randomness; return `false` on error or if
105
+ // there is no strong randomization available.
106
+ bool _mi_prim_random_buf(void* buf, size_t buf_len);
107
+
108
+ // Called on the first thread start, and should ensure `_mi_thread_done` is called on thread termination.
109
+ void _mi_prim_thread_init_auto_done(void);
110
+
111
+ // Called on process exit and may take action to clean up resources associated with the thread auto done.
112
+ void _mi_prim_thread_done_auto_done(void);
113
+
114
+ // Called when the default heap for a thread changes
115
+ void _mi_prim_thread_associate_default_heap(mi_heap_t* heap);
116
+
117
+
118
+ //-------------------------------------------------------------------
119
+ // Thread id: `_mi_prim_thread_id()`
120
+ //
121
+ // Getting the thread id should be performant as it is called in the
122
+ // fast path of `_mi_free` and we specialize for various platforms as
123
+ // inlined definitions. Regular code should call `init.c:_mi_thread_id()`.
124
+ // We only require _mi_prim_thread_id() to return a unique id
125
+ // for each thread (unequal to zero).
126
+ //-------------------------------------------------------------------
127
+
128
+ // defined in `init.c`; do not use these directly
129
+ extern mi_decl_thread mi_heap_t* _mi_heap_default; // default heap to allocate from
130
+ extern bool _mi_process_is_initialized; // has mi_process_init been called?
131
+
132
+ static inline mi_threadid_t _mi_prim_thread_id(void) mi_attr_noexcept;
133
+
134
+ #ifdef MI_PRIM_THREAD_ID
135
+
136
+ static inline mi_threadid_t _mi_prim_thread_id(void) mi_attr_noexcept {
137
+ return MI_PRIM_THREAD_ID();
138
+ }
139
+
140
+ #elif defined(_WIN32)
141
+
142
+ #define WIN32_LEAN_AND_MEAN
143
+ #include <windows.h>
144
+ static inline mi_threadid_t _mi_prim_thread_id(void) mi_attr_noexcept {
145
+ // Windows: works on Intel and ARM in both 32- and 64-bit
146
+ return (uintptr_t)NtCurrentTeb();
147
+ }
148
+
149
+ // We use assembly for a fast thread id on the main platforms. The TLS layout depends on
150
+ // both the OS and libc implementation so we use specific tests for each main platform.
151
+ // If you test on another platform and it works please send a PR :-)
152
+ // see also https://akkadia.org/drepper/tls.pdf for more info on the TLS register.
153
+ #elif defined(__GNUC__) && ( \
154
+ (defined(__GLIBC__) && (defined(__x86_64__) || defined(__i386__) || (defined(__arm__) && __ARM_ARCH >= 7) || defined(__aarch64__))) \
155
+ || (defined(__APPLE__) && (defined(__x86_64__) || defined(__aarch64__))) \
156
+ || (defined(__BIONIC__) && (defined(__x86_64__) || defined(__i386__) || (defined(__arm__) && __ARM_ARCH >= 7) || defined(__aarch64__))) \
157
+ || (defined(__FreeBSD__) && (defined(__x86_64__) || defined(__i386__) || defined(__aarch64__))) \
158
+ || (defined(__OpenBSD__) && (defined(__x86_64__) || defined(__i386__) || defined(__aarch64__))) \
159
+ )
160
+
161
+ static inline void* mi_prim_tls_slot(size_t slot) mi_attr_noexcept {
162
+ void* res;
163
+ const size_t ofs = (slot*sizeof(void*));
164
+ #if defined(__i386__)
165
+ __asm__("movl %%gs:%1, %0" : "=r" (res) : "m" (*((void**)ofs)) : ); // x86 32-bit always uses GS
166
+ #elif defined(__APPLE__) && defined(__x86_64__)
167
+ __asm__("movq %%gs:%1, %0" : "=r" (res) : "m" (*((void**)ofs)) : ); // x86_64 macOSX uses GS
168
+ #elif defined(__x86_64__) && (MI_INTPTR_SIZE==4)
169
+ __asm__("movl %%fs:%1, %0" : "=r" (res) : "m" (*((void**)ofs)) : ); // x32 ABI
170
+ #elif defined(__x86_64__)
171
+ __asm__("movq %%fs:%1, %0" : "=r" (res) : "m" (*((void**)ofs)) : ); // x86_64 Linux, BSD uses FS
172
+ #elif defined(__arm__)
173
+ void** tcb; MI_UNUSED(ofs);
174
+ __asm__ volatile ("mrc p15, 0, %0, c13, c0, 3\nbic %0, %0, #3" : "=r" (tcb));
175
+ res = tcb[slot];
176
+ #elif defined(__aarch64__)
177
+ void** tcb; MI_UNUSED(ofs);
178
+ #if defined(__APPLE__) // M1, issue #343
179
+ __asm__ volatile ("mrs %0, tpidrro_el0\nbic %0, %0, #7" : "=r" (tcb));
180
+ #else
181
+ __asm__ volatile ("mrs %0, tpidr_el0" : "=r" (tcb));
182
+ #endif
183
+ res = tcb[slot];
184
+ #endif
185
+ return res;
186
+ }
187
+
188
+ // setting a tls slot is only used on macOS for now
189
+ static inline void mi_prim_tls_slot_set(size_t slot, void* value) mi_attr_noexcept {
190
+ const size_t ofs = (slot*sizeof(void*));
191
+ #if defined(__i386__)
192
+ __asm__("movl %1,%%gs:%0" : "=m" (*((void**)ofs)) : "rn" (value) : ); // 32-bit always uses GS
193
+ #elif defined(__APPLE__) && defined(__x86_64__)
194
+ __asm__("movq %1,%%gs:%0" : "=m" (*((void**)ofs)) : "rn" (value) : ); // x86_64 macOS uses GS
195
+ #elif defined(__x86_64__) && (MI_INTPTR_SIZE==4)
196
+ __asm__("movl %1,%%fs:%0" : "=m" (*((void**)ofs)) : "rn" (value) : ); // x32 ABI
197
+ #elif defined(__x86_64__)
198
+ __asm__("movq %1,%%fs:%0" : "=m" (*((void**)ofs)) : "rn" (value) : ); // x86_64 Linux, BSD uses FS
199
+ #elif defined(__arm__)
200
+ void** tcb; MI_UNUSED(ofs);
201
+ __asm__ volatile ("mrc p15, 0, %0, c13, c0, 3\nbic %0, %0, #3" : "=r" (tcb));
202
+ tcb[slot] = value;
203
+ #elif defined(__aarch64__)
204
+ void** tcb; MI_UNUSED(ofs);
205
+ #if defined(__APPLE__) // M1, issue #343
206
+ __asm__ volatile ("mrs %0, tpidrro_el0\nbic %0, %0, #7" : "=r" (tcb));
207
+ #else
208
+ __asm__ volatile ("mrs %0, tpidr_el0" : "=r" (tcb));
209
+ #endif
210
+ tcb[slot] = value;
211
+ #endif
212
+ }
213
+
214
+ static inline mi_threadid_t _mi_prim_thread_id(void) mi_attr_noexcept {
215
+ #if defined(__BIONIC__)
216
+ // issue #384, #495: on the Bionic libc (Android), slot 1 is the thread id
217
+ // see: https://github.com/aosp-mirror/platform_bionic/blob/c44b1d0676ded732df4b3b21c5f798eacae93228/libc/platform/bionic/tls_defines.h#L86
218
+ return (uintptr_t)mi_prim_tls_slot(1);
219
+ #else
220
+ // in all our other targets, slot 0 is the thread id
221
+ // glibc: https://sourceware.org/git/?p=glibc.git;a=blob_plain;f=sysdeps/x86_64/nptl/tls.h
222
+ // apple: https://github.com/apple/darwin-xnu/blob/main/libsyscall/os/tsd.h#L36
223
+ return (uintptr_t)mi_prim_tls_slot(0);
224
+ #endif
225
+ }
226
+
227
+ #else
228
+
229
+ // otherwise use portable C, taking the address of a thread local variable (this is still very fast on most platforms).
230
+ static inline mi_threadid_t _mi_prim_thread_id(void) mi_attr_noexcept {
231
+ return (uintptr_t)&_mi_heap_default;
232
+ }
233
+
234
+ #endif
235
+
236
+
237
+
238
+ /* ----------------------------------------------------------------------------------------
239
+ The thread local default heap: `_mi_prim_get_default_heap()`
240
+ This is inlined here as it is on the fast path for allocation functions.
241
+
242
+ On most platforms (Windows, Linux, FreeBSD, NetBSD, etc), this just returns a
243
+ __thread local variable (`_mi_heap_default`). With the initial-exec TLS model this ensures
244
+ that the storage will always be available (allocated on the thread stacks).
245
+
246
+ On some platforms though we cannot use that when overriding `malloc` since the underlying
247
+ TLS implementation (or the loader) will call itself `malloc` on a first access and recurse.
248
+ We try to circumvent this in an efficient way:
249
+ - macOSX : we use an unused TLS slot from the OS allocated slots (MI_TLS_SLOT). On OSX, the
250
+ loader itself calls `malloc` even before the modules are initialized.
251
+ - OpenBSD: we use an unused slot from the pthread block (MI_TLS_PTHREAD_SLOT_OFS).
252
+ - DragonFly: defaults are working but seem slow compared to freeBSD (see PR #323)
253
+ ------------------------------------------------------------------------------------------- */
254
+
255
+ static inline mi_heap_t* mi_prim_get_default_heap(void);
256
+
257
+ #if defined(MI_MALLOC_OVERRIDE)
258
+ #if defined(__APPLE__) // macOS
259
+ #define MI_TLS_SLOT 89 // seems unused?
260
+ // #define MI_TLS_RECURSE_GUARD 1
261
+ // other possible unused ones are 9, 29, __PTK_FRAMEWORK_JAVASCRIPTCORE_KEY4 (94), __PTK_FRAMEWORK_GC_KEY9 (112) and __PTK_FRAMEWORK_OLDGC_KEY9 (89)
262
+ // see <https://github.com/rweichler/substrate/blob/master/include/pthread_machdep.h>
263
+ #elif defined(__OpenBSD__)
264
+ // use end bytes of a name; goes wrong if anyone uses names > 23 characters (ptrhread specifies 16)
265
+ // see <https://github.com/openbsd/src/blob/master/lib/libc/include/thread_private.h#L371>
266
+ #define MI_TLS_PTHREAD_SLOT_OFS (6*sizeof(int) + 4*sizeof(void*) + 24)
267
+ // #elif defined(__DragonFly__)
268
+ // #warning "mimalloc is not working correctly on DragonFly yet."
269
+ // #define MI_TLS_PTHREAD_SLOT_OFS (4 + 1*sizeof(void*)) // offset `uniqueid` (also used by gdb?) <https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/lib/libthread_xu/thread/thr_private.h#L458>
270
+ #elif defined(__ANDROID__)
271
+ // See issue #381
272
+ #define MI_TLS_PTHREAD
273
+ #endif
274
+ #endif
275
+
276
+
277
+ #if defined(MI_TLS_SLOT)
278
+
279
+ static inline mi_heap_t* mi_prim_get_default_heap(void) {
280
+ mi_heap_t* heap = (mi_heap_t*)mi_prim_tls_slot(MI_TLS_SLOT);
281
+ if mi_unlikely(heap == NULL) {
282
+ #ifdef __GNUC__
283
+ __asm(""); // prevent conditional load of the address of _mi_heap_empty
284
+ #endif
285
+ heap = (mi_heap_t*)&_mi_heap_empty;
286
+ }
287
+ return heap;
288
+ }
289
+
290
+ #elif defined(MI_TLS_PTHREAD_SLOT_OFS)
291
+
292
+ static inline mi_heap_t** mi_prim_tls_pthread_heap_slot(void) {
293
+ pthread_t self = pthread_self();
294
+ #if defined(__DragonFly__)
295
+ if (self==NULL) return NULL;
296
+ #endif
297
+ return (mi_heap_t**)((uint8_t*)self + MI_TLS_PTHREAD_SLOT_OFS);
298
+ }
299
+
300
+ static inline mi_heap_t* mi_prim_get_default_heap(void) {
301
+ mi_heap_t** pheap = mi_prim_tls_pthread_heap_slot();
302
+ if mi_unlikely(pheap == NULL) return _mi_heap_main_get();
303
+ mi_heap_t* heap = *pheap;
304
+ if mi_unlikely(heap == NULL) return (mi_heap_t*)&_mi_heap_empty;
305
+ return heap;
306
+ }
307
+
308
+ #elif defined(MI_TLS_PTHREAD)
309
+
310
+ extern pthread_key_t _mi_heap_default_key;
311
+ static inline mi_heap_t* mi_prim_get_default_heap(void) {
312
+ mi_heap_t* heap = (mi_unlikely(_mi_heap_default_key == (pthread_key_t)(-1)) ? _mi_heap_main_get() : (mi_heap_t*)pthread_getspecific(_mi_heap_default_key));
313
+ return (mi_unlikely(heap == NULL) ? (mi_heap_t*)&_mi_heap_empty : heap);
314
+ }
315
+
316
+ #else // default using a thread local variable; used on most platforms.
317
+
318
+ static inline mi_heap_t* mi_prim_get_default_heap(void) {
319
+ #if defined(MI_TLS_RECURSE_GUARD)
320
+ if (mi_unlikely(!_mi_process_is_initialized)) return _mi_heap_main_get();
321
+ #endif
322
+ return _mi_heap_default;
323
+ }
324
+
325
+ #endif // mi_prim_get_default_heap()
326
+
327
+
328
+
329
+ #endif // MIMALLOC_PRIM_H
@@ -0,0 +1,147 @@
1
+ /* ----------------------------------------------------------------------------
2
+ Copyright (c) 2018-2023, 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_TRACK_H
9
+ #define MIMALLOC_TRACK_H
10
+
11
+ /* ------------------------------------------------------------------------------------------------------
12
+ Track memory ranges with macros for tools like Valgrind address sanitizer, or other memory checkers.
13
+ These can be defined for tracking allocation:
14
+
15
+ #define mi_track_malloc_size(p,reqsize,size,zero)
16
+ #define mi_track_free_size(p,_size)
17
+
18
+ The macros are set up such that the size passed to `mi_track_free_size`
19
+ always matches the size of `mi_track_malloc_size`. (currently, `size == mi_usable_size(p)`).
20
+ The `reqsize` is what the user requested, and `size >= reqsize`.
21
+ The `size` is either byte precise (and `size==reqsize`) if `MI_PADDING` is enabled,
22
+ or otherwise it is the usable block size which may be larger than the original request.
23
+ Use `_mi_block_size_of(void* p)` to get the full block size that was allocated (including padding etc).
24
+ The `zero` parameter is `true` if the allocated block is zero initialized.
25
+
26
+ Optional:
27
+
28
+ #define mi_track_align(p,alignedp,offset,size)
29
+ #define mi_track_resize(p,oldsize,newsize)
30
+ #define mi_track_init()
31
+
32
+ The `mi_track_align` is called right after a `mi_track_malloc` for aligned pointers in a block.
33
+ The corresponding `mi_track_free` still uses the block start pointer and original size (corresponding to the `mi_track_malloc`).
34
+ The `mi_track_resize` is currently unused but could be called on reallocations within a block.
35
+ `mi_track_init` is called at program start.
36
+
37
+ The following macros are for tools like asan and valgrind to track whether memory is
38
+ defined, undefined, or not accessible at all:
39
+
40
+ #define mi_track_mem_defined(p,size)
41
+ #define mi_track_mem_undefined(p,size)
42
+ #define mi_track_mem_noaccess(p,size)
43
+
44
+ -------------------------------------------------------------------------------------------------------*/
45
+
46
+ #if MI_TRACK_VALGRIND
47
+ // valgrind tool
48
+
49
+ #define MI_TRACK_ENABLED 1
50
+ #define MI_TRACK_HEAP_DESTROY 1 // track free of individual blocks on heap_destroy
51
+ #define MI_TRACK_TOOL "valgrind"
52
+
53
+ #include <valgrind/valgrind.h>
54
+ #include <valgrind/memcheck.h>
55
+
56
+ #define mi_track_malloc_size(p,reqsize,size,zero) VALGRIND_MALLOCLIKE_BLOCK(p,size,MI_PADDING_SIZE /*red zone*/,zero)
57
+ #define mi_track_free_size(p,_size) VALGRIND_FREELIKE_BLOCK(p,MI_PADDING_SIZE /*red zone*/)
58
+ #define mi_track_resize(p,oldsize,newsize) VALGRIND_RESIZEINPLACE_BLOCK(p,oldsize,newsize,MI_PADDING_SIZE /*red zone*/)
59
+ #define mi_track_mem_defined(p,size) VALGRIND_MAKE_MEM_DEFINED(p,size)
60
+ #define mi_track_mem_undefined(p,size) VALGRIND_MAKE_MEM_UNDEFINED(p,size)
61
+ #define mi_track_mem_noaccess(p,size) VALGRIND_MAKE_MEM_NOACCESS(p,size)
62
+
63
+ #elif MI_TRACK_ASAN
64
+ // address sanitizer
65
+
66
+ #define MI_TRACK_ENABLED 1
67
+ #define MI_TRACK_HEAP_DESTROY 0
68
+ #define MI_TRACK_TOOL "asan"
69
+
70
+ #include <sanitizer/asan_interface.h>
71
+
72
+ #define mi_track_malloc_size(p,reqsize,size,zero) ASAN_UNPOISON_MEMORY_REGION(p,size)
73
+ #define mi_track_free_size(p,size) ASAN_POISON_MEMORY_REGION(p,size)
74
+ #define mi_track_mem_defined(p,size) ASAN_UNPOISON_MEMORY_REGION(p,size)
75
+ #define mi_track_mem_undefined(p,size) ASAN_UNPOISON_MEMORY_REGION(p,size)
76
+ #define mi_track_mem_noaccess(p,size) ASAN_POISON_MEMORY_REGION(p,size)
77
+
78
+ #elif MI_TRACK_ETW
79
+ // windows event tracing
80
+
81
+ #define MI_TRACK_ENABLED 1
82
+ #define MI_TRACK_HEAP_DESTROY 1
83
+ #define MI_TRACK_TOOL "ETW"
84
+
85
+ #define WIN32_LEAN_AND_MEAN
86
+ #include <windows.h>
87
+ #include "../src/prim/windows/etw.h"
88
+
89
+ #define mi_track_init() EventRegistermicrosoft_windows_mimalloc();
90
+ #define mi_track_malloc_size(p,reqsize,size,zero) EventWriteETW_MI_ALLOC((UINT64)(p), size)
91
+ #define mi_track_free_size(p,size) EventWriteETW_MI_FREE((UINT64)(p), size)
92
+
93
+ #else
94
+ // no tracking
95
+
96
+ #define MI_TRACK_ENABLED 0
97
+ #define MI_TRACK_HEAP_DESTROY 0
98
+ #define MI_TRACK_TOOL "none"
99
+
100
+ #define mi_track_malloc_size(p,reqsize,size,zero)
101
+ #define mi_track_free_size(p,_size)
102
+
103
+ #endif
104
+
105
+ // -------------------
106
+ // Utility definitions
107
+
108
+ #ifndef mi_track_resize
109
+ #define mi_track_resize(p,oldsize,newsize) mi_track_free_size(p,oldsize); mi_track_malloc(p,newsize,false)
110
+ #endif
111
+
112
+ #ifndef mi_track_align
113
+ #define mi_track_align(p,alignedp,offset,size) mi_track_mem_noaccess(p,offset)
114
+ #endif
115
+
116
+ #ifndef mi_track_init
117
+ #define mi_track_init()
118
+ #endif
119
+
120
+ #ifndef mi_track_mem_defined
121
+ #define mi_track_mem_defined(p,size)
122
+ #endif
123
+
124
+ #ifndef mi_track_mem_undefined
125
+ #define mi_track_mem_undefined(p,size)
126
+ #endif
127
+
128
+ #ifndef mi_track_mem_noaccess
129
+ #define mi_track_mem_noaccess(p,size)
130
+ #endif
131
+
132
+
133
+ #if MI_PADDING
134
+ #define mi_track_malloc(p,reqsize,zero) \
135
+ if ((p)!=NULL) { \
136
+ mi_assert_internal(mi_usable_size(p)==(reqsize)); \
137
+ mi_track_malloc_size(p,reqsize,reqsize,zero); \
138
+ }
139
+ #else
140
+ #define mi_track_malloc(p,reqsize,zero) \
141
+ if ((p)!=NULL) { \
142
+ mi_assert_internal(mi_usable_size(p)>=(reqsize)); \
143
+ mi_track_malloc_size(p,reqsize,mi_usable_size(p),zero); \
144
+ }
145
+ #endif
146
+
147
+ #endif