about summary refs log tree commit diff
path: root/sysdeps/sparc/sparc64/multiarch/sha512-block.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/sparc/sparc64/multiarch/sha512-block.c')
-rw-r--r--sysdeps/sparc/sparc64/multiarch/sha512-block.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/sysdeps/sparc/sparc64/multiarch/sha512-block.c b/sysdeps/sparc/sparc64/multiarch/sha512-block.c
new file mode 100644
index 0000000000..0d1c3dd6d8
--- /dev/null
+++ b/sysdeps/sparc/sparc64/multiarch/sha512-block.c
@@ -0,0 +1,30 @@
+#include <sparc-ifunc.h>
+
+#define sha512_process_block sha512_process_block_generic
+extern void sha512_process_block_generic (const void *buffer, size_t len,
+					  struct sha512_ctx *ctx);
+
+#include <crypt/sha512-block.c>
+
+#undef sha512_process_block
+
+extern void __sha512_process_block_crop (const void *buffer, size_t len,
+					 struct sha512_ctx *ctx);
+
+static bool cpu_supports_sha512(int hwcap)
+{
+  unsigned long cfr;
+
+  if (!(hwcap & HWCAP_SPARC_CRYPTO))
+    return false;
+
+  __asm__ ("rd %%asr26, %0" : "=r" (cfr));
+  if (cfr & (1 << 6))
+    return true;
+
+  return false;
+}
+
+extern void sha512_process_block (const void *buffer, size_t len,
+				  struct sha512_ctx *ctx);
+sparc_libc_ifunc(sha512_process_block, cpu_supports_sha512(hwcap) ? __sha512_process_block_crop : sha512_process_block_generic);