This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Define HAS_CPUID/HAS_I586/HAS_I686 from -march=
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: GNU C Library <libc-alpha at sourceware dot org>
- Date: Wed, 19 Aug 2015 04:21:48 -0700
- Subject: Re: [PATCH] Define HAS_CPUID/HAS_I586/HAS_I686 from -march=
- Authentication-results: sourceware.org; auth=none
- References: <20150817231005 dot GA24205 at intel dot com> <20150818143258 dot GM1584 at vapier> <CAMe9rOov73oYeEtXF3OjK62xmRcm60ptU_LRo99=40OrUwhrWw at mail dot gmail dot com> <20150818160232 dot GN1584 at vapier> <CAMe9rOq52Vu1M7Z1kLA6qJBoHFSN9Vu9fmF7SHZTXjOXv+6reA at mail dot gmail dot com> <20150819031041 dot GT1584 at vapier>
On Tue, Aug 18, 2015 at 8:10 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On 18 Aug 2015 09:08, H.J. Lu wrote:
>> On Tue, Aug 18, 2015 at 9:02 AM, Mike Frysinger wrote:
>> > On 18 Aug 2015 07:56, H.J. Lu wrote:
>> >> On Tue, Aug 18, 2015 at 7:32 AM, Mike Frysinger wrote:
>> >> > On 17 Aug 2015 16:10, H.J. Lu wrote:
>> >> >> +#ifdef __x86_64__
>> >> >> +# define HAS_CPUID 1
>> >> >> +#elif defined __pentium__
>> >> >> +# define HAS_CPUID 1
>> >> >> +# define HAS_I586 1
>> >> >> +# define HAS_I686 0
>> >> >> +#elif (defined __pentiumpro__ || defined __pentium4__ \
>> >> >> + || defined __nocona__ || defined __atom__ \
>> >> >> + || defined __core2__ || defined __corei7__ \
>> >> >> + || defined __corei7_avx__ || defined __core_avx2__ \
>> >> >> + || defined __nehalem__ || defined __sandybridge__ \
>> >> >> + || defined __haswell__ || defined __knl__ \
>> >> >> + || defined __bonnell__ || defined __silvermont__ \
>> >> >> + || defined __k6__ || defined __k8__ \
>> >> >> + || defined __athlon__ || defined __amdfam10__ \
>> >> >> + || defined __bdver1__ || defined __bdver2__ \
>> >> >> + || defined __bdver3__ || defined __bdver4__ \
>> >> >> + || defined __btver1__ || defined __btver2__)
>> >> >> +# define HAS_CPUID 1
>> >> >> +# define HAS_I586 1
>> >> >> +# define HAS_I686 1
>> >> >> +#else
>> >> >> +# define HAS_CPUID 0
>> >> >> +# define HAS_I586 0
>> >> >> +# define HAS_I686 0
>> >> >> +#endif
>> >> >
>> >> > why is testing for __i686__ & __i586__ unacceptable ?
>> >>
>> >> -march=haswell doesn't define __i686__ since __i686__ is
>> >> mapped to -mach=i686.
>> >
>> > that's not entirely accurate. i did check before posting, but it looks like
>> > the first two entries do set up i586 and i686 correctly (and i stopped after
>> > spot checking the first two). so i guess change __pentium__ to __i586__ and
>> > __pentiumpro__ to __i686__ ?
>>
>> My change is based on sysdeps/x86/bits/string.h and
>> sysdeps/x86/bits/byteswap.h. None of them check
>> __i586__ nor __i686__.
>
> i'm aware of the provenance. that's not a reason to not improve things :).
> -mike
This is what I checked in.
--
H.J.From 477fa2c8433218ab84625e61932228781125ba54 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Wed, 19 Aug 2015 04:19:58 -0700
Subject: [PATCH] Also check __i586__/__i686__ for HAS_I586/HAS_I686
* sysdeps/x86/cpu-features.h (HAS_I586): Defined to 1 if
__i586__ is defined.
(HAS_I686): Defined to 1 if __i686__ is defined.
---
ChangeLog | 6 ++++++
sysdeps/x86/cpu-features.h | 17 +++++++++--------
2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 7b8181e..962794a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-08-10 H.J. Lu <hongjiu.lu@intel.com>
+
+ * sysdeps/x86/cpu-features.h (HAS_I586): Defined to 1 if
+ __i586__ is defined.
+ (HAS_I686): Defined to 1 if __i686__ is defined.
+
2015-08-19 Joseph Myers <joseph@codesourcery.com>
* elf/Makefile [$(have-z-execstack) = yes]
diff --git a/sysdeps/x86/cpu-features.h b/sysdeps/x86/cpu-features.h
index 6b8299f..6e70624 100644
--- a/sysdeps/x86/cpu-features.h
+++ b/sysdeps/x86/cpu-features.h
@@ -239,17 +239,18 @@ extern const struct cpu_features
*__get_cpu_features (void)
#ifdef __x86_64__
# define HAS_CPUID 1
-#elif defined __pentium__
+#elif defined __i586__ || defined __pentium__
# define HAS_CPUID 1
# define HAS_I586 1
# define HAS_I686 0
-#elif (defined __pentiumpro__ || defined __pentium4__ \
- || defined __nocona__ || defined __atom__ \
- || defined __core2__ || defined __corei7__ \
- || defined __corei7_avx__ || defined __core_avx2__ \
- || defined __nehalem__ || defined __sandybridge__ \
- || defined __haswell__ || defined __knl__ \
- || defined __bonnell__ || defined __silvermont__ \
+#elif (defined __i686__ || defined __pentiumpro__ \
+ || defined __pentium4__ || defined __nocona__ \
+ || defined __atom__ || defined __core2__ \
+ || defined __corei7__ || defined __corei7_avx__ \
+ || defined __core_avx2__ || defined __nehalem__ \
+ || defined __sandybridge__ || defined __haswell__ \
+ || defined __knl__ || defined __bonnell__ \
+ || defined __silvermont__ \
|| defined __k6__ || defined __k8__ \
|| defined __athlon__ || defined __amdfam10__ \
|| defined __bdver1__ || defined __bdver2__ \
--
2.4.3
---