This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix asm constraints in HP_TIMING_ACCUM (take 2)


Hi!

The testcase newly added in #789 showed further problems.
__newval >> 32 as well as __newval & 0xffffffff are long long, so must be
cast to some 32-bit type.
On x86-64, we know that (Diff) - GLRO(dl_hp_timing_overhead) is not an
immediate, so don't need to put that as constraint.

2005-03-15  Jakub Jelinek  <jakub@redhat.com>

	[BZ #789]
	* sysdeps/i386/i686/hp-timing.h (HP_TIMING_ACCUM): Fix asm constraints.

	* sysdeps/x86_64/hp-timing.h (HP_TIMING_ACCUM): Make the addition
	thread-safe.  Subtract GLRO(dl_hp_timing_overhead) from Diff.

--- libc/sysdeps/i386/i686/hp-timing.h.jj	2004-03-08 12:01:51.000000000 +0100
+++ libc/sysdeps/i386/i686/hp-timing.h	2005-03-15 10:29:19.826506997 +0100
@@ -1,5 +1,5 @@
 /* High precision, low overhead timing functions.  i686 version.
-   Copyright (C) 1998, 2002, 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
 
@@ -133,9 +133,9 @@ typedef unsigned long long int hp_timing
 			      : "=q" (__not_done), "=m" (Sum),		      \
 				"=A" (__oldval), "=c" (__temp0),	      \
 				"=SD" (__temp1)				      \
-			      : "1" (Sum), "2" (__oldval),		      \
-				"3" (__newval >> 32),			      \
-				"4" (__newval & 0xffffffff)		      \
+			      : "m" (Sum), "2" (__oldval),		      \
+				"3" ((unsigned int) (__newval >> 32)),	      \
+				"4" ((unsigned int) __newval)		      \
 			      : "memory");				      \
       }									      \
     while (__not_done);							      \
--- libc/sysdeps/x86_64/hp-timing.h.jj	2004-03-23 15:51:54.000000000 +0100
+++ libc/sysdeps/x86_64/hp-timing.h	2005-03-14 16:09:22.000000000 +0100
@@ -1,5 +1,5 @@
 /* High precision, low overhead timing functions.  x86-64 version.
-   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -31,7 +31,11 @@
 
 /* The funny business for 32-bit mode is not required here.  */
 # undef HP_TIMING_ACCUM
-# define HP_TIMING_ACCUM(Sum, Diff) ((Sum) += (Diff))
-
+# define HP_TIMING_ACCUM(Sum, Diff) \
+  do {									      \
+    hp_timing_t __diff = (Diff) - GLRO(dl_hp_timing_overhead);		      \
+    __asm__ __volatile__ ("lock; addq %1, %0"				      \
+			  : "=m" (Sum) : "r" (__diff), "m" (Sum) : "memory"); \
+  } while (0)
 
 #endif /* hp-timing.h */

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]