From 8c7d34ff2161c338f072d3015112aaa1eb333dd7 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Fri, 5 Mar 2021 16:52:42 +0100 Subject: [PATCH] rpi_platform_drv: remove placement new operator Issue #2106 --- .../spec/rpi/platform/property_message.h | 26 ++++--------------- .../platform/rpi/framebuffer_message.h | 2 -- repos/os/src/drivers/platform/rpi/mbox.h | 3 ++- .../drivers/platform/rpi/property_message.h | 26 ++++--------------- .../platform/spec/rpi/framebuffer_message.h | 2 -- repos/os/src/drivers/platform/spec/rpi/mbox.h | 3 ++- 6 files changed, 14 insertions(+), 48 deletions(-) diff --git a/repos/os/include/spec/rpi/platform/property_message.h b/repos/os/include/spec/rpi/platform/property_message.h index d080f9837c..4ceefef63f 100644 --- a/repos/os/include/spec/rpi/platform/property_message.h +++ b/repos/os/include/spec/rpi/platform/property_message.h @@ -16,6 +16,7 @@ /* Genode includes */ #include +#include #include /* board-specific includes */ @@ -111,29 +112,16 @@ struct Platform::Property_message return 0; } - template - struct Placeable : T - { - template - Placeable(ARGS... args) : T(args...) { } - - inline void *operator new (__SIZE_TYPE__, void *ptr) { return ptr; } - }; - template void construct_request(typename T::Request *, ARGS... args) { - new ((typename T::Request *)payload) - Placeable(args...); + construct_at(payload, args...); } - template - void construct_request(...) { } - template void construct_response(typename T::Response *) { - new (payload) Placeable; + construct_at(payload); } template @@ -159,8 +147,6 @@ struct Platform::Property_message construct_response(0); construct_request(0, request_args...); } - - inline void *operator new (__SIZE_TYPE__, void *ptr) { return ptr; } }; void reset() @@ -175,7 +161,7 @@ struct Platform::Property_message template typename POLICY::Response const &append(REQUEST_ARGS... request_args) { - auto *tag = new (buffer + buf_size) Tag(request_args...); + auto *tag = construct_at >(buffer + buf_size, request_args...); buf_size += sizeof(Tag) + Tag::payload_size(); @@ -185,7 +171,7 @@ struct Platform::Property_message template void append_no_response(REQUEST_ARGS... request_args) { - new (buffer + buf_size) Tag(request_args...); + construct_at >(buffer + buf_size, request_args...); buf_size += sizeof(Tag) + Tag::payload_size(); } @@ -218,8 +204,6 @@ struct Platform::Property_message } } } - - inline void *operator new (__SIZE_TYPE__, void *ptr) { return ptr; } }; #endif /* _PLATFORM__PROPERTY_MESSAGE_H_ */ diff --git a/repos/os/src/drivers/platform/rpi/framebuffer_message.h b/repos/os/src/drivers/platform/rpi/framebuffer_message.h index 3edb90a3e8..f860ed1c10 100644 --- a/repos/os/src/drivers/platform/rpi/framebuffer_message.h +++ b/repos/os/src/drivers/platform/rpi/framebuffer_message.h @@ -56,8 +56,6 @@ struct Platform::Framebuffer_message : Framebuffer_info log(" addr: ", Genode::Hex(addr)); log(" size: ", Genode::Hex(size)); } - - inline void *operator new (__SIZE_TYPE__, void *ptr) { return ptr; } }; #endif /* _FRAMEBUFFER_MESSAGE_H_ */ diff --git a/repos/os/src/drivers/platform/rpi/mbox.h b/repos/os/src/drivers/platform/rpi/mbox.h index f341088750..2fc4dbf84d 100644 --- a/repos/os/src/drivers/platform/rpi/mbox.h +++ b/repos/os/src/drivers/platform/rpi/mbox.h @@ -16,6 +16,7 @@ /* Genode includes */ #include +#include #include #include #include @@ -84,7 +85,7 @@ class Mbox : Genode::Attached_mmio template MESSAGE &message(ARGS... args) { - return *(new (_msg_buffer.local_addr()) MESSAGE(args...)); + return *Genode::construct_at(_msg_buffer.local_addr(), args...); } template diff --git a/repos/os/src/drivers/platform/rpi/property_message.h b/repos/os/src/drivers/platform/rpi/property_message.h index ae4a9f5a01..cb544dd7f9 100644 --- a/repos/os/src/drivers/platform/rpi/property_message.h +++ b/repos/os/src/drivers/platform/rpi/property_message.h @@ -16,6 +16,7 @@ /* Genode includes */ #include +#include #include /* board-specific includes */ @@ -111,29 +112,16 @@ struct Driver::Property_message return 0; } - template - struct Placeable : T - { - template - Placeable(ARGS... args) : T(args...) { } - - inline void *operator new (__SIZE_TYPE__, void *ptr) { return ptr; } - }; - template void construct_request(typename T::Request *, ARGS... args) { - new ((typename T::Request *)payload) - Placeable(args...); + construct_at(payload, args...); } - template - void construct_request(...) { } - template void construct_response(typename T::Response *) { - new (payload) Placeable; + construct_at(payload); } template @@ -159,8 +147,6 @@ struct Driver::Property_message construct_response(0); construct_request(0, request_args...); } - - inline void *operator new (__SIZE_TYPE__, void *ptr) { return ptr; } }; void reset() @@ -175,7 +161,7 @@ struct Driver::Property_message template typename POLICY::Response const &append(REQUEST_ARGS... request_args) { - auto *tag = new (buffer + buf_size) Tag(request_args...); + auto *tag = construct_at >(buffer + buf_size, request_args...); buf_size += sizeof(Tag) + Tag::payload_size(); @@ -185,7 +171,7 @@ struct Driver::Property_message template void append_no_response(REQUEST_ARGS... request_args) { - new (buffer + buf_size) Tag(request_args...); + construct_at >(buffer + buf_size, request_args...); buf_size += sizeof(Tag) + Tag::payload_size(); } @@ -218,8 +204,6 @@ struct Driver::Property_message } } } - - inline void *operator new (__SIZE_TYPE__, void *ptr) { return ptr; } }; #endif /* _SRC__DRIVERS__PLATFORM__RPI__PROPERTY_MESSAGE_H_ */ diff --git a/repos/os/src/drivers/platform/spec/rpi/framebuffer_message.h b/repos/os/src/drivers/platform/spec/rpi/framebuffer_message.h index 3edb90a3e8..f860ed1c10 100644 --- a/repos/os/src/drivers/platform/spec/rpi/framebuffer_message.h +++ b/repos/os/src/drivers/platform/spec/rpi/framebuffer_message.h @@ -56,8 +56,6 @@ struct Platform::Framebuffer_message : Framebuffer_info log(" addr: ", Genode::Hex(addr)); log(" size: ", Genode::Hex(size)); } - - inline void *operator new (__SIZE_TYPE__, void *ptr) { return ptr; } }; #endif /* _FRAMEBUFFER_MESSAGE_H_ */ diff --git a/repos/os/src/drivers/platform/spec/rpi/mbox.h b/repos/os/src/drivers/platform/spec/rpi/mbox.h index f341088750..2fc4dbf84d 100644 --- a/repos/os/src/drivers/platform/spec/rpi/mbox.h +++ b/repos/os/src/drivers/platform/spec/rpi/mbox.h @@ -16,6 +16,7 @@ /* Genode includes */ #include +#include #include #include #include @@ -84,7 +85,7 @@ class Mbox : Genode::Attached_mmio template MESSAGE &message(ARGS... args) { - return *(new (_msg_buffer.local_addr()) MESSAGE(args...)); + return *Genode::construct_at(_msg_buffer.local_addr(), args...); } template