export.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #pragma once
  2. // clang-format off
  3. #if defined(_WIN32) || defined(_WIN64)
  4. #ifdef PY_DYNAMIC_MODULE
  5. #define PK_API __declspec(dllimport)
  6. #else
  7. #define PK_API __declspec(dllexport)
  8. #endif
  9. #define PK_EXPORT __declspec(dllexport)
  10. #define PY_SYS_PLATFORM 0
  11. #define PY_SYS_PLATFORM_STRING "win32"
  12. #elif __EMSCRIPTEN__
  13. #define PK_API
  14. #define PK_EXPORT
  15. #define PY_SYS_PLATFORM 1
  16. #define PY_SYS_PLATFORM_STRING "emscripten"
  17. #elif __APPLE__
  18. #include <TargetConditionals.h>
  19. #if TARGET_IPHONE_SIMULATOR
  20. // iOS, tvOS, or watchOS Simulator
  21. #define PY_SYS_PLATFORM 2
  22. #define PY_SYS_PLATFORM_STRING "ios"
  23. #elif TARGET_OS_IPHONE
  24. // iOS, tvOS, or watchOS device
  25. #define PY_SYS_PLATFORM 2
  26. #define PY_SYS_PLATFORM_STRING "ios"
  27. #elif TARGET_OS_MAC
  28. #define PY_SYS_PLATFORM 3
  29. #define PY_SYS_PLATFORM_STRING "darwin"
  30. #else
  31. # error "Unknown Apple platform"
  32. #endif
  33. #define PK_API __attribute__((visibility("default")))
  34. #define PK_EXPORT __attribute__((visibility("default")))
  35. #elif __ANDROID__
  36. #define PK_API __attribute__((visibility("default")))
  37. #define PK_EXPORT __attribute__((visibility("default")))
  38. #define PY_SYS_PLATFORM 4
  39. #define PY_SYS_PLATFORM_STRING "android"
  40. #elif __linux__
  41. #define PK_API __attribute__((visibility("default")))
  42. #define PK_EXPORT __attribute__((visibility("default")))
  43. #define PY_SYS_PLATFORM 5
  44. #define PY_SYS_PLATFORM_STRING "linux"
  45. #else
  46. #define PK_API
  47. #define PY_SYS_PLATFORM 6
  48. #define PY_SYS_PLATFORM_STRING "unknown"
  49. #endif
  50. #if PY_SYS_PLATFORM == 0 || PY_SYS_PLATFORM == 3 || PY_SYS_PLATFORM == 5
  51. #define PK_IS_DESKTOP_PLATFORM 1
  52. #else
  53. #define PK_IS_DESKTOP_PLATFORM 0
  54. #endif
  55. #if defined(__GNUC__) || defined(__clang__)
  56. #define PK_DEPRECATED __attribute__((deprecated))
  57. #else
  58. #define PK_DEPRECATED
  59. #endif
  60. #ifdef NDEBUG
  61. #if defined(__GNUC__)
  62. #define PK_INLINE __attribute__((always_inline)) inline
  63. #elif defined(_MSC_VER) && !defined(__clang__)
  64. #define PK_INLINE __forceinline
  65. #else
  66. #define PK_INLINE inline
  67. #endif
  68. #else
  69. #define PK_INLINE
  70. #endif