aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFanbo Meng <fanbo.meng@ibm.com>2020-10-21 11:39:54 -0400
committerGitHub <noreply@github.com>2020-10-21 16:39:54 +0100
commitdce3322a549650d18f50b5f1428a5942327ab6a5 (patch)
treeb18a3fa8368f13f71f9bb804f24e30168c23cdb5
parent3d1c2677686718d906f28c1d4da001c42666e6d2 (diff)
downloadgoogle-benchmark-dce3322a549650d18f50b5f1428a5942327ab6a5.tar.gz
Add support for z/OS XL compiler inline asm syntax (#1063)
On s390 architecture, z/OS XL compiler uses HLASM inline assembly, which has different syntax and needs to be distinguished to avoid compilation error.
-rw-r--r--CONTRIBUTORS1
-rw-r--r--src/cycleclock.h5
-rw-r--r--src/internal_macros.h8
3 files changed, 13 insertions, 1 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 7071d7b..d2f6435 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -41,6 +41,7 @@ Eric Backus <eric_backus@alum.mit.edu>
Eric Fiselier <eric@efcs.ca>
Eugene Zhuk <eugene.zhuk@gmail.com>
Evgeny Safronov <division494@gmail.com>
+Fanbo Meng <fanbo.meng@ibm.com>
Federico Ficarelli <federico.ficarelli@gmail.com>
Felix Homann <linuxaudio@showlabor.de>
Geoffrey Martin-Noble <gcmn@google.com> <gmngeoffrey@gmail.com>
diff --git a/src/cycleclock.h b/src/cycleclock.h
index 93d579a..77be7b9 100644
--- a/src/cycleclock.h
+++ b/src/cycleclock.h
@@ -170,7 +170,12 @@ inline BENCHMARK_ALWAYS_INLINE int64_t Now() {
#elif defined(__s390__) // Covers both s390 and s390x.
// Return the CPU clock.
uint64_t tsc;
+#if defined(BENCHMARK_OS_ZOS) && defined(COMPILER_IBMXL)
+ // z/OS XL compiler HLASM syntax.
+ asm(" stck %0" : "=m"(tsc) : : "cc");
+#else
asm("stck %0" : "=Q"(tsc) : : "cc");
+#endif
return tsc;
#elif defined(__riscv) // RISC-V
// Use RDCYCLE (and RDCYCLEH on riscv32)
diff --git a/src/internal_macros.h b/src/internal_macros.h
index 889b353..91f367b 100644
--- a/src/internal_macros.h
+++ b/src/internal_macros.h
@@ -13,7 +13,11 @@
#endif
#if defined(__clang__)
- #if !defined(COMPILER_CLANG)
+ #if defined(__ibmxl__)
+ #if !defined(COMPILER_IBMXL)
+ #define COMPILER_IBMXL
+ #endif
+ #elif !defined(COMPILER_CLANG)
#define COMPILER_CLANG
#endif
#elif defined(_MSC_VER)
@@ -74,6 +78,8 @@
#define BENCHMARK_OS_SOLARIS 1
#elif defined(__QNX__)
#define BENCHMARK_OS_QNX 1
+#elif defined(__MVS__)
+#define BENCHMARK_OS_ZOS 1
#endif
#if defined(__ANDROID__) && defined(__GLIBCXX__)