summary refs log tree commit diff
path: root/sysdeps/sparc/sparc64/multiarch/md5-block.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2012-11-12 15:17:31 -0800
committerDavid S. Miller <davem@davemloft.net>2012-11-13 17:12:45 -0800
commit3a0d900a997f8ade1332b56cd952e44158770491 (patch)
treed9b0b8c117b3f7019476682ac065f8eaf883bba1 /sysdeps/sparc/sparc64/multiarch/md5-block.c
parente27d476a652874ad8556fcdb06d877ebabb3e9c7 (diff)
downloadglibc-3a0d900a997f8ade1332b56cd952e44158770491.tar.gz
glibc-3a0d900a997f8ade1332b56cd952e44158770491.tar.xz
glibc-3a0d900a997f8ade1332b56cd952e44158770491.zip
Add support for sparc cryptographic hash opcodes.
	* crypt/Makefile: Move test targets after toplevel Rules
	inclusion.  Grab any necessary sysdep routines when linking.
	* crypt/md5.c (md5_process_block): Remove define, we will always
	name it __md5_process_block.
	(md5_finish_ctx): Update md5_process_block call.
	(md5_stream): Likewise.
	(md5_process_bytes): Likewise.
	(md5_process_block): Rename to __md5_process_block and move to ...
	* crypt/md5-block.c: ... here.
	* crypt/sha256.c (sha256_process_block): Move to ...
	* crypt/sha256-block.c: ... here.
	* crypt/sha512.c (sha512_process_block): Move to ...
	* crypt/sha512-block.c: ... here.
	* locale/Makefile (CFLAGS-md5.c): Define to add crypt/ to include
	path.
	* sysdeps/sparc/sparc-ifunc.c (sparc_libc_ifunc): Define.
	* sysdeps/sparc/sparc64/multiarch/Makefile
	(libcrypt-sysdep_routines): Add crypto assembler sysdeps when in
	crypt subdir.
	(localedef-aux): Add md5 crypto assembler when in locale subdir.
	* sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile: Mirror sparc64
	multiarch changes.
	* sysdeps/sparc/sparc64/multiarch/md5-block.c: New file.
	* sysdeps/sparc/sparc64/multiarch/md5-crop.S: New file.
	* sysdeps/sparc/sparc64/multiarch/sha256-block.c: New file.
	* sysdeps/sparc/sparc64/multiarch/sha256-crop.S: New file.
	* sysdeps/sparc/sparc64/multiarch/sha512-block.c: New file.
	* sysdeps/sparc/sparc64/multiarch/sha512-crop.S: New file.
	* sysdeps/sparc/sparc32/sparcv9/multiarch/md5-block.c: New file.
	* sysdeps/sparc/sparc32/sparcv9/multiarch/md5-crop.S: New file.
	* sysdeps/sparc/sparc32/sparcv9/multiarch/sha256-block.c: New
	file.
	* sysdeps/sparc/sparc32/sparcv9/multiarch/sha256-crop.S: New file.
	* sysdeps/sparc/sparc32/sparcv9/multiarch/sha512-block.c: New
	file.
	* sysdeps/sparc/sparc32/sparcv9/multiarch/sha512-crop.S: New file.
Diffstat (limited to 'sysdeps/sparc/sparc64/multiarch/md5-block.c')
-rw-r--r--sysdeps/sparc/sparc64/multiarch/md5-block.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/sysdeps/sparc/sparc64/multiarch/md5-block.c b/sysdeps/sparc/sparc64/multiarch/md5-block.c
new file mode 100644
index 0000000000..7c1a3a368f
--- /dev/null
+++ b/sysdeps/sparc/sparc64/multiarch/md5-block.c
@@ -0,0 +1,29 @@
+#include <sparc-ifunc.h>
+
+#define  __md5_process_block __md5_process_block_generic
+extern void __md5_process_block_generic (const void *buffer, size_t len,
+					 struct md5_ctx *ctx);
+
+#include <crypt/md5-block.c>
+
+#undef __md5_process_block
+
+extern void __md5_process_block_crop (const void *buffer, size_t len,
+				      struct md5_ctx *ctx);
+static bool cpu_supports_md5(int hwcap)
+{
+  unsigned long cfr;
+
+  if (!(hwcap & HWCAP_SPARC_CRYPTO))
+    return false;
+
+  __asm__ ("rd %%asr26, %0" : "=r" (cfr));
+  if (cfr & (1 << 4))
+    return true;
+
+  return false;
+}
+
+extern void __md5_process_block (const void *buffer, size_t len,
+				 struct md5_ctx *ctx);
+sparc_libc_ifunc(__md5_process_block, cpu_supports_md5(hwcap) ? __md5_process_block_crop : __md5_process_block_generic);