Blame SOURCES/mysql-s390-tsc.patch

4522a4
Support s390/s390x in performance schema's cycle-counting functions.
4522a4
Filed upstream at http://bugs.mysql.com/bug.php?id=59953
4522a4
4522a4
diff --git a/include/my_rdtsc.h b/include/my_rdtsc.h
4522a4
index 65f7df19..a28f470c 100644
4522a4
--- a/include/my_rdtsc.h
4522a4
+++ b/include/my_rdtsc.h
4522a4
@@ -128,5 +128,6 @@ void my_timer_init(MY_TIMER_INFO *mti);
4522a4
 #define MY_TIMER_ROUTINE_GETSYSTEMTIMEASFILETIME 26
4522a4
 #define MY_TIMER_ROUTINE_ASM_SUNPRO_X86_64 27
4522a4
 #define MY_TIMER_ROUTINE_ASM_AARCH64 28
4522a4
+#define MY_TIMER_ROUTINE_ASM_S390 29
4522a4
 
4522a4
 #endif
4522a4
diff --git a/mysys/my_rdtsc.cc b/mysys/my_rdtsc.cc
4522a4
index 54d19691..f18c182f 100644
4522a4
--- a/mysys/my_rdtsc.cc
4522a4
+++ b/mysys/my_rdtsc.cc
4522a4
@@ -204,6 +204,13 @@ ulonglong my_timer_cycles(void) {
4522a4
     __asm __volatile__("mrs %[rt],cntvct_el0" : [ rt ] "=r"(result));
4522a4
     return result;
4522a4
   }
4522a4
+#elif defined(__GNUC__) && defined(__s390__)
4522a4
+  /* covers both s390 and s390x */
4522a4
+  {
4522a4
+    ulonglong result;
4522a4
+    __asm__ __volatile__ ("stck %0" : "=Q" (result) : : "cc");
4522a4
+   return result;
4522a4
+  }
4522a4
 #elif defined(HAVE_SYS_TIMES_H) && defined(HAVE_GETHRTIME)
4522a4
   /* gethrtime may appear as either cycle or nanosecond counter */
4522a4
   return (ulonglong)gethrtime();
4522a4
@@ -505,6 +512,8 @@ void my_timer_init(MY_TIMER_INFO *mti) {
4522a4
   mti->cycles.routine = MY_TIMER_ROUTINE_ASM_GCC_SPARC32;
4522a4
 #elif defined(__GNUC__) && defined(__aarch64__)
4522a4
   mti->cycles.routine = MY_TIMER_ROUTINE_ASM_AARCH64;
4522a4
+#elif defined(__GNUC__) && defined(__s390__)
4522a4
+  mti->cycles.routine = MY_TIMER_ROUTINE_ASM_S390;
4522a4
 #elif defined(HAVE_SYS_TIMES_H) && defined(HAVE_GETHRTIME)
4522a4
   mti->cycles.routine = MY_TIMER_ROUTINE_GETHRTIME;
4522a4
 #else