[x265-commits] [x265] cmake: backout cmake_policy(); cmake is idiotic
Steve Borho
steve at borho.org
Fri Nov 22 07:18:22 CET 2013
details: http://hg.videolan.org/x265/rev/830deb5fb3d3
branches:
changeset: 5257:830deb5fb3d3
user: Steve Borho <steve at borho.org>
date: Fri Nov 22 00:17:04 2013 -0600
description:
cmake: backout cmake_policy(); cmake is idiotic
Why would you issue an error if your version of cmake doesn't know about the
given policy? Especially if the selected policy is OLD? Hello??
Subject: [x265] cpu: fix non-Windows build with ASM disabled
details: http://hg.videolan.org/x265/rev/5009254d3d3a
branches:
changeset: 5258:5009254d3d3a
user: Steve Borho <steve at borho.org>
date: Fri Nov 22 00:17:46 2013 -0600
description:
cpu: fix non-Windows build with ASM disabled
diffstat:
source/CMakeLists.txt | 1 -
source/common/cpu.cpp | 28 ++++++++++++++++++++--------
2 files changed, 20 insertions(+), 9 deletions(-)
diffs (77 lines):
diff -r f4e10e4d3f0d -r 5009254d3d3a source/CMakeLists.txt
--- a/source/CMakeLists.txt Thu Nov 21 18:03:46 2013 -0600
+++ b/source/CMakeLists.txt Fri Nov 22 00:17:46 2013 -0600
@@ -5,7 +5,6 @@ if(NOT CMAKE_BUILD_TYPE)
"Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif()
-cmake_policy(SET CMP0025 OLD) # CMAKE_CXX_COMPILER_ID is Clang on Mac OS X (not AppleClang)
project (x265)
cmake_minimum_required (VERSION 2.8.8) # OBJECT libraries require 2.8.8
diff -r f4e10e4d3f0d -r 5009254d3d3a source/common/cpu.cpp
--- a/source/common/cpu.cpp Thu Nov 21 18:03:46 2013 -0600
+++ b/source/common/cpu.cpp Fri Nov 22 00:17:46 2013 -0600
@@ -291,13 +291,28 @@ uint32_t cpu_detect(void)
}
#if !ENABLE_ASM_PRIMITIVES
+
+#if defined(_MSC_VER)
#include <intrin.h>
+#endif
+
extern "C" {
int x265_cpu_cpuid_test(void)
{
return 0;
}
+#if defined(_MSC_VER)
+#pragma warning(disable: 4100)
+#elif defined(__GNUC__) || defined(__clang__) // use inline assembly, Gnu/AT&T syntax
+#define __cpuidex(regsArray, level, index)\
+ __asm__ __volatile__ ("cpuid"\
+ : "=a" ((regsArray)[0]), "=b" ((regsArray)[1]), "=c" ((regsArray)[2]), "=d" ((regsArray)[3])\
+ : "0" (level), "2" (index));
+#else
+#error "compiler not supported"
+#endif
+
void x265_cpu_cpuid(uint32_t op, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)
{
int output[4];
@@ -309,28 +324,25 @@ void x265_cpu_cpuid(uint32_t op, uint32_
*edx = output[3];
}
-#if defined(_MSC_VER)
-#pragma warning(disable: 4100)
-#endif
void x265_cpu_xgetbv(uint32_t op, uint32_t *eax, uint32_t *edx)
{
+ uint64_t out = 0;
+
#if (defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 160040000) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 1200)
// MSVC 2010 SP1 or later, or similar Intel release
- uint64_t out = _xgetbv(op);
+ out = _xgetbv(op);
-#elif defined(__GNUC__) // use inline assembly, Gnu/AT&T syntax
+#elif defined(__GNUC__) || defined(__clang__) // use inline assembly, Gnu/AT&T syntax
uint32_t a, d;
- __asm("xgetbv" : "=a" (a), "=d" (d) : "c" (ctr) :);
+ __asm("xgetbv" : "=a" (a), "=d" (d) : "c" (op) :);
*eax = a;
*edx = d;
return;
#elif defined(_WIN64) // On x64 with older compilers, this is impossible
- uint64_t out = 0;
-
#endif // if (defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 160040000) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 1200)
*eax = (uint32_t)out;
More information about the x265-commits
mailing list