[Bf-blender-cvs] [10f354c4b44] temp-remove-mingw: MinGW: From review: revert edits to Cycles, Libmv, FindGflags
Aaron Carlisle
noreply at git.blender.org
Tue Apr 25 20:30:56 CEST 2017
Commit: 10f354c4b44aa64eff2e456c506d914f19c1001c
Author: Aaron Carlisle
Date: Tue Apr 25 13:58:45 2017 -0400
Branches: temp-remove-mingw
https://developer.blender.org/rB10f354c4b44aa64eff2e456c506d914f19c1001c
MinGW: From review: revert edits to Cycles, Libmv, FindGflags
===================================================================
M build_files/cmake/Modules/FindGflags.cmake
M intern/cycles/util/util_aligned_malloc.cpp
M intern/cycles/util/util_optimization.h
M intern/cycles/util/util_path.cpp
M intern/cycles/util/util_simd.h
M intern/cycles/util/util_system.cpp
M intern/cycles/util/util_types.h
M intern/libmv/libmv/base/aligned_malloc.cc
M intern/libmv/libmv/numeric/numeric.h
===================================================================
diff --git a/build_files/cmake/Modules/FindGflags.cmake b/build_files/cmake/Modules/FindGflags.cmake
index 4766dfb0f9b..0a138c02465 100644
--- a/build_files/cmake/Modules/FindGflags.cmake
+++ b/build_files/cmake/Modules/FindGflags.cmake
@@ -496,7 +496,8 @@ if(NOT GFLAGS_FOUND)
# detect threads, we assume that gflags requires it.
find_package(Threads QUIET)
set(GFLAGS_LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
- # On Windows, the Shlwapi library is used by gflags if available.
+ # On Windows (including MinGW), the Shlwapi library is used by gflags if
+ # available.
if(WIN32)
include(CheckIncludeFileCXX)
check_include_file_cxx("shlwapi.h" HAVE_SHLWAPI)
diff --git a/intern/cycles/util/util_aligned_malloc.cpp b/intern/cycles/util/util_aligned_malloc.cpp
index 78669a17c72..cc7252dcc58 100644
--- a/intern/cycles/util/util_aligned_malloc.cpp
+++ b/intern/cycles/util/util_aligned_malloc.cpp
@@ -23,6 +23,13 @@
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
/* Needed for memalign on Linux and _aligned_alloc on Windows. */
+# ifdef FREE_WINDOWS
+/* Make sure _aligned_malloc is included. */
+# ifdef __MSVCRT_VERSION__
+# undef __MSVCRT_VERSION__
+# endif
+# define __MSVCRT_VERSION__ 0x0700
+# endif /* FREE_WINDOWS */
# include <malloc.h>
#else
/* Apple's malloc is 16-byte aligned, and does not have malloc.h, so include
diff --git a/intern/cycles/util/util_optimization.h b/intern/cycles/util/util_optimization.h
index d441198cb2b..6f70a474fe7 100644
--- a/intern/cycles/util/util_optimization.h
+++ b/intern/cycles/util/util_optimization.h
@@ -99,6 +99,7 @@
* We assume __KERNEL_SSEX__ flags to have been defined at this point */
/* SSE intrinsics headers */
+#ifndef FREE_WINDOWS64
#ifdef _MSC_VER
# include <intrin.h>
@@ -106,6 +107,14 @@
# include <x86intrin.h>
#endif
+#else
+
+/* MinGW64 has conflicting declarations for these SSE headers in <windows.h>.
+ * Since we can't avoid including <windows.h>, better only include that */
+#include "util/util_windows.h"
+
+#endif
+
#endif
#endif /* __UTIL_OPTIMIZATION_H__ */
diff --git a/intern/cycles/util/util_path.cpp b/intern/cycles/util/util_path.cpp
index b0d46d39b50..cd3067f7650 100644
--- a/intern/cycles/util/util_path.cpp
+++ b/intern/cycles/util/util_path.cpp
@@ -50,8 +50,10 @@ OIIO_NAMESPACE_USING
CCL_NAMESPACE_BEGIN
#ifdef _WIN32
-# if defined(_MSC_VER)
+# if defined(_MSC_VER) || defined(__MINGW64__)
typedef struct _stat64 path_stat_t;
+# elif defined(__MINGW32__)
+typedef struct _stati64 path_stat_t;
# else
typedef struct _stat path_stat_t;
# endif
@@ -566,8 +568,10 @@ static string path_make_compatible(const string& path)
static int path_wstat(const wstring& path_wc, path_stat_t *st)
{
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) || defined(__MINGW64__)
return _wstat64(path_wc.c_str(), st);
+#elif defined(__MINGW32__)
+ return _wstati64(path_wc.c_str(), st);
#else
return _wstat(path_wc.c_str(), st);
#endif
diff --git a/intern/cycles/util/util_simd.h b/intern/cycles/util/util_simd.h
index 69dbc2ed86d..557809a5719 100644
--- a/intern/cycles/util/util_simd.h
+++ b/intern/cycles/util/util_simd.h
@@ -71,7 +71,7 @@ __forceinline operator int ( ) const { return std::numeric_limits<
#define _lzcnt_u64 __lzcnt64
#endif
-#if defined(_WIN32) && !defined(__clang__)
+#if defined(_WIN32) && !defined(__MINGW32__) && !defined(__clang__)
__forceinline int __popcnt(int in) {
return _mm_popcnt_u32(in);
diff --git a/intern/cycles/util/util_system.cpp b/intern/cycles/util/util_system.cpp
index 9c993d6ba08..a942d738b8a 100644
--- a/intern/cycles/util/util_system.cpp
+++ b/intern/cycles/util/util_system.cpp
@@ -22,6 +22,9 @@
#include "util/util_string.h"
#ifdef _WIN32
+# if(!defined(FREE_WINDOWS))
+# include <intrin.h>
+# endif
# include "util_windows.h"
#elif defined(__APPLE__)
# include <sys/sysctl.h>
@@ -102,7 +105,7 @@ unsigned short system_cpu_process_groups(unsigned short max_groups,
#endif
}
-#if !defined(_WIN32)
+#if !defined(_WIN32) || defined(FREE_WINDOWS)
static void __cpuid(int data[4], int selector)
{
#ifdef __x86_64__
diff --git a/intern/cycles/util/util_types.h b/intern/cycles/util/util_types.h
index fe7b7f6b2b5..5a8f11694a7 100644
--- a/intern/cycles/util/util_types.h
+++ b/intern/cycles/util/util_types.h
@@ -43,7 +43,7 @@
#define ccl_restrict __restrict
#define __KERNEL_WITH_SSE_ALIGN__
-#if defined(_WIN32)
+#if defined(_WIN32) && !defined(FREE_WINDOWS)
#define ccl_device_inline static __forceinline
#define ccl_device_forceinline static __forceinline
#define ccl_align(...) __declspec(align(__VA_ARGS__))
@@ -63,6 +63,9 @@
#define ccl_device_inline static inline __attribute__((always_inline))
#define ccl_device_forceinline static inline __attribute__((always_inline))
#define ccl_align(...) __attribute__((aligned(__VA_ARGS__)))
+#ifndef FREE_WINDOWS64
+#define __forceinline inline __attribute__((always_inline))
+#endif
#define ccl_try_align(...) __attribute__((aligned(__VA_ARGS__)))
#define ccl_may_alias __attribute__((__may_alias__))
#define ccl_always_inline __attribute__((always_inline))
diff --git a/intern/libmv/libmv/base/aligned_malloc.cc b/intern/libmv/libmv/base/aligned_malloc.cc
index 7a3231da9ac..cc0a5fbbba7 100644
--- a/intern/libmv/libmv/base/aligned_malloc.cc
+++ b/intern/libmv/libmv/base/aligned_malloc.cc
@@ -23,6 +23,14 @@
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
// Needed for memalign on Linux and _aligned_alloc on Windows.
+# ifdef FREE_WINDOWS
+/* make sure _aligned_malloc is included */
+# ifdef __MSVCRT_VERSION__
+# undef __MSVCRT_VERSION__
+# endif
+
+# define __MSVCRT_VERSION__ 0x0700
+# endif // FREE_WINDOWS
# include <malloc.h>
#else
diff --git a/intern/libmv/libmv/numeric/numeric.h b/intern/libmv/libmv/numeric/numeric.h
index 98e4cd97a46..1a23d653676 100644
--- a/intern/libmv/libmv/numeric/numeric.h
+++ b/intern/libmv/libmv/numeric/numeric.h
@@ -33,15 +33,17 @@
#include <Eigen/QR>
#include <Eigen/SVD>
-#if defined(_WIN32) || defined(__APPLE__) || \
- defined(__FreeBSD__) || defined(__NetBSD__)
+#if !defined(__MINGW64__)
+# if defined(_WIN32) || defined(__APPLE__) || \
+ defined(__FreeBSD__) || defined(__NetBSD__)
inline void sincos(double x, double *sinx, double *cosx) {
*sinx = sin(x);
*cosx = cos(x);
}
# endif
+#endif // !__MINGW64__
-#if (defined(WIN32) || defined(WIN64))
+#if (defined(WIN32) || defined(WIN64)) && !defined(__MINGW32__)
inline long lround(double d) {
return (long)(d>0 ? d+0.5 : ceil(d-0.5));
}
More information about the Bf-blender-cvs
mailing list