public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Nathan Phillips <waic9e@protonmail.com>
To: "libc-alpha@sourceware.org" <libc-alpha@sourceware.org>
Subject: [PATCH] powerpc: Expose VSX feature test
Date: Wed, 28 Mar 2018 08:20:00 -0000	[thread overview]
Message-ID: <klDQRjHsGNLyUfoTY_7IVfFKRRAhSEeHVIYr89lVsb-ufm0FM5_KS2Wok7jCSBaVZXDYTJFmlGNMT7uJxbt0dIyn3m2SLuzdyWsoALd0pi4=@protonmail.com> (raw)

Hope it's OK to submit a small change like this. Trying to familiarize myself
with the patch process.

My copyright assignment is underway.

--

Read the HWCAP auxval key to test for VSX support. Expose result through
the cpu_features interface.

Preliminary change to prepare for PowerPC optimized libmvec implementations
[BZ #20123]. Enables selecting optimized version at load time in ifunc
resolver.

	* sysdeps/powerpc/cpu-features.h (cpu_features): Add vsx field.
	* sysdeps/powerpc/cpu-features.c (init_cpu_features):
	Feature test VSX availability.
---
diff --git a/sysdeps/powerpc/cpu-features.c b/sysdeps/powerpc/cpu-features.c
index 955d4778a6..477c7504b9 100644
--- a/sysdeps/powerpc/cpu-features.c
+++ b/sysdeps/powerpc/cpu-features.c
@@ -16,6 +16,8 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#include <errno.h>
+#include <sys/auxv.h>
 #include <stdint.h>
 #include <cpu-features.h>
 
@@ -26,6 +28,9 @@
 static inline void
 init_cpu_features (struct cpu_features *cpu_features)
 {
+  errno = 0;
+  unsigned long int hwcap = getauxval (AT_HWCAP);
+
   /* Default is to use aligned memory access on optimized function unless
      tunables is enable, since for this case user can explicit disable
      unaligned optimizations.  */
@@ -36,4 +41,13 @@ init_cpu_features (struct cpu_features *cpu_features)
 #else
   cpu_features->use_cached_memopt = false;
 #endif
+
+  if (errno == ENOENT)
+    {
+      cpu_features->vsx = false;
+    }
+  else
+    {
+      cpu_features->vsx = ((hwcap & PPC_FEATURE_HAS_VSX) != 0);
+    }
 }
diff --git a/sysdeps/powerpc/cpu-features.h b/sysdeps/powerpc/cpu-features.h
index e596385b4b..0248862b8a 100644
--- a/sysdeps/powerpc/cpu-features.h
+++ b/sysdeps/powerpc/cpu-features.h
@@ -23,6 +23,7 @@
 struct cpu_features
 {
   bool use_cached_memopt;
+  bool vsx;
 };
 
 #endif /* __CPU_FEATURES_H  */

             reply	other threads:[~2018-03-28  8:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-28  8:20 Nathan Phillips [this message]
2018-03-28 12:16 ` Tulio Magno Quites Machado Filho
2018-03-28 12:42   ` Adhemerval Zanella
2018-03-28 13:31     ` Tulio Magno Quites Machado Filho
2018-03-28 13:36       ` Adhemerval Zanella
2018-03-28 13:46   ` Nathan Phillips

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='klDQRjHsGNLyUfoTY_7IVfFKRRAhSEeHVIYr89lVsb-ufm0FM5_KS2Wok7jCSBaVZXDYTJFmlGNMT7uJxbt0dIyn3m2SLuzdyWsoALd0pi4=@protonmail.com' \
    --to=waic9e@protonmail.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).