Skip to content

Commit 106a365

Browse files
committed
Merge branch 'lt/block-sha1'
* 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
2 parents 24343c6 + 30ae47b commit 106a365

File tree

11 files changed

+54
-531
lines changed

11 files changed

+54
-531
lines changed

Makefile

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ all::
1616
# when attempting to read from an fopen'ed directory.
1717
#
1818
# Define NO_OPENSSL environment variable if you do not have OpenSSL.
19-
# This also implies MOZILLA_SHA1.
19+
# This also implies BLK_SHA1.
2020
#
2121
# Define NO_CURL if you do not have libcurl installed. git-http-pull and
2222
# git-http-push are not built, and you cannot use http:// and https://
@@ -91,14 +91,6 @@ all::
9191
# Define PPC_SHA1 environment variable when running make to make use of
9292
# a bundled SHA1 routine optimized for PowerPC.
9393
#
94-
# Define ARM_SHA1 environment variable when running make to make use of
95-
# a bundled SHA1 routine optimized for ARM.
96-
#
97-
# Define MOZILLA_SHA1 environment variable when running make to make use of
98-
# a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast
99-
# on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default
100-
# choice) has very fast version optimized for i586.
101-
#
10294
# Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
10395
#
10496
# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
@@ -925,10 +917,6 @@ else
925917
NO_PTHREADS = YesPlease
926918
endif
927919
endif
928-
ifneq (,$(findstring arm,$(uname_M)))
929-
ARM_SHA1 = YesPlease
930-
NO_MKSTEMPS = YesPlease
931-
endif
932920

933921
-include config.mak.autogen
934922
-include config.mak
@@ -1021,7 +1009,7 @@ ifndef NO_OPENSSL
10211009
endif
10221010
else
10231011
BASIC_CFLAGS += -DNO_OPENSSL
1024-
MOZILLA_SHA1 = 1
1012+
BLK_SHA1 = 1
10251013
OPENSSL_LIBSSL =
10261014
endif
10271015
ifdef NEEDS_SSL_WITH_CRYPTO
@@ -1177,21 +1165,11 @@ else
11771165
ifdef PPC_SHA1
11781166
SHA1_HEADER = "ppc/sha1.h"
11791167
LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
1180-
else
1181-
ifdef ARM_SHA1
1182-
SHA1_HEADER = "arm/sha1.h"
1183-
LIB_OBJS += arm/sha1.o arm/sha1_arm.o
1184-
else
1185-
ifdef MOZILLA_SHA1
1186-
SHA1_HEADER = "mozilla-sha1/sha1.h"
1187-
LIB_OBJS += mozilla-sha1/sha1.o
11881168
else
11891169
SHA1_HEADER = <openssl/sha.h>
11901170
EXTLIBS += $(LIB_4_CRYPTO)
11911171
endif
11921172
endif
1193-
endif
1194-
endif
11951173
ifdef NO_PERL_MAKEMAKER
11961174
export NO_PERL_MAKEMAKER
11971175
endif

arm/sha1.c

Lines changed: 0 additions & 82 deletions
This file was deleted.

arm/sha1.h

Lines changed: 0 additions & 23 deletions
This file was deleted.

arm/sha1_arm.S

Lines changed: 0 additions & 183 deletions
This file was deleted.

block-sha1/sha1.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
/*
2-
* Based on the Mozilla SHA1 (see mozilla-sha1/sha1.c),
3-
* optimized to do word accesses rather than byte accesses,
2+
* SHA1 routine optimized to do word accesses rather than byte accesses,
43
* and to avoid unnecessary copies into the context array.
4+
*
5+
* This was initially based on the Mozilla SHA1 implementation, although
6+
* none of the original Mozilla code remains.
57
*/
68

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

1012
#include "sha1.h"
1113

12-
#if defined(__i386__) || defined(__x86_64__)
14+
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
1315

1416
/*
1517
* Force usage of rol or ror by selecting the one with the smaller constant.
@@ -54,7 +56,7 @@
5456

5557
#if defined(__i386__) || defined(__x86_64__)
5658
#define setW(x, val) (*(volatile unsigned int *)&W(x) = (val))
57-
#elif defined(__arm__)
59+
#elif defined(__GNUC__) && defined(__arm__)
5860
#define setW(x, val) do { W(x) = (val); __asm__("":::"memory"); } while (0)
5961
#else
6062
#define setW(x, val) (W(x) = (val))

0 commit comments

Comments
 (0)