config.hpp 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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_ASIO_NAMESPACE asio
  9. #define BOOST_PROCESS_V2_COMPLETION_TOKEN_FOR(Sig) ASIO_COMPLETION_TOKEN_FOR(Sig)
  10. #define BOOST_PROCESS_V2_DEFAULT_COMPLETION_TOKEN_TYPE(Executor) ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(Executor)
  11. #define BOOST_PROCESS_V2_INITFN_AUTO_RESULT_TYPE(Token, Signature) ASIO_INITFN_AUTO_RESULT_TYPE(Token, Signature)
  12. #define BOOST_PROCESS_V2_DEFAULT_COMPLETION_TOKEN(Executor) ASIO_DEFAULT_COMPLETION_TOKEN(Executor)
  13. #define BOOST_PROCESS_V2_INITFN_DEDUCED_RESULT_TYPE(x,y,z) ASIO_INITFN_DEDUCED_RESULT_TYPE(x,y,z)
  14. #include <asio/detail/config.hpp>
  15. #include <system_error>
  16. #include <filesystem>
  17. #include <string_view>
  18. #include <iomanip>
  19. #include <optional>
  20. #if defined(ASIO_WINDOWS)
  21. #define BOOST_PROCESS_V2_WINDOWS 1
  22. // Windows: suppress definition of "min" and "max" macros.
  23. #if !defined(NOMINMAX)
  24. # define NOMINMAX 1
  25. #endif
  26. #endif
  27. #if defined(ASIO_HAS_UNISTD_H)
  28. #define BOOST_PROCESS_V2_POSIX 1
  29. #endif
  30. #define BOOST_PROCESS_V2_BEGIN_NAMESPACE namespace process_v2 {
  31. #define BOOST_PROCESS_V2_END_NAMESPACE }
  32. #define BOOST_PROCESS_V2_NAMESPACE process_v2
  33. #else
  34. #define BOOST_PROCESS_V2_ASIO_NAMESPACE boost::asio
  35. #define BOOST_PROCESS_V2_COMPLETION_TOKEN_FOR(Sig) BOOST_ASIO_COMPLETION_TOKEN_FOR(Sig)
  36. #define BOOST_PROCESS_V2_DEFAULT_COMPLETION_TOKEN_TYPE(Executor) BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(Executor)
  37. #define BOOST_PROCESS_V2_INITFN_AUTO_RESULT_TYPE(Token, Signature) BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(Token, Signature)
  38. #define BOOST_PROCESS_V2_DEFAULT_COMPLETION_TOKEN(Executor) BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(Executor)
  39. #define BOOST_PROCESS_V2_INITFN_DEDUCED_RESULT_TYPE(x,y,z) BOOST_ASIO_INITFN_DEDUCED_RESULT_TYPE(x,y,z)
  40. #include <boost/config.hpp>
  41. #include <boost/io/quoted.hpp>
  42. #include <boost/system/error_code.hpp>
  43. #include <boost/system/system_category.hpp>
  44. #include <boost/system/system_error.hpp>
  45. #include <boost/optional.hpp>
  46. #if defined(BOOST_WINDOWS_API)
  47. #define BOOST_PROCESS_V2_WINDOWS 1
  48. // Windows: suppress definition of "min" and "max" macros.
  49. #if !defined(NOMINMAX)
  50. # define NOMINMAX 1
  51. #endif
  52. #endif
  53. #if defined(BOOST_POSIX_API)
  54. #define BOOST_PROCESS_V2_POSIX 1
  55. #endif
  56. #if !defined(BOOST_PROCESS_V2_WINDOWS) && !defined(BOOST_POSIX_API)
  57. #error Unsupported operating system
  58. #endif
  59. #if defined(BOOST_PROCESS_USE_STD_FS)
  60. #include <filesystem>
  61. #else
  62. #include <boost/filesystem/path.hpp>
  63. #include <boost/filesystem/operations.hpp>
  64. #endif
  65. #define BOOST_PROCESS_V2_BEGIN_NAMESPACE namespace boost { namespace process { namespace v2 {
  66. #define BOOST_PROCESS_V2_END_NAMESPACE } } }
  67. #define BOOST_PROCESS_V2_NAMESPACE boost::process::v2
  68. #endif
  69. BOOST_PROCESS_V2_BEGIN_NAMESPACE
  70. #if defined(BOOST_PROCESS_STANDALONE)
  71. using std::error_code ;
  72. using std::error_category ;
  73. using std::system_category ;
  74. using std::system_error ;
  75. namespace filesystem = std::filesystem;
  76. using std::quoted;
  77. using std::optional;
  78. #define BOOST_PROCESS_V2_RETURN_EC(ev) \
  79. return ::BOOST_PROCESS_V2_NAMESPACE::error_code(ev, ::BOOST_PROCESS_V2_NAMESPACE::system_category()); \
  80. #define BOOST_PROCESS_V2_ASSIGN_EC(ec, ...) ec.assign(__VA_ARGS__);
  81. #define BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) \
  82. ec.assign(::BOOST_PROCESS_V2_NAMESPACE::detail::get_last_error()); \
  83. #else
  84. using boost::system::error_code ;
  85. using boost::system::error_category ;
  86. using boost::system::system_category ;
  87. using boost::system::system_error ;
  88. using boost::io::quoted;
  89. using boost::optional;
  90. #ifdef BOOST_PROCESS_USE_STD_FS
  91. namespace filesystem = std::filesystem;
  92. #else
  93. namespace filesystem = boost::filesystem;
  94. #endif
  95. #define BOOST_PROCESS_V2_RETURN_EC(ev) \
  96. { \
  97. static constexpr auto loc##__LINE__((BOOST_CURRENT_LOCATION)); \
  98. return ::BOOST_PROCESS_V2_NAMESPACE::error_code(ev, ::BOOST_PROCESS_V2_NAMESPACE::system_category(), &loc##__LINE__); \
  99. }
  100. #define BOOST_PROCESS_V2_ASSIGN_EC(ec, ...) \
  101. { \
  102. static constexpr auto loc##__LINE__((BOOST_CURRENT_LOCATION)); \
  103. ec.assign(__VA_ARGS__, &loc##__LINE__); \
  104. }
  105. #define BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) \
  106. { \
  107. static constexpr auto loc##__LINE__((BOOST_CURRENT_LOCATION)); \
  108. ec.assign(::BOOST_PROCESS_V2_NAMESPACE::detail::get_last_error(), &loc##__LINE__); \
  109. }
  110. #endif
  111. BOOST_PROCESS_V2_END_NAMESPACE
  112. #ifndef BOOST_PROCESS_V2_HEADER_ONLY
  113. # ifndef BOOST_PROCESS_V2_SEPARATE_COMPILATION
  114. # define BOOST_PROCESS_V2_HEADER_ONLY 1
  115. # endif
  116. #endif
  117. #if BOOST_PROCESS_V2_DOXYGEN
  118. # define BOOST_PROCESS_V2_DECL
  119. #elif defined(BOOST_PROCESS_V2_HEADER_ONLY)
  120. # define BOOST_PROCESS_V2_DECL inline
  121. #else
  122. # define BOOST_PROCESS_V2_DECL
  123. #endif
  124. #if defined(BOOST_PROCESS_V2_POSIX)
  125. #if defined(__linux__) && !defined(BOOST_PROCESS_V2_DISABLE_PIDFD_OPEN)
  126. #include <sys/syscall.h>
  127. #if defined(SYS_pidfd_open)
  128. #define BOOST_PROCESS_V2_PIDFD_OPEN 1
  129. #define BOOST_PROCESS_V2_HAS_PROCESS_HANDLE 1
  130. #endif
  131. #endif
  132. #if defined(__FreeBSD__) && defined(BOOST_PROCESS_V2_ENABLE_PDFORK)
  133. #define BOOST_PROCESS_V2_PDFORK 1
  134. #define BOOST_PROCESS_V2_HAS_PROCESS_HANDLE 1
  135. #endif
  136. #else
  137. #define BOOST_PROCESS_V2_HAS_PROCESS_HANDLE 1
  138. #endif
  139. #endif //BOOST_PROCESS_V2_DETAIL_CONFIG_HPP