Replacing some integral typedefs with standard types
[libcds.git] / cds / details / defs.h
index ff482c1787248ed49b227d28acb756338eb927c1..93ea0a236153aefb2c597a951e1ea4cd392c5cf8 100644 (file)
@@ -3,9 +3,11 @@
 #ifndef __CDS_DEFS_H
 #define __CDS_DEFS_H
 
+#include <stddef.h>
 #include <assert.h>
 #include <cstdint>
 #include <exception>
+#include <stdexcept>
 #include <string>
 #include <memory>
 
@@ -42,9 +44,7 @@
    The main part of lock-free data structs is garbage collecting. The garbage collector (GC) solves the problem of safe
    memory reclamation that is one of the main problems for lock-free programming.
    The library contains the implementations of several light-weight \ref cds_garbage_collector "memory reclamation schemes":
-   - M.Michael's Hazard Pointer - see cds::gc::HP for more explanation
-   - Gidenstam's memory reclamation schema based on Hazard Pointer and reference counting - see cds::gc::HRC
-   - M.Herlihy and M.Moir's Pass The Buck algorithm - see cds::gc::PTB
+   - M.Michael's Hazard Pointer - \p see cds::gc::HP, \p cds::gc::DHP for more explanation
    - User-space Read-Copy Update (RCU) - see cds::urcu namespace
    - there is cds::gc::nogc "GC" for containers that do not support item reclamation.
 
    Usually, the application is based on only one type of GC.
 
    In the next example we mean that your application uses Hazard Pointer (cds::gc::HP) - based containers.
-   Other GCs (cds::gc::HRC, cds::gc::PTB) are applied analogously.
 
     First, in your code you should initialize \p cds library and a garbage collector in \p main function:
     \code
@@ -348,9 +347,6 @@ namespace cds {}
 //@cond
 // typedefs for back compatibility
 namespace cds {
-    /// Atomic pointer
-    typedef void *            pointer_t;
-
     /// 64bit unaligned int
     typedef int64_t     atomic64_unaligned;
 
@@ -368,24 +364,6 @@ namespace cds {
 
     /// 64bit atomic unsigned int (aligned)
     typedef atomic64u_aligned   atomic64u_t;
-
-    /// 32bit atomic int
-    typedef int32_t     atomic32_t;
-
-    /// 32bit atomic unsigned int
-    typedef uint32_t    atomic32u_t;
-
-    /// atomic int
-    typedef atomic32_t          atomic_t;
-
-    /// atomic unsigned int
-    typedef atomic32u_t         unsigned_atomic_t;
-
-    /// atomic int sized as pointer
-    typedef intptr_t ptr_atomic_t;
-
-    /// atomic unsigned int sized as pointer
-    typedef uintptr_t uptr_atomic_t;
 } // namespace cds
 //@endcond
 
@@ -395,77 +373,9 @@ namespace cds {
 
 namespace cds {
 
-    /// Base of all exceptions in the library
-    class Exception: public std::exception
-    {
-    protected:
-        std::string    m_strMsg    ;    ///< Exception message
-    public:
-        /// Create empty exception
-        Exception()
-        {}
-        /// Create exception with message
-        explicit Exception( const char * pszMsg )
-            : m_strMsg( pszMsg )
-        {}
-        /// Create exception with message
-        explicit Exception( const std::string& strMsg )
-            :m_strMsg( strMsg )
-        {}
-
-        /// Destructor
-        virtual ~Exception() throw()
-        {}
-
-        /// Return exception message
-        virtual const char * what( ) const throw()
-        {
-            return m_strMsg.c_str();
-        }
-    };
-
-//@cond
-#   define CDS_PURE_VIRTUAL_FUNCTION_CALLED    { assert(false); throw Exception("Pure virtual function called"); }
-#   define CDS_PURE_VIRTUAL_FUNCTION_CALLED_(method_name)    { assert(false); throw Exception("Pure virtual function called " method_name ); }
-//@endcond
-
     /// any_type is used as a placeholder for auto-calculated type (usually in \p rebind templates)
     struct any_type {};
 
-    /** \def CDS_DECLARE_EXCEPTION( _class, _msg )
-        Simplifying declaration of specific exception (usual within classes)
-        - @p _class - the class name of exception
-        - @p _msg - exception message (const char *)
-    */
-#define CDS_DECLARE_EXCEPTION( _class, _msg )       \
-    struct _class: public std::exception {          \
-    public:                                         \
-    _class(): std::exception() {}                   \
-    virtual const char * what( ) const throw() { return _msg; } \
-    }
-
 } // namespace cds
 
-
-//@cond
-#ifdef _DEBUG
-#   define cds_assert(X)    assert(X)
-#else
-#   include <stdio.h>   // snprintf
-    static inline void cds_assert_( bool bCond, char const * pszMsg, char const * pszFile, int nLine )
-    {
-        if ( !bCond ) {
-            char buf[4096];
-#   if CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CS_OSI_WINDOWS)
-            _snprintf_s( buf, sizeof(buf)/sizeof(buf[0]), _TRUNCATE, pszMsg, pszFile, nLine );
-#   else
-            snprintf( buf, sizeof(buf)/sizeof(buf[0]), pszMsg, pszFile, nLine );
-#   endif
-            throw cds::Exception( buf );
-        }
-    }
-#   define cds_assert(X)    cds_assert_( X, "%s (%d): Assert failed: " #X, __FILE__, __LINE__ );
-#endif
-//@endcond
-
 #endif // #ifndef __CDS_DEFS_H