From: khizmax Date: Fri, 28 Nov 2014 20:54:08 +0000 (+0300) Subject: Made cds::OS children namespaces inline, removed OS-specific syserror.h headers X-Git-Tag: v2.0.0~46 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=libcds.git;a=commitdiff_plain;h=3683a950e8f85ea3407320270aa428fba7ebf71e Made cds::OS children namespaces inline, removed OS-specific syserror.h headers --- diff --git a/cds/os/libc/alloc_aligned.h b/cds/os/libc/alloc_aligned.h index 4079dae2..bf55b65d 100644 --- a/cds/os/libc/alloc_aligned.h +++ b/cds/os/libc/alloc_aligned.h @@ -7,7 +7,7 @@ //@cond none namespace cds { namespace OS { - namespace libc { + CDS_CXX11_INLINE_NAMESPACE namespace libc { /// Allocates memory on a specified alignment boundary static inline void * aligned_malloc( size_t nSize, ///< Size of the requested memory allocation @@ -26,8 +26,10 @@ namespace cds { namespace OS { } } // namespace libc +#ifndef CDS_CXX11_INLINE_NAMESPACE_SUPPORT using libc::aligned_malloc; using libc::aligned_free; +#endif }} // namespace cds::OS //@endcond diff --git a/cds/os/posix/alloc_aligned.h b/cds/os/posix/alloc_aligned.h index 664063f7..b123a642 100644 --- a/cds/os/posix/alloc_aligned.h +++ b/cds/os/posix/alloc_aligned.h @@ -14,7 +14,7 @@ //@cond none namespace cds { namespace OS { - namespace posix { + CDS_CXX11_INLINE_NAMESPACE namespace posix { /// Allocates memory on a specified alignment boundary static inline void * aligned_malloc( size_t nSize, ///< Size of the requested memory allocation @@ -34,8 +34,10 @@ namespace cds { namespace OS { } } // namespace posix +#ifndef CDS_CXX11_INLINE_NAMESPACE_SUPPORT using posix::aligned_malloc; using posix::aligned_free; +#endif }} // namespace cds::OS //@endcond diff --git a/cds/os/posix/fake_topology.h b/cds/os/posix/fake_topology.h index c5f91c5c..4fca62f2 100644 --- a/cds/os/posix/fake_topology.h +++ b/cds/os/posix/fake_topology.h @@ -11,7 +11,7 @@ #include namespace cds { namespace OS { - namespace posix { + CDS_CXX11_INLINE_NAMESPACE namespace posix { /// Fake system topology struct topology { /// Logical processor count for the system. Always returns 1 @@ -44,7 +44,10 @@ namespace cds { namespace OS { }; } // namespace posix +#ifndef CDS_CXX11_INLINE_NAMESPACE_SUPPORT using posix::topology; +#endif + }} // namespace cds::OS #endif // #ifndef __CDS_OS_POSIX_FAKE_TOPOLOGY_H diff --git a/cds/os/posix/syserror.h b/cds/os/posix/syserror.h deleted file mode 100644 index 2929e016..00000000 --- a/cds/os/posix/syserror.h +++ /dev/null @@ -1,40 +0,0 @@ -//$$CDS-header$$ - -#ifndef __CDS_OS_POSIX_SYSERROR_H -#define __CDS_OS_POSIX_SYSERROR_H - -#include // system -#include -#include -#include -#include -#include -#include - -namespace cds { namespace OS { - namespace posix { - /// Posix error code type - typedef int error_code; - - /// Get text for system error \p nCode - static inline std::string getSystemErrorText( error_code nCode ) - { - char *msg = strerror( nCode ); - return std::string( msg ); - } - - /// Get curent error code (returns \p errno) - static inline error_code getErrorCode() - { - return errno; - } - - } // namespace posix - - using posix::error_code; - using posix::getErrorCode; - using posix::getSystemErrorText; -}} // namespace cds::OS - - -#endif // #ifndef __CDS_OS_POSIX_SYSERROR_H diff --git a/cds/os/posix/thread.h b/cds/os/posix/thread.h index 5b8ddf92..adaf022e 100644 --- a/cds/os/posix/thread.h +++ b/cds/os/posix/thread.h @@ -8,7 +8,7 @@ namespace cds { namespace OS { /// posix-related wrappers - namespace posix { + CDS_CXX11_INLINE_NAMESPACE namespace posix { /// Posix thread id type typedef std::thread::native_handle_type ThreadId; @@ -29,13 +29,14 @@ namespace cds { namespace OS { } } // namespace posix - //@cond + constexpr const posix::ThreadId c_NullThreadId = 0; + +#ifndef CDS_CXX11_INLINE_NAMESPACE_SUPPORT using posix::ThreadId; - constexpr const ThreadId c_NullThreadId = 0; using posix::getCurrentThreadId; using posix::isThreadAlive; - //@endcond +#endif }} // namespace cds::OS diff --git a/cds/os/posix/timer.h b/cds/os/posix/timer.h index 9275a241..1220a5b4 100644 --- a/cds/os/posix/timer.h +++ b/cds/os/posix/timer.h @@ -11,7 +11,7 @@ //@cond none namespace cds { namespace OS { - namespace posix { + CDS_CXX11_INLINE_NAMESPACE namespace posix { // High resolution timer // From Linux as an example @@ -79,7 +79,9 @@ namespace cds { namespace OS { }; } // namespace posix +#ifndef CDS_CXX11_INLINE_NAMESPACE_SUPPORT using posix::Timer; +#endif }} // namespace cds::OS //@endcond diff --git a/cds/os/win/alloc_aligned.h b/cds/os/win/alloc_aligned.h index 061afc4f..5a6bf1df 100644 --- a/cds/os/win/alloc_aligned.h +++ b/cds/os/win/alloc_aligned.h @@ -7,7 +7,7 @@ //@cond none namespace cds { namespace OS { - namespace Win32 { + CDS_CXX11_INLINE_NAMESPACE namespace Win32 { /// Allocates memory on a specified alignment boundary static inline void * aligned_malloc( size_t nSize, ///< Size of the requested memory allocation @@ -26,8 +26,10 @@ namespace cds { namespace OS { } } // namespace Win32 +#ifndef CDS_CXX11_INLINE_NAMESPACE_SUPPORT using Win32::aligned_malloc; using Win32::aligned_free; +#endif }} // namespace cds::OS //@endcond diff --git a/cds/os/win/syserror.h b/cds/os/win/syserror.h deleted file mode 100644 index 26491e05..00000000 --- a/cds/os/win/syserror.h +++ /dev/null @@ -1,48 +0,0 @@ -//$$CDS-header$$ - -#ifndef __CDS_OS_WIN_SYSERROR_H -#define __CDS_OS_WIN_SYSERROR_H - -#include -#include - -namespace cds { namespace OS { - namespace Win32 { - - /// OS-specific type of error code - typedef DWORD error_code; - - /// Get system error code - static inline error_code getErrorCode() - { - return ::GetLastError(); - } - - /// Get system error text - static inline std::string getSystemErrorText( error_code nCode ) - { - char *ptmp = 0; - if ( !FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - nullptr, - nCode, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR) &ptmp, 0, 0 ) - ) - { - if ( ptmp ) - LocalFree( ptmp ); - return std::string(); - } - std::string str( ptmp ); - LocalFree( ptmp ); - return str; - } - } // namespace Win32 - - using Win32::error_code; - using Win32::getErrorCode; - using Win32::getSystemErrorText; -}} // namespace cds::OS - -#endif // #ifndef __CDS_OS_WIN_SYSERROR_H - diff --git a/cds/os/win/thread.h b/cds/os/win/thread.h index 2185d7aa..0e3d6646 100644 --- a/cds/os/win/thread.h +++ b/cds/os/win/thread.h @@ -7,7 +7,7 @@ namespace cds { namespace OS { /// Windows-specific functions - namespace Win32 { + CDS_CXX11_INLINE_NAMESPACE namespace Win32 { /// OS-specific type of thread identifier typedef DWORD ThreadId; @@ -30,11 +30,13 @@ namespace cds { namespace OS { } // namespace Win32 //@cond - using Win32::ThreadId; - CDS_CONSTEXPR const ThreadId c_NullThreadId = 0; + CDS_CONSTEXPR const Win32::ThreadId c_NullThreadId = 0; +#ifndef CDS_CXX11_INLINE_NAMESPACE_SUPPORT + using Win32::ThreadId; using Win32::getCurrentThreadId; using Win32::isThreadAlive; +#endif //@endcond }} // namespace cds::OS diff --git a/projects/Win/vc12/cds.vcxproj b/projects/Win/vc12/cds.vcxproj index 2f974617..011f15fd 100644 --- a/projects/Win/vc12/cds.vcxproj +++ b/projects/Win/vc12/cds.vcxproj @@ -881,13 +881,11 @@ - - diff --git a/projects/Win/vc12/cds.vcxproj.filters b/projects/Win/vc12/cds.vcxproj.filters index 0fcc08e7..732a2ae5 100644 --- a/projects/Win/vc12/cds.vcxproj.filters +++ b/projects/Win/vc12/cds.vcxproj.filters @@ -386,9 +386,6 @@ Header Files\cds\OS\posix - - Header Files\cds\OS\posix - Header Files\cds\OS\posix @@ -404,9 +401,6 @@ Header Files\cds\OS\win - - Header Files\cds\OS\win - Header Files\cds\OS\win diff --git a/projects/Win/vc12/unit-prerequisites.vcxproj b/projects/Win/vc12/unit-prerequisites.vcxproj index 7d7b9881..3890ae73 100644 --- a/projects/Win/vc12/unit-prerequisites.vcxproj +++ b/projects/Win/vc12/unit-prerequisites.vcxproj @@ -423,7 +423,14 @@ - + + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + diff --git a/readme b/readme index c5ec7b52..eeab1c5d 100644 --- a/readme +++ b/readme @@ -93,7 +93,7 @@ Supported compilers --------------------------------- GCC: 4.8 and above -MS Visual C++: 12 (2013) and above +MS Visual C++: 12 (2013) Update 4 and above Clang: 3.3 and above How to build