Thread (11 messages) flat view 11 messages, 4 authors, 2016-06-15
STALE3730d

[PATCH] block-sha1: guard gcc extensions with __GNUC__

From: Nicolas Pitre <hidden>
Date: 2016-06-15 22:47:16
Subsystem: the rest · Maintainer: Linus Torvalds

With this, the code should now be portable to any C compiler.

Signed-off-by: Nicolas Pitre <redacted>
---

On Tue, 18 Aug 2009, Nicolas Pitre wrote:
On Tue, 18 Aug 2009, Junio C Hamano wrote:
quoted
Another issue, especially with your "openssl sha1 removal" patch, is if we
can assume gcc everywhere.  As far as I can tell, block-sha1/sha1.c will
be the first unconditional use of inline asm or statement expression on
i386/amd64.  Are folks on Solaris and other platforms Ok with this?
I guess we can guard the first with ifdef(__GNUC__) which should help 
people with MSVC.  That should take care of x86 at least.
Here it is.
diff --git a/block-sha1/sha1.c b/block-sha1/sha1.c
index d31f2e3..92d9121 100644
--- a/block-sha1/sha1.c
+++ b/block-sha1/sha1.c
@@ -9,7 +9,7 @@
 
 #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.
@@ -54,7 +54,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))
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help