Skip to content

Commit 90b116b

Browse files
committed
depends: Update libmultiprocess library before converting to subtree
This should be the final update to the libmultiprocess package via the depends system. It brings in the libmultiprocess cmake changes from bitcoin-core/libmultiprocess#136 needed to support building as subtree. After this, a followup PR will add libmultiprocess as a git subtree and depends will just use the git subtree instead of hardcoding its own version hash. Since there have been libmultiprocess API changes since the last update, this commit also updates bitcoin code to be compatible with them. This update brings in the following changes: bitcoin-core/libmultiprocess#121 ProxyClientBase: avoid static_cast to partially constructed object bitcoin-core/libmultiprocess#120 proxy-types.h: add static_assert to detect int/enum size mismatch bitcoin-core/libmultiprocess#127 ProxyClientBase: avoid static_cast to partially destructed object bitcoin-core/libmultiprocess#129 Fix "disconnected: write(m_post_fd, &buffer, 1): Broken pipe" EventLoop shutdown races. bitcoin-core/libmultiprocess#130 refactor: Add CleanupRun function to dedup clean list code bitcoin-core/libmultiprocess#131 doc: fix startAsyncThread comment bitcoin-core/libmultiprocess#133 Fix debian "libatomic not found" error in downstream builds bitcoin-core/libmultiprocess#94 c++ 20 cleanups bitcoin-core/libmultiprocess#135 refactor: proxy-types.h API cleanup bitcoin-core/libmultiprocess#136 cmake: Support being included with add_subdirectory
1 parent 0a931a9 commit 90b116b

File tree

5 files changed

+29
-50
lines changed

5 files changed

+29
-50
lines changed

depends/packages/native_libmultiprocess.mk

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package=native_libmultiprocess
2-
$(package)_version=abe254b9734f2e2b220d1456de195532d6e6ac1e
2+
$(package)_version=e89b2c6ac2cfeb03b71f90b2b44797ceee4d6500
33
$(package)_download_path=https://github.com/chaincodelabs/libmultiprocess/archive
44
$(package)_file_name=$($(package)_version).tar.gz
5-
$(package)_sha256_hash=85777073259fdc75d24ac5777a19991ec1156c5f12db50b252b861c95dcb4f46
5+
$(package)_sha256_hash=6520593a7aaa8fa6592f7a822c941a785f2c5bc8f59c351ec0b707d7f33b12bd
66
$(package)_dependencies=native_capnp
77

88
define $(package)_config_cmds

src/ipc/capnp/common-types.h

+13-46
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@
1414

1515
#include <cstddef>
1616
#include <mp/proxy-types.h>
17+
#include <mp/type-chrono.h>
18+
#include <mp/type-context.h>
19+
#include <mp/type-data.h>
20+
#include <mp/type-decay.h>
21+
#include <mp/type-interface.h>
22+
#include <mp/type-message.h>
23+
#include <mp/type-number.h>
24+
#include <mp/type-optional.h>
25+
#include <mp/type-pointer.h>
26+
#include <mp/type-string.h>
27+
#include <mp/type-struct.h>
28+
#include <mp/type-threadmap.h>
29+
#include <mp/type-vector.h>
1730
#include <type_traits>
1831
#include <utility>
1932

@@ -94,26 +107,6 @@ requires ipc::capnp::Deserializable<LocalType>
94107
return read_dest.construct(::deserialize, wrapper);
95108
}
96109

