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 3232
3333namespace {
3434
35- using msg_id_t = std::uint32_t ;
36- using acc_t = std::atomic<msg_id_t >;
35+ using msg_id_t = std::uint32_t ;
36+ using acc_t = std::atomic<msg_id_t >;
3737
3838template <std::size_t DataSize, std::size_t AlignSize>
3939struct msg_t ;
@@ -505,8 +505,8 @@ static ipc::buff_t recv(ipc::handle_t h, std::size_t tm) {
505505 if (buf != nullptr ) {
506506 if (recycled) {
507507 return ipc::buff_t {buf, msg_size, [](void * pmid, std::size_t size) {
508- release_storage (reinterpret_cast <ipc::storage_id_t >(pmid) - 1 , size);
509- }, reinterpret_cast <void *>(buf_id + 1 )};
508+ release_storage (ipc::detail::horrible_cast <ipc::storage_id_t >(pmid) - 1 , size);
509+ }, ipc::detail::horrible_cast <void *>(buf_id + 1 )};
510510 } else {
511511 return ipc::buff_t {buf, msg_size}; // no recycle
512512 }
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