Skip to content

Commit

Permalink
Merge branch 'lt/block-sha1'
Browse files Browse the repository at this point in the history
* lt/block-sha1:
  remove ARM and Mozilla SHA1 implementations
  block-sha1: guard gcc extensions with __GNUC__
  make sure byte swapping is optimal for git
  block-sha1: make the size member first in the context struct
  • Loading branch information
Junio C Hamano committed Aug 28, 2009
2 parents 24343c6 + 30ae47b commit 106a365
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 531 deletions.
26 changes: 2 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ all::
# when attempting to read from an fopen'ed directory.
#
# Define NO_OPENSSL environment variable if you do not have OpenSSL.
# This also implies MOZILLA_SHA1.
# This also implies BLK_SHA1.
#
# Define NO_CURL if you do not have libcurl installed. git-http-pull and
# git-http-push are not built, and you cannot use http:// and https://
Expand Down Expand Up @@ -91,14 +91,6 @@ all::
# Define PPC_SHA1 environment variable when running make to make use of
# a bundled SHA1 routine optimized for PowerPC.
#
# Define ARM_SHA1 environment variable when running make to make use of
# a bundled SHA1 routine optimized for ARM.
#
# Define MOZILLA_SHA1 environment variable when running make to make use of
# a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast
# on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default
# choice) has very fast version optimized for i586.
#
# Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
#
# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
Expand Down Expand Up @@ -925,10 +917,6 @@ else
NO_PTHREADS = YesPlease
endif
endif
ifneq (,$(findstring arm,$(uname_M)))
ARM_SHA1 = YesPlease
NO_MKSTEMPS = YesPlease
endif

-include config.mak.autogen
-include config.mak
Expand Down Expand Up @@ -1021,7 +1009,7 @@ ifndef NO_OPENSSL
endif
else
BASIC_CFLAGS += -DNO_OPENSSL
MOZILLA_SHA1 = 1
BLK_SHA1 = 1
OPENSSL_LIBSSL =
endif
ifdef NEEDS_SSL_WITH_CRYPTO
Expand Down Expand Up @@ -1177,21 +1165,11 @@ else
ifdef PPC_SHA1
SHA1_HEADER = "ppc/sha1.h"
LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
else
ifdef ARM_SHA1
SHA1_HEADER = "arm/sha1.h"
LIB_OBJS += arm/sha1.o arm/sha1_arm.o
else
ifdef MOZILLA_SHA1
SHA1_HEADER = "mozilla-sha1/sha1.h"
LIB_OBJS += mozilla-sha1/sha1.o
else
SHA1_HEADER = <openssl/sha.h>
EXTLIBS += $(LIB_4_CRYPTO)
endif
endif
endif
endif
ifdef NO_PERL_MAKEMAKER
export NO_PERL_MAKEMAKER
endif
Expand Down
82 changes: 0 additions & 82 deletions arm/sha1.c

This file was deleted.

23 changes: 0 additions & 23 deletions arm/sha1.h

This file was deleted.

183 changes: 0 additions & 183 deletions arm/sha1_arm.S

This file was deleted.

14 changes: 8 additions & 6 deletions block-sha1/sha1.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
/*
* Based on the Mozilla SHA1 (see mozilla-sha1/sha1.c),
* optimized to do word accesses rather than byte accesses,
* SHA1 routine optimized to do word accesses rather than byte accesses,
* and to avoid unnecessary copies into the context array.
*
* This was initially based on the Mozilla SHA1 implementation, although
* none of the original Mozilla code remains.
*/

#include <string.h>
#include <arpa/inet.h>
/* this is only to get definitions for memcpy(), ntohl() and htonl() */
#include "../git-compat-util.h"

#include "sha1.h"

#if defined(__i386__) || defined(__x86_64__)
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))

/*
* Force usage of rol or ror by selecting the one with the smaller constant.
Expand Down Expand Up @@ -54,7 +56,7 @@

#if defined(__i386__) || defined(__x86_64__)
#define setW(x, val) (*(volatile unsigned int *)&W(x) = (val))
#elif defined(__arm__)
#elif defined(__GNUC__) && defined(__arm__)
#define setW(x, val) do { W(x) = (val); __asm__("":::"memory"); } while (0)
#else
#define setW(x, val) (W(x) = (val))
Expand Down
Loading

0 comments on commit 106a365

Please sign in to comment.