Made cds::OS children namespaces inline, removed OS-specific syserror.h headers
authorkhizmax <libcds.dev@gmail.com>
Fri, 28 Nov 2014 20:54:08 +0000 (23:54 +0300)
committerkhizmax <libcds.dev@gmail.com>
Fri, 28 Nov 2014 20:54:08 +0000 (23:54 +0300)
13 files changed:
cds/os/libc/alloc_aligned.h
cds/os/posix/alloc_aligned.h
cds/os/posix/fake_topology.h
cds/os/posix/syserror.h [deleted file]
cds/os/posix/thread.h
cds/os/posix/timer.h
cds/os/win/alloc_aligned.h
cds/os/win/syserror.h [deleted file]
cds/os/win/thread.h
projects/Win/vc12/cds.vcxproj
projects/Win/vc12/cds.vcxproj.filters
projects/Win/vc12/unit-prerequisites.vcxproj
readme

index 4079dae2e8a5f026a478aadbcc39b94c6a96d69d..bf55b65d0a39838739ef047357d97c2aea9cc707 100644 (file)
@@ -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
index 664063f74f2f6433a18a146a6d68a185618e6266..b123a6424520db4aacbbbe844e909b00f4fae4ca 100644 (file)
@@ -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
index c5f91c5c7c826432bca3ad41280cd99362c51806..4fca62f223d18a3932db638a9be7213b9614015d 100644 (file)
@@ -11,7 +11,7 @@
 #include <unistd.h>
 
 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 (file)
index 2929e01..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-//$$CDS-header$$
-
-#ifndef __CDS_OS_POSIX_SYSERROR_H
-#define __CDS_OS_POSIX_SYSERROR_H
-
-#include <stdlib.h>     // system
-#include <pthread.h>
-#include <sched.h>
-#include <cerrno>
-#include <cstdlib>
-#include <string>
-#include <string.h>
-
-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
index 5b8ddf925e6ed1a04ef4ca75869160d09cc0155d..adaf022e0299e27c154bfe3bf7b0666b9b9cc581 100644 (file)
@@ -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
 
index 9275a241b5a48a7cb4dc2f123fee8f287fc6f8f6..1220a5b40a867b9957e33aadbca49acafb535767 100644 (file)
@@ -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
index 061afc4f292d44daf0f168ef1f20e1a9e6a7b410..5a6bf1df677efc19ae4392d735d0992b65b44646 100644 (file)
@@ -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 (file)
index 26491e0..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-//$$CDS-header$$
-
-#ifndef __CDS_OS_WIN_SYSERROR_H
-#define __CDS_OS_WIN_SYSERROR_H
-
-#include <windows.h>
-#include <string>
-
-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
-
index 2185d7aaa2036230409c7e77e3445e78f760f0f7..0e3d66466d55b4f1cd7230c9587530366c39cbee 100644 (file)
@@ -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
index 2f974617655c259a4b0a36bd86060d5a02b9a21a..011f15fd64b418a679e8b75962b6e5a9cc229a02 100644 (file)
     <ClInclude Include="..\..\..\cds\os\linux\timer.h" />\r
     <ClInclude Include="..\..\..\cds\os\linux\topology.h" />\r
     <ClInclude Include="..\..\..\cds\os\posix\alloc_aligned.h" />\r
-    <ClInclude Include="..\..\..\cds\os\posix\syserror.h" />\r
     <ClInclude Include="..\..\..\cds\os\posix\thread.h" />\r
     <ClInclude Include="..\..\..\cds\os\sunos\alloc_aligned.h" />\r
     <ClInclude Include="..\..\..\cds\os\sunos\timer.h" />\r
     <ClInclude Include="..\..\..\cds\os\sunos\topology.h" />\r
     <ClInclude Include="..\..\..\cds\os\win\alloc_aligned.h" />\r
-    <ClInclude Include="..\..\..\cds\os\win\syserror.h" />\r
     <ClInclude Include="..\..\..\cds\os\win\thread.h" />\r
     <ClInclude Include="..\..\..\cds\os\win\timer.h" />\r
     <ClInclude Include="..\..\..\cds\os\win\topology.h" />\r
index 0fcc08e724a7a93e2a2e366d031ef0bc19ae3234..732a2ae5a0eac5269d276079c7f9979c71b43021 100644 (file)
     <ClInclude Include="..\..\..\cds\os\posix\alloc_aligned.h">\r
       <Filter>Header Files\cds\OS\posix</Filter>\r
     </ClInclude>\r
-    <ClInclude Include="..\..\..\cds\os\posix\syserror.h">\r
-      <Filter>Header Files\cds\OS\posix</Filter>\r
-    </ClInclude>\r
     <ClInclude Include="..\..\..\cds\os\posix\thread.h">\r
       <Filter>Header Files\cds\OS\posix</Filter>\r
     </ClInclude>\r
     <ClInclude Include="..\..\..\cds\os\win\alloc_aligned.h">\r
       <Filter>Header Files\cds\OS\win</Filter>\r
     </ClInclude>\r
-    <ClInclude Include="..\..\..\cds\os\win\syserror.h">\r
-      <Filter>Header Files\cds\OS\win</Filter>\r
-    </ClInclude>\r
     <ClInclude Include="..\..\..\cds\os\win\thread.h">\r
       <Filter>Header Files\cds\OS\win</Filter>\r
     </ClInclude>\r
index 7d7b9881b574f3ff7721265ee1827dd0f5608577..3890ae73ae3cd9c3c14bc59f416c945f9fe11c3f 100644 (file)
   <ItemGroup>\r
     <ClCompile Include="..\..\..\tests\unit\ellen_bintree_update_desc_pool.cpp" />\r
     <ClCompile Include="..\..\..\tests\unit\michael_alloc.cpp" />\r
-    <ClCompile Include="..\..\..\tests\cppunit\test_main.cpp" />\r
+    <ClCompile Include="..\..\..\tests\cppunit\test_main.cpp">\r
+      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='DebugVLD|Win32'">_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='ICL-Debug|Win32'">_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='DebugVLD|x64'">_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='ICL-Debug|x64'">_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+    </ClCompile>\r
     <ClCompile Include="..\..\..\tests\cppunit\thread.cpp" />\r
   </ItemGroup>\r
   <ItemGroup>\r
diff --git a/readme b/readme
index c5ec7b523793fdd20170327b8b3bfc41ff317449..eeab1c5dd00955c3ee15de1567a8eee9a8692bc5 100644 (file)
--- a/readme
+++ b/readme
@@ -93,7 +93,7 @@ Supported compilers
 ---------------------------------\r
 \r
 GCC: 4.8 and above\r
-MS Visual C++: 12 (2013) and above\r
+MS Visual C++: 12 (2013) Update 4 and above\r
 Clang: 3.3 and above\r
 \r
 How to build\r