On Wed, Nov 05, 2014 at 11:31:28AM +0100, Dominik Vogt wrote:
> On Tue, Nov 04, 2014 at 02:39:34PM -0800, Ian Taylor wrote:
> > Note that libgo/runtime/runtime.c now refers to S390_HAVE_STCKF.  It's
> > not obvious to me that that is defined anywhere.  Perhaps it is in a
> > later patch in this series--I haven't looked.

The attached patch fixes this (by using stckf unconditionally).

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany
ChangeLog
2014-11-05  Dominik Vogt  <v...@linux.vnet.ibm.com>

        * libgo/runtime/runtime.c (runtime_cputicks): s390: use stckf
        unconditionally
>From 9b787b6190b5dd12e5be42e4c65a6907ca99bb59 Mon Sep 17 00:00:00 2001
From: Dominik Vogt <v...@linux.vnet.ibm.com>
Date: Wed, 5 Nov 2014 13:38:23 +0100
Subject: [PATCH 1/2] libgo: Use stckf unconditionally on s390[x].

---
 libgo/runtime/runtime.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libgo/runtime/runtime.c b/libgo/runtime/runtime.c
index abc1aff..496e77b 100644
--- a/libgo/runtime/runtime.c
+++ b/libgo/runtime/runtime.c
@@ -195,12 +195,12 @@ runtime_cputicks(void)
   asm("rdtsc" : "=a" (low), "=d" (high));
   return (int64)(((uint64)high << 32) | (uint64)low);
 #elif defined (__s390__) || defined (__s390x__)
-  uint64 clock;
-#ifdef S390_HAVE_STCKF
-  asm("stckf\t%0" : "=Q" (clock) : : );
-#else
-  clock = 0;
-#endif
+  uint64 clock = 0;
+  /* stckf may not write the return variable in case of a clock error, so make
+     it read-write to prevent that the initialisation is optimised out.
+     Note: Targets below z9-109 will crash when executing store clock fast, i.e.
+     we don't support Go for machines older than that.  */
+  asm volatile(".insn s,0xb27c0000,%0" /* stckf */ : "+Q" (clock) : : "cc" );
   return (int64)clock;
 #else
   // FIXME: implement for other processors.
-- 
1.8.4.2

Reply via email to