7a5573f
Support s390/s390x in performance schema's cycle-counting functions.
7a5573f
Filed upstream at http://bugs.mysql.com/bug.php?id=59953
7a5573f
a4a6473
diff --git a/include/my_rdtsc.h b/include/my_rdtsc.h
Lars Tangvald 8b3f2e1
index 6e378e94..7703cf85 100644
a4a6473
--- a/include/my_rdtsc.h
a4a6473
+++ b/include/my_rdtsc.h
Lars Tangvald 8b3f2e1
@@ -137,5 +137,6 @@ void my_timer_init(MY_TIMER_INFO *mti);
Lars Tangvald 1eedf72
 /* #define MY_TIMER_ROUTINE_ASM_SUNPRO_X86_64       27  - No longer used */
a4a6473
 #define MY_TIMER_ROUTINE_ASM_AARCH64 28
Lars Tangvald 8b3f2e1
 #define MY_TIMER_ROUTINE_GET_THREAD_TIMES 29
Lars Tangvald 8b3f2e1
+#define MY_TIMER_ROUTINE_ASM_S390 30
7a5573f
 
7a5573f
 #endif
a4a6473
diff --git a/mysys/my_rdtsc.cc b/mysys/my_rdtsc.cc
Lars Tangvald 8b3f2e1
index 3869db57..655a955e 100644
a4a6473
--- a/mysys/my_rdtsc.cc
a4a6473
+++ b/mysys/my_rdtsc.cc
Lars Tangvald 8b3f2e1
@@ -169,6 +169,13 @@ ulonglong my_timer_cycles(void) {
Lars Tangvald dbb00c9
     __asm __volatile__("mrs %[rt],cntvct_el0" : [ rt ] "=r"(result));
Jakub Dorňák bf0a83b
     return result;
7a5573f
   }
7a5573f
+#elif defined(__GNUC__) && defined(__s390__)
7a5573f
+  /* covers both s390 and s390x */
7a5573f
+  {
7a5573f
+    ulonglong result;
7a5573f
+    __asm__ __volatile__ ("stck %0" : "=Q" (result) : : "cc");
Jakub Dorňák bf0a83b
+   return result;
7a5573f
+  }
7a5573f
 #elif defined(HAVE_SYS_TIMES_H) && defined(HAVE_GETHRTIME)
7a5573f
   /* gethrtime may appear as either cycle or nanosecond counter */
a4a6473
   return (ulonglong)gethrtime();
Lars Tangvald 8b3f2e1
@@ -491,6 +498,8 @@ void my_timer_init(MY_TIMER_INFO *mti) {
Lars Tangvald 1eedf72
   mti->cycles.routine = MY_TIMER_ROUTINE_ASM_GCC_SPARC64;
Jakub Dorňák bf0a83b
 #elif defined(__GNUC__) && defined(__aarch64__)
a4a6473
   mti->cycles.routine = MY_TIMER_ROUTINE_ASM_AARCH64;
7a5573f
+#elif defined(__GNUC__) && defined(__s390__)
a4a6473
+  mti->cycles.routine = MY_TIMER_ROUTINE_ASM_S390;
7a5573f
 #elif defined(HAVE_SYS_TIMES_H) && defined(HAVE_GETHRTIME)
a4a6473
   mti->cycles.routine = MY_TIMER_ROUTINE_GETHRTIME;
7a5573f
 #else