File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 3131
3232namespace {
3333
34- using msg_id_t = std::uint32_t ;
35- using acc_t = std::atomic<msg_id_t >;
34+ using msg_id_t = std::uint32_t ;
35+ using acc_t = std::atomic<msg_id_t >;
3636
3737template <std::size_t DataSize, std::size_t AlignSize>
3838struct msg_t ;
@@ -492,8 +492,8 @@ static ipc::buff_t recv(ipc::handle_t h, std::size_t tm) {
492492 if (buf != nullptr ) {
493493 if (recycled) {
494494 return ipc::buff_t {buf, msg_size, [](void * pmid, std::size_t size) {
495- release_storage (reinterpret_cast <ipc::storage_id_t >(pmid) - 1 , size);
496- }, reinterpret_cast <void *>(buf_id + 1 )};
495+ release_storage (ipc::detail::horrible_cast <ipc::storage_id_t >(pmid) - 1 , size);
496+ }, ipc::detail::horrible_cast <void *>(buf_id + 1 )};
497497 } else {
498498 return ipc::buff_t {buf, msg_size}; // no recycle
499499 }
Original file line number Diff line number Diff line change @@ -111,5 +111,17 @@ constexpr const T& (min)(const T& a, const T& b) {
111111
112112#endif/* __cplusplus < 201703L*/
113113
114+ template <typename T, typename U>
115+ auto horrible_cast (U rhs) noexcept
116+ -> typename std::enable_if<std::is_trivially_copyable<T>::value
117+ && std::is_trivially_copyable<U>::value, T>::type {
118+ union {
119+ T t;
120+ U u;
121+ } r = {};
122+ r.u = rhs;
123+ return r.t ;
124+ }
125+
114126} // namespace detail
115127} // namespace ipc
You can’t perform that action at this time.
0 commit comments