#define __CDS_DEFS_H
#include <assert.h>
+#include <cstdint>
#include <exception>
#include <string>
#include <memory>
schema used. However, any implementation supports common interface for the type of data structure.
To implement any lock-free data structure, two things are needed:
- - atomic operation library conforming with C++11 memory model. The <b>libcds</b> has such feature, see cds::cxx11_atomics namespace for
+ - atomic operation library conforming with C++11 memory model. The <b>libcds</b> has such feature, see cds::cxx11_atomic namespace for
details and compiler-specific information.
- safe memory reclamation (SMR) or garbage collecting (GC) algorithm. The <b>libcds</b> has an implementation of several
well-known SMR algos, see below.
// CDS_VERIFY: Debug - assert(_expr); Release - _expr
#ifdef CDS_DEBUG
# define CDS_VERIFY( _expr ) assert( _expr )
-# define CDS_DEBUG_DO( _expr ) _expr
+# define CDS_DEBUG_ONLY( _expr ) _expr
#else
# define CDS_VERIFY( _expr ) _expr
-# define CDS_DEBUG_DO( _expr )
+# define CDS_DEBUG_ONLY( _expr )
#endif
#ifdef CDS_STRICT
// Compiler-specific defines
#include <cds/compiler/defs.h>
-// New C++11 features
-#include <cds/details/cxx11_features.h>
#define CDS_NOEXCEPT CDS_NOEXCEPT_SUPPORT
#define CDS_NOEXCEPT_( expr ) CDS_NOEXCEPT_SUPPORT_( expr )
-#ifndef CDS_NOEXCEPT_DEFAULTED
- // Some compilers do not allow noexcept specification in defaulted function
- // For example, GCC 4.6.x raise following error:
- // void foo() noexcept = default
- // error: function \91foo\92 defaulted on its first declaration must not have an exception-specification
- // For such compiler empty CDS_NOEXCEPT_DEFAULTED must be defined
-# define CDS_NOEXCEPT_DEFAULTED CDS_NOEXCEPT
-# define CDS_NOEXCEPT_DEFAULTED_(expr) CDS_NOEXCEPT_( expr )
-#endif
-
-#if defined(CDS_CXX11_VARIADIC_TEMPLATE_SUPPORT) && defined(CDS_MOVE_SEMANTICS_SUPPORT)
-# define CDS_EMPLACE_SUPPORT
-#endif
#ifdef CDS_CXX11_INLINE_NAMESPACE_SUPPORT
# define CDS_CXX11_INLINE_NAMESPACE inline
Common things
**************************************************************************/
-#include <cds/numtraits.h>
-
namespace cds {
- //@cond
- /// Helper template: converts volatile pointer to non-volatile one
- template <typename T>
- static inline T * non_volatile( T volatile * p ) { return const_cast<T *>( p ); }
-
- template <typename T>
- static inline T * non_volatile( T * p ) { return p; }
- //@endcond
-
/// Base of all exceptions in the library
class Exception: public std::exception
{
virtual const char * what( ) const throw() { return _msg; } \
}
-
- //@cond
- // This template function should be replaced with nullptr keyword when all compilers will support it
- template <typename T>
- static inline CDS_CONSTEXPR T null_ptr() CDS_NOEXCEPT
- {
- return reinterpret_cast<T>( NULL );
- }
- //@endcond
-
} // namespace cds
-/// @defgroup cds_cxx11_stdlib_wrapper New C++11 standard library support
-
-/// C++11 standard library wrapper namespace
-/** @ingroup cds_cxx11_stdlib_wrapper
- libcds needs support from new features defined in C++11 standard library.
- In case when an old compiler and corresponding \p std library has no required feature
- the \p boost library is used if possible. The \p %cds_std namespace is a wrapper for new C++11 stdlib classes:
- - if the compiler supports new feature, this feature places (with \p using directive) into \p %cds_std namespace "as is"
- - otherwise the \p boost analog is used and it places into \p %cds_std namespace too
-
- For example, for class \p std::mutex the \p libcds does the following:
- - for old compiler: \code
- #include <boost/thread/mutex.hpp>
- namespace cds_std {
- using boost::mutex;
- }
- \endcode
- - for C++11-ready compiler: \code
- #include <mutex>
- namespace cds_std {
- using std::mutex;
- }
- \endcode
-
- Everywhere in \p libcds the class \p %cds_std::mutex is used instead of \p std::mutex.
-
- Note, not all C++11 features are contained in \p %cds_std but only required by \p libcds.
-
- In future when all compilers will be C++11-ready we can transform the \p libcds
- to new C++11 standard library changing \p %cds_std namespace to native \p std.
-*/
-namespace cds_std {}
-
//@cond
#ifdef _DEBUG
# define cds_assert(X) assert(X)
{
if ( !bCond ) {
char buf[4096];
-# if CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL
+# 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 );