mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-13 03:30:42 +02:00
Diff-minimise
This commit is contained in:
parent
0706589391
commit
8a4e129845
@ -1273,6 +1273,12 @@ if test "$use_boost" = "yes"; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
case $host in
|
||||||
|
dnl Re-enable it after enabling Windows support in cpp-subprocess.
|
||||||
|
*mingw*)
|
||||||
|
true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
if test "$use_external_signer" = "yes"; then
|
if test "$use_external_signer" = "yes"; then
|
||||||
AC_DEFINE([ENABLE_EXTERNAL_SIGNER], [1], [Define if external signer support is enabled])
|
AC_DEFINE([ENABLE_EXTERNAL_SIGNER], [1], [Define if external signer support is enabled])
|
||||||
fi
|
fi
|
||||||
|
@ -89,8 +89,8 @@ BOOST_AUTO_TEST_CASE(run_command)
|
|||||||
BOOST_CHECK_EXCEPTION(RunCommandParseJSON(command), std::runtime_error, HasReason("Unable to parse JSON: {"));
|
BOOST_CHECK_EXCEPTION(RunCommandParseJSON(command), std::runtime_error, HasReason("Unable to parse JSON: {"));
|
||||||
}
|
}
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
|
// Test std::in
|
||||||
{
|
{
|
||||||
// Test std::in
|
|
||||||
const UniValue result = RunCommandParseJSON("cat", "{\"success\": true}");
|
const UniValue result = RunCommandParseJSON("cat", "{\"success\": true}");
|
||||||
BOOST_CHECK(result.isObject());
|
BOOST_CHECK(result.isObject());
|
||||||
const UniValue& success = result.find_value("success");
|
const UniValue& success = result.find_value("success");
|
||||||
|
@ -56,11 +56,15 @@ Documentation for C++ subprocessing library.
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
#define __USING_WINDOWS__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __USING_WINDOWS__
|
||||||
#include <codecvt>
|
#include <codecvt>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#ifdef WIN32
|
#ifdef __USING_WINDOWS__
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <cwchar>
|
#include <cwchar>
|
||||||
@ -219,7 +223,7 @@ namespace util
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef __USING_WINDOWS__
|
||||||
inline std::string get_last_error(DWORD errorMessageID)
|
inline std::string get_last_error(DWORD errorMessageID)
|
||||||
{
|
{
|
||||||
if (errorMessageID == 0)
|
if (errorMessageID == 0)
|
||||||
@ -320,7 +324,7 @@ namespace util
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef __USING_WINDOWS__
|
||||||
/*!
|
/*!
|
||||||
* Function: set_clo_on_exec
|
* Function: set_clo_on_exec
|
||||||
* Sets/Resets the FD_CLOEXEC flag on the provided file descriptor
|
* Sets/Resets the FD_CLOEXEC flag on the provided file descriptor
|
||||||
@ -408,7 +412,7 @@ namespace util
|
|||||||
static inline
|
static inline
|
||||||
int read_atmost_n(FILE* fp, char* buf, size_t read_upto)
|
int read_atmost_n(FILE* fp, char* buf, size_t read_upto)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef __USING_WINDOWS__
|
||||||
return (int)fread(buf, 1, read_upto, fp);
|
return (int)fread(buf, 1, read_upto, fp);
|
||||||
#else
|
#else
|
||||||
int fd = subprocess_fileno(fp);
|
int fd = subprocess_fileno(fp);
|
||||||
@ -481,7 +485,7 @@ namespace util
|
|||||||
return total_bytes_read;
|
return total_bytes_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef __USING_WINDOWS__
|
||||||
/*!
|
/*!
|
||||||
* Function: wait_for_child_exit
|
* Function: wait_for_child_exit
|
||||||
* Waits for the process with pid `pid` to exit
|
* Waits for the process with pid `pid` to exit
|
||||||
@ -582,7 +586,7 @@ struct input
|
|||||||
}
|
}
|
||||||
explicit input(IOTYPE typ) {
|
explicit input(IOTYPE typ) {
|
||||||
assert (typ == PIPE && "STDOUT/STDERR not allowed");
|
assert (typ == PIPE && "STDOUT/STDERR not allowed");
|
||||||
#ifndef WIN32
|
#ifndef __USING_WINDOWS__
|
||||||
std::tie(rd_ch_, wr_ch_) = util::pipe_cloexec();
|
std::tie(rd_ch_, wr_ch_) = util::pipe_cloexec();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -615,7 +619,7 @@ struct output
|
|||||||
}
|
}
|
||||||
explicit output(IOTYPE typ) {
|
explicit output(IOTYPE typ) {
|
||||||
assert (typ == PIPE && "STDOUT/STDERR not allowed");
|
assert (typ == PIPE && "STDOUT/STDERR not allowed");
|
||||||
#ifndef WIN32
|
#ifndef __USING_WINDOWS__
|
||||||
std::tie(rd_ch_, wr_ch_) = util::pipe_cloexec();
|
std::tie(rd_ch_, wr_ch_) = util::pipe_cloexec();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -647,7 +651,7 @@ struct error
|
|||||||
explicit error(IOTYPE typ) {
|
explicit error(IOTYPE typ) {
|
||||||
assert ((typ == PIPE || typ == STDOUT) && "STDERR not allowed");
|
assert ((typ == PIPE || typ == STDOUT) && "STDERR not allowed");
|
||||||
if (typ == PIPE) {
|
if (typ == PIPE) {
|
||||||
#ifndef WIN32
|
#ifndef __USING_WINDOWS__
|
||||||
std::tie(rd_ch_, wr_ch_) = util::pipe_cloexec();
|
std::tie(rd_ch_, wr_ch_) = util::pipe_cloexec();
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
@ -858,7 +862,7 @@ public:// Yes they are public
|
|||||||
std::shared_ptr<FILE> output_ = nullptr;
|
std::shared_ptr<FILE> output_ = nullptr;
|
||||||
std::shared_ptr<FILE> error_ = nullptr;
|
std::shared_ptr<FILE> error_ = nullptr;
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef __USING_WINDOWS__
|
||||||
HANDLE g_hChildStd_IN_Rd = nullptr;
|
HANDLE g_hChildStd_IN_Rd = nullptr;
|
||||||
HANDLE g_hChildStd_IN_Wr = nullptr;
|
HANDLE g_hChildStd_IN_Wr = nullptr;
|
||||||
HANDLE g_hChildStd_OUT_Rd = nullptr;
|
HANDLE g_hChildStd_OUT_Rd = nullptr;
|
||||||
@ -999,7 +1003,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
detail::Streams stream_;
|
detail::Streams stream_;
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef __USING_WINDOWS__
|
||||||
HANDLE process_handle_;
|
HANDLE process_handle_;
|
||||||
std::future<void> cleanup_future_;
|
std::future<void> cleanup_future_;
|
||||||
#endif
|
#endif
|
||||||
@ -1040,7 +1044,7 @@ inline void Popen::populate_c_argv()
|
|||||||
|
|
||||||
inline int Popen::wait() noexcept(false)
|
inline int Popen::wait() noexcept(false)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef __USING_WINDOWS__
|
||||||
int ret = WaitForSingleObject(process_handle_, INFINITE);
|
int ret = WaitForSingleObject(process_handle_, INFINITE);
|
||||||
if (ret != WAIT_OBJECT_0) return -1;
|
if (ret != WAIT_OBJECT_0) return -1;
|
||||||
|
|
||||||
@ -1068,7 +1072,7 @@ inline int Popen::wait() noexcept(false)
|
|||||||
|
|
||||||
inline void Popen::execute_process() noexcept(false)
|
inline void Popen::execute_process() noexcept(false)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef __USING_WINDOWS__
|
||||||
if (exe_name_.length()) {
|
if (exe_name_.length()) {
|
||||||
this->vargs_.insert(this->vargs_.begin(), this->exe_name_);
|
this->vargs_.insert(this->vargs_.begin(), this->exe_name_);
|
||||||
this->populate_c_argv();
|
this->populate_c_argv();
|
||||||
@ -1242,7 +1246,7 @@ namespace detail {
|
|||||||
|
|
||||||
|
|
||||||
inline void Child::execute_child() {
|
inline void Child::execute_child() {
|
||||||
#ifndef WIN32
|
#ifndef __USING_WINDOWS__
|
||||||
int sys_ret = -1;
|
int sys_ret = -1;
|
||||||
auto& stream = parent_->stream_;
|
auto& stream = parent_->stream_;
|
||||||
|
|
||||||
@ -1308,7 +1312,7 @@ namespace detail {
|
|||||||
|
|
||||||
inline void Streams::setup_comm_channels()
|
inline void Streams::setup_comm_channels()
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef __USING_WINDOWS__
|
||||||
util::configure_pipe(&this->g_hChildStd_IN_Rd, &this->g_hChildStd_IN_Wr, &this->g_hChildStd_IN_Wr);
|
util::configure_pipe(&this->g_hChildStd_IN_Rd, &this->g_hChildStd_IN_Wr, &this->g_hChildStd_IN_Wr);
|
||||||
this->input(util::file_from_handle(this->g_hChildStd_IN_Wr, "w"));
|
this->input(util::file_from_handle(this->g_hChildStd_IN_Wr, "w"));
|
||||||
this->write_to_child_ = _fileno(this->input());
|
this->write_to_child_ = _fileno(this->input());
|
||||||
|
Loading…
Reference in New Issue
Block a user