{"thread":{"id":"15732","subject":"[PATCH, resent] fix openssl headers conflicting with custom SHA1 implementations","startedAt":"2008-09-30T20:22:45Z","lastAt":"2008-10-01T18:05:20Z","messageCount":11,"participants":["Nicolas Pitre","Shawn O. Pearce","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"91983","messageId":"alpine.LFD.2.00.0809301621091.3635@xanadu.home","threadId":"15732","inReplyTo":null,"subject":"[PATCH, resent] fix openssl headers conflicting with custom SHA1 implementations","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2008-09-30T20:22:45Z","receivedAt":"2008-09-30T20:22:45Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On ARM I have the following compilation errors:\n\n    CC fast-import.o\nIn file included from cache.h:8,\n                 from builtin.h:6,\n                 from fast-import.c:142:\narm/sha1.h:14: error: conflicting types for 'SHA_CTX'\n/usr/include/openssl/sha.h:105: error: previous declaration of 'SHA_CTX' was here\narm/sha1.h:16: error: conflicting types for 'SHA1_Init'\n/usr/include/openssl/sha.h:115: error: previous declaration of 'SHA1_Init' was here\narm/sha1.h:17: error: conflicting types for 'SHA1_Update'\n/usr/include/openssl/sha.h:116: error: previous declaration of 'SHA1_Update' was here\narm/sha1.h:18: error: conflicting types for 'SHA1_Final'\n/usr/include/openssl/sha.h:117: error: previous declaration of 'SHA1_Final' was here\nmake: *** [fast-import.o] Error 1\n\nThis is because openssl header files are always included in \ngit-compat-util.h since commit 684ec6c63c whenever NO_OPENSSL is not \nset, which somehow brings in <openssl/sha1.h> clashing with the custom \nARM version.  Compilation of git is probably broken on PPC too for the \nsame reason.\n\nTurns out that the only file requiring openssl/ssl.h and openssl/err.h \nis imap-send.c.  But only moving those problematic includes there \ndoesn't solve the issue as it also includes cache.h which brings in the \nconflicting header.  So also conditionally including SHA1_HEADER allows \nfor not including it when compiling imap-send.c.\n\nSigned-off-by: Nicolas Pitre <nico@cam.org>\n\n---\n\nThis is a bit ugly but given the rat nest of system includes we have I \ndon't know how to solve this any better.\n\ndiff --git a/Makefile b/Makefile\nindex 3c0664a..a0f86dd 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1242,6 +1242,9 @@ endif\n git-%$X: %.o $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)\n \n+imap-send.o: imap-send.c GIT-CFLAGS\n+\t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -USHA1_HEADER $<\n+\n git-imap-send$X: imap-send.o $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n \t\t$(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL)\ndiff --git a/cache.h b/cache.h\nindex de8c2b6..d93e086 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -5,7 +5,10 @@\n #include \"strbuf.h\"\n #include \"hash.h\"\n \n+#ifdef SHA1_HEADER\n #include SHA1_HEADER\n+#endif\n+\n #include <zlib.h>\n \n #if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex db2836f..044f62b 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -99,11 +99,6 @@\n #include <iconv.h>\n #endif\n \n-#ifndef NO_OPENSSL\n-#include <openssl/ssl.h>\n-#include <openssl/err.h>\n-#endif\n-\n /* On most systems <limits.h> would have given us this, but\n  * not on some systems (e.g. GNU/Hurd).\n  */\ndiff --git a/imap-send.c b/imap-send.c\nindex af7e08c..01f1c9a 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -22,11 +22,15 @@\n  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n  */\n \n-#include \"cache.h\"\n #ifdef NO_OPENSSL\n typedef void *SSL;\n+#else\n+#include <openssl/ssl.h>\n+#include <openssl/err.h>\n #endif\n \n+#include \"cache.h\"\n+\n struct store_conf {\n \tchar *name;\n \tconst char *path; /* should this be here? its interpretation is driver-specific */\n\n\n\n\nNicolas\n"},{"id":"91986","messageId":"20080930203928.GN21310@spearce.org","threadId":"15732","inReplyTo":"alpine.LFD.2.00.0809301621091.3635@xanadu.home","subject":"Re: [PATCH, resent] fix openssl headers conflicting with custom SHA1 implementations","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-09-30T20:39:28Z","receivedAt":"2008-09-30T20:39:28Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Nicolas Pitre <nico@cam.org> wrote:\n> On ARM I have the following compilation errors:\n...\n> This is a bit ugly but given the rat nest of system includes we have I \n> don't know how to solve this any better.\n\nHmm.  On Linux x86 with your change:\n\nIn file included from imap-send.c:32:\ncache.h: In function 'create_ce_mode':\ncache.h:186: error: 'S_IFLNK' undeclared (first use in this function)\n\nI think that last hunk which moved the openssl includes to be before\ncache.h is the problem.  This squashed in seems to make it my build\nwork again:\n\ndiff --git a/imap-send.c b/imap-send.c\nindex 01f1c9a..6b8c66e 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -22,6 +22,7 @@\n  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n  */\n \n+#include \"cache.h\"\n #ifdef NO_OPENSSL\n typedef void *SSL;\n #else\n@@ -29,8 +30,6 @@ typedef void *SSL;\n #include <openssl/err.h>\n #endif\n \n-#include \"cache.h\"\n-\n struct store_conf {\n \tchar *name;\n \tconst char *path; /* should this be here? its interpretation is driver-specific */\n\n-- \nShawn.\n"},{"id":"91987","messageId":"alpine.LFD.2.00.0809301645340.3635@xanadu.home","threadId":"15732","inReplyTo":"20080930203928.GN21310@spearce.org","subject":"Re: [PATCH, resent] fix openssl headers conflicting with custom SHA1 implementations","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2008-09-30T20:46:56Z","receivedAt":"2008-09-30T20:46:56Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Tue, 30 Sep 2008, Shawn O. Pearce wrote:\n\n> Nicolas Pitre <nico@cam.org> wrote:\n> > On ARM I have the following compilation errors:\n> ...\n> > This is a bit ugly but given the rat nest of system includes we have I \n> > don't know how to solve this any better.\n> \n> Hmm.  On Linux x86 with your change:\n> \n> In file included from imap-send.c:32:\n> cache.h: In function 'create_ce_mode':\n> cache.h:186: error: 'S_IFLNK' undeclared (first use in this function)\n> \n> I think that last hunk which moved the openssl includes to be before\n> cache.h is the problem.  This squashed in seems to make it my build\n> work again:\n> \n> diff --git a/imap-send.c b/imap-send.c\n> index 01f1c9a..6b8c66e 100644\n> --- a/imap-send.c\n> +++ b/imap-send.c\n> @@ -22,6 +22,7 @@\n>   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n>   */\n>  \n> +#include \"cache.h\"\n>  #ifdef NO_OPENSSL\n>  typedef void *SSL;\n>  #else\n> @@ -29,8 +30,6 @@ typedef void *SSL;\n>  #include <openssl/err.h>\n>  #endif\n>  \n> -#include \"cache.h\"\n> -\n>  struct store_conf {\n>  \tchar *name;\n>  \tconst char *path; /* should this be here? its interpretation is driver-specific */\n\nWith that, my build on ARM bombs out with:\n\n    CC imap-send.o\nIn file included from /usr/include/openssl/kssl.h:71,\n                 from /usr/include/openssl/ssl.h:191,\n                 from imap-send.c:30:\n/usr/include/ctype.h:102: error: expected expression before ']' token\n/usr/include/ctype.h:102: error: expected ')' before '!=' token\n/usr/include/ctype.h:103: error: expected expression before ']' token\n/usr/include/ctype.h:103: error: expected ')' before '!=' token\n/usr/include/ctype.h:105: error: expected expression before ']' token\n/usr/include/ctype.h:105: error: expected ')' before '!=' token\n/usr/include/ctype.h:110: error: expected expression before ']' token\n/usr/include/ctype.h:110: error: expected ')' before '!=' token\n/usr/include/ctype.h:116: error: expected declaration specifiers or '...' before '(' token\n/usr/include/ctype.h:116: error: expected declaration specifiers or '...' before numeric constant\n/usr/include/ctype.h:119: error: expected declaration specifiers or '...' before '(' token\n/usr/include/ctype.h:119: error: expected declaration specifiers or '...' before numeric constant\n/usr/include/ctype.h:191: error: expected declaration specifiers or '...' before '(' token\n/usr/include/ctype.h:191: error: expected declaration specifiers or '...' before numeric constant\n/usr/include/ctype.h:192: error: redefinition of 'sane_case'\ngit-compat-util.h:338: error: previous definition of 'sane_case' was here\n/usr/include/ctype.h: In function 'sane_case':\n/usr/include/ctype.h:192: error: number of arguments doesn't match prototype\ngit-compat-util.h:338: error: prototype declaration\n/usr/include/ctype.h:193: error: '__c' undeclared (first use in this function)\n/usr/include/ctype.h:193: error: (Each undeclared identifier is reported only once\n/usr/include/ctype.h:193: error: for each function it appears in.)\n/usr/include/ctype.h: At top level:\n/usr/include/ctype.h:197: error: expected declaration specifiers or '...' before '(' token\n/usr/include/ctype.h:197: error: expected declaration specifiers or '...' before numeric constant\n/usr/include/ctype.h:198: error: redefinition of 'sane_case'\n/usr/include/ctype.h:192: error: previous definition of 'sane_case' was here\n/usr/include/ctype.h: In function 'sane_case':\n/usr/include/ctype.h:198: error: number of arguments doesn't match prototype\n/usr/include/ctype.h:192: error: prototype declaration\n/usr/include/ctype.h:199: error: '__c' undeclared (first use in this function)\nmake: *** [imap-send.o] Error 1\n\n\nNicolas\n"},{"id":"91988","messageId":"20080930205122.GO21310@spearce.org","threadId":"15732","inReplyTo":"alpine.LFD.2.00.0809301645340.3635@xanadu.home","subject":"Re: [PATCH, resent] fix openssl headers conflicting with custom SHA1 implementations","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-09-30T20:51:22Z","receivedAt":"2008-09-30T20:51:22Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Nicolas Pitre <nico@cam.org> wrote:\n> On Tue, 30 Sep 2008, Shawn O. Pearce wrote:\n> > Nicolas Pitre <nico@cam.org> wrote:\n> > > On ARM I have the following compilation errors:\n> > ...\n> > > This is a bit ugly but given the rat nest of system includes we have I \n> > > don't know how to solve this any better.\n> > \n> > Hmm.  On Linux x86 with your change:\n> > \n> > In file included from imap-send.c:32:\n> > cache.h: In function 'create_ce_mode':\n> > cache.h:186: error: 'S_IFLNK' undeclared (first use in this function)\n> > \n> > I think that last hunk which moved the openssl includes to be before\n> > cache.h is the problem.\n> \n> With that, my build on ARM bombs out with:\n> \n>     CC imap-send.o\n> In file included from /usr/include/openssl/kssl.h:71,\n>                  from /usr/include/openssl/ssl.h:191,\n>                  from imap-send.c:30:\n> /usr/include/ctype.h:102: error: expected expression before ']' token\n\n*sigh*\n\nYea, its a bit ugly due to the rats nest of system includes.\nRight now I don't see how we can include your patch, it breaks a\nmajor platform for us.  But obviously my \"fix\" is also bogus and\nwon't get ARM working again.\n\nAny other ideas we can try?  'cause I don't have any right now.  :-|\n\n-- \nShawn.\n"},{"id":"92017","messageId":"20081001034712.GE24513@coredump.intra.peff.net","threadId":"15732","inReplyTo":"20080930205122.GO21310@spearce.org","subject":"Re: [PATCH, resent] fix openssl headers conflicting with custom SHA1 implementations","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-10-01T03:47:12Z","receivedAt":"2008-10-01T03:47:12Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Sep 30, 2008 at 01:51:22PM -0700, Shawn O. Pearce wrote:\n\n> Yea, its a bit ugly due to the rats nest of system includes.\n> Right now I don't see how we can include your patch, it breaks a\n> major platform for us.  But obviously my \"fix\" is also bogus and\n> won't get ARM working again.\n> \n> Any other ideas we can try?  'cause I don't have any right now.  :-|\n\nI think you have an inherent conflict. Using openssl is going to end up\nincluding their SHA definition, and we clearly can't include both..\nRight now, you are trying to find a way to squeak by because imap-send\nis the only thing that uses openssl, and it doesn't actually need our\nSHA definition. But any solution that exploits that characteristic is\nprone to failing later, when something _does_ need both of them.\n\nYou _could_ do something hack-ish like defining HEADER_SHA_H to avoid\ntheirs being loaded, but:\n\n  1. You are relying on their header guard never changing.\n\n  2. This actually leaves room for subtle problems, since some code\n     thinks a SHA_CTX is defined one way, and other code thinks it is\n     defined another way. If one piece of code passes a SHA_CTX to the\n     other (say another part of openssl), you risk invoking nasal\n     demons.\n\nSo I think the right way is probably to use a level of indirection. Turn\nthe ARM implementation into\n\n  void ARM_SHA1_Init()\n\nand\n\n  #define SHA1_Init ARM_SHA1_Init\n\nmaking sure not to allow such a macro to be in effect when including\nopenssl. This is similar to the way we override compat functions.\n\nYou can make it even simpler by just having all code call git_SHA1_Init,\nand that will expand to whichever implementation has been chosen.\n\n-Peff\n"},{"id":"92069","messageId":"20081001155458.GF21310@spearce.org","threadId":"15732","inReplyTo":"20081001034712.GE24513@coredump.intra.peff.net","subject":"Re: [PATCH, resent] fix openssl headers conflicting with custom SHA1 implementations","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-10-01T15:54:58Z","receivedAt":"2008-10-01T15:54:58Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Jeff King <peff@peff.net> wrote:\n> On Tue, Sep 30, 2008 at 01:51:22PM -0700, Shawn O. Pearce wrote:\n> \n> > Yea, its a bit ugly due to the rats nest of system includes.\n> > Right now I don't see how we can include your patch, it breaks a\n> > major platform for us.  But obviously my \"fix\" is also bogus and\n> > won't get ARM working again.\n> > \n> > Any other ideas we can try?  'cause I don't have any right now.  :-|\n> \n> I think you have an inherent conflict. Using openssl is going to end up\n> including their SHA definition, and we clearly can't include both..\n...\n> So I think the right way is probably to use a level of indirection. Turn\n> the ARM implementation into\n> \n>   void ARM_SHA1_Init()\n> \n> and\n> \n>   #define SHA1_Init ARM_SHA1_Init\n\nIck.  I agree that renaming our SHA1 implementation to a different\nset of symbols is the right solution.  But this could cause trouble\nin any code that needs both SHA1 implementation and OpenSSL,\nespecially if a SHA_CTX was passed to a function in another module.\n \n> You can make it even simpler by just having all code call git_SHA1_Init,\n> and that will expand to whichever implementation has been chosen.\n\n $ git grep --cached SHA1_Init | wc -l\n 32\n $ git grep --cached SHA1_Final | wc -l\n 26\n $ git grep --cached SHA1_Update | wc -l\n 39\n $ git grep --cached SHA_CTX | wc -l\n 48\n\nI think its easy enough to just rename our SHA_CTX and SHA_*\nfunctions to something more git specific.  Since its mostly a global\ns/// we should be able to run it through into master without too\nmuch effort.  It would however make merging certain changes from\nmaint fun, but I think we can handle it until the 1.6.1 release\ngoes final.  We tend not to twiddle SHA1 related code in maint.\n\nOf course this is me speaking... Junio is the one that would be faced\nwith the brunt of that pain.  If it comes down to it I'd be willing\nto handle the maint branch and its merges back into master for him.\n\nA funny thing from the above stats... we have 6 SHA1_Init calls\nwhich aren't balanced by a SHA1_Final call.  Weird.\n\n-- \nShawn.\n"},{"id":"92070","messageId":"20081001160418.GA13917@coredump.intra.peff.net","threadId":"15732","inReplyTo":"20081001155458.GF21310@spearce.org","subject":"Re: [PATCH, resent] fix openssl headers conflicting with custom SHA1 implementations","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-10-01T16:04:18Z","receivedAt":"2008-10-01T16:04:18Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Oct 01, 2008 at 08:54:58AM -0700, Shawn O. Pearce wrote:\n\n> >   void ARM_SHA1_Init()\n> > \n> > and\n> > \n> >   #define SHA1_Init ARM_SHA1_Init\n> \n> Ick.  I agree that renaming our SHA1 implementation to a different\n> set of symbols is the right solution.  But this could cause trouble\n> in any code that needs both SHA1 implementation and OpenSSL,\n> especially if a SHA_CTX was passed to a function in another module.\n\nYes. You're never going to be able to get access to _both_\nimplementations if they have the same name. ;)\n\n> I think its easy enough to just rename our SHA_CTX and SHA_*\n> functions to something more git specific.  Since its mostly a global\n\nI think that is the cleanest and simplest solution. As for merging pain,\nI think Junio would generally do a mechanical change like this as the\nfirst thing after a release. However, in this case, I think we might\nwant it sooner if the conflict is causing breakage.\n\n-Peff\n"},{"id":"92071","messageId":"20081001161047.GG21310@spearce.org","threadId":"15732","inReplyTo":"20081001160418.GA13917@coredump.intra.peff.net","subject":"Re: [PATCH, resent] fix openssl headers conflicting with custom SHA1 implementations","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-10-01T16:10:47Z","receivedAt":"2008-10-01T16:10:47Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Jeff King <peff@peff.net> wrote:\n> On Wed, Oct 01, 2008 at 08:54:58AM -0700, Shawn O. Pearce wrote:\n> \n> > I think its easy enough to just rename our SHA_CTX and SHA_*\n> > functions to something more git specific.  Since its mostly a global\n> \n> I think that is the cleanest and simplest solution. As for merging pain,\n> I think Junio would generally do a mechanical change like this as the\n> first thing after a release. However, in this case, I think we might\n> want it sooner if the conflict is causing breakage.\n\nOh, yea, that's probably true.  But with ARM broken according to\nNico I'd almost just want this fixed in the upcoming 1.6.1 release.\nIts simple enough to do.  We can even do something like this during\nthe transition period until right before the 1.6.1 final:\n\ndiff --git a/cache.h b/cache.h\nindex 46f82bd..e77adf9 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -5,6 +5,10 @@\n #include \"strbuf.h\"\n #include \"hash.h\"\n \n+#define SHA_CTX     not_the_SHA_CTX_you_are_looking_for\n+#define SHA1_Init   not_the_SHA1_Init_you_are_looking_for\n+#define SHA1_Update not_the_SHA1_Update_you_are_looking_for\n+#define SHA1_Final  not_the_SHA1_Final_you_are_looking_for\n #include SHA1_HEADER\n #include <zlib.h>\n\nand we'll catch anything using the old symbol name.  Only cache.h\nincludes the SHA1_HEADER so anyone using the (old) SHA_* functions\nwould hit these #defines and fall over the undefined symbol.\n\n-- \nShawn.\n"},{"id":"92074","messageId":"alpine.LFD.2.00.0810011222090.3635@xanadu.home","threadId":"15732","inReplyTo":"20081001161047.GG21310@spearce.org","subject":"Re: [PATCH, resent] fix openssl headers conflicting with custom SHA1 implementations","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2008-10-01T16:35:07Z","receivedAt":"2008-10-01T16:35:07Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Wed, 1 Oct 2008, Shawn O. Pearce wrote:\n\n> Jeff King <peff@peff.net> wrote:\n> > On Wed, Oct 01, 2008 at 08:54:58AM -0700, Shawn O. Pearce wrote:\n> > \n> > > I think its easy enough to just rename our SHA_CTX and SHA_*\n> > > functions to something more git specific.  Since its mostly a global\n> > \n> > I think that is the cleanest and simplest solution. As for merging pain,\n> > I think Junio would generally do a mechanical change like this as the\n> > first thing after a release. However, in this case, I think we might\n> > want it sooner if the conflict is causing breakage.\n> \n> Oh, yea, that's probably true.  But with ARM broken according to\n> Nico I'd almost just want this fixed in the upcoming 1.6.1 release.\n\nNot only ARM, but PPC as well, and any configuration using the Mozilla \nSHA1 implementation and linking openssl (although I don't know why one \nwould want that in the later case).\n\n> Its simple enough to do.  We can even do something like this during\n> the transition period until right before the 1.6.1 final:\n\nBecause it's easy to do then I'd do it sooner than later.  Right now the \nmaster branch is broken for ARM and PPC which is not nice.  And I don't \nthink there is much work to be merged which would conflict with such a \nchange.\n\n\nNicolas\n"},{"id":"92075","messageId":"20081001163952.GJ21310@spearce.org","threadId":"15732","inReplyTo":"alpine.LFD.2.00.0810011222090.3635@xanadu.home","subject":"Re: [PATCH, resent] fix openssl headers conflicting with custom SHA1 implementations","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-10-01T16:39:52Z","receivedAt":"2008-10-01T16:39:52Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Nicolas Pitre <nico@cam.org> wrote:\n> On Wed, 1 Oct 2008, Shawn O. Pearce wrote:\n> > Jeff King <peff@peff.net> wrote:\n> > > On Wed, Oct 01, 2008 at 08:54:58AM -0700, Shawn O. Pearce wrote:\n> > > \n> > > > I think its easy enough to just rename our SHA_CTX and SHA_*\n> > > > functions to something more git specific.  Since its mostly a global\n> > > \n> > > I think that is the cleanest and simplest solution. As for merging pain,\n> > > I think Junio would generally do a mechanical change like this as the\n> > > first thing after a release. However, in this case, I think we might\n> > > want it sooner if the conflict is causing breakage.\n> > \n> > Oh, yea, that's probably true.  But with ARM broken according to\n> > Nico I'd almost just want this fixed in the upcoming 1.6.1 release.\n> \n> > Its simple enough to do.  We can even do something like this during\n> > the transition period until right before the 1.6.1 final:\n> \n> Because it's easy to do then I'd do it sooner than later.\n\nNico, are you going to write a patch for this?  If not I'll do it\nmyself later today or tomorrow morning.  I don't mind doing it,\nI just don't want to duplicate work with you.  I've got too much\nelse going on to waste my time that way.\n\nOf course I'm wasting time on this email... ;-)\n\n-- \nShawn.\n"},{"id":"92078","messageId":"alpine.LFD.2.00.0810011341040.3635@xanadu.home","threadId":"15732","inReplyTo":"20081001163952.GJ21310@spearce.org","subject":"[PATCH v2] fix openssl headers conflicting with custom SHA1 implementations","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2008-10-01T18:05:20Z","receivedAt":"2008-10-01T18:05:20Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On ARM I have the following compilation errors:\n\n    CC fast-import.o\nIn file included from cache.h:8,\n                 from builtin.h:6,\n                 from fast-import.c:142:\narm/sha1.h:14: error: conflicting types for 'SHA_CTX'\n/usr/include/openssl/sha.h:105: error: previous declaration of 'SHA_CTX' was here\narm/sha1.h:16: error: conflicting types for 'SHA1_Init'\n/usr/include/openssl/sha.h:115: error: previous declaration of 'SHA1_Init' was here\narm/sha1.h:17: error: conflicting types for 'SHA1_Update'\n/usr/include/openssl/sha.h:116: error: previous declaration of 'SHA1_Update' was here\narm/sha1.h:18: error: conflicting types for 'SHA1_Final'\n/usr/include/openssl/sha.h:117: error: previous declaration of 'SHA1_Final' was here\nmake: *** [fast-import.o] Error 1\n\nThis is because openssl header files are always included in \ngit-compat-util.h since commit 684ec6c63c whenever NO_OPENSSL is not \nset, which somehow brings in <openssl/sha1.h> clashing with the custom \nARM version.  Compilation of git is probably broken on PPC too for the \nsame reason.\n\nTurns out that the only file requiring openssl/ssl.h and openssl/err.h \nis imap-send.c.  But only moving those problematic includes there \ndoesn't solve the issue as it also includes cache.h which brings in the \nconflicting local SHA1 header file.\n\nAs suggested by Jeff King, the best solution is to rename our references\nto SHA1 functions and structure to something git specific, and define those\naccording to the implementation used. \n\nSigned-off-by: Nicolas Pitre <nico@cam.org>\n\n---\n\nOn Wed, 1 Oct 2008, Shawn O. Pearce wrote:\n\n> Nicolas Pitre <nico@cam.org> wrote:\n> > On Wed, 1 Oct 2008, Shawn O. Pearce wrote:\n> > > Jeff King <peff@peff.net> wrote:\n> > > > On Wed, Oct 01, 2008 at 08:54:58AM -0700, Shawn O. Pearce wrote:\n> > > > \n> > > > > I think its easy enough to just rename our SHA_CTX and SHA_*\n> > > > > functions to something more git specific.  Since its mostly a \nglobal\n> > > > \n> > > > I think that is the cleanest and simplest solution. As for merging pain,\n> > > > I think Junio would generally do a mechanical change like this as the\n> > > > first thing after a release. However, in this case, I think we might\n> > > > want it sooner if the conflict is causing breakage.\n> > > \n> > > Oh, yea, that's probably true.  But with ARM broken according to\n> > > Nico I'd almost just want this fixed in the upcoming 1.6.1 release.\n> > \n> > > Its simple enough to do.  We can even do something like this during\n> > > the transition period until right before the 1.6.1 final:\n> > \n> > Because it's easy to do then I'd do it sooner than later.\n> \n> Nico, are you going to write a patch for this?\n\nHere it is.  Tested with straight openssl, the mozilla version, and the \nARM version.  Can't test the ppc version but this should look straight \nforward enough.\n\n arm/sha1.c               |   16 ++++++++--------\n arm/sha1.h               |   15 ++++++++++-----\n arm/sha1_arm.S           |    4 ++--\n builtin-unpack-objects.c |   10 +++++-----\n cache.h                  |    8 +++++++-\n csum-file.c              |    8 ++++----\n csum-file.h              |    2 +-\n diff.c                   |   12 ++++++------\n fast-import.c            |   18 +++++++++---------\n http-push.c              |   10 +++++-----\n http-walker.c            |   10 +++++-----\n index-pack.c             |    8 ++++----\n mozilla-sha1/sha1.c      |   18 +++++++++---------\n mozilla-sha1/sha1.h      |   13 +++++++++----\n pack-check.c             |   16 ++++++++--------\n pack-write.c             |   30 +++++++++++++++---------------\n patch-id.c               |   12 ++++++------\n ppc/sha1.c               |   18 +++++++++---------\n ppc/sha1.h               |   15 ++++++++++-----\n ppc/sha1ppc.S            |    4 ++--\n read-cache.c             |   28 ++++++++++++++--------------\n rerere.c                 |   10 +++++-----\n sha1_file.c              |   10 +++++-----\n test-sha1.c              |    8 ++++----\n 24 files changed, 162 insertions(+), 141 deletions(-)\n\ndiff --git a/arm/sha1.c b/arm/sha1.c\nindex 9e3ae03..c61ad4a 100644\n--- a/arm/sha1.c\n+++ b/arm/sha1.c\n@@ -8,9 +8,9 @@\n #include <string.h>\n #include \"sha1.h\"\n \n-extern void sha_transform(uint32_t *hash, const unsigned char *data, uint32_t *W);\n+extern void arm_sha_transform(uint32_t *hash, const unsigned char *data, uint32_t *W);\n \n-void SHA1_Init(SHA_CTX *c)\n+void arm_SHA1_Init(arm_SHA_CTX *c)\n {\n \tc->len = 0;\n \tc->hash[0] = 0x67452301;\n@@ -20,7 +20,7 @@ void SHA1_Init(SHA_CTX *c)\n \tc->hash[4] = 0xc3d2e1f0;\n }\n \n-void SHA1_Update(SHA_CTX *c, const void *p, unsigned long n)\n+void arm_SHA1_Update(arm_SHA_CTX *c, const void *p, unsigned long n)\n {\n \tuint32_t workspace[80];\n \tunsigned int partial;\n@@ -32,12 +32,12 @@ void SHA1_Update(SHA_CTX *c, const void *p, unsigned long n)\n \t\tif (partial) {\n \t\t\tdone = 64 - partial;\n \t\t\tmemcpy(c->buffer + partial, p, done);\n-\t\t\tsha_transform(c->hash, c->buffer, workspace);\n+\t\t\tarm_sha_transform(c->hash, c->buffer, workspace);\n \t\t\tpartial = 0;\n \t\t} else\n \t\t\tdone = 0;\n \t\twhile (n >= done + 64) {\n-\t\t\tsha_transform(c->hash, p + done, workspace);\n+\t\t\tarm_sha_transform(c->hash, p + done, workspace);\n \t\t\tdone += 64;\n \t\t}\n \t} else\n@@ -46,7 +46,7 @@ void SHA1_Update(SHA_CTX *c, const void *p, unsigned long n)\n \t\tmemcpy(c->buffer + partial, p + done, n - done);\n }\n \n-void SHA1_Final(unsigned char *hash, SHA_CTX *c)\n+void arm_SHA1_Final(unsigned char *hash, arm_SHA_CTX *c)\n {\n \tuint64_t bitlen;\n \tuint32_t bitlen_hi, bitlen_lo;\n@@ -57,7 +57,7 @@ void SHA1_Final(unsigned char *hash, SHA_CTX *c)\n \tbitlen = c->len << 3;\n \toffset = c->len & 0x3f;\n \tpadlen = ((offset < 56) ? 56 : (64 + 56)) - offset;\n-\tSHA1_Update(c, padding, padlen);\n+\tarm_SHA1_Update(c, padding, padlen);\n \n \tbitlen_hi = bitlen >> 32;\n \tbitlen_lo = bitlen & 0xffffffff;\n@@ -69,7 +69,7 @@ void SHA1_Final(unsigned char *hash, SHA_CTX *c)\n \tbits[5] = bitlen_lo >> 16;\n \tbits[6] = bitlen_lo >> 8;\n \tbits[7] = bitlen_lo;\n-\tSHA1_Update(c, bits, 8);\n+\tarm_SHA1_Update(c, bits, 8);\n \n \tfor (i = 0; i < 5; i++) {\n \t\tuint32_t v = c->hash[i];\ndiff --git a/arm/sha1.h b/arm/sha1.h\nindex 3952646..b61b618 100644\n--- a/arm/sha1.h\n+++ b/arm/sha1.h\n@@ -7,12 +7,17 @@\n \n #include <stdint.h>\n \n-typedef struct sha_context {\n+typedef struct {\n \tuint64_t len;\n \tuint32_t hash[5];\n \tunsigned char buffer[64];\n-} SHA_CTX;\n+} arm_SHA_CTX;\n \n-void SHA1_Init(SHA_CTX *c);\n-void SHA1_Update(SHA_CTX *c, const void *p, unsigned long n);\n-void SHA1_Final(unsigned char *hash, SHA_CTX *c);\n+void arm_SHA1_Init(arm_SHA_CTX *c);\n+void arm_SHA1_Update(arm_SHA_CTX *c, const void *p, unsigned long n);\n+void arm_SHA1_Final(unsigned char *hash, arm_SHA_CTX *c);\n+\n+#define git_SHA_CTX\tarm_SHA_CTX\n+#define git_SHA1_Init\tarm_SHA1_Init\n+#define git_SHA1_Update\tarm_SHA1_Update\n+#define git_SHA1_Final\tarm_SHA1_Final\ndiff --git a/arm/sha1_arm.S b/arm/sha1_arm.S\nindex 8c1cb99..41e9263 100644\n--- a/arm/sha1_arm.S\n+++ b/arm/sha1_arm.S\n@@ -10,7 +10,7 @@\n  */\n \n \t.text\n-\t.globl\tsha_transform\n+\t.globl\tarm_sha_transform\n \n /*\n  * void sha_transform(uint32_t *hash, const unsigned char *data, uint32_t *W);\n@@ -18,7 +18,7 @@\n  * note: the \"data\" pointer may be unaligned.\n  */\n \n-sha_transform:\n+arm_sha_transform:\n \n \tstmfd\tsp!, {r4 - r8, lr}\n \ndiff --git a/builtin-unpack-objects.c b/builtin-unpack-objects.c\nindex 40b20f2..d2796b6 100644\n--- a/builtin-unpack-objects.c\n+++ b/builtin-unpack-objects.c\n@@ -19,7 +19,7 @@ static const char unpack_usage[] = \"git unpack-objects [-n] [-q] [-r] [--strict]\n static unsigned char buffer[4096];\n static unsigned int offset, len;\n static off_t consumed_bytes;\n-static SHA_CTX ctx;\n+static git_SHA_CTX ctx;\n \n /*\n  * When running under --strict mode, objects whose reachability are\n@@ -59,7 +59,7 @@ static void *fill(int min)\n \tif (min > sizeof(buffer))\n \t\tdie(\"cannot fill %d bytes\", min);\n \tif (offset) {\n-\t\tSHA1_Update(&ctx, buffer, offset);\n+\t\tgit_SHA1_Update(&ctx, buffer, offset);\n \t\tmemmove(buffer, buffer + offset, len);\n \t\toffset = 0;\n \t}\n@@ -539,10 +539,10 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix)\n \t\t/* We don't take any non-flag arguments now.. Maybe some day */\n \t\tusage(unpack_usage);\n \t}\n-\tSHA1_Init(&ctx);\n+\tgit_SHA1_Init(&ctx);\n \tunpack_all();\n-\tSHA1_Update(&ctx, buffer, offset);\n-\tSHA1_Final(sha1, &ctx);\n+\tgit_SHA1_Update(&ctx, buffer, offset);\n+\tgit_SHA1_Final(sha1, &ctx);\n \tif (strict)\n \t\twrite_rest();\n \tif (hashcmp(fill(20), sha1))\ndiff --git a/cache.h b/cache.h\nindex f4b8ddf..9ff1b2f 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -6,8 +6,14 @@\n #include \"hash.h\"\n \n #include SHA1_HEADER\n-#include <zlib.h>\n+#ifndef git_SHA_CTX\n+#define git_SHA_CTX\tSHA_CTX\n+#define git_SHA1_Init\tSHA1_Init\n+#define git_SHA1_Update\tSHA1_Update\n+#define git_SHA1_Final\tSHA1_Final\n+#endif\n \n+#include <zlib.h>\n #if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200\n #define deflateBound(c,s)  ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)\n #endif\ndiff --git a/csum-file.c b/csum-file.c\nindex bb70c75..717d29f 100644\n--- a/csum-file.c\n+++ b/csum-file.c\n@@ -36,11 +36,11 @@ int sha1close(struct sha1file *f, unsigned char *result, unsigned int flags)\n \tunsigned offset = f->offset;\n \n \tif (offset) {\n-\t\tSHA1_Update(&f->ctx, f->buffer, offset);\n+\t\tgit_SHA1_Update(&f->ctx, f->buffer, offset);\n \t\tsha1flush(f, f->buffer, offset);\n \t\tf->offset = 0;\n \t}\n-\tSHA1_Final(f->buffer, &f->ctx);\n+\tgit_SHA1_Final(f->buffer, &f->ctx);\n \tif (result)\n \t\thashcpy(result, f->buffer);\n \tif (flags & (CSUM_CLOSE | CSUM_FSYNC)) {\n@@ -82,7 +82,7 @@ int sha1write(struct sha1file *f, void *buf, unsigned int count)\n \t\tbuf = (char *) buf + nr;\n \t\tleft -= nr;\n \t\tif (!left) {\n-\t\t\tSHA1_Update(&f->ctx, data, offset);\n+\t\t\tgit_SHA1_Update(&f->ctx, data, offset);\n \t\t\tsha1flush(f, data, offset);\n \t\t\toffset = 0;\n \t\t}\n@@ -105,7 +105,7 @@ struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp\n \tf->tp = tp;\n \tf->name = name;\n \tf->do_crc = 0;\n-\tSHA1_Init(&f->ctx);\n+\tgit_SHA1_Init(&f->ctx);\n \treturn f;\n }\n \ndiff --git a/csum-file.h b/csum-file.h\nindex 72c9487..9e13342 100644\n--- a/csum-file.h\n+++ b/csum-file.h\n@@ -7,7 +7,7 @@ struct progress;\n struct sha1file {\n \tint fd;\n \tunsigned int offset;\n-\tSHA_CTX ctx;\n+\tgit_SHA_CTX ctx;\n \toff_t total;\n \tstruct progress *tp;\n \tconst char *name;\ndiff --git a/diff.c b/diff.c\nindex b001d7b..e023348 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3089,7 +3089,7 @@ static void diff_summary(FILE *file, struct diff_filepair *p)\n }\n \n struct patch_id_t {\n-\tSHA_CTX *ctx;\n+\tgit_SHA_CTX *ctx;\n \tint patchlen;\n };\n \n@@ -3117,7 +3117,7 @@ static void patch_id_consume(void *priv, char *line, unsigned long len)\n \n \tnew_len = remove_space(line, len);\n \n-\tSHA1_Update(data->ctx, line, new_len);\n+\tgit_SHA1_Update(data->ctx, line, new_len);\n \tdata->patchlen += new_len;\n }\n \n@@ -3126,11 +3126,11 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)\n {\n \tstruct diff_queue_struct *q = &diff_queued_diff;\n \tint i;\n-\tSHA_CTX ctx;\n+\tgit_SHA_CTX ctx;\n \tstruct patch_id_t data;\n \tchar buffer[PATH_MAX * 4 + 20];\n \n-\tSHA1_Init(&ctx);\n+\tgit_SHA1_Init(&ctx);\n \tmemset(&data, 0, sizeof(struct patch_id_t));\n \tdata.ctx = &ctx;\n \n@@ -3192,7 +3192,7 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)\n \t\t\t\t\tlen2, p->two->path,\n \t\t\t\t\tlen1, p->one->path,\n \t\t\t\t\tlen2, p->two->path);\n-\t\tSHA1_Update(&ctx, buffer, len1);\n+\t\tgit_SHA1_Update(&ctx, buffer, len1);\n \n \t\txpp.flags = XDF_NEED_MINIMAL;\n \t\txecfg.ctxlen = 3;\n@@ -3201,7 +3201,7 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)\n \t\t\t      &xpp, &xecfg, &ecb);\n \t}\n \n-\tSHA1_Final(sha1, &ctx);\n+\tgit_SHA1_Final(sha1, &ctx);\n \treturn 0;\n }\n \ndiff --git a/fast-import.c b/fast-import.c\nindex ab6689a..3c035a5 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -845,7 +845,7 @@ static int oecmp (const void *a_, const void *b_)\n static char *create_index(void)\n {\n \tstatic char tmpfile[PATH_MAX];\n-\tSHA_CTX ctx;\n+\tgit_SHA_CTX ctx;\n \tstruct sha1file *f;\n \tstruct object_entry **idx, **c, **last, *e;\n \tstruct object_entry_pool *o;\n@@ -882,17 +882,17 @@ static char *create_index(void)\n \tidx_fd = xmkstemp(tmpfile);\n \tf = sha1fd(idx_fd, tmpfile);\n \tsha1write(f, array, 256 * sizeof(int));\n-\tSHA1_Init(&ctx);\n+\tgit_SHA1_Init(&ctx);\n \tfor (c = idx; c != last; c++) {\n \t\tuint32_t offset = htonl((*c)->offset);\n \t\tsha1write(f, &offset, 4);\n \t\tsha1write(f, (*c)->sha1, sizeof((*c)->sha1));\n-\t\tSHA1_Update(&ctx, (*c)->sha1, 20);\n+\t\tgit_SHA1_Update(&ctx, (*c)->sha1, 20);\n \t}\n \tsha1write(f, pack_data->sha1, sizeof(pack_data->sha1));\n \tsha1close(f, NULL, CSUM_FSYNC);\n \tfree(idx);\n-\tSHA1_Final(pack_data->sha1, &ctx);\n+\tgit_SHA1_Final(pack_data->sha1, &ctx);\n \treturn tmpfile;\n }\n \n@@ -1033,15 +1033,15 @@ static int store_object(\n \tunsigned char hdr[96];\n \tunsigned char sha1[20];\n \tunsigned long hdrlen, deltalen;\n-\tSHA_CTX c;\n+\tgit_SHA_CTX c;\n \tz_stream s;\n \n \thdrlen = sprintf((char*)hdr,\"%s %lu\", typename(type),\n \t\t(unsigned long)dat->len) + 1;\n-\tSHA1_Init(&c);\n-\tSHA1_Update(&c, hdr, hdrlen);\n-\tSHA1_Update(&c, dat->buf, dat->len);\n-\tSHA1_Final(sha1, &c);\n+\tgit_SHA1_Init(&c);\n+\tgit_SHA1_Update(&c, hdr, hdrlen);\n+\tgit_SHA1_Update(&c, dat->buf, dat->len);\n+\tgit_SHA1_Final(sha1, &c);\n \tif (sha1out)\n \t\thashcpy(sha1out, sha1);\n \ndiff --git a/http-push.c b/http-push.c\nindex c9dd9a1..42f4d78 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -126,7 +126,7 @@ struct transfer_request\n \tchar errorstr[CURL_ERROR_SIZE];\n \tlong http_code;\n \tunsigned char real_sha1[20];\n-\tSHA_CTX c;\n+\tgit_SHA_CTX c;\n \tz_stream stream;\n \tint zret;\n \tint rename;\n@@ -209,7 +209,7 @@ static size_t fwrite_sha1_file(void *ptr, size_t eltsize, size_t nmemb,\n \t\trequest->stream.next_out = expn;\n \t\trequest->stream.avail_out = sizeof(expn);\n \t\trequest->zret = inflate(&request->stream, Z_SYNC_FLUSH);\n-\t\tSHA1_Update(&request->c, expn,\n+\t\tgit_SHA1_Update(&request->c, expn,\n \t\t\t    sizeof(expn) - request->stream.avail_out);\n \t} while (request->stream.avail_in && request->zret == Z_OK);\n \tdata_received++;\n@@ -270,7 +270,7 @@ static void start_fetch_loose(struct transfer_request *request)\n \n \tinflateInit(&request->stream);\n \n-\tSHA1_Init(&request->c);\n+\tgit_SHA1_Init(&request->c);\n \n \turl = xmalloc(strlen(remote->url) + 50);\n \trequest->url = xmalloc(strlen(remote->url) + 50);\n@@ -310,7 +310,7 @@ static void start_fetch_loose(struct transfer_request *request)\n \tif (prev_read == -1) {\n \t\tmemset(&request->stream, 0, sizeof(request->stream));\n \t\tinflateInit(&request->stream);\n-\t\tSHA1_Init(&request->c);\n+\t\tgit_SHA1_Init(&request->c);\n \t\tif (prev_posn>0) {\n \t\t\tprev_posn = 0;\n \t\t\tlseek(request->local_fileno, 0, SEEK_SET);\n@@ -742,7 +742,7 @@ static void finish_request(struct transfer_request *request)\n \t\t\t\tfprintf(stderr, \"Warning: requested range invalid; we may already have all the data.\\n\");\n \n \t\t\tinflateEnd(&request->stream);\n-\t\t\tSHA1_Final(request->real_sha1, &request->c);\n+\t\t\tgit_SHA1_Final(request->real_sha1, &request->c);\n \t\t\tif (request->zret != Z_STREAM_END) {\n \t\t\t\tunlink(request->tmpfile);\n \t\t\t} else if (hashcmp(request->obj->sha1, request->real_sha1)) {\ndiff --git a/http-walker.c b/http-walker.c\nindex 9dc6b27..7271c7d 100644\n--- a/http-walker.c\n+++ b/http-walker.c\n@@ -36,7 +36,7 @@ struct object_request\n \tchar errorstr[CURL_ERROR_SIZE];\n \tlong http_code;\n \tunsigned char real_sha1[20];\n-\tSHA_CTX c;\n+\tgit_SHA_CTX c;\n \tz_stream stream;\n \tint zret;\n \tint rename;\n@@ -83,7 +83,7 @@ static size_t fwrite_sha1_file(void *ptr, size_t eltsize, size_t nmemb,\n \t\tobj_req->stream.next_out = expn;\n \t\tobj_req->stream.avail_out = sizeof(expn);\n \t\tobj_req->zret = inflate(&obj_req->stream, Z_SYNC_FLUSH);\n-\t\tSHA1_Update(&obj_req->c, expn,\n+\t\tgit_SHA1_Update(&obj_req->c, expn,\n \t\t\t    sizeof(expn) - obj_req->stream.avail_out);\n \t} while (obj_req->stream.avail_in && obj_req->zret == Z_OK);\n \tdata_received++;\n@@ -144,7 +144,7 @@ static void start_object_request(struct walker *walker,\n \n \tinflateInit(&obj_req->stream);\n \n-\tSHA1_Init(&obj_req->c);\n+\tgit_SHA1_Init(&obj_req->c);\n \n \turl = xmalloc(strlen(obj_req->repo->base) + 51);\n \tobj_req->url = xmalloc(strlen(obj_req->repo->base) + 51);\n@@ -184,7 +184,7 @@ static void start_object_request(struct walker *walker,\n \tif (prev_read == -1) {\n \t\tmemset(&obj_req->stream, 0, sizeof(obj_req->stream));\n \t\tinflateInit(&obj_req->stream);\n-\t\tSHA1_Init(&obj_req->c);\n+\t\tgit_SHA1_Init(&obj_req->c);\n \t\tif (prev_posn>0) {\n \t\t\tprev_posn = 0;\n \t\t\tlseek(obj_req->local, 0, SEEK_SET);\n@@ -244,7 +244,7 @@ static void finish_object_request(struct object_request *obj_req)\n \t}\n \n \tinflateEnd(&obj_req->stream);\n-\tSHA1_Final(obj_req->real_sha1, &obj_req->c);\n+\tgit_SHA1_Final(obj_req->real_sha1, &obj_req->c);\n \tif (obj_req->zret != Z_STREAM_END) {\n \t\tunlink(obj_req->tmpfile);\n \t\treturn;\ndiff --git a/index-pack.c b/index-pack.c\nindex 530d820..2e4c088 100644\n--- a/index-pack.c\n+++ b/index-pack.c\n@@ -67,7 +67,7 @@ static struct progress *progress;\n static unsigned char input_buffer[4096];\n static unsigned int input_offset, input_len;\n static off_t consumed_bytes;\n-static SHA_CTX input_ctx;\n+static git_SHA_CTX input_ctx;\n static uint32_t input_crc32;\n static int input_fd, output_fd, pack_fd;\n \n@@ -119,7 +119,7 @@ static void flush(void)\n \tif (input_offset) {\n \t\tif (output_fd >= 0)\n \t\t\twrite_or_die(output_fd, input_buffer, input_offset);\n-\t\tSHA1_Update(&input_ctx, input_buffer, input_offset);\n+\t\tgit_SHA1_Update(&input_ctx, input_buffer, input_offset);\n \t\tmemmove(input_buffer, input_buffer + input_offset, input_len);\n \t\tinput_offset = 0;\n \t}\n@@ -188,7 +188,7 @@ static char *open_pack_file(char *pack_name)\n \t\toutput_fd = -1;\n \t\tpack_fd = input_fd;\n \t}\n-\tSHA1_Init(&input_ctx);\n+\tgit_SHA1_Init(&input_ctx);\n \treturn pack_name;\n }\n \n@@ -588,7 +588,7 @@ static void parse_pack_objects(unsigned char *sha1)\n \n \t/* Check pack integrity */\n \tflush();\n-\tSHA1_Final(sha1, &input_ctx);\n+\tgit_SHA1_Final(sha1, &input_ctx);\n \tif (hashcmp(fill(20), sha1))\n \t\tdie(\"pack is corrupted (SHA1 mismatch)\");\n \tuse(20);\ndiff --git a/mozilla-sha1/sha1.c b/mozilla-sha1/sha1.c\nindex 3f06b83..95a4ebf 100644\n--- a/mozilla-sha1/sha1.c\n+++ b/mozilla-sha1/sha1.c\n@@ -35,9 +35,9 @@\n \n #include \"sha1.h\"\n \n-static void shaHashBlock(SHA_CTX *ctx);\n+static void shaHashBlock(moz_SHA_CTX *ctx);\n \n-void SHA1_Init(SHA_CTX *ctx) {\n+void moz_SHA1_Init(moz_SHA_CTX *ctx) {\n   int i;\n \n   ctx->lenW = 0;\n@@ -56,7 +56,7 @@ void SHA1_Init(SHA_CTX *ctx) {\n }\n \n \n-void SHA1_Update(SHA_CTX *ctx, const void *_dataIn, int len) {\n+void moz_SHA1_Update(moz_SHA_CTX *ctx, const void *_dataIn, int len) {\n   const unsigned char *dataIn = _dataIn;\n   int i;\n \n@@ -75,7 +75,7 @@ void SHA1_Update(SHA_CTX *ctx, const void *_dataIn, int len) {\n }\n \n \n-void SHA1_Final(unsigned char hashout[20], SHA_CTX *ctx) {\n+void moz_SHA1_Final(unsigned char hashout[20], moz_SHA_CTX *ctx) {\n   unsigned char pad0x80 = 0x80;\n   unsigned char pad0x00 = 0x00;\n   unsigned char padlen[8];\n@@ -91,10 +91,10 @@ void SHA1_Final(unsigned char hashout[20], SHA_CTX *ctx) {\n   padlen[5] = (unsigned char)((ctx->sizeLo >> 16) & 255);\n   padlen[6] = (unsigned char)((ctx->sizeLo >> 8) & 255);\n   padlen[7] = (unsigned char)((ctx->sizeLo >> 0) & 255);\n-  SHA1_Update(ctx, &pad0x80, 1);\n+  moz_SHA1_Update(ctx, &pad0x80, 1);\n   while (ctx->lenW != 56)\n-    SHA1_Update(ctx, &pad0x00, 1);\n-  SHA1_Update(ctx, padlen, 8);\n+    moz_SHA1_Update(ctx, &pad0x00, 1);\n+  moz_SHA1_Update(ctx, padlen, 8);\n \n   /* Output hash\n    */\n@@ -106,13 +106,13 @@ void SHA1_Final(unsigned char hashout[20], SHA_CTX *ctx) {\n   /*\n    *  Re-initialize the context (also zeroizes contents)\n    */\n-  SHA1_Init(ctx);\n+  moz_SHA1_Init(ctx);\n }\n \n \n #define SHA_ROT(X,n) (((X) << (n)) | ((X) >> (32-(n))))\n \n-static void shaHashBlock(SHA_CTX *ctx) {\n+static void shaHashBlock(moz_SHA_CTX *ctx) {\n   int t;\n   unsigned int A,B,C,D,E,TEMP;\n \ndiff --git a/mozilla-sha1/sha1.h b/mozilla-sha1/sha1.h\nindex 16f2d3d..aa48a46 100644\n--- a/mozilla-sha1/sha1.h\n+++ b/mozilla-sha1/sha1.h\n@@ -38,8 +38,13 @@ typedef struct {\n   unsigned int W[80];\n   int lenW;\n   unsigned int sizeHi,sizeLo;\n-} SHA_CTX;\n+} moz_SHA_CTX;\n \n-void SHA1_Init(SHA_CTX *ctx);\n-void SHA1_Update(SHA_CTX *ctx, const void *dataIn, int len);\n-void SHA1_Final(unsigned char hashout[20], SHA_CTX *ctx);\n+void moz_SHA1_Init(moz_SHA_CTX *ctx);\n+void moz_SHA1_Update(moz_SHA_CTX *ctx, const void *dataIn, int len);\n+void moz_SHA1_Final(unsigned char hashout[20], moz_SHA_CTX *ctx);\n+\n+#define git_SHA_CTX\tmoz_SHA_CTX\n+#define git_SHA1_Init\tmoz_SHA1_Init\n+#define git_SHA1_Update\tmoz_SHA1_Update\n+#define git_SHA1_Final\tmoz_SHA1_Final\ndiff --git a/pack-check.c b/pack-check.c\nindex f596bf2..90c33b1 100644\n--- a/pack-check.c\n+++ b/pack-check.c\n@@ -47,7 +47,7 @@ static int verify_packfile(struct packed_git *p,\n {\n \toff_t index_size = p->index_size;\n \tconst unsigned char *index_base = p->index_data;\n-\tSHA_CTX ctx;\n+\tgit_SHA_CTX ctx;\n \tunsigned char sha1[20], *pack_sig;\n \toff_t offset = 0, pack_sig_ofs = p->pack_size - 20;\n \tuint32_t nr_objects, i;\n@@ -60,16 +60,16 @@ static int verify_packfile(struct packed_git *p,\n \t * immediately.\n \t */\n \n-\tSHA1_Init(&ctx);\n+\tgit_SHA1_Init(&ctx);\n \twhile (offset < pack_sig_ofs) {\n \t\tunsigned int remaining;\n \t\tunsigned char *in = use_pack(p, w_curs, offset, &remaining);\n \t\toffset += remaining;\n \t\tif (offset > pack_sig_ofs)\n \t\t\tremaining -= (unsigned int)(offset - pack_sig_ofs);\n-\t\tSHA1_Update(&ctx, in, remaining);\n+\t\tgit_SHA1_Update(&ctx, in, remaining);\n \t}\n-\tSHA1_Final(sha1, &ctx);\n+\tgit_SHA1_Final(sha1, &ctx);\n \tpack_sig = use_pack(p, w_curs, pack_sig_ofs, NULL);\n \tif (hashcmp(sha1, pack_sig))\n \t\terr = error(\"%s SHA1 checksum mismatch\",\n@@ -135,7 +135,7 @@ int verify_pack(struct packed_git *p)\n {\n \toff_t index_size;\n \tconst unsigned char *index_base;\n-\tSHA_CTX ctx;\n+\tgit_SHA_CTX ctx;\n \tunsigned char sha1[20];\n \tint err = 0;\n \tstruct pack_window *w_curs = NULL;\n@@ -146,9 +146,9 @@ int verify_pack(struct packed_git *p)\n \tindex_base = p->index_data;\n \n \t/* Verify SHA1 sum of the index file */\n-\tSHA1_Init(&ctx);\n-\tSHA1_Update(&ctx, index_base, (unsigned int)(index_size - 20));\n-\tSHA1_Final(sha1, &ctx);\n+\tgit_SHA1_Init(&ctx);\n+\tgit_SHA1_Update(&ctx, index_base, (unsigned int)(index_size - 20));\n+\tgit_SHA1_Final(sha1, &ctx);\n \tif (hashcmp(sha1, index_base + index_size - 20))\n \t\terr = error(\"Packfile index for %s SHA1 mismatch\",\n \t\t\t    p->pack_name);\ndiff --git a/pack-write.c b/pack-write.c\nindex 3621f1d..b426006 100644\n--- a/pack-write.c\n+++ b/pack-write.c\n@@ -25,7 +25,7 @@ char *write_idx_file(char *index_name, struct pack_idx_entry **objects,\n \toff_t last_obj_offset = 0;\n \tuint32_t array[256];\n \tint i, fd;\n-\tSHA_CTX ctx;\n+\tgit_SHA_CTX ctx;\n \tuint32_t index_version;\n \n \tif (nr_objects) {\n@@ -86,7 +86,7 @@ char *write_idx_file(char *index_name, struct pack_idx_entry **objects,\n \tsha1write(f, array, 256 * 4);\n \n \t/* compute the SHA1 hash of sorted object names. */\n-\tSHA1_Init(&ctx);\n+\tgit_SHA1_Init(&ctx);\n \n \t/*\n \t * Write the actual SHA1 entries..\n@@ -99,7 +99,7 @@ char *write_idx_file(char *index_name, struct pack_idx_entry **objects,\n \t\t\tsha1write(f, &offset, 4);\n \t\t}\n \t\tsha1write(f, obj->sha1, 20);\n-\t\tSHA1_Update(&ctx, obj->sha1, 20);\n+\t\tgit_SHA1_Update(&ctx, obj->sha1, 20);\n \t}\n \n \tif (index_version >= 2) {\n@@ -140,7 +140,7 @@ char *write_idx_file(char *index_name, struct pack_idx_entry **objects,\n \n \tsha1write(f, sha1, 20);\n \tsha1close(f, NULL, CSUM_FSYNC);\n-\tSHA1_Final(sha1, &ctx);\n+\tgit_SHA1_Final(sha1, &ctx);\n \treturn index_name;\n }\n \n@@ -168,12 +168,12 @@ void fixup_pack_header_footer(int pack_fd,\n \t\t\t off_t partial_pack_offset)\n {\n \tint aligned_sz, buf_sz = 8 * 1024;\n-\tSHA_CTX old_sha1_ctx, new_sha1_ctx;\n+\tgit_SHA_CTX old_sha1_ctx, new_sha1_ctx;\n \tstruct pack_header hdr;\n \tchar *buf;\n \n-\tSHA1_Init(&old_sha1_ctx);\n-\tSHA1_Init(&new_sha1_ctx);\n+\tgit_SHA1_Init(&old_sha1_ctx);\n+\tgit_SHA1_Init(&new_sha1_ctx);\n \n \tif (lseek(pack_fd, 0, SEEK_SET) != 0)\n \t\tdie(\"Failed seeking to start of %s: %s\", pack_name, strerror(errno));\n@@ -181,9 +181,9 @@ void fixup_pack_header_footer(int pack_fd,\n \t\tdie(\"Unable to reread header of %s: %s\", pack_name, strerror(errno));\n \tif (lseek(pack_fd, 0, SEEK_SET) != 0)\n \t\tdie(\"Failed seeking to start of %s: %s\", pack_name, strerror(errno));\n-\tSHA1_Update(&old_sha1_ctx, &hdr, sizeof(hdr));\n+\tgit_SHA1_Update(&old_sha1_ctx, &hdr, sizeof(hdr));\n \thdr.hdr_entries = htonl(object_count);\n-\tSHA1_Update(&new_sha1_ctx, &hdr, sizeof(hdr));\n+\tgit_SHA1_Update(&new_sha1_ctx, &hdr, sizeof(hdr));\n \twrite_or_die(pack_fd, &hdr, sizeof(hdr));\n \tpartial_pack_offset -= sizeof(hdr);\n \n@@ -198,7 +198,7 @@ void fixup_pack_header_footer(int pack_fd,\n \t\t\tbreak;\n \t\tif (n < 0)\n \t\t\tdie(\"Failed to checksum %s: %s\", pack_name, strerror(errno));\n-\t\tSHA1_Update(&new_sha1_ctx, buf, n);\n+\t\tgit_SHA1_Update(&new_sha1_ctx, buf, n);\n \n \t\taligned_sz -= n;\n \t\tif (!aligned_sz)\n@@ -207,11 +207,11 @@ void fixup_pack_header_footer(int pack_fd,\n \t\tif (!partial_pack_sha1)\n \t\t\tcontinue;\n \n-\t\tSHA1_Update(&old_sha1_ctx, buf, n);\n+\t\tgit_SHA1_Update(&old_sha1_ctx, buf, n);\n \t\tpartial_pack_offset -= n;\n \t\tif (partial_pack_offset == 0) {\n \t\t\tunsigned char sha1[20];\n-\t\t\tSHA1_Final(sha1, &old_sha1_ctx);\n+\t\t\tgit_SHA1_Final(sha1, &old_sha1_ctx);\n \t\t\tif (hashcmp(sha1, partial_pack_sha1) != 0)\n \t\t\t\tdie(\"Unexpected checksum for %s \"\n \t\t\t\t    \"(disk corruption?)\", pack_name);\n@@ -220,7 +220,7 @@ void fixup_pack_header_footer(int pack_fd,\n \t\t\t * pack, which also means making partial_pack_offset\n \t\t\t * big enough not to matter anymore.\n \t\t\t */\n-\t\t\tSHA1_Init(&old_sha1_ctx);\n+\t\t\tgit_SHA1_Init(&old_sha1_ctx);\n \t\t\tpartial_pack_offset = ~partial_pack_offset;\n \t\t\tpartial_pack_offset -= MSB(partial_pack_offset, 1);\n \t\t}\n@@ -228,8 +228,8 @@ void fixup_pack_header_footer(int pack_fd,\n \tfree(buf);\n \n \tif (partial_pack_sha1)\n-\t\tSHA1_Final(partial_pack_sha1, &old_sha1_ctx);\n-\tSHA1_Final(new_pack_sha1, &new_sha1_ctx);\n+\t\tgit_SHA1_Final(partial_pack_sha1, &old_sha1_ctx);\n+\tgit_SHA1_Final(new_pack_sha1, &new_sha1_ctx);\n \twrite_or_die(pack_fd, new_pack_sha1, 20);\n \tfsync_or_die(pack_fd, pack_name);\n }\ndiff --git a/patch-id.c b/patch-id.c\nindex 9349bc5..871f1d2 100644\n--- a/patch-id.c\n+++ b/patch-id.c\n@@ -1,6 +1,6 @@\n #include \"cache.h\"\n \n-static void flush_current_id(int patchlen, unsigned char *id, SHA_CTX *c)\n+static void flush_current_id(int patchlen, unsigned char *id, git_SHA_CTX *c)\n {\n \tunsigned char result[20];\n \tchar name[50];\n@@ -8,10 +8,10 @@ static void flush_current_id(int patchlen, unsigned char *id, SHA_CTX *c)\n \tif (!patchlen)\n \t\treturn;\n \n-\tSHA1_Final(result, c);\n+\tgit_SHA1_Final(result, c);\n \tmemcpy(name, sha1_to_hex(id), 41);\n \tprintf(\"%s %s\\n\", sha1_to_hex(result), name);\n-\tSHA1_Init(c);\n+\tgit_SHA1_Init(c);\n }\n \n static int remove_space(char *line)\n@@ -31,10 +31,10 @@ static void generate_id_list(void)\n {\n \tstatic unsigned char sha1[20];\n \tstatic char line[1000];\n-\tSHA_CTX ctx;\n+\tgit_SHA_CTX ctx;\n \tint patchlen = 0;\n \n-\tSHA1_Init(&ctx);\n+\tgit_SHA1_Init(&ctx);\n \twhile (fgets(line, sizeof(line), stdin) != NULL) {\n \t\tunsigned char n[20];\n \t\tchar *p = line;\n@@ -67,7 +67,7 @@ static void generate_id_list(void)\n \t\t/* Compute the sha without whitespace */\n \t\tlen = remove_space(line);\n \t\tpatchlen += len;\n-\t\tSHA1_Update(&ctx, line, len);\n+\t\tgit_SHA1_Update(&ctx, line, len);\n \t}\n \tflush_current_id(patchlen, sha1, &ctx);\n }\ndiff --git a/ppc/sha1.c b/ppc/sha1.c\nindex 738e36c..ec6a192 100644\n--- a/ppc/sha1.c\n+++ b/ppc/sha1.c\n@@ -10,10 +10,10 @@\n #include <string.h>\n #include \"sha1.h\"\n \n-extern void sha1_core(uint32_t *hash, const unsigned char *p,\n-\t\t      unsigned int nblocks);\n+extern void ppc_sha1_core(uint32_t *hash, const unsigned char *p,\n+\t\t\t  unsigned int nblocks);\n \n-int SHA1_Init(SHA_CTX *c)\n+int ppc_SHA1_Init(ppc_SHA_CTX *c)\n {\n \tc->hash[0] = 0x67452301;\n \tc->hash[1] = 0xEFCDAB89;\n@@ -25,7 +25,7 @@ int SHA1_Init(SHA_CTX *c)\n \treturn 0;\n }\n \n-int SHA1_Update(SHA_CTX *c, const void *ptr, unsigned long n)\n+int ppc_SHA1_Update(ppc_SHA_CTX *c, const void *ptr, unsigned long n)\n {\n \tunsigned long nb;\n \tconst unsigned char *p = ptr;\n@@ -38,12 +38,12 @@ int SHA1_Update(SHA_CTX *c, const void *ptr, unsigned long n)\n \t\t\t\tnb = n;\n \t\t\tmemcpy(&c->buf.b[c->cnt], p, nb);\n \t\t\tif ((c->cnt += nb) == 64) {\n-\t\t\t\tsha1_core(c->hash, c->buf.b, 1);\n+\t\t\t\tppc_sha1_core(c->hash, c->buf.b, 1);\n \t\t\t\tc->cnt = 0;\n \t\t\t}\n \t\t} else {\n \t\t\tnb = n >> 6;\n-\t\t\tsha1_core(c->hash, p, nb);\n+\t\t\tppc_sha1_core(c->hash, p, nb);\n \t\t\tnb <<= 6;\n \t\t}\n \t\tn -= nb;\n@@ -52,7 +52,7 @@ int SHA1_Update(SHA_CTX *c, const void *ptr, unsigned long n)\n \treturn 0;\n }\n \n-int SHA1_Final(unsigned char *hash, SHA_CTX *c)\n+int ppc_SHA1_Final(unsigned char *hash, ppc_SHA_CTX *c)\n {\n \tunsigned int cnt = c->cnt;\n \n@@ -60,13 +60,13 @@ int SHA1_Final(unsigned char *hash, SHA_CTX *c)\n \tif (cnt > 56) {\n \t\tif (cnt < 64)\n \t\t\tmemset(&c->buf.b[cnt], 0, 64 - cnt);\n-\t\tsha1_core(c->hash, c->buf.b, 1);\n+\t\tppc_sha1_core(c->hash, c->buf.b, 1);\n \t\tcnt = 0;\n \t}\n \tif (cnt < 56)\n \t\tmemset(&c->buf.b[cnt], 0, 56 - cnt);\n \tc->buf.l[7] = c->len;\n-\tsha1_core(c->hash, c->buf.b, 1);\n+\tppc_sha1_core(c->hash, c->buf.b, 1);\n \tmemcpy(hash, c->hash, 20);\n \treturn 0;\n }\ndiff --git a/ppc/sha1.h b/ppc/sha1.h\nindex c3c51aa..c405f73 100644\n--- a/ppc/sha1.h\n+++ b/ppc/sha1.h\n@@ -5,7 +5,7 @@\n  */\n #include <stdint.h>\n \n-typedef struct sha_context {\n+typedef struct {\n \tuint32_t hash[5];\n \tuint32_t cnt;\n \tuint64_t len;\n@@ -13,8 +13,13 @@ typedef struct sha_context {\n \t\tunsigned char b[64];\n \t\tuint64_t l[8];\n \t} buf;\n-} SHA_CTX;\n+} ppc_SHA_CTX;\n \n-int SHA1_Init(SHA_CTX *c);\n-int SHA1_Update(SHA_CTX *c, const void *p, unsigned long n);\n-int SHA1_Final(unsigned char *hash, SHA_CTX *c);\n+int ppc_SHA1_Init(ppc_SHA_CTX *c);\n+int ppc_SHA1_Update(ppc_SHA_CTX *c, const void *p, unsigned long n);\n+int ppc_SHA1_Final(unsigned char *hash, ppc_SHA_CTX *c);\n+\n+#define git_SHA_CTX\tppc_SHA_CTX\n+#define git_SHA1_Init\tppc_SHA1_Init\n+#define git_SHA1_Update\tppc_SHA1_Update\n+#define git_SHA1_Final\tppc_SHA1_Final\ndiff --git a/ppc/sha1ppc.S b/ppc/sha1ppc.S\nindex f132696..1711eef 100644\n--- a/ppc/sha1ppc.S\n+++ b/ppc/sha1ppc.S\n@@ -162,8 +162,8 @@ add RE(t),RE(t),%r0;  rotlwi RB(t),RB(t),30\n \tSTEPUP4(fn, (t)+12, (s)+12,);\t\\\n \tSTEPUP4(fn, (t)+16, (s)+16, loadk)\n \n-\t.globl\tsha1_core\n-sha1_core:\n+\t.globl\tppc_sha1_core\n+ppc_sha1_core:\n \tstwu\t%r1,-80(%r1)\n \tstmw\t%r13,4(%r1)\n \ndiff --git a/read-cache.c b/read-cache.c\nindex c5a8659..d7900f3 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -1091,16 +1091,16 @@ struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int really)\n \n static int verify_hdr(struct cache_header *hdr, unsigned long size)\n {\n-\tSHA_CTX c;\n+\tgit_SHA_CTX c;\n \tunsigned char sha1[20];\n \n \tif (hdr->hdr_signature != htonl(CACHE_SIGNATURE))\n \t\treturn error(\"bad signature\");\n \tif (hdr->hdr_version != htonl(2))\n \t\treturn error(\"bad index version\");\n-\tSHA1_Init(&c);\n-\tSHA1_Update(&c, hdr, size - 20);\n-\tSHA1_Final(sha1, &c);\n+\tgit_SHA1_Init(&c);\n+\tgit_SHA1_Update(&c, hdr, size - 20);\n+\tgit_SHA1_Final(sha1, &c);\n \tif (hashcmp(sha1, (unsigned char *)hdr + size - 20))\n \t\treturn error(\"bad index file sha1 signature\");\n \treturn 0;\n@@ -1297,11 +1297,11 @@ int unmerged_index(const struct index_state *istate)\n static unsigned char write_buffer[WRITE_BUFFER_SIZE];\n static unsigned long write_buffer_len;\n \n-static int ce_write_flush(SHA_CTX *context, int fd)\n+static int ce_write_flush(git_SHA_CTX *context, int fd)\n {\n \tunsigned int buffered = write_buffer_len;\n \tif (buffered) {\n-\t\tSHA1_Update(context, write_buffer, buffered);\n+\t\tgit_SHA1_Update(context, write_buffer, buffered);\n \t\tif (write_in_full(fd, write_buffer, buffered) != buffered)\n \t\t\treturn -1;\n \t\twrite_buffer_len = 0;\n@@ -1309,7 +1309,7 @@ static int ce_write_flush(SHA_CTX *context, int fd)\n \treturn 0;\n }\n \n-static int ce_write(SHA_CTX *context, int fd, void *data, unsigned int len)\n+static int ce_write(git_SHA_CTX *context, int fd, void *data, unsigned int len)\n {\n \twhile (len) {\n \t\tunsigned int buffered = write_buffer_len;\n@@ -1331,7 +1331,7 @@ static int ce_write(SHA_CTX *context, int fd, void *data, unsigned int len)\n \treturn 0;\n }\n \n-static int write_index_ext_header(SHA_CTX *context, int fd,\n+static int write_index_ext_header(git_SHA_CTX *context, int fd,\n \t\t\t\t  unsigned int ext, unsigned int sz)\n {\n \text = htonl(ext);\n@@ -1340,13 +1340,13 @@ static int write_index_ext_header(SHA_CTX *context, int fd,\n \t\t(ce_write(context, fd, &sz, 4) < 0)) ? -1 : 0;\n }\n \n-static int ce_flush(SHA_CTX *context, int fd)\n+static int ce_flush(git_SHA_CTX *context, int fd)\n {\n \tunsigned int left = write_buffer_len;\n \n \tif (left) {\n \t\twrite_buffer_len = 0;\n-\t\tSHA1_Update(context, write_buffer, left);\n+\t\tgit_SHA1_Update(context, write_buffer, left);\n \t}\n \n \t/* Flush first if not enough space for SHA1 signature */\n@@ -1357,7 +1357,7 @@ static int ce_flush(SHA_CTX *context, int fd)\n \t}\n \n \t/* Append the SHA1 signature at the end */\n-\tSHA1_Final(write_buffer + left, context);\n+\tgit_SHA1_Final(write_buffer + left, context);\n \tleft += 20;\n \treturn (write_in_full(fd, write_buffer, left) != left) ? -1 : 0;\n }\n@@ -1411,7 +1411,7 @@ static void ce_smudge_racily_clean_entry(struct cache_entry *ce)\n \t}\n }\n \n-static int ce_write_entry(SHA_CTX *c, int fd, struct cache_entry *ce)\n+static int ce_write_entry(git_SHA_CTX *c, int fd, struct cache_entry *ce)\n {\n \tint size = ondisk_ce_size(ce);\n \tstruct ondisk_cache_entry *ondisk = xcalloc(1, size);\n@@ -1435,7 +1435,7 @@ static int ce_write_entry(SHA_CTX *c, int fd, struct cache_entry *ce)\n \n int write_index(const struct index_state *istate, int newfd)\n {\n-\tSHA_CTX c;\n+\tgit_SHA_CTX c;\n \tstruct cache_header hdr;\n \tint i, err, removed;\n \tstruct cache_entry **cache = istate->cache;\n@@ -1449,7 +1449,7 @@ int write_index(const struct index_state *istate, int newfd)\n \thdr.hdr_version = htonl(2);\n \thdr.hdr_entries = htonl(entries - removed);\n \n-\tSHA1_Init(&c);\n+\tgit_SHA1_Init(&c);\n \tif (ce_write(&c, newfd, &hdr, sizeof(hdr)) < 0)\n \t\treturn -1;\n \ndiff --git a/rerere.c b/rerere.c\nindex 8447cae..121f911 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -73,7 +73,7 @@ static int write_rr(struct string_list *rr, int out_fd)\n static int handle_file(const char *path,\n \t unsigned char *sha1, const char *output)\n {\n-\tSHA_CTX ctx;\n+\tgit_SHA_CTX ctx;\n \tchar buf[1024];\n \tint hunk_no = 0;\n \tenum {\n@@ -95,7 +95,7 @@ static int handle_file(const char *path,\n \t}\n \n \tif (sha1)\n-\t\tSHA1_Init(&ctx);\n+\t\tgit_SHA1_Init(&ctx);\n \n \tstrbuf_init(&one, 0);\n \tstrbuf_init(&two,  0);\n@@ -127,9 +127,9 @@ static int handle_file(const char *path,\n \t\t\t\tfputs(\">>>>>>>\\n\", out);\n \t\t\t}\n \t\t\tif (sha1) {\n-\t\t\t\tSHA1_Update(&ctx, one.buf ? one.buf : \"\",\n+\t\t\t\tgit_SHA1_Update(&ctx, one.buf ? one.buf : \"\",\n \t\t\t\t\t    one.len + 1);\n-\t\t\t\tSHA1_Update(&ctx, two.buf ? two.buf : \"\",\n+\t\t\t\tgit_SHA1_Update(&ctx, two.buf ? two.buf : \"\",\n \t\t\t\t\t    two.len + 1);\n \t\t\t}\n \t\t\tstrbuf_reset(&one);\n@@ -154,7 +154,7 @@ static int handle_file(const char *path,\n \tif (out)\n \t\tfclose(out);\n \tif (sha1)\n-\t\tSHA1_Final(sha1, &ctx);\n+\t\tgit_SHA1_Final(sha1, &ctx);\n \tif (hunk != RR_CONTEXT) {\n \t\tif (output)\n \t\t\tunlink(output);\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 70ff904..7515987 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -2132,16 +2132,16 @@ static void write_sha1_file_prepare(const void *buf, unsigned long len,\n                                     const char *type, unsigned char *sha1,\n                                     char *hdr, int *hdrlen)\n {\n-\tSHA_CTX c;\n+\tgit_SHA_CTX c;\n \n \t/* Generate the header */\n \t*hdrlen = sprintf(hdr, \"%s %lu\", type, len)+1;\n \n \t/* Sha1.. */\n-\tSHA1_Init(&c);\n-\tSHA1_Update(&c, hdr, *hdrlen);\n-\tSHA1_Update(&c, buf, len);\n-\tSHA1_Final(sha1, &c);\n+\tgit_SHA1_Init(&c);\n+\tgit_SHA1_Update(&c, hdr, *hdrlen);\n+\tgit_SHA1_Update(&c, buf, len);\n+\tgit_SHA1_Final(sha1, &c);\n }\n \n /*\ndiff --git a/test-sha1.c b/test-sha1.c\nindex 78d7e98..9b98d07 100644\n--- a/test-sha1.c\n+++ b/test-sha1.c\n@@ -2,7 +2,7 @@\n \n int main(int ac, char **av)\n {\n-\tSHA_CTX ctx;\n+\tgit_SHA_CTX ctx;\n \tunsigned char sha1[20];\n \tunsigned bufsz = 8192;\n \tchar *buffer;\n@@ -20,7 +20,7 @@ int main(int ac, char **av)\n \t\t\tdie(\"OOPS\");\n \t}\n \n-\tSHA1_Init(&ctx);\n+\tgit_SHA1_Init(&ctx);\n \n \twhile (1) {\n \t\tssize_t sz, this_sz;\n@@ -39,9 +39,9 @@ int main(int ac, char **av)\n \t\t}\n \t\tif (this_sz == 0)\n \t\t\tbreak;\n-\t\tSHA1_Update(&ctx, buffer, this_sz);\n+\t\tgit_SHA1_Update(&ctx, buffer, this_sz);\n \t}\n-\tSHA1_Final(sha1, &ctx);\n+\tgit_SHA1_Final(sha1, &ctx);\n \tputs(sha1_to_hex(sha1));\n \texit(0);\n }\n"}]}