From: Linus Torvalds Date: Tue, 18 Aug 2009 16:08:38 GMT Subject: Re: [PATCH] block-sha1: Windows declares ntohl() in winsock2.h Message-ID: In-Reply-To: On Tue, 18 Aug 2009, Linus Torvalds wrote: > > I'd suggest not using a gcc builtin, since if you're using gcc you might > as well just use inline asm that has been around forever (unlike the > builtin). That seems to be what glibc does too. Here's a patch. Linus --- block-sha1/sha1.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/block-sha1/sha1.c b/block-sha1/sha1.c index 464cb25..e6e7170 100644 --- a/block-sha1/sha1.c +++ b/block-sha1/sha1.c @@ -22,6 +22,11 @@ #define SHA_ROL(x,n) SHA_ASM("rol", x, n) #define SHA_ROR(x,n) SHA_ASM("ror", x, n) +#undef htonl +#undef ntohl +#define htonl(x) ({ unsigned int __res; __asm__("bswap %0":"=r" (__res):"0" (x)); __res; }) +#define ntohl(x) htonl(x) + #else #define SHA_ROT(X,l,r) (((X) << (l)) | ((X) >> (r)))