diff --git a/src/cycle.h b/src/cycle.h
index 4925808f5a4c4ea7828bc1a6b7a9490d2d2ca255..f220ecd120b14db0a8cdaf5d1105be4bd0e70831 100644
--- a/src/cycle.h
+++ b/src/cycle.h
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2003, 2007-8 Matteo Frigo
- * Copyright (c) 2003, 2007-8 Massachusetts Institute of Technology
+ * Copyright (c) 2003, 2007-14 Matteo Frigo
+ * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
  *
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
@@ -179,14 +179,7 @@ INLINE_ELAPSED(__inline__)
     !defined(HAVE_TICK_COUNTER)
 typedef unsigned long long ticks;
 
-#ifndef INLINE
-#if __GNUC__ && !__GNUC_STDC_INLINE__
-#define INLINE extern inline
-#else
-#define INLINE inline
-#endif
-#endif
-INLINE static ticks getticks(void) {
+static __inline__ ticks getticks(void) {
   ticks ret;
 
   __asm__ __volatile__("rdtsc" : "=A"(ret));
@@ -210,8 +203,9 @@ static __inline ticks getticks(void) {
   ticks retval;
 
   __asm {
-    RDTSC
-    mov retval.HighPart, edx mov retval.LowPart, eax
+	  RDTSC
+	  mov retval.HighPart, edx
+	  mov retval.LowPart, eax
   }
   return retval;
 }
@@ -232,22 +226,16 @@ static __inline double elapsed(ticks t1, ticks t0) {
     defined(__x86_64__) && !defined(HAVE_TICK_COUNTER)
 typedef unsigned long long ticks;
 
-#ifndef INLINE
-#if __GNUC__ && !__GNUC_STDC_INLINE__
-#define INLINE extern inline
-#else
-#define INLINE inline
-#endif
-#endif
-INLINE static ticks getticks(void) {
+static __inline__ ticks getticks(void) {
   unsigned a, d;
-  asm volatile("rdtsc" : "=a"(a), "=d"(d));
+  __asm__ __volatile__("rdtsc" : "=a"(a), "=d"(d));
   return ((ticks)a) | (((ticks)d) << 32);
 }
 
 INLINE_ELAPSED(__inline__)
 
 #define HAVE_TICK_COUNTER
+#define TIME_MIN 5000.0
 #endif
 
 /* PGI compiler, courtesy Cristiano Calonaci, Andrea Tarsi, & Roberto Gori.
@@ -260,6 +248,7 @@ static ticks getticks(void) {
 }
 INLINE_ELAPSED(__inline__)
 #define HAVE_TICK_COUNTER
+#define TIME_MIN 5000.0
 #endif
 
 /* Visual C++, courtesy of Dirk Michaelis */
@@ -273,6 +262,7 @@ typedef unsigned __int64 ticks;
 INLINE_ELAPSED(__inline)
 
 #define HAVE_TICK_COUNTER
+#define TIME_MIN 5000.0
 #endif
 
 /*----------------------------------------------------------------*/
@@ -352,7 +342,7 @@ INLINE_ELAPSED(inline)
 /*
  * PA-RISC cycle counter
  */
-#if defined(__hppa__) || defined(__hppa) && !defined(HAVE_TICK_COUNTER)
+#if (defined(__hppa__) || defined(__hppa)) && !defined(HAVE_TICK_COUNTER)
 typedef unsigned long ticks;
 
 #ifdef __GNUC__
@@ -445,7 +435,7 @@ INLINE_ELAPSED(__inline)
 /*----------------------------------------------------------------*/
 /* SGI/Irix */
 #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_SGI_CYCLE) && \
-    !defined(HAVE_TICK_COUNTER)
+    !defined(HAVE_TICK_COUNTER) && !defined(__ANDROID__)
 typedef struct timespec ticks;
 
 static inline ticks getticks(void) {
@@ -517,3 +507,37 @@ INLINE_ELAPSED(inline)
 #define HAVE_TICK_COUNTER
 #endif
 #endif /* HAVE_MIPS_ZBUS_TIMER */
+
+#if defined(HAVE_ARMV7A_CNTVCT)
+typedef uint64_t ticks;
+static inline ticks getticks(void) {
+  uint32_t Rt, Rt2 = 0;
+  asm volatile("mrrc p15, 1, %0, %1, c14" : "=r"(Rt), "=r"(Rt2));
+  return ((uint64_t)Rt) | (((uint64_t)Rt2) << 32);
+}
+INLINE_ELAPSED(inline)
+#define HAVE_TICK_COUNTER
+#endif
+
+#if defined(__aarch64__) && defined(HAVE_ARMV8_CNTVCT_EL0) && \
+    !defined(HAVE_ARMV8CC)
+typedef uint64_t ticks;
+static inline ticks getticks(void) {
+  uint64_t Rt;
+  asm volatile("mrs %0,  CNTVCT_EL0" : "=r"(Rt));
+  return Rt;
+}
+INLINE_ELAPSED(inline)
+#define HAVE_TICK_COUNTER
+#endif
+
+#if defined(__aarch64__) && defined(HAVE_ARMV8CC)
+typedef uint64_t ticks;
+static inline ticks getticks(void) {
+  uint64_t cc = 0;
+  asm volatile("mrs %0, PMCCNTR_EL0" : "=r"(cc));
+  return cc;
+}
+INLINE_ELAPSED(inline)
+#define HAVE_TICK_COUNTER
+#endif