97-
//! Overload CustomBuildField and CustomReadField to serialize std::chrono
98-
//! parameters and return values as numbers.
99-
template <class Rep, class Period, typename Value, typename Output>
100-
void CustomBuildField(TypeList<std::chrono::duration<Rep, Period>>, Priority<1>, InvokeContext& invoke_context, Value&& value,
101-
Output&& output)
102-
{
103-
static_assert(std::numeric_limits<decltype(output.get())>::lowest() <= std::numeric_limits<Rep>::lowest(),
104-
"capnp type does not have enough range to hold lowest std::chrono::duration value");
105-
static_assert(std::numeric_limits<decltype(output.get())>::max() >= std::numeric_limits<Rep>::max(),
106-
"capnp type does not have enough range to hold highest std::chrono::duration value");
107-
output.set(value.count());
108-
}
109-
110-
template <class Rep, class Period, typename Input, typename ReadDest>
111-
decltype(auto) CustomReadField(TypeList<std::chrono::duration<Rep, Period>>, Priority<1>, InvokeContext& invoke_context,
112-
Input&& input, ReadDest&& read_dest)
113-
{
114-
return read_dest.construct(input.get());
115-
}
116-
117110
//! Overload CustomBuildField and CustomReadField to serialize UniValue
118111
//! parameters and return values as JSON strings.
119112
template <typename Value, typename Output>
@@ -134,32 +127,6 @@ decltype(auto) CustomReadField(TypeList<UniValue>, Priority<1>, InvokeContext& i
134127
});
135128
}
136129

137-
//! Generic ::capnp::Data field builder for any C++ type that can be converted
138-
//! to a span of bytes, like std::vector<char> or std::array<uint8_t>, or custom
139-
//! blob types like uint256 or PKHash with data() and size() methods pointing to
140-
//! bytes.
141-
//!
142-
//! Note: it might make sense to move this function into libmultiprocess, since
143-
//! it is fairly generic. However this would require decreasing its priority so
144-
//! it can be overridden, which would require more changes inside
145-
//! libmultiprocess to avoid conflicting with the Priority<1> CustomBuildField
146-
//! function it already provides for std::vector. Also, it might make sense to
147-
//! provide a CustomReadField counterpart to this function, which could be
148-
//! called to read C++ types that can be constructed from spans of bytes from
149-
//! ::capnp::Data fields. But so far there hasn't been a need for this.
150-
template <typename LocalType, typename Value, typename Output>
151-
void CustomBuildField(TypeList<LocalType>, Priority<2>, InvokeContext& invoke_context, Value&& value, Output&& output)
152-
requires
153-
(std::is_same_v<decltype(output.get()), ::capnp::Data::Builder>) &&
154-
(std::convertible_to<Value, std::span<const std::byte>> ||
155-
std::convertible_to<Value, std::span<const char>> ||
156-
std::convertible_to<Value, std::span<const unsigned char>> ||
157-
std::convertible_to<Value, std::span<const signed char>>)
158-
{
159-
auto data = std::span{value};
160-
auto result = output.init(data.size());
161-
memcpy(result.begin(), data.data(), data.size());
162-
}
163130
} // namespace mp
164131

165132
#endif // BITCOIN_IPC_CAPNP_COMMON_TYPES_H

src/ipc/capnp/echo-types.h

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) 2025 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#ifndef BITCOIN_IPC_CAPNP_ECHO_TYPES_H
6+
#define BITCOIN_IPC_CAPNP_ECHO_TYPES_H
7+
8+
#include <mp/type-context.h>
9+
#include <mp/type-decay.h>
10+
#include <mp/type-string.h>
11+
12+
#endif // BITCOIN_IPC_CAPNP_ECHO_TYPES_H

src/ipc/capnp/echo.capnp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ $Cxx.namespace("ipc::capnp::messages");
99

1010
using Proxy = import "/mp/proxy.capnp";
1111
$Proxy.include("interfaces/echo.h");
12-
$Proxy.include("ipc/capnp/echo.capnp.h");
12+
$Proxy.includeTypes("ipc/capnp/echo-types.h");
1313

1414
interface Echo $Proxy.wrap("interfaces::Echo") {
1515
destroy @0 (context :Proxy.Context) -> ();

src/ipc/capnp/protocol.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class CapnpProtocol : public Protocol
7373
}
7474
void addCleanup(std::type_index type, void* iface, std::function<void()> cleanup) override
7575
{
76-
mp::ProxyTypeRegister::types().at(type)(iface).cleanup.emplace_back(std::move(cleanup));
76+
mp::ProxyTypeRegister::types().at(type)(iface).cleanup_fns.emplace_back(std::move(cleanup));
7777
}
7878
Context& context() override { return m_context; }
7979
void startLoop(const char* exe_name)

0 commit comments

Comments
 (0)