config.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #pragma once
  2. #ifdef PK_USER_CONFIG_H
  3. #include "user_config.h"
  4. #else
  5. /*************** feature settings ***************/
  6. // Whether to compile os-related modules or not
  7. #define PK_ENABLE_OS 1
  8. // Enable this if you are working with multi-threading (experimental)
  9. // This triggers necessary locks to make the VM thread-safe
  10. #define PK_ENABLE_THREAD 0
  11. // Enable this for `vm->_ceval_on_step`
  12. #define PK_ENABLE_CEVAL_CALLBACK 0
  13. // Whether to use `std::function` to do bindings or not
  14. // By default, functions to be binded must be a C function pointer without capture
  15. // However, someone thinks it's not convenient.
  16. // By setting this to 1, capturing lambdas can be binded,
  17. // but it's slower and may cause severe "code bloat", also needs more time to compile.
  18. #define PK_ENABLE_STD_FUNCTION 0
  19. /*************** debug settings ***************/
  20. // Enable this may help you find bugs
  21. #define PK_DEBUG_EXTRA_CHECK 0
  22. // Do not edit the following settings unless you know what you are doing
  23. #define PK_DEBUG_NO_BUILTINS 0
  24. #define PK_DEBUG_DIS_EXEC 0
  25. #define PK_DEBUG_CEVAL_STEP 0
  26. #define PK_DEBUG_FULL_EXCEPTION 0
  27. #define PK_DEBUG_MEMORY_POOL 0
  28. #define PK_DEBUG_NO_MEMORY_POOL 0
  29. #define PK_DEBUG_NO_AUTO_GC 0
  30. #define PK_DEBUG_GC_STATS 0
  31. /*************** internal settings ***************/
  32. // This is the maximum size of the value stack in void* units
  33. // The actual size in bytes equals `sizeof(void*) * PK_VM_STACK_SIZE`
  34. #define PK_VM_STACK_SIZE 32768
  35. // This is the maximum number of arguments in a function declaration
  36. // including positional arguments, keyword-only arguments, and varargs
  37. // (not recommended to change this)
  38. #define PK_MAX_CO_VARNAMES 255
  39. namespace pkpy{
  40. // Hash table load factor (smaller ones mean less collision but more memory)
  41. // For class instance
  42. inline const float kInstAttrLoadFactor = 0.67f;
  43. // For class itself
  44. inline const float kTypeAttrLoadFactor = 0.5f;
  45. #ifdef _WIN32
  46. inline const char kPlatformSep = '\\';
  47. #else
  48. inline const char kPlatformSep = '/';
  49. #endif
  50. }
  51. #ifdef _MSC_VER
  52. #pragma warning (disable:4267)
  53. #pragma warning (disable:4100)
  54. #pragma warning (disable:4244)
  55. #define strdup _strdup
  56. #endif
  57. #ifdef _MSC_VER
  58. #define PK_ENABLE_COMPUTED_GOTO 0
  59. #define UNREACHABLE() __assume(0)
  60. #else
  61. #define PK_ENABLE_COMPUTED_GOTO 1
  62. #define UNREACHABLE() __builtin_unreachable()
  63. #endif
  64. #if PK_DEBUG_CEVAL_STEP && defined(PK_ENABLE_COMPUTED_GOTO)
  65. #undef PK_ENABLE_COMPUTED_GOTO
  66. #endif
  67. /*************** module settings ***************/
  68. #define PK_MODULE_RE 1
  69. #define PK_MODULE_RANDOM 1
  70. #define PK_MODULE_BASE64 1
  71. #define PK_MODULE_LINALG 1
  72. #define PK_MODULE_EASING 1
  73. #define PK_MODULE_REQUESTS 0
  74. #endif