config.hpp 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. #if !defined(BOOST_PROCESS_VERSION)
  66. #define BOOST_PROCESS_VERSION 1
  67. #endif
  68. #if BOOST_PROCESS_VERSION == 2
  69. #define BOOST_PROCESS_V2_BEGIN_NAMESPACE namespace boost { namespace process { namespace v2 {
  70. #else
  71. #define BOOST_PROCESS_V2_BEGIN_NAMESPACE namespace boost { namespace process { inline namespace v2 {
  72. #endif
  73. #define BOOST_PROCESS_V2_END_NAMESPACE } } }
  74. #define BOOST_PROCESS_V2_NAMESPACE boost::process::v2
  75. #endif
  76. BOOST_PROCESS_V2_BEGIN_NAMESPACE
  77. #if defined(BOOST_PROCESS_STANDALONE)
  78. using std::error_code ;
  79. using std::error_category ;
  80. using std::system_category ;
  81. using std::system_error ;
  82. namespace filesystem = std::filesystem;
  83. using std::quoted;
  84. using std::optional;
  85. #define BOOST_PROCESS_V2_RETURN_EC(ev) \
  86. return ::BOOST_PROCESS_V2_NAMESPACE::error_code(ev, ::BOOST_PROCESS_V2_NAMESPACE::system_category()); \
  87. #define BOOST_PROCESS_V2_ASSIGN_EC(ec, ...) ec.assign(__VA_ARGS__);
  88. #define BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) \
  89. ec.assign(::BOOST_PROCESS_V2_NAMESPACE::detail::get_last_error()); \
  90. #else
  91. using boost::system::error_code ;
  92. using boost::system::error_category ;
  93. using boost::system::system_category ;
  94. using boost::system::system_error ;
  95. using boost::io::quoted;
  96. using boost::optional;
  97. #ifdef BOOST_PROCESS_USE_STD_FS
  98. namespace filesystem = std::filesystem;
  99. #else
  100. namespace filesystem = boost::filesystem;
  101. #endif
  102. #define BOOST_PROCESS_V2_RETURN_EC(ev) \
  103. { \
  104. static constexpr auto loc##__LINE__((BOOST_CURRENT_LOCATION)); \
  105. return ::BOOST_PROCESS_V2_NAMESPACE::error_code(ev, ::BOOST_PROCESS_V2_NAMESPACE::system_category(), &loc##__LINE__); \
  106. }
  107. #define BOOST_PROCESS_V2_ASSIGN_EC(ec, ...) \
  108. { \
  109. static constexpr auto loc##__LINE__((BOOST_CURRENT_LOCATION)); \
  110. ec.assign(__VA_ARGS__, &loc##__LINE__); \
  111. }
  112. #define BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) \
  113. { \
  114. static constexpr auto loc##__LINE__((BOOST_CURRENT_LOCATION)); \
  115. ec.assign(::BOOST_PROCESS_V2_NAMESPACE::detail::get_last_error(), &loc##__LINE__); \
  116. }
  117. #endif
  118. BOOST_PROCESS_V2_END_NAMESPACE
  119. #if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_PROCESS_DYN_LINK)
  120. #if defined(BOOST_PROCESS_SOURCE)
  121. #define BOOST_PROCESS_V2_DECL BOOST_SYMBOL_EXPORT
  122. #else
  123. #define BOOST_PROCESS_V2_DECL BOOST_SYMBOL_IMPORT
  124. #endif
  125. #else
  126. #define BOOST_PROCESS_V2_DECL
  127. #endif
  128. #if defined(BOOST_PROCESS_V2_POSIX)
  129. #if defined(__linux__) && !defined(BOOST_PROCESS_V2_DISABLE_PIDFD_OPEN)
  130. #include <sys/syscall.h>
  131. #if defined(SYS_pidfd_open)
  132. #define BOOST_PROCESS_V2_PIDFD_OPEN 1
  133. #define BOOST_PROCESS_V2_HAS_PROCESS_HANDLE 1
  134. #endif
  135. #endif
  136. #if defined(__FreeBSD__) && defined(BOOST_PROCESS_V2_ENABLE_PDFORK)
  137. #define BOOST_PROCESS_V2_PDFORK 1
  138. #define BOOST_PROCESS_V2_HAS_PROCESS_HANDLE 1
  139. #endif
  140. #else
  141. #define BOOST_PROCESS_V2_HAS_PROCESS_HANDLE 1
  142. #endif
  143. #if BOOST_PROCESS_VERSION == 2
  144. #define BOOST_PROCESS_V2_INLINE inline
  145. #else
  146. #define BOOST_PROCESS_V2_INLINE
  147. #endif
  148. #endif //BOOST_PROCESS_V2_DETAIL_CONFIG_HPP