diff --git a/src/mem/port.cc b/src/mem/port.cc index 18793d487b..e36323fb74 100644 --- a/src/mem/port.cc +++ b/src/mem/port.cc @@ -120,9 +120,23 @@ DefaultResponsePort defaultResponsePort; /** * Request port */ -RequestPort::RequestPort(const std::string& name, SimObject* _owner, - PortID _id) : Port(name, _id), _responsePort(&defaultResponsePort), - owner(*_owner) +[[deprecated]] +RequestPort::RequestPort(const std::string& name, + SimObject* _owner, + PortID _id): + Port(name, _id), _responsePort(&defaultResponsePort), owner{*_owner} +{ +} + +/*** FIXME: + * The owner reference member is going through a deprecation path. In the + * meantime, it must be initialized but no valid reference is available here. + * Using 1 instead of nullptr prevents warning upon dereference. It should be + * OK until definitive removal of owner. + */ +RequestPort::RequestPort(const std::string& name, PortID _id) : + Port(name, _id), _responsePort(&defaultResponsePort), + owner{*reinterpret_cast(1)} { } @@ -175,9 +189,30 @@ RequestPort::printAddr(Addr a) /** * Response port */ -ResponsePort::ResponsePort(const std::string& name, SimObject* _owner, - PortID id) : Port(name, id), _requestPort(&defaultRequestPort), - defaultBackdoorWarned(false), owner(*_owner) + +[[deprecated]] +ResponsePort::ResponsePort(const std::string& name, + SimObject* _owner, + PortID _id): + Port(name, _id), + _requestPort(&defaultRequestPort), + defaultBackdoorWarned(false), + owner{*_owner} +{ +} + + +/*** FIXME: + * The owner reference member is going through a deprecation path. In the + * meantime, it must be initialized but no valid reference is available here. + * Using 1 instead of nullptr prevents warning upon dereference. It should be + * OK until definitive removal of owner. + */ +ResponsePort::ResponsePort(const std::string& name, PortID id) : + Port(name, id), + _requestPort(&defaultRequestPort), + defaultBackdoorWarned(false), + owner{*reinterpret_cast(1)} { } diff --git a/src/mem/port.hh b/src/mem/port.hh index fb0f4b8812..0d61787f62 100644 --- a/src/mem/port.hh +++ b/src/mem/port.hh @@ -86,8 +86,13 @@ class RequestPort: public Port, public AtomicRequestProtocol, SimObject &owner; public: + [[deprecated("RequestPort ownership is deprecated. " + "Owner should now be registered in derived classes.")]] RequestPort(const std::string& name, SimObject* _owner, - PortID id=InvalidPortID); + PortID id=InvalidPortID); + + RequestPort(const std::string& name, PortID id=InvalidPortID); + virtual ~RequestPort(); /** @@ -266,9 +271,7 @@ class RequestPort: public Port, public AtomicRequestProtocol, class [[deprecated]] MasterPort : public RequestPort { public: - MasterPort(const std::string& name, SimObject* _owner, - PortID id=InvalidPortID) : RequestPort(name, _owner, id) - {} + using RequestPort::RequestPort; }; /** @@ -294,8 +297,13 @@ class ResponsePort : public Port, public AtomicResponseProtocol, SimObject& owner; public: + [[deprecated("ResponsePort ownership is deprecated. " + "Owner should now be registered in derived classes.")]] ResponsePort(const std::string& name, SimObject* _owner, - PortID id=InvalidPortID); + PortID id=InvalidPortID); + + ResponsePort(const std::string& name, PortID id=InvalidPortID); + virtual ~ResponsePort(); /**