This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
[PATCH] Fix asm constraints in HP_TIMING_ACCUM
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Ulrich Drepper <drepper at redhat dot com>, Roland McGrath <roland at redhat dot com>
- Cc: libc-alpha at sources dot redhat dot com
- Date: Mon, 14 Mar 2005 10:14:36 -0500
- Subject: [PATCH] Fix asm constraints in HP_TIMING_ACCUM
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
glibc doesn't use HP_TIMING_ACCUM, but as long as the macros are there,
they should be correct. Using matching "1" constraint for "=m" is wrong,
plus x86-64 was not thread safe and was not subtracting timing overhead
like all other implementations did.
2005-03-14 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-14 15:49:57.959331067 +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,7 +133,7 @@ typedef unsigned long long int hp_timing
: "=q" (__not_done), "=m" (Sum), \
"=A" (__oldval), "=c" (__temp0), \
"=SD" (__temp1) \
- : "1" (Sum), "2" (__oldval), \
+ : "m" (Sum), "2" (__oldval), \
"3" (__newval >> 32), \
"4" (__newval & 0xffffffff) \
: "memory"); \
--- 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.708695570 +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 %q1, %0" \
+ : "=m" (Sum) : "ir" (__diff), "m" (Sum) : "memory");\
+ } while (0)
#endif /* hp-timing.h */
Jakub