[AIX] Added missing byteswap.h
authorkhizmax <libcds.dev@gmail.com>
Sat, 27 May 2017 15:16:27 +0000 (18:16 +0300)
committerkhizmax <libcds.dev@gmail.com>
Sat, 27 May 2017 15:16:27 +0000 (18:16 +0300)
projects/Win/vc14/cds.sln
projects/Win/vc141/cds.sln
test/CMakeLists.txt
test/include/cds_test/ext_byteswap.h [new file with mode: 0644]
test/stress/framework/city.cpp

index 06367d4751dacc1bb69e4db9ca2296471ac8373a..0fe447d5d69309cbb1f8f21fe22525a361584487 100644 (file)
@@ -18,6 +18,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cds_test", "cds_test", "{3A
        ProjectSection(SolutionItems) = preProject\r
                ..\..\..\test\include\cds_test\check_size.h = ..\..\..\test\include\cds_test\check_size.h\r
                ..\..\..\test\include\cds_test\city.h = ..\..\..\test\include\cds_test\city.h\r
+               ..\..\..\test\include\cds_test\ext_byteswap.h = ..\..\..\test\include\cds_test\ext_byteswap.h\r
+               ..\..\..\test\include\cds_test\ext_gtest.h = ..\..\..\test\include\cds_test\ext_gtest.h\r
                ..\..\..\test\include\cds_test\fc_hevy_value.h = ..\..\..\test\include\cds_test\fc_hevy_value.h\r
                ..\..\..\test\include\cds_test\fixture.h = ..\..\..\test\include\cds_test\fixture.h\r
                ..\..\..\test\include\cds_test\hash_func.h = ..\..\..\test\include\cds_test\hash_func.h\r
index cb9297c8389746c67d8de6a32cc55f47437c1822..2f7694cce3391a4c1daff665d45d19834a8cc716 100644 (file)
@@ -18,6 +18,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cds_test", "cds_test", "{3A
        ProjectSection(SolutionItems) = preProject
                ..\..\..\test\include\cds_test\check_size.h = ..\..\..\test\include\cds_test\check_size.h
                ..\..\..\test\include\cds_test\city.h = ..\..\..\test\include\cds_test\city.h
+               ..\..\..\test\include\cds_test\ext_byteswap.h = ..\..\..\test\include\cds_test\ext_byteswap.h
                ..\..\..\test\include\cds_test\ext_gtest.h = ..\..\..\test\include\cds_test\ext_gtest.h
                ..\..\..\test\include\cds_test\fc_hevy_value.h = ..\..\..\test\include\cds_test\fc_hevy_value.h
                ..\..\..\test\include\cds_test\fixture.h = ..\..\..\test\include\cds_test\fixture.h
index 5892581882b9f07f9e1a8308d10c8ebf528be228..62f2419b1df3aca3e254f4cbf086380d2c1611bc 100644 (file)
@@ -67,6 +67,20 @@ set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
 if(GTEST_INSTANTIATE_TEST_CASE_P_HAS_4TH_ARG)
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGTEST_LANG_CXX11 -DCDSTEST_GTEST_INSTANTIATE_TEST_CASE_P_HAS_4TH_ARG") 
 endif()
+
+# Check if there is byteswap.h (needed for cityhash)
+CHECK_CXX_SOURCE_COMPILES("
+#include <byteswap.h>
+int main( int argc, char **argv ) 
+{
+    return 0;
+}
+" CDSTEST_HAVE_BYTESWAP_H )
+
+if(CDSTEST_HAVE_BYTESWAP_H)
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCDSTEST_HAVE_BYTESWAP_H") 
+endif()
+
  
 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/unit)
 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/stress)
diff --git a/test/include/cds_test/ext_byteswap.h b/test/include/cds_test/ext_byteswap.h
new file mode 100644 (file)
index 0000000..14628f9
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+    This file is a part of libcds - Concurrent Data Structures library
+
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
+
+    Source code repo: http://github.com/khizmax/libcds/
+    Download: http://sourceforge.net/projects/libcds/files/
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice, this
+    list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef CDSTEST_BYTESWAP_H
+#define CDSTEST_BYTESWAP_H
+
+#ifdef CDSTEST_HAVE_BYTESWAP_H
+#   include <byteswap.h>
+#else
+
+#define bswap_16(value) ((((value) & 0xff) << 8) | ((value) >> 8))
+
+#define bswap_32(value) (((uint32_t)bswap_16((uint16_t)((value) & 0xffff)) << 16) | (uint32_t)bswap_16((uint16_t)((value) >> 16)))
+
+#define bswap_64(value) (((uint64_t)bswap_32((uint32_t)((value) & 0xffffffff)) << 32) | (uint64_t)bswap_32((uint32_t)((value) >> 32)))
+
+#endif
+#endif // CDSTEST_BYTESWAP_H
\ No newline at end of file
index 26c53cbea2a5acbeee8e56828a82a19617e39e8a..1d995578ff43f6064a05f3ee479592af421df9b4 100644 (file)
@@ -72,7 +72,7 @@ static uint32 UNALIGNED_LOAD32(const char *p) {
 
 #else
 
-#include <byteswap.h>
+#include <cds_test/ext_byteswap.h>
 
 #endif