config.hpp 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. // Copyright (c) 2022 Klemens D. Morgenstern
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_PROCESS_V2_DETAIL_CONFIG_HPP
  6. #define BOOST_PROCESS_V2_DETAIL_CONFIG_HPP
  7. #if defined(BOOST_PROCESS_V2_STANDALONE)
  8. #define BOOST_PROCESS_V2_COMPLETION_TOKEN_FOR(Sig) ASIO_COMPLETION_TOKEN_FOR(Sig)
  9. #include <asio/detail/config.hpp>
  10. #include <system_error>
  11. #include <filesystem>
  12. #include <string_view>
  13. #include <iomanip>
  14. #include <optional>
  15. #if defined(ASIO_WINDOWS)
  16. #define BOOST_PROCESS_V2_WINDOWS 1
  17. #endif
  18. #if defined(ASIO_HAS_UNISTD_H)
  19. #define BOOST_PROCESS_V2_POSIX 1
  20. #endif
  21. #define BOOST_PROCESS_V2_BEGIN_NAMESPACE namespace process_v2 {
  22. #define BOOST_PROCESS_V2_END_NAMESPACE }
  23. #define BOOST_PROCESS_V2_NAMESPACE process_v2
  24. namespace asio {}
  25. BOOST_PROCESS_V2_BEGIN_NAMESPACE
  26. namespace net = ::asio;
  27. BOOST_PROCESS_V2_END_NAMESPACE
  28. #else
  29. #define BOOST_PROCESS_V2_COMPLETION_TOKEN_FOR(Sig) BOOST_ASIO_COMPLETION_TOKEN_FOR(Sig)
  30. #include <boost/config.hpp>
  31. #include <boost/io/quoted.hpp>
  32. #include <boost/system/error_code.hpp>
  33. #include <boost/system/system_category.hpp>
  34. #include <boost/system/system_error.hpp>
  35. #include <boost/optional.hpp>
  36. #if defined(BOOST_WINDOWS_API)
  37. #define BOOST_PROCESS_V2_WINDOWS 1
  38. #endif
  39. #if defined(BOOST_POSIX_API)
  40. #define BOOST_PROCESS_V2_POSIX 1
  41. #endif
  42. #if !defined(BOOST_PROCESS_V2_WINDOWS) && !defined(BOOST_POSIX_API)
  43. #error Unsupported operating system
  44. #endif
  45. #if defined(BOOST_PROCESS_USE_STD_FS)
  46. #include <filesystem>
  47. #else
  48. #include <boost/filesystem/path.hpp>
  49. #include <boost/filesystem/operations.hpp>
  50. #endif
  51. #if !defined(BOOST_PROCESS_VERSION)
  52. #define BOOST_PROCESS_VERSION 2
  53. #endif
  54. #if BOOST_PROCESS_VERSION == 1
  55. #define BOOST_PROCESS_V2_BEGIN_NAMESPACE namespace boost { namespace process { namespace v2 {
  56. #else
  57. #define BOOST_PROCESS_V2_BEGIN_NAMESPACE namespace boost { namespace process { inline namespace v2 {
  58. #endif
  59. #define BOOST_PROCESS_V2_END_NAMESPACE } } }
  60. #define BOOST_PROCESS_V2_NAMESPACE boost::process::v2
  61. namespace boost { namespace asio {} }
  62. BOOST_PROCESS_V2_BEGIN_NAMESPACE
  63. namespace net = ::boost::asio;
  64. BOOST_PROCESS_V2_END_NAMESPACE
  65. #endif
  66. BOOST_PROCESS_V2_BEGIN_NAMESPACE
  67. #if defined(BOOST_PROCESS_STANDALONE)
  68. using std::error_code ;
  69. using std::error_category ;
  70. using std::system_category ;
  71. using std::system_error ;
  72. namespace filesystem = std::filesystem;
  73. using std::quoted;
  74. using std::optional;
  75. #define BOOST_PROCESS_V2_ASSIGN_EC(ec, ...) ec.assign(__VA_ARGS__);
  76. #define BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) \
  77. ec.assign(::BOOST_PROCESS_V2_NAMESPACE::detail::get_last_error()); \
  78. #else
  79. using boost::system::error_code ;
  80. using boost::system::error_category ;
  81. using boost::system::system_category ;
  82. using boost::system::system_error ;
  83. using boost::io::quoted;
  84. using boost::optional;
  85. #ifdef BOOST_PROCESS_USE_STD_FS
  86. namespace filesystem = std::filesystem;
  87. #else
  88. namespace filesystem = boost::filesystem;
  89. #endif
  90. #define BOOST_PROCESS_V2_ASSIGN_EC(ec, ...) \
  91. do \
  92. { \
  93. static constexpr auto loc##__LINE__((BOOST_CURRENT_LOCATION)); \
  94. ec.assign(__VA_ARGS__, &loc##__LINE__); \
  95. } \
  96. while (false)
  97. #define BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) \
  98. do \
  99. { \
  100. static constexpr auto loc##__LINE__((BOOST_CURRENT_LOCATION)); \
  101. ec.assign(::BOOST_PROCESS_V2_NAMESPACE::detail::get_last_error(), &loc##__LINE__); \
  102. } \
  103. while (false)
  104. #endif
  105. BOOST_PROCESS_V2_END_NAMESPACE
  106. #if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_PROCESS_DYN_LINK)
  107. #if defined(BOOST_PROCESS_SOURCE)
  108. #define BOOST_PROCESS_V2_DECL BOOST_SYMBOL_EXPORT
  109. #else
  110. #define BOOST_PROCESS_V2_DECL BOOST_SYMBOL_IMPORT
  111. #endif
  112. #else
  113. #define BOOST_PROCESS_V2_DECL
  114. #endif
  115. #if !defined(BOOST_PROCESS_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_PROCESS_NO_LIB)
  116. #define BOOST_LIB_NAME boost_process
  117. #if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_PROCESS_DYN_LINK)
  118. #define BOOST_DYN_LINK
  119. #endif
  120. #include <boost/config/auto_link.hpp>
  121. #endif
  122. #if defined(BOOST_PROCESS_V2_POSIX)
  123. #if defined(__linux__) && !defined(BOOST_PROCESS_V2_DISABLE_PIDFD_OPEN)
  124. #include <sys/syscall.h>
  125. #if defined(SYS_pidfd_open) && !defined(BOOST_PROCESS_V2_DISABLE_PIDFD_OPEN)
  126. #define BOOST_PROCESS_V2_PIDFD_OPEN 1
  127. #define BOOST_PROCESS_V2_HAS_PROCESS_HANDLE 1
  128. #endif
  129. #endif
  130. #if defined(__FreeBSD__) && defined(BOOST_PROCESS_V2_ENABLE_PDFORK)
  131. #define BOOST_PROCESS_V2_PDFORK 1
  132. #define BOOST_PROCESS_V2_HAS_PROCESS_HANDLE 1
  133. #endif
  134. #else
  135. #define BOOST_PROCESS_V2_HAS_PROCESS_HANDLE 1
  136. #endif
  137. #endif //BOOST_PROCESS_V2_DETAIL_CONFIG_HPP