diff --git a/mesosphere/include/mesosphere/core/KAutoObject.hpp b/mesosphere/include/mesosphere/core/KAutoObject.hpp index 76a5ac44e..a038a33c8 100644 --- a/mesosphere/include/mesosphere/core/KAutoObject.hpp +++ b/mesosphere/include/mesosphere/core/KAutoObject.hpp @@ -12,47 +12,29 @@ virtual ushort GetClassToken() const\ return KAutoObject::GenerateClassToken();\ }\ +#define MESOSPHERE_AUTO_OBJECT_FW_DECL(BaseId)\ +class K##BaseId;\ +void intrusive_ptr_add_ref(K##BaseId *obj);\ +void intrusive_ptr_release(K##BaseId *obj); + + +#define MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(BaseId)\ +inline void intrusive_ptr_add_ref(K##BaseId *obj) { intrusive_ptr_add_ref((KAutoObject *)obj); }\ +inline void intrusive_ptr_release(K##BaseId *obj) { intrusive_ptr_release((KAutoObject *)obj); } + namespace mesosphere { -// Foward declarations for intrusive_ptr -class KProcess; -class KResourceLimit; -class KThread; -class KEvent; -class KReadableEvent; -class KWritableEvent; -class KInterruptEvent; -class KBaseSession; -class KBaseClientSession; -class KBaseServerSession; - -void intrusive_ptr_add_ref(KProcess *obj); -void intrusive_ptr_release(KProcess *obj); - -void intrusive_ptr_add_ref(KResourceLimit *obj); -void intrusive_ptr_release(KResourceLimit *obj); - -void intrusive_ptr_add_ref(KEvent *obj); -void intrusive_ptr_release(KEvent *obj); - -void intrusive_ptr_add_ref(KReadableEvent *obj); -void intrusive_ptr_release(KReadableEvent *obj); - -void intrusive_ptr_add_ref(KWritableEvent *obj); -void intrusive_ptr_release(KWritableEvent *obj); - -void intrusive_ptr_add_ref(KInterruptEvent *obj); -void intrusive_ptr_release(KInterruptEvent *obj); - -void intrusive_ptr_add_ref(KBaseSession *obj); -void intrusive_ptr_release(KBaseSession *obj); - -void intrusive_ptr_add_ref(KBaseClientSession *obj); -void intrusive_ptr_release(KBaseClientSession *obj); - -void intrusive_ptr_add_ref(KBaseClientSession *obj); -void intrusive_ptr_release(KBaseServerSession *obj); +MESOSPHERE_AUTO_OBJECT_FW_DECL(Process); +MESOSPHERE_AUTO_OBJECT_FW_DECL(ResourceLimit); +MESOSPHERE_AUTO_OBJECT_FW_DECL(Thread); +MESOSPHERE_AUTO_OBJECT_FW_DECL(Event); +MESOSPHERE_AUTO_OBJECT_FW_DECL(ReadableEvent); +MESOSPHERE_AUTO_OBJECT_FW_DECL(WritableEvent); +MESOSPHERE_AUTO_OBJECT_FW_DECL(InterruptEvent); +MESOSPHERE_AUTO_OBJECT_FW_DECL(BaseSession); +MESOSPHERE_AUTO_OBJECT_FW_DECL(BaseClientSession); +MESOSPHERE_AUTO_OBJECT_FW_DECL(BaseServerSession); class KAutoObject { public: diff --git a/mesosphere/include/mesosphere/core/KSynchronizationObject.hpp b/mesosphere/include/mesosphere/core/KSynchronizationObject.hpp index f73839bfc..cb9f51b29 100644 --- a/mesosphere/include/mesosphere/core/KSynchronizationObject.hpp +++ b/mesosphere/include/mesosphere/core/KSynchronizationObject.hpp @@ -23,4 +23,6 @@ class KSynchronizationObject : public KAutoObject { KLinkedList waiters{}; }; +MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(SynchronizationObject); + } diff --git a/mesosphere/include/mesosphere/kresources/KResourceLimit.hpp b/mesosphere/include/mesosphere/kresources/KResourceLimit.hpp index 3ee4905ba..feee2f361 100644 --- a/mesosphere/include/mesosphere/kresources/KResourceLimit.hpp +++ b/mesosphere/include/mesosphere/kresources/KResourceLimit.hpp @@ -5,10 +5,7 @@ namespace mesosphere { -class KThread; -class KEvent; class KTransferMemory; -class KSession; class KResourceLimit final : public KAutoObject, @@ -71,13 +68,6 @@ class KResourceLimit final : mutable KConditionVariable condvar{}; }; -inline void intrusive_ptr_add_ref(KResourceLimit *obj) -{ - intrusive_ptr_add_ref((KAutoObject *)obj); -} +MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(ResourceLimit); -inline void intrusive_ptr_release(KResourceLimit *obj) -{ - intrusive_ptr_add_ref((KAutoObject *)obj); -} } diff --git a/mesosphere/include/mesosphere/processes/KBaseClientSession.hpp b/mesosphere/include/mesosphere/processes/KBaseClientSession.hpp index 956db4dbb..3f711e115 100644 --- a/mesosphere/include/mesosphere/processes/KBaseClientSession.hpp +++ b/mesosphere/include/mesosphere/processes/KBaseClientSession.hpp @@ -32,14 +32,6 @@ class KBaseClientSession : public KAutoObject, public IClient client{}; }; -inline void intrusive_ptr_add_ref(KWritableEvent *obj) -{ - intrusive_ptr_add_ref((KAutoObject *)obj); -} - -inline void intrusive_ptr_release(KWritableEvent *obj) -{ - intrusive_ptr_release((KAutoObject *)obj); -} +MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(WritableEvent); } diff --git a/mesosphere/include/mesosphere/threading/KThread.hpp b/mesosphere/include/mesosphere/threading/KThread.hpp index e335ceedd..686171923 100644 --- a/mesosphere/include/mesosphere/threading/KThread.hpp +++ b/mesosphere/include/mesosphere/threading/KThread.hpp @@ -309,14 +309,6 @@ private: u64 lastScheduledTime = 0; }; -inline void intrusive_ptr_add_ref(KThread *obj) -{ - intrusive_ptr_add_ref((KAutoObject *)obj); -} - -inline void intrusive_ptr_release(KThread *obj) -{ - intrusive_ptr_release((KAutoObject *)obj); -} +MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(Thread); }