arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject arrow git commit: ARROW-202: Integrate with appveyor ci for windows
Date Sat, 26 Nov 2016 19:22:55 GMT
Repository: arrow
Updated Branches:
  refs/heads/master 197120cbc -> 86f56a607


ARROW-202: Integrate with appveyor ci for windows

This only adds yet a successful compilation for windows. Tests don't
run.

Author: Uwe L. Korn <uwelk@xhochy.com>

Closes #213 from xhochy/ARROW-202 and squashes the following commits:

d5088a6 [Uwe L. Korn] Correctly reference Kudu in LICENSE and NOTICE
72a583b [Uwe L. Korn] Differentiate Boost libraries based on build type
6c75699 [Uwe L. Korn] Add license header
e33b08c [Uwe L. Korn] Pick up shared Boost libraries correctly
5da5f5d [Uwe L. Korn] ARROW-202: Integrate with appveyor ci for windows


Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/86f56a60
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/86f56a60
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/86f56a60

Branch: refs/heads/master
Commit: 86f56a6073c3254487ede3aff1dc9d117d24adaf
Parents: 197120c
Author: Uwe L. Korn <uwelk@xhochy.com>
Authored: Sat Nov 26 14:22:47 2016 -0500
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Sat Nov 26 14:22:47 2016 -0500

----------------------------------------------------------------------
 LICENSE.txt                          | 12 ++++++
 NOTICE.txt                           | 14 +++++++
 appveyor.yml                         | 39 +++++++++++++++++++
 cpp/CMakeLists.txt                   | 64 +++++++++++++++++--------------
 cpp/cmake_modules/CompilerInfo.cmake | 42 ++++++++++++--------
 cpp/src/arrow/array-test.cc          |  1 +
 cpp/src/arrow/io/CMakeLists.txt      | 14 +++++--
 cpp/src/arrow/io/io-file-test.cc     |  9 ++++-
 cpp/src/arrow/io/memory.cc           | 13 ++++++-
 cpp/src/arrow/io/mman.h              | 12 +++---
 cpp/src/arrow/io/test-common.h       | 12 ++++++
 cpp/src/arrow/test-util.h            |  8 ++++
 cpp/src/arrow/type.h                 |  2 +-
 cpp/src/arrow/util/CMakeLists.txt    | 25 ++++++------
 cpp/src/arrow/util/buffer.h          |  4 +-
 cpp/src/arrow/util/memory-pool.cc    | 14 +++++++
 cpp/src/arrow/util/visibility.h      |  1 +
 17 files changed, 217 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/86f56a60/LICENSE.txt
----------------------------------------------------------------------
diff --git a/LICENSE.txt b/LICENSE.txt
index d645695..c3bec43 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -200,3 +200,15 @@
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
+
+--------------------------------------------------------------------------------
+
+This product includes code from Apache Kudu.
+
+ * cpp/cmake_modules/CompilerInfo.cmake is based on Kudu's cmake_modules/CompilerInfo.cmake
+
+Copyright: 2016 The Apache Software Foundation.
+Home page: https://kudu.apache.org/
+License: http://www.apache.org/licenses/LICENSE-2.0
+
+--------------------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/arrow/blob/86f56a60/NOTICE.txt
----------------------------------------------------------------------
diff --git a/NOTICE.txt b/NOTICE.txt
index 5c699ca..02cb4dd 100644
--- a/NOTICE.txt
+++ b/NOTICE.txt
@@ -41,3 +41,17 @@ This product includes software from the CMake project
 
 This product includes software from https://github.com/matthew-brett/multibuild (BSD 2-clause)
  * Copyright (c) 2013-2016, Matt Terry and Matthew Brett; all rights reserved.
+
+--------------------------------------------------------------------------------
+
+This product includes code from Apache Kudu, which includes the following in
+its NOTICE file:
+
+  Apache Kudu
+  Copyright 2016 The Apache Software Foundation
+
+  This product includes software developed at
+  The Apache Software Foundation (http://www.apache.org/).
+
+  Portions of this software were developed at
+  Cloudera, Inc (http://www.cloudera.com/).

http://git-wip-us.apache.org/repos/asf/arrow/blob/86f56a60/appveyor.yml
----------------------------------------------------------------------
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..6747848
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,39 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Operating system (build VM template)
+os: Visual Studio 2015
+
+environment:
+  matrix:
+    - GENERATOR: Visual Studio 14 2015 Win64
+    # - GENERATOR: Visual Studio 14 2015
+  MSVC_DEFAULT_OPTIONS: ON
+  BOOST_ROOT: C:\Libraries\boost_1_59_0
+  BOOST_LIBRARYDIR: C:\Libraries\boost_1_59_0\lib64-msvc-14.0
+
+build_script:
+ - cd cpp
+ - mkdir build
+ - cd build
+ # A lot of features are still deactivated as they do not build on Windows
+ #  * gbenchmark doesn't build with MSVC
+ - cmake -G "%GENERATOR%" -DARROW_BOOST_USE_SHARED=OFF -DARROW_IPC=OFF -DARROW_HDFS=OFF -DARROW_BUILD_BENCHMARKS=OFF
..
+ - cmake --build . --config Debug
+
+# test_script:
+#  - ctest -VV

http://git-wip-us.apache.org/repos/asf/arrow/blob/86f56a60/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index 839ea17..0edb8ce 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -141,9 +141,11 @@ endif()
 # For CMAKE_BUILD_TYPE=Release
 #   -O3: Enable all compiler optimizations
 #   -g: Enable symbols for profiler tools (TODO: remove for shipping)
-set(CXX_FLAGS_DEBUG "-ggdb -O0")
-set(CXX_FLAGS_FASTDEBUG "-ggdb -O1")
-set(CXX_FLAGS_RELEASE "-O3 -g -DNDEBUG")
+if (NOT MSVC)
+  set(CXX_FLAGS_DEBUG "-ggdb -O0")
+  set(CXX_FLAGS_FASTDEBUG "-ggdb -O1")
+  set(CXX_FLAGS_RELEASE "-O3 -g -DNDEBUG")
+endif()
 
 set(CXX_FLAGS_PROFILE_GEN "${CXX_FLAGS_RELEASE} -fprofile-generate")
 set(CXX_FLAGS_PROFILE_BUILD "${CXX_FLAGS_RELEASE} -fprofile-use")
@@ -347,6 +349,8 @@ function(ADD_ARROW_TEST REL_TEST_NAME)
       COMPILE_FLAGS " -DARROW_VALGRIND")
     add_test(${TEST_NAME}
       valgrind --tool=memcheck --leak-check=full --error-exitcode=1 ${TEST_PATH})
+  elseif(MSVC)
+    add_test(${TEST_NAME} ${TEST_PATH})
   else()
     add_test(${TEST_NAME}
       ${BUILD_SUPPORT_DIR}/run-test.sh ${CMAKE_BINARY_DIR} test ${TEST_PATH})
@@ -431,40 +435,44 @@ endfunction()
 # ----------------------------------------------------------------------
 # Add Boost dependencies (code adapted from Apache Kudu (incubating))
 
-# find boost headers and libs
+# Find static boost headers and libs
+# TODO Differentiate here between release and debug builds
 set(Boost_DEBUG TRUE)
 set(Boost_USE_MULTITHREADED ON)
 set(Boost_USE_STATIC_LIBS ON)
 find_package(Boost COMPONENTS system filesystem REQUIRED)
-include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
-set(BOOST_STATIC_LIBS ${Boost_LIBRARIES})
-list(LENGTH BOOST_STATIC_LIBS BOOST_STATIC_LIBS_LEN)
+if ("${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
+  set(BOOST_STATIC_SYSTEM_LIBRARY ${Boost_SYSTEM_LIBRARY_DEBUG})
+  set(BOOST_STATIC_FILESYSTEM_LIBRARY ${Boost_FILESYSTEM_LIBRARY_DEBUG})
+else()
+  set(BOOST_STATIC_SYSTEM_LIBRARY ${Boost_SYSTEM_LIBRARY_RELEASE})
+  set(BOOST_STATIC_FILESYSTEM_LIBRARY ${Boost_FILESYSTEM_LIBRARY_RELEASE})
+endif()
 
-# Find Boost shared libraries.
+# Find shared Boost libraries.
 set(Boost_USE_STATIC_LIBS OFF)
 find_package(Boost COMPONENTS system filesystem REQUIRED)
-set(BOOST_SHARED_LIBS ${Boost_LIBRARIES})
-list(LENGTH BOOST_SHARED_LIBS BOOST_SHARED_LIBS_LEN)
-list(SORT BOOST_SHARED_LIBS)
+if ("${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
+  set(BOOST_SHARED_SYSTEM_LIBRARY ${Boost_SYSTEM_LIBRARY_DEBUG})
+  set(BOOST_SHARED_FILESYSTEM_LIBRARY ${Boost_FILESYSTEM_LIBRARY_DEBUG})
+else()
+  set(BOOST_SHARED_SYSTEM_LIBRARY ${Boost_SYSTEM_LIBRARY_RELEASE})
+  set(BOOST_SHARED_FILESYSTEM_LIBRARY ${Boost_FILESYSTEM_LIBRARY_RELEASE})
+endif()
 
 message(STATUS "Boost include dir: " ${Boost_INCLUDE_DIRS})
 message(STATUS "Boost libraries: " ${Boost_LIBRARIES})
 
-math(EXPR LAST_IDX "${BOOST_STATIC_LIBS_LEN} - 1")
-foreach(IDX RANGE ${LAST_IDX})
-  list(GET BOOST_STATIC_LIBS ${IDX} BOOST_STATIC_LIB)
-  list(GET BOOST_SHARED_LIBS ${IDX} BOOST_SHARED_LIB)
+ADD_THIRDPARTY_LIB(boost_system
+    STATIC_LIB "${BOOST_STATIC_SYSTEM_LIBRARY}"
+    SHARED_LIB "${BOOST_SHARED_SYSTEM_LIBRARY}")
+
+ADD_THIRDPARTY_LIB(boost_filesystem
+    STATIC_LIB "${BOOST_STATIC_FILESYSTEM_LIBRARY}"
+    SHARED_LIB "${BOOST_SHARED_FILESYSTEM_LIBRARY}")
+
+SET(ARROW_BOOST_LIBS boost_system boost_filesystem)
 
-  # Remove the prefix/suffix from the library name.
-  #
-  # e.g. libboost_system-mt --> boost_system
-  get_filename_component(LIB_NAME ${BOOST_STATIC_LIB} NAME_WE)
-  string(REGEX REPLACE "lib([^-]*)(-mt)?" "\\1" LIB_NAME_NO_PREFIX_SUFFIX ${LIB_NAME})
-  ADD_THIRDPARTY_LIB(${LIB_NAME_NO_PREFIX_SUFFIX}
-    STATIC_LIB "${BOOST_STATIC_LIB}"
-    SHARED_LIB "${BOOST_SHARED_LIB}")
-  list(APPEND ARROW_BOOST_LIBS ${LIB_NAME_NO_PREFIX_SUFFIX})
-endforeach()
 include_directories(SYSTEM ${Boost_INCLUDE_DIR})
 
 # ----------------------------------------------------------------------
@@ -482,7 +490,7 @@ if(ARROW_BUILD_TESTS)
 
     ExternalProject_Add(googletest_ep
       URL "https://github.com/google/googletest/archive/release-${GTEST_VERSION}.tar.gz"
-      CMAKE_ARGS -DCMAKE_CXX_FLAGS=${GTEST_CMAKE_CXX_FLAGS}
+      CMAKE_ARGS -DCMAKE_CXX_FLAGS=${GTEST_CMAKE_CXX_FLAGS} -Dgtest_force_shared_crt=ON
       # googletest doesn't define install rules, so just build in the
       # source dir and don't try to install.  See its README for
       # details.
@@ -491,7 +499,7 @@ if(ARROW_BUILD_TESTS)
 
     set(GTEST_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/googletest_ep-prefix/src/googletest_ep")
     set(GTEST_INCLUDE_DIR "${GTEST_PREFIX}/include")
-    set(GTEST_STATIC_LIB "${GTEST_PREFIX}/libgtest.a")
+    set(GTEST_STATIC_LIB "${GTEST_PREFIX}/${CMAKE_CFG_INTDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}")
     set(GTEST_VENDORED 1)
   else()
     find_package(GTest REQUIRED)
@@ -571,7 +579,7 @@ if(ARROW_BUILD_BENCHMARKS)
         "-DCMAKE_CXX_FLAGS=-fPIC ${GBENCHMARK_CMAKE_CXX_FLAGS}")
 
     set(GBENCHMARK_INCLUDE_DIR "${GBENCHMARK_PREFIX}/include")
-    set(GBENCHMARK_STATIC_LIB "${GBENCHMARK_PREFIX}/lib/libbenchmark.a")
+    set(GBENCHMARK_STATIC_LIB "${GBENCHMARK_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}benchmark${CMAKE_STATIC_LIBRARY_SUFFIX}")
     set(GBENCHMARK_VENDORED 1)
   else()
     find_package(GBenchmark REQUIRED)

http://git-wip-us.apache.org/repos/asf/arrow/blob/86f56a60/cpp/cmake_modules/CompilerInfo.cmake
----------------------------------------------------------------------
diff --git a/cpp/cmake_modules/CompilerInfo.cmake b/cpp/cmake_modules/CompilerInfo.cmake
index 02f6fd4..187698f 100644
--- a/cpp/cmake_modules/CompilerInfo.cmake
+++ b/cpp/cmake_modules/CompilerInfo.cmake
@@ -1,25 +1,32 @@
-# Copyright 2013 Cloudera, Inc.
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
 #
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
+#   http://www.apache.org/licenses/LICENSE-2.0
 #
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
 #
 # Sets COMPILER_FAMILY to 'clang' or 'gcc'
 # Sets COMPILER_VERSION to the version
 execute_process(COMMAND "${CMAKE_CXX_COMPILER}" -v
                 ERROR_VARIABLE COMPILER_VERSION_FULL)
 message(INFO " ${COMPILER_VERSION_FULL}")
+message(INFO " ${CMAKE_CXX_COMPILER_ID}")
+
+if(MSVC)
+  set(COMPILER_FAMILY "msvc")
 
 # clang on Linux and Mac OS X before 10.9
-if("${COMPILER_VERSION_FULL}" MATCHES ".*clang version.*")
+elseif("${COMPILER_VERSION_FULL}" MATCHES ".*clang version.*")
   set(COMPILER_FAMILY "clang")
   string(REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1"
     COMPILER_VERSION "${COMPILER_VERSION_FULL}")
@@ -29,10 +36,15 @@ elseif("${COMPILER_VERSION_FULL}" MATCHES ".*based on LLVM.*")
   string(REGEX REPLACE ".*based on LLVM ([0-9]+\\.[0.9]+).*" "\\1"
     COMPILER_VERSION "${COMPILER_VERSION_FULL}")
 
-# clang on Mac OS X, XCode 7+. No version replacement is done
-# because Apple no longer advertises the upstream LLVM version.
-elseif("${COMPILER_VERSION_FULL}" MATCHES "clang-.*")
+# clang on Mac OS X, XCode 7.
+elseif("${COMPILER_VERSION_FULL}" MATCHES ".*clang-7")
+  set(COMPILER_FAMILY "clang")
+  set(COMPILER_VERSION "3.7.0svn")
+
+# clang on Mac OS X, XCode 8.
+elseif("${COMPILER_VERSION_FULL}" MATCHES ".*clang-8")
   set(COMPILER_FAMILY "clang")
+  set(COMPILER_VERSION "3.8.0svn")
 
 # gcc
 elseif("${COMPILER_VERSION_FULL}" MATCHES ".*gcc version.*")

http://git-wip-us.apache.org/repos/asf/arrow/blob/86f56a60/cpp/src/arrow/array-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/array-test.cc b/cpp/src/arrow/array-test.cc
index 3b47363..1581244 100644
--- a/cpp/src/arrow/array-test.cc
+++ b/cpp/src/arrow/array-test.cc
@@ -18,6 +18,7 @@
 #include <cstdint>
 #include <cstdlib>
 #include <memory>
+#include <numeric>
 #include <vector>
 
 #include "gtest/gtest.h"

http://git-wip-us.apache.org/repos/asf/arrow/blob/86f56a60/cpp/src/arrow/io/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/CMakeLists.txt b/cpp/src/arrow/io/CMakeLists.txt
index 47bb089..a1892a9 100644
--- a/cpp/src/arrow/io/CMakeLists.txt
+++ b/cpp/src/arrow/io/CMakeLists.txt
@@ -18,10 +18,16 @@
 # ----------------------------------------------------------------------
 # arrow_io : Arrow IO interfaces
 
-set(ARROW_IO_LINK_LIBS
-  arrow_shared
-  dl
-)
+if (MSVC)
+  set(ARROW_IO_LINK_LIBS
+    arrow_shared
+  )
+else()
+  set(ARROW_IO_LINK_LIBS
+    arrow_shared
+    dl
+  )
+endif()
 
 if (ARROW_BOOST_USE_SHARED)
   set(ARROW_IO_PRIVATE_LINK_LIBS

http://git-wip-us.apache.org/repos/asf/arrow/blob/86f56a60/cpp/src/arrow/io/io-file-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/io-file-test.cc b/cpp/src/arrow/io/io-file-test.cc
index cde769f..54c21d2 100644
--- a/cpp/src/arrow/io/io-file-test.cc
+++ b/cpp/src/arrow/io/io-file-test.cc
@@ -18,7 +18,9 @@
 #include <cstdint>
 #include <cstdio>
 #include <cstring>
-#include <fcntl.h>
+#ifndef _MSC_VER
+# include <fcntl.h>
+#endif
 #include <fstream>
 #include <memory>
 #include <sstream>
@@ -38,7 +40,12 @@ static bool FileExists(const std::string& path) {
 }
 
 static bool FileIsClosed(int fd) {
+#ifdef _MSC_VER
+  // Close file a second time, this should set errno to EBADF
+  close(fd);
+#else
   if (-1 != fcntl(fd, F_GETFD)) { return false; }
+#endif
   return errno == EBADF;
 }
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/86f56a60/cpp/src/arrow/io/memory.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/memory.cc b/cpp/src/arrow/io/memory.cc
index c7d0ae5..71b0f1e 100644
--- a/cpp/src/arrow/io/memory.cc
+++ b/cpp/src/arrow/io/memory.cc
@@ -17,7 +17,18 @@
 
 #include "arrow/io/memory.h"
 
-#include <sys/mman.h>  // For memory-mapping
+// sys/mman.h not present in Visual Studio or Cygwin
+#ifdef _WIN32
+#ifndef NOMINMAX
+#define NOMINMAX
+#endif
+#include "arrow/io/mman.h"
+#undef Realloc
+#undef Free
+#include <windows.h>
+#else
+#include <sys/mman.h>
+#endif
 
 #include <algorithm>
 #include <cerrno>

http://git-wip-us.apache.org/repos/asf/arrow/blob/86f56a60/cpp/src/arrow/io/mman.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/mman.h b/cpp/src/arrow/io/mman.h
index 00d1f93..27d9736 100644
--- a/cpp/src/arrow/io/mman.h
+++ b/cpp/src/arrow/io/mman.h
@@ -76,7 +76,7 @@ static DWORD __map_mmap_prot_file(const int prot) {
   return desiredAccess;
 }
 
-void* mmap(void* addr, size_t len, int prot, int flags, int fildes, off_t off) {
+static void* mmap(void* addr, size_t len, int prot, int flags, int fildes, off_t off) {
   HANDLE fm, h;
 
   void* map = MAP_FAILED;
@@ -143,7 +143,7 @@ void* mmap(void* addr, size_t len, int prot, int flags, int fildes, off_t
off) {
   return map;
 }
 
-int munmap(void* addr, size_t len) {
+static int munmap(void* addr, size_t len) {
   if (UnmapViewOfFile(addr)) return 0;
 
   errno = __map_mman_error(GetLastError(), EPERM);
@@ -151,7 +151,7 @@ int munmap(void* addr, size_t len) {
   return -1;
 }
 
-int mprotect(void* addr, size_t len, int prot) {
+static int mprotect(void* addr, size_t len, int prot) {
   DWORD newProtect = __map_mmap_prot_page(prot);
   DWORD oldProtect = 0;
 
@@ -162,7 +162,7 @@ int mprotect(void* addr, size_t len, int prot) {
   return -1;
 }
 
-int msync(void* addr, size_t len, int flags) {
+static int msync(void* addr, size_t len, int flags) {
   if (FlushViewOfFile(addr, len)) return 0;
 
   errno = __map_mman_error(GetLastError(), EPERM);
@@ -170,7 +170,7 @@ int msync(void* addr, size_t len, int flags) {
   return -1;
 }
 
-int mlock(const void* addr, size_t len) {
+static int mlock(const void* addr, size_t len) {
   if (VirtualLock((LPVOID)addr, len)) return 0;
 
   errno = __map_mman_error(GetLastError(), EPERM);
@@ -178,7 +178,7 @@ int mlock(const void* addr, size_t len) {
   return -1;
 }
 
-int munlock(const void* addr, size_t len) {
+static int munlock(const void* addr, size_t len) {
   if (VirtualUnlock((LPVOID)addr, len)) return 0;
 
   errno = __map_mman_error(GetLastError(), EPERM);

http://git-wip-us.apache.org/repos/asf/arrow/blob/86f56a60/cpp/src/arrow/io/test-common.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/test-common.h b/cpp/src/arrow/io/test-common.h
index 1954d47..f8fed88 100644
--- a/cpp/src/arrow/io/test-common.h
+++ b/cpp/src/arrow/io/test-common.h
@@ -24,6 +24,14 @@
 #include <string>
 #include <vector>
 
+#if defined(__MINGW32__)  // MinGW
+// nothing
+#elif defined(_MSC_VER)  // Visual Studio
+#include <io.h>
+#else  // POSIX / Linux
+// nothing
+#endif
+
 #include "arrow/io/memory.h"
 #include "arrow/test-util.h"
 #include "arrow/util/buffer.h"
@@ -43,7 +51,11 @@ class MemoryMapFixture {
   void CreateFile(const std::string path, int64_t size) {
     FILE* file = fopen(path.c_str(), "w");
     if (file != nullptr) { tmp_files_.push_back(path); }
+#ifdef _MSC_VER
+    _chsize(fileno(file), size);
+#else
     ftruncate(fileno(file), size);
+#endif
     fclose(file);
   }
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/86f56a60/cpp/src/arrow/test-util.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/test-util.h b/cpp/src/arrow/test-util.h
index ab4b980..93dd5b6 100644
--- a/cpp/src/arrow/test-util.h
+++ b/cpp/src/arrow/test-util.h
@@ -59,6 +59,14 @@
     EXPECT_TRUE(s.ok());        \
   } while (0)
 
+// Alias MSVC popcount to GCC name
+#ifdef _MSC_VER
+#  include <intrin.h>
+#  define __builtin_popcount __popcnt
+#  include <nmmintrin.h>
+#  define __builtin_popcountll _mm_popcnt_u64
+#endif
+
 namespace arrow {
 
 class TestBase : public ::testing::Test {

http://git-wip-us.apache.org/repos/asf/arrow/blob/86f56a60/cpp/src/arrow/type.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/type.h b/cpp/src/arrow/type.h
index 5b4d7bc..876d7ea 100644
--- a/cpp/src/arrow/type.h
+++ b/cpp/src/arrow/type.h
@@ -184,7 +184,7 @@ struct ARROW_EXPORT Field {
 };
 typedef std::shared_ptr<Field> FieldPtr;
 
-struct PrimitiveCType : public DataType {
+struct ARROW_EXPORT PrimitiveCType : public DataType {
   using DataType::DataType;
 };
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/86f56a60/cpp/src/arrow/util/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/CMakeLists.txt b/cpp/src/arrow/util/CMakeLists.txt
index fd23c1a..6e19730 100644
--- a/cpp/src/arrow/util/CMakeLists.txt
+++ b/cpp/src/arrow/util/CMakeLists.txt
@@ -40,17 +40,20 @@ if (ARROW_BUILD_TESTS)
 	test_main.cc)
 
   if (APPLE)
-	target_link_libraries(arrow_test_main
-      gtest
-      dl)
-	set_target_properties(arrow_test_main
-      PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
+	  target_link_libraries(arrow_test_main
+        gtest
+        dl)
+	  set_target_properties(arrow_test_main
+        PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
+  elseif(MSVC)
+	  target_link_libraries(arrow_test_main
+        gtest)
   else()
-	target_link_libraries(arrow_test_main
-      gtest
-      pthread
-      dl
-	  )
+	  target_link_libraries(arrow_test_main
+        gtest
+        pthread
+        dl
+	    )
   endif()
 endif()
 
@@ -71,4 +74,4 @@ endif()
 ADD_ARROW_TEST(bit-util-test)
 ADD_ARROW_TEST(buffer-test)
 ADD_ARROW_TEST(memory-pool-test)
-ADD_ARROW_TEST(status-test)
\ No newline at end of file
+ADD_ARROW_TEST(status-test)

http://git-wip-us.apache.org/repos/asf/arrow/blob/86f56a60/cpp/src/arrow/util/buffer.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/buffer.h b/cpp/src/arrow/util/buffer.h
index 04ad6c2..330e15f 100644
--- a/cpp/src/arrow/util/buffer.h
+++ b/cpp/src/arrow/util/buffer.h
@@ -103,7 +103,7 @@ class ARROW_EXPORT Buffer : public std::enable_shared_from_this<Buffer>
{
 
 // Construct a view on passed buffer at the indicated offset and length. This
 // function cannot fail and does not error checking (except in debug builds)
-std::shared_ptr<Buffer> SliceBuffer(
+ARROW_EXPORT std::shared_ptr<Buffer> SliceBuffer(
     const std::shared_ptr<Buffer>& buffer, int64_t offset, int64_t length);
 
 // A Buffer whose contents can be mutated. May or may not own its data.
@@ -154,7 +154,7 @@ class ARROW_EXPORT PoolBuffer : public ResizableBuffer {
   MemoryPool* pool_;
 };
 
-class BufferBuilder {
+class ARROW_EXPORT BufferBuilder {
  public:
   explicit BufferBuilder(MemoryPool* pool)
       : pool_(pool), data_(nullptr), capacity_(0), size_(0) {}

http://git-wip-us.apache.org/repos/asf/arrow/blob/86f56a60/cpp/src/arrow/util/memory-pool.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/memory-pool.cc b/cpp/src/arrow/util/memory-pool.cc
index 9f83afe..9aa7066 100644
--- a/cpp/src/arrow/util/memory-pool.cc
+++ b/cpp/src/arrow/util/memory-pool.cc
@@ -33,6 +33,15 @@ namespace {
 Status AllocateAligned(int64_t size, uint8_t** out) {
   // TODO(emkornfield) find something compatible with windows
   constexpr size_t kAlignment = 64;
+#ifdef _MSC_VER
+  // Special code path for MSVC
+  *out = reinterpret_cast<uint8_t*>(_aligned_malloc(size, kAlignment));
+  if (!*out) {
+    std::stringstream ss;
+    ss << "malloc of size " << size << " failed";
+    return Status::OutOfMemory(ss.str());
+  }
+#else
   const int result = posix_memalign(reinterpret_cast<void**>(out), kAlignment, size);
   if (result == ENOMEM) {
     std::stringstream ss;
@@ -45,6 +54,7 @@ Status AllocateAligned(int64_t size, uint8_t** out) {
     ss << "invalid alignment parameter: " << kAlignment;
     return Status::Invalid(ss.str());
   }
+#endif
   return Status::OK();
 }
 }  // namespace
@@ -83,7 +93,11 @@ int64_t InternalMemoryPool::bytes_allocated() const {
 void InternalMemoryPool::Free(uint8_t* buffer, int64_t size) {
   std::lock_guard<std::mutex> guard(pool_lock_);
   DCHECK_GE(bytes_allocated_, size);
+#ifdef _MSC_VER
+  _aligned_free(buffer);
+#else
   std::free(buffer);
+#endif
   bytes_allocated_ -= size;
 }
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/86f56a60/cpp/src/arrow/util/visibility.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/visibility.h b/cpp/src/arrow/util/visibility.h
index b197c19..9321cc5 100644
--- a/cpp/src/arrow/util/visibility.h
+++ b/cpp/src/arrow/util/visibility.h
@@ -20,6 +20,7 @@
 
 #if defined(_WIN32) || defined(__CYGWIN__)
 #define ARROW_EXPORT __declspec(dllexport)
+#define ARROW_NO_EXPORT
 #else  // Not Windows
 #ifndef ARROW_EXPORT
 #define ARROW_EXPORT __attribute__((visibility("default")))


Mime
View raw message