[sheepdog] [PATCH 2/2] sha1: add x86 hardware acceleration for sha1
MORITA Kazutaka
morita.kazutaka at lab.ntt.co.jp
Mon Sep 9 11:51:45 CEST 2013
At Mon, 9 Sep 2013 17:45:17 +0800,
Liu Yuan wrote:
>
> On Mon, Sep 09, 2013 at 06:15:24PM +0900, MORITA Kazutaka wrote:
> > At Thu, 5 Sep 2013 18:47:52 +0800,
> > Liu Yuan wrote:
> > >
> > > This doesn't change the sha1 algorithm. This patch tries to make use of intel's
> > > ssse3 and avx for sha1 acceleration.
> > >
> > > Signed-off-by: Liu Yuan <namei.unix at gmail.com>
> > > ---
> > > include/sha1.h | 11 +-
> > > lib/Makefile.am | 2 +-
> > > lib/sha1.c | 159 +++++++++++++--
> > > lib/sha1_ssse3.S | 564 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > > 4 files changed, 721 insertions(+), 15 deletions(-)
> > > create mode 100644 lib/sha1_ssse3.S
> > >
> > > diff --git a/include/sha1.h b/include/sha1.h
> > > index a778aea..9ae70b5 100644
> > > --- a/include/sha1.h
> > > +++ b/include/sha1.h
> > > @@ -23,9 +23,14 @@ struct sha1_ctx {
> > > uint8_t buffer[SHA1_BLOCK_SIZE];
> > > };
> > >
> > > -void sha1_init(void *ctx);
> > > -void sha1_update(void *ctx, const uint8_t *data, unsigned int len);
> > > -void sha1_final(void *ctx, uint8_t *out);
> > > +typedef void (*sha1_init_func_t)(void *);
> > > +typedef void (*sha1_update_func_t)(void *, const uint8_t *, unsigned int);
> > > +typedef void (*sha1_final_func_t)(void *, uint8_t *);
> > > +
> > > +sha1_init_func_t sha1_init;
> > > +sha1_update_func_t sha1_update;
> > > +sha1_final_func_t sha1_final;
> > > +
> > > const char *sha1_to_hex(const unsigned char *sha1);
> > > void sha1_from_buffer(const void *buf, size_t size, unsigned char *sha1);
> > >
> > > diff --git a/lib/Makefile.am b/lib/Makefile.am
> > > index 22edf6e..2fa84be 100644
> > > --- a/lib/Makefile.am
> > > +++ b/lib/Makefile.am
> > > @@ -5,7 +5,7 @@ INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
> > > noinst_LIBRARIES = libsheepdog.a
> > >
> > > libsheepdog_a_SOURCES = event.c logger.c net.c util.c rbtree.c strbuf.c \
> > > - sha1.c option.c work.c sockfd_cache.c
> > > + sha1.c option.c work.c sockfd_cache.c sha1_ssse3.S
> >
> > This can be compiled only on x86_64. Can you add ifdef and make other
> > architectures use the old code?
> >
>
> See patch 1/2 and __sha1_init, which implement your suggestion.
But this Makefile links sha1_ssse3.S anyway and I got a compile error
at least on i386.
Thanks,
Kazutaka
More information about the sheepdog
mailing list