From dce3322a549650d18f50b5f1428a5942327ab6a5 Mon Sep 17 00:00:00 2001 From: Fanbo Meng Date: Wed, 21 Oct 2020 11:39:54 -0400 Subject: [PATCH] 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. --- CONTRIBUTORS | 1 + src/cycleclock.h | 5 +++++ src/internal_macros.h | 8 +++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 7071d7bf..d2f64356 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -41,6 +41,7 @@ Eric Backus Eric Fiselier Eugene Zhuk Evgeny Safronov +Fanbo Meng Federico Ficarelli Felix Homann Geoffrey Martin-Noble diff --git a/src/cycleclock.h b/src/cycleclock.h index 93d579a7..77be7b92 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 889b3537..91f367b8 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__)