config.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. // Whether to use `std::function` to do bindings or not
  12. // By default, functions to be binded must be a C function pointer without capture
  13. // However, someone thinks it's not convenient.
  14. // By setting this to 1, capturing lambdas can be binded,
  15. // but it's slower and may cause severe "code bloat", also needs more time to compile.
  16. #define PK_ENABLE_STD_FUNCTION 0
  17. /*************** debug settings ***************/
  18. // Enable this may help you find bugs
  19. #define DEBUG_EXTRA_CHECK 0
  20. // Do not edit the following settings unless you know what you are doing
  21. #define DEBUG_NO_BUILTIN_MODULES 0
  22. #define DEBUG_DIS_EXEC 0
  23. #define DEBUG_CEVAL_STEP 0
  24. #define DEBUG_FULL_EXCEPTION 0
  25. #define DEBUG_MEMORY_POOL 0
  26. #define DEBUG_NO_MEMORY_POOL 0
  27. #define DEBUG_NO_AUTO_GC 0
  28. #define DEBUG_GC_STATS 0
  29. /*************** internal settings ***************/
  30. // This is the maximum size of the value stack in void* units
  31. // The actual size in bytes equals `sizeof(void*) * PK_VM_STACK_SIZE`
  32. #define PK_VM_STACK_SIZE 32768
  33. // This is the maximum number of arguments in a function declaration
  34. // including positional arguments, keyword-only arguments, and varargs
  35. // (not recommended to change this)
  36. #define PK_MAX_CO_VARNAMES 255
  37. // Hash table load factor (smaller ones mean less collision but more memory)
  38. // For class instance
  39. inline const float kInstAttrLoadFactor = 0.67f;
  40. // For class itself
  41. inline const float kTypeAttrLoadFactor = 0.5f;
  42. #ifdef _WIN32
  43. inline const char kPlatformSep = '\\';
  44. #else
  45. inline const char kPlatformSep = '/';
  46. #endif
  47. #ifdef _MSC_VER
  48. #pragma warning (disable:4267)
  49. #pragma warning (disable:4101)
  50. #pragma warning (disable:4244)
  51. #define _CRT_NONSTDC_NO_DEPRECATE
  52. #endif
  53. #ifdef _MSC_VER
  54. #define PK_ENABLE_COMPUTED_GOTO 0
  55. #define UNREACHABLE() __assume(0)
  56. #else
  57. #define PK_ENABLE_COMPUTED_GOTO 1
  58. #define UNREACHABLE() __builtin_unreachable()
  59. #endif
  60. #if DEBUG_CEVAL_STEP && defined(PK_ENABLE_COMPUTED_GOTO)
  61. #undef PK_ENABLE_COMPUTED_GOTO
  62. #endif
  63. /*************** module settings ***************/
  64. #define PK_MODULE_RE 1
  65. #define PK_MODULE_RANDOM 1
  66. #define PK_MODULE_BASE64 1
  67. #define PK_MODULE_LINALG 1
  68. #define PK_MODULE_EASING 1
  69. #define PK_MODULE_REQUESTS 0
  70. #endif