This is the mail archive of the libc-alpha@sourceware.org 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] Add sysdeps/x86/i686


There are very few differences between 32-bit and 64-bit verions of
cacheinfo.c and hp-timing.[ch].  This patch adds sysdeps/x86/i686 for
cacheinfo.c and hp-timing.[ch].   Tested on i686 and x86-64.  OK to
install?

Thanks.


H.J.
---
 sysdeps/i386/i686/Implies                |  1 +
 sysdeps/i386/i686/Makefile               |  9 -------
 sysdeps/i386/i686/cacheinfo.c            |  2 +-
 sysdeps/x86/i686/Makefile                |  8 +++++++
 sysdeps/{x86_64 => x86/i686}/cacheinfo.c |  0
 sysdeps/{i386 => x86}/i686/hp-timing.c   |  0
 sysdeps/{i386 => x86}/i686/hp-timing.h   | 22 ++++++++++++++++--
 sysdeps/x86_64/Implies                   |  1 +
 sysdeps/x86_64/Makefile                  |  4 +---
 sysdeps/x86_64/hp-timing.c               |  2 --
 sysdeps/x86_64/hp-timing.h               | 40 --------------------------------
 sysdeps/x86_64/multiarch/cacheinfo.c     |  2 +-
 13 files changed, 53 insertions(+), 58 deletions(-)
 create mode 100644 ChangeLog.i686
 create mode 100644 sysdeps/x86/i686/Makefile
 rename sysdeps/{x86_64 => x86/i686}/cacheinfo.c (100%)
 rename sysdeps/{i386 => x86}/i686/hp-timing.c (100%)
 rename sysdeps/{i386 => x86}/i686/hp-timing.h (88%)
 delete mode 100644 sysdeps/x86_64/hp-timing.c
 delete mode 100644 sysdeps/x86_64/hp-timing.h

2013-01-05  H.J. Lu  <hongjiu.lu@intel.com>

	* sysdeps/i386/i686/Implies: Add x86/i686.
	* sysdeps/x86_64/Implies: Likewise.
	* sysdeps/i386/i686/Makefile (sysdep_routines): Don't add
	hp-timing nor cacheinfo.
	(elide-routines.os): Don't add hp-timing.
	* sysdeps/x86_64/Makefile: Likewise.
	* sysdeps/i386/i686/cacheinfo.c: Updated.
	* sysdeps/x86_64/multiarch/cacheinfo.c: Likewise.
	* sysdeps/i386/i686/hp-timing.c: Moved to ...
	* sysdeps/x86/i686/hp-timing.c: Here.
	* sysdeps/i386/i686/hp-timing.h: Moved to ...
	* sysdeps/x86/i686/hp-timing.h: Here.
	(HP_TIMING_NOW): Support x86-64.
	(HP_TIMING_ACCUM): Likewise.
	* sysdeps/x86/i686/Makefile: New file.
	* sysdeps/x86_64/cacheinfo.c: Removed.
	* sysdeps/x86_64/hp-timing.c: Likewise.
	* sysdeps/x86_64/hp-timing.h: Likewise.

diff --git a/sysdeps/i386/i686/Implies b/sysdeps/i386/i686/Implies
index e1fcccd..656cd9e 100644
--- a/sysdeps/i386/i686/Implies
+++ b/sysdeps/i386/i686/Implies
@@ -1,4 +1,5 @@
 # Due to the reordering and the other nifty extensions in the i686 it is
 # not really good to use heavily i586 optimized code on a i686.  It's
 # better to use i486/i386 code.
+x86/i686
 i386/i486
diff --git a/sysdeps/i386/i686/Makefile b/sysdeps/i386/i686/Makefile
index e6b2924..f10e368 100644
--- a/sysdeps/i386/i686/Makefile
+++ b/sysdeps/i386/i686/Makefile
@@ -1,15 +1,6 @@
-ifeq ($(subdir),csu)
-sysdep_routines += hp-timing
-elide-routines.os += hp-timing
-endif
-
 # So that we can test __m128's alignment
 stack-align-test-flags += -msse
 
-ifeq ($(subdir),string)
-sysdep_routines += cacheinfo
-endif
-
 ifeq (yes,$(config-asflags-i686))
 CFLAGS-.o += -Wa,-mtune=i686
 CFLAGS-.os += -Wa,-mtune=i686
diff --git a/sysdeps/i386/i686/cacheinfo.c b/sysdeps/i386/i686/cacheinfo.c
index 0f869df..dfee51a 100644
--- a/sysdeps/i386/i686/cacheinfo.c
+++ b/sysdeps/i386/i686/cacheinfo.c
@@ -1,4 +1,4 @@
 #define DISABLE_PREFETCHW
 #define DISABLE_PREFERRED_MEMORY_INSTRUCTION
 
-#include <sysdeps/x86_64/cacheinfo.c>
+#include <sysdeps/x86/i686/cacheinfo.c>
diff --git a/sysdeps/x86/i686/Makefile b/sysdeps/x86/i686/Makefile
new file mode 100644
index 0000000..0aabcc5
--- /dev/null
+++ b/sysdeps/x86/i686/Makefile
@@ -0,0 +1,8 @@
+ifeq ($(subdir),csu)
+sysdep_routines += hp-timing
+elide-routines.os += hp-timing
+endif
+
+ifeq ($(subdir),string)
+sysdep_routines += cacheinfo
+endif
diff --git a/sysdeps/x86_64/cacheinfo.c b/sysdeps/x86/i686/cacheinfo.c
similarity index 100%
rename from sysdeps/x86_64/cacheinfo.c
rename to sysdeps/x86/i686/cacheinfo.c
diff --git a/sysdeps/i386/i686/hp-timing.c b/sysdeps/x86/i686/hp-timing.c
similarity index 100%
rename from sysdeps/i386/i686/hp-timing.c
rename to sysdeps/x86/i686/hp-timing.c
diff --git a/sysdeps/i386/i686/hp-timing.h b/sysdeps/x86/i686/hp-timing.h
similarity index 88%
rename from sysdeps/i386/i686/hp-timing.h
rename to sysdeps/x86/i686/hp-timing.h
index 920d441..ba702d7 100644
--- a/sysdeps/i386/i686/hp-timing.h
+++ b/sysdeps/x86/i686/hp-timing.h
@@ -91,7 +91,15 @@ typedef unsigned long long int hp_timing_t;
    running in this moment.  This could be changed by using a barrier like
    'cpuid' right before the `rdtsc' instruciton.  But we are not interested
    in accurate clock cycles here so we don't do this.  */
-#define HP_TIMING_NOW(Var)	__asm__ __volatile__ ("rdtsc" : "=A" (Var))
+#ifdef __x86_64__
+/* The "=A" constraint used in 32-bit mode does not work in 64-bit mode.  */
+# define HP_TIMING_NOW(Var) \
+  ({ unsigned int _hi, _lo; \
+     asm volatile ("rdtsc" : "=a" (_lo), "=d" (_hi)); \
+     (Var) = ((unsigned long long int) _hi << 32) | _lo; })
+#else
+# define HP_TIMING_NOW(Var)	__asm__ __volatile__ ("rdtsc" : "=A" (Var))
+#endif
 
 /* Use two 'rdtsc' instructions in a row to find out how long it takes.  */
 #define HP_TIMING_DIFF_INIT() \
@@ -115,8 +123,17 @@ typedef unsigned long long int hp_timing_t;
 /* It's simple arithmetic for us.  */
 #define HP_TIMING_DIFF(Diff, Start, End)	(Diff) = ((End) - (Start))
 
+#ifdef __x86_64__
+/* The funny business for 32-bit mode is not required here.  */
+# 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));	      \
+  } while (0)
+#else
 /* We have to jump through hoops to get this correctly implemented.  */
-#define HP_TIMING_ACCUM(Sum, Diff) \
+# define HP_TIMING_ACCUM(Sum, Diff) \
   do {									      \
     int __not_done;							      \
     hp_timing_t __oldval = (Sum);					      \
@@ -137,6 +154,7 @@ typedef unsigned long long int hp_timing_t;
       }									      \
     while ((unsigned char) __not_done);					      \
   } while (0)
+#endif
 
 /* No threads, no extra work.  */
 #define HP_TIMING_ACCUM_NT(Sum, Diff)	(Sum) += (Diff)
diff --git a/sysdeps/x86_64/Implies b/sysdeps/x86_64/Implies
index 811c19a..fc0daf3 100644
--- a/sysdeps/x86_64/Implies
+++ b/sysdeps/x86_64/Implies
@@ -1,4 +1,5 @@
 x86
+x86/i686
 ieee754/ldbl-96
 ieee754/dbl-64/wordsize-64
 ieee754/dbl-64
diff --git a/sysdeps/x86_64/Makefile b/sysdeps/x86_64/Makefile
index 78c98e7..a5976ea 100644
--- a/sysdeps/x86_64/Makefile
+++ b/sysdeps/x86_64/Makefile
@@ -2,8 +2,6 @@
 long-double-fcts = yes
 
 ifeq ($(subdir),csu)
-sysdep_routines += hp-timing
-elide-routines.os += hp-timing
 gen-as-const-headers += link-defines.sym
 endif
 
@@ -16,7 +14,7 @@ tests += tst-mallocalign1
 endif
 
 ifeq ($(subdir),string)
-sysdep_routines += cacheinfo strcasecmp_l-nonascii strncase_l-nonascii
+sysdep_routines += strcasecmp_l-nonascii strncase_l-nonascii
 gen-as-const-headers += locale-defines.sym
 endif
 
diff --git a/sysdeps/x86_64/hp-timing.c b/sysdeps/x86_64/hp-timing.c
deleted file mode 100644
index 289ca4c..0000000
--- a/sysdeps/x86_64/hp-timing.c
+++ /dev/null
@@ -1,2 +0,0 @@
-/* We can use the i686 implementation without changes.  */
-#include <sysdeps/i386/i686/hp-timing.c>
diff --git a/sysdeps/x86_64/hp-timing.h b/sysdeps/x86_64/hp-timing.h
deleted file mode 100644
index 87dc0bb..0000000
--- a/sysdeps/x86_64/hp-timing.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* High precision, low overhead timing functions.  x86-64 version.
-   Copyright (C) 2002-2013 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
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#ifndef _HP_TIMING_H
-
-/* We can use some of the i686 implementation without changes.  */
-# include <sysdeps/i386/i686/hp-timing.h>
-
-/* The "=A" constraint used in 32-bit mode does not work in 64-bit mode.  */
-# undef HP_TIMING_NOW
-# define HP_TIMING_NOW(Var) \
-  ({ unsigned int _hi, _lo; \
-     asm volatile ("rdtsc" : "=a" (_lo), "=d" (_hi)); \
-     (Var) = ((unsigned long long int) _hi << 32) | _lo; })
-
-/* The funny business for 32-bit mode is not required here.  */
-# undef HP_TIMING_ACCUM
-# 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));	      \
-  } while (0)
-
-#endif /* hp-timing.h */
diff --git a/sysdeps/x86_64/multiarch/cacheinfo.c b/sysdeps/x86_64/multiarch/cacheinfo.c
index f87b8dc..f6cd3e4 100644
--- a/sysdeps/x86_64/multiarch/cacheinfo.c
+++ b/sysdeps/x86_64/multiarch/cacheinfo.c
@@ -1,2 +1,2 @@
 #define DISABLE_PREFERRED_MEMORY_INSTRUCTION
-#include "../cacheinfo.c"
+#include <sysdeps/x86/i686/cacheinfo.c>
-- 
1.7.11.7


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