From 8e761289a2446367267c6c0d9a26e734f0f78306 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 16 Dec 2020 20:29:05 +0300 Subject: Get rid of legacy build systems and rename cutl/ to libcutl/ --- cutl/shared-ptr/base.cxx | 64 --------------- cutl/shared-ptr/base.hxx | 102 ------------------------ cutl/shared-ptr/base.ixx | 80 ------------------- cutl/shared-ptr/base.txx | 198 ----------------------------------------------- 4 files changed, 444 deletions(-) delete mode 100644 cutl/shared-ptr/base.cxx delete mode 100644 cutl/shared-ptr/base.hxx delete mode 100644 cutl/shared-ptr/base.ixx delete mode 100644 cutl/shared-ptr/base.txx (limited to 'cutl/shared-ptr') diff --git a/cutl/shared-ptr/base.cxx b/cutl/shared-ptr/base.cxx deleted file mode 100644 index 913e6f2..0000000 --- a/cutl/shared-ptr/base.cxx +++ /dev/null @@ -1,64 +0,0 @@ -// file : cutl/shared-ptr/base.cxx -// license : MIT; see accompanying LICENSE file - -#include - -using std::size_t; - -// -// -cutl::share shared = cutl::share (1); -cutl::share exclusive = cutl::share (2); - -// -// -namespace cutl -{ - char const* not_shared:: - what () const LIBCUTL_NOTHROW_NOEXCEPT - { - return "object is not shared"; - } -} - -// -// -void* -operator new (size_t n, cutl::share s) -#ifndef LIBCUTL_CXX11 - throw (std::bad_alloc) -#endif -{ - if (s == shared) - { - // Here we need to make sure we don't break the alignment of the - // returned block. For that we need to know the maximum alignment - // of this platform. Twice the pointer size is a good guess for - // most platforms. - // - size_t* p = static_cast (operator new (n + 2 * sizeof (size_t))); - *p++ = 1; // Initial count. - *p++ = 0xDEADBEEF; // Signature. - return p; - } - else - return operator new (n); - -} - -void -operator delete (void* p, cutl::share s) LIBCUTL_NOTHROW_NOEXCEPT -{ - // This version of operator delete is only called when the c-tor - // fails. In this case there is no object and we can just free the - // memory. - // - if (s == shared) - { - size_t* sp = static_cast (p); - sp -= 2; - operator delete (sp); - } - else - operator delete (p); -} diff --git a/cutl/shared-ptr/base.hxx b/cutl/shared-ptr/base.hxx deleted file mode 100644 index a37115b..0000000 --- a/cutl/shared-ptr/base.hxx +++ /dev/null @@ -1,102 +0,0 @@ -// file : cutl/shared-ptr/base.hxx -// license : MIT; see accompanying LICENSE file - -#ifndef CUTL_SHARED_PTR_BASE_HXX -#define CUTL_SHARED_PTR_BASE_HXX - -#include -#include // std::size_t - -#include - -#include -#include - -namespace cutl -{ - struct share - { - explicit - share (char id); - - bool - operator== (share) const; - - private: - char id_; - }; -} - -extern LIBCUTL_EXPORT cutl::share shared; -extern LIBCUTL_EXPORT cutl::share exclusive; - -#ifdef LIBCUTL_CXX11 -LIBCUTL_EXPORT void* -operator new (std::size_t, cutl::share); -#else -LIBCUTL_EXPORT void* -operator new (std::size_t, cutl::share) throw (std::bad_alloc); -#endif - -LIBCUTL_EXPORT void -operator delete (void*, cutl::share) LIBCUTL_NOTHROW_NOEXCEPT; - -namespace cutl -{ - struct LIBCUTL_EXPORT not_shared: exception - { - virtual char const* - what () const LIBCUTL_NOTHROW_NOEXCEPT; - }; - - struct LIBCUTL_EXPORT shared_base - { - shared_base (); - shared_base (shared_base const&); - shared_base& - operator= (shared_base const&); - - void - _inc_ref (); - - bool - _dec_ref (); - - std::size_t - _ref_count () const; - -#ifdef LIBCUTL_CXX11 - void* - operator new (std::size_t, share); -#else - void* - operator new (std::size_t, share) throw (std::bad_alloc); -#endif - - void - operator delete (void*, share) LIBCUTL_NOTHROW_NOEXCEPT; - - void - operator delete (void*) LIBCUTL_NOTHROW_NOEXCEPT; - - protected: - std::size_t counter_; - }; - - template - inline X* - inc_ref (X*); - - template - inline void - dec_ref (X*); - - template - inline std::size_t - ref_count (X const*); -} - -#include -#include - -#endif // CUTL_SHARED_PTR_BASE_HXX diff --git a/cutl/shared-ptr/base.ixx b/cutl/shared-ptr/base.ixx deleted file mode 100644 index 21ea856..0000000 --- a/cutl/shared-ptr/base.ixx +++ /dev/null @@ -1,80 +0,0 @@ -// file : cutl/shared-ptr/base.ixx -// license : MIT; see accompanying LICENSE file - -namespace cutl -{ - // share - // - - inline share:: - share (char id) - : id_ (id) - { - } - - inline bool share:: - operator== (share x) const - { - return id_ == x.id_; - } - - // shared_base - // - - inline shared_base:: - shared_base () - : counter_ (1) - { - } - - inline shared_base:: - shared_base (shared_base const&) - : counter_ (1) - { - } - - inline shared_base& shared_base:: - operator= (shared_base const&) - { - return *this; - } - - inline void shared_base:: - _inc_ref () - { - counter_++; - } - - inline bool shared_base:: - _dec_ref () - { - return --counter_ == 0; - } - - inline std::size_t shared_base:: - _ref_count () const - { - return counter_; - } - - inline void* shared_base:: - operator new (std::size_t n, share) -#ifndef LIBCUTL_CXX11 - throw (std::bad_alloc) -#endif - { - return ::operator new (n); - } - - inline void shared_base:: - operator delete (void* p, share) LIBCUTL_NOTHROW_NOEXCEPT - { - ::operator delete (p); - } - - inline void shared_base:: - operator delete (void* p) LIBCUTL_NOTHROW_NOEXCEPT - { - ::operator delete (p); - } -} diff --git a/cutl/shared-ptr/base.txx b/cutl/shared-ptr/base.txx deleted file mode 100644 index d483481..0000000 --- a/cutl/shared-ptr/base.txx +++ /dev/null @@ -1,198 +0,0 @@ -// file : cutl/shared-ptr/base.txx -// license : MIT; see accompanying LICENSE file - -#include -#include - -namespace cutl -{ - namespace bits - { - // Support for locating the counter in the memory block. - // - template ::r> - struct locator; - - template - struct locator - { - static std::size_t* - counter (X* x) - { - std::size_t* p (reinterpret_cast (x)); - - if (*(--p) != 0xDEADBEEF) - throw not_shared (); - - return --p; - } - }; - - template - struct locator - { - static std::size_t* - counter (X* x) - { - std::size_t* p ( - static_cast ( - dynamic_cast (x))); - - if (*(--p) != 0xDEADBEEF) - throw not_shared (); - - return --p; - } - }; - - template - std::size_t* - counter (X const* p) - { - return bits::locator::counter (const_cast (p)); - } - - // Counter type and operations. - // - meta::no test (...); - meta::yes test (shared_base*); - - template (0)))> - struct counter_type; - - template - struct counter_type - { - typedef X r; - }; - - template - struct counter_type - { - typedef shared_base r; - }; - - template - struct counter_ops; - - template - struct counter_ops - { - counter_ops (X const* p) : counter_ (p ? bits::counter (p) : 0) {} - counter_ops (counter_ops const& x) : counter_ (x.counter_) {} - - template - counter_ops (counter_ops const& x) : counter_ (x.counter_) {} - - counter_ops& - operator= (counter_ops const& x) - { - counter_ = x.counter_; - return *this; - } - - template - counter_ops& - operator= (counter_ops const& x) - { - counter_ = x.counter_; - return *this; - } - - void - reset (X const* p) - { - counter_ = p ? bits::counter (p) : 0; - } - - void - inc (X*) - { - (*counter_)++; - } - - void - dec (X* p) - { - if (--(*counter_) == 0) - { - p->~X (); - operator delete (counter_); // Counter is the top of the memory block. - } - } - - std::size_t - count (X const*) const - { - return *counter_; - } - - std::size_t* counter_; - }; - - template - struct counter_ops - { - counter_ops (Y const*) {} - counter_ops (counter_ops const&) {} - - template - counter_ops (counter_ops const&) {} - - counter_ops& - operator= (counter_ops const&) - { - return *this; - } - - template - counter_ops& - operator= (counter_ops const&) - { - return *this; - } - - void - reset (Y const*) {} - - void - inc (shared_base* p) {p->_inc_ref ();} - - void - dec (Y* p) - { - if (static_cast (p)->_dec_ref ()) - delete p; - } - - std::size_t - count (shared_base const* p) const {return p->_ref_count ();} - }; - } - - template - inline X* - inc_ref (X* p) - { - bits::counter_ops::r, X> c (p); - c.inc (p); - return p; - } - - template - inline void - dec_ref (X* p) - { - bits::counter_ops::r, X> c (p); - c.dec (p); - } - - template - inline std::size_t - ref_count (X const* p) - { - bits::counter_ops::r, X> c (p); - return c.count (p); - } -} -- cgit v1.1