config.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #pragma once
  2. /*************** feature settings ***************/
  3. // Whether to compile os-related modules or not
  4. #ifndef PK_ENABLE_OS // can be overridden by cmake
  5. #define PK_ENABLE_OS 0
  6. #endif
  7. // Enable this if you are working with multi-threading (experimental)
  8. // This triggers necessary locks to make the VM thread-safe
  9. #ifndef PK_ENABLE_THREAD // can be overridden by cmake
  10. #define PK_ENABLE_THREAD 0
  11. #endif
  12. // Enable `line_profiler` module and `breakpoint()` function
  13. #ifndef PK_ENABLE_PROFILER // can be overridden by cmake
  14. #define PK_ENABLE_PROFILER 0
  15. #endif
  16. // GC min threshold
  17. #ifndef PK_GC_MIN_THRESHOLD // can be overridden by cmake
  18. #define PK_GC_MIN_THRESHOLD 32768
  19. #endif
  20. // Whether to use `std::function` to do bindings or not
  21. // By default, functions to be binded must be a C function pointer without capture
  22. // However, someone thinks it's not convenient.
  23. // By setting this to 1, capturing lambdas can be binded,
  24. // but it's slower and may cause severe "code bloat", also needs more time to compile.
  25. #define PK_ENABLE_STD_FUNCTION 0
  26. /*************** debug settings ***************/
  27. // Enable this may help you find bugs
  28. #define PK_DEBUG_EXTRA_CHECK 1
  29. // Do not edit the following settings unless you know what you are doing
  30. #define PK_DEBUG_CEVAL_STEP 0
  31. #define PK_DEBUG_MEMORY_POOL 1
  32. #define PK_DEBUG_NO_MEMORY_POOL 1
  33. #define PK_DEBUG_NO_AUTO_GC 0
  34. #define PK_DEBUG_GC_STATS 0
  35. #ifndef PK_DEBUG_PRECOMPILED_EXEC
  36. #define PK_DEBUG_PRECOMPILED_EXEC 0
  37. #endif
  38. /*************** internal settings ***************/
  39. // This is the maximum size of the value stack in PyVar units
  40. // The actual size in bytes equals `sizeof(PyVar) * PK_VM_STACK_SIZE`
  41. #define PK_VM_STACK_SIZE 32768
  42. // This is the maximum number of local variables in a function
  43. // (not recommended to change this / it should be less than 200)
  44. #define PK_MAX_CO_VARNAMES 64
  45. // Hash table load factor (smaller ones mean less collision but more memory)
  46. // For class instance
  47. #define PK_INST_ATTR_LOAD_FACTOR 0.67
  48. // For class itself
  49. #define PK_TYPE_ATTR_LOAD_FACTOR 0.5
  50. #ifdef _WIN32
  51. #define PK_PLATFORM_SEP '\\'
  52. #else
  53. #define PK_PLATFORM_SEP '/'
  54. #endif
  55. #ifdef _MSC_VER
  56. #pragma warning (disable:4267)
  57. #pragma warning (disable:4100)
  58. #pragma warning (disable:4244)
  59. #pragma warning (disable:4996)
  60. #endif
  61. #ifdef _MSC_VER
  62. #define PK_UNREACHABLE() __assume(0);
  63. #else
  64. #define PK_UNREACHABLE() __builtin_unreachable();
  65. #endif