Skip to content

Commit 81944e9

Browse files
committed
Merge branch 'bc/sha1-header-selection-with-cpp-macros'
Our source code has used the SHA1_HEADER cpp macro after "#include" in the C code to switch among the SHA-1 implementations. Instead, list the exact header file names and switch among implementations using "#ifdef BLK_SHA1/#include "block-sha1/sha1.h"/.../#endif"; this helps some IDE tools. * bc/sha1-header-selection-with-cpp-macros: hash.h: move SHA-1 implementation selection into a header file
2 parents 58e9773 + f18f816 commit 81944e9

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

Makefile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,19 +1384,19 @@ ifdef APPLE_COMMON_CRYPTO
13841384
endif
13851385

13861386
ifdef BLK_SHA1
1387-
SHA1_HEADER = "block-sha1/sha1.h"
13881387
LIB_OBJS += block-sha1/sha1.o
1388+
BASIC_CFLAGS += -DSHA1_BLK
13891389
else
13901390
ifdef PPC_SHA1
1391-
SHA1_HEADER = "ppc/sha1.h"
13921391
LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
1392+
BASIC_CFLAGS += -DSHA1_PPC
13931393
else
13941394
ifdef APPLE_COMMON_CRYPTO
13951395
COMPAT_CFLAGS += -DCOMMON_DIGEST_FOR_OPENSSL
1396-
SHA1_HEADER = <CommonCrypto/CommonDigest.h>
1396+
BASIC_CFLAGS += -DSHA1_APPLE
13971397
else
1398-
SHA1_HEADER = <openssl/sha.h>
13991398
EXTLIBS += $(LIB_4_CRYPTO)
1399+
BASIC_CFLAGS += -DSHA1_OPENSSL
14001400
endif
14011401
endif
14021402
endif
@@ -1588,7 +1588,6 @@ endif
15881588

15891589
# Shell quote (do not use $(call) to accommodate ancient setups);
15901590

1591-
SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
15921591
ETC_GITCONFIG_SQ = $(subst ','\'',$(ETC_GITCONFIG))
15931592
ETC_GITATTRIBUTES_SQ = $(subst ','\'',$(ETC_GITATTRIBUTES))
15941593

@@ -1621,8 +1620,7 @@ PERLLIB_EXTRA_SQ = $(subst ','\'',$(PERLLIB_EXTRA))
16211620
# from the dependency list, that would make each entry appear twice.
16221621
LIBS = $(filter-out %.o, $(GITLIBS)) $(EXTLIBS)
16231622

1624-
BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \
1625-
$(COMPAT_CFLAGS)
1623+
BASIC_CFLAGS += $(COMPAT_CFLAGS)
16261624
LIB_OBJS += $(COMPAT_OBJS)
16271625

16281626
# Quote for C

cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#include "trace.h"
1111
#include "string-list.h"
1212
#include "pack-revindex.h"
13+
#include "hash.h"
1314

14-
#include SHA1_HEADER
1515
#ifndef platform_SHA_CTX
1616
/*
1717
* platform's underlying implementation of SHA-1; could be OpenSSL,

hash.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef HASH_H
2+
#define HASH_H
3+
4+
#if defined(SHA1_PPC)
5+
#include "ppc/sha1.h"
6+
#elif defined(SHA1_APPLE)
7+
#include <CommonCrypto/CommonDigest.h>
8+
#elif defined(SHA1_OPENSSL)
9+
#include <openssl/sha.h>
10+
#else /* SHA1_BLK */
11+
#include "block-sha1/sha1.h"
12+
#endif
13+
14+
#endif

0 commit comments

Comments
 (0)