Git development
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: Sebastian Schuberth <sschuberth@gmail.com>,
	Artur Skawina <art.08.09@gmail.com>,
	Johannes Sixt <j.sixt@viscovery.net>,
	msysGit <msysgit@googlegroups.com>, Nicolas Pitre <nico@cam.org>,
	Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] block-sha1: Windows declares ntohl() in winsock2.h
Date: Tue, 18 Aug 2009 08:40:24 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.2.01.0908180836440.3162@localhost.localdomain> (raw)
In-Reply-To: <7v4os5gs0p.fsf@alter.siamese.dyndns.org>



On Tue, 18 Aug 2009, Junio C Hamano wrote:

> Sebastian Schuberth <sschuberth@gmail.com> writes:
> 
> > On Tue, Aug 18, 2009 at 14:56, Artur Skawina<art.08.09@gmail.com> wrote:
> > ...
> >> I'd limit it to windows and any other ia32 platform that doesn't pick the
> >> bswaps itself; as is, it just adds an unnecessary hidden gcc dependency.
> >>
> >> Hmm, it's actually a gcc-4.3+ dependency, so it won't even build w/ gcc 4.2;
> >> something like this would be required: "(__GNUC__>=4 && __GNUC_MINOR__>=3)" .
> >
> > So, as you say the code makes no difference under Linux, would you be
> > OK with just testing for GCC 4.3+, and not for Windows? That would get
> > rid of the "hidden" GCC dependency and not make the preprocessor
> > checks overly complex. Moreover, limiting my patch to any "platform
> > that doesn't pick the bswaps itself" could possibly require
> > maintenance on compiler / CRT updates.
> 
> I would say that should be fine, but I'd let Linus and Nico to overrule me
> on this if they have any input.

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).

Just do:

	#if defined(__GNUC__)
	#define htonl(x) ({ unsigned int __res; \
		__asm__("bswap %0":"=r" (__res):"0" (x)); \
		__res; })
	#define ntohl(x) htonl(x)
	#endif

or similar in the x86 section that does the rol/ror thing.

			Linus

  reply	other threads:[~2009-08-18 15:41 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-18  7:15 [PATCH] block-sha1: Windows declares ntohl() in winsock2.h Johannes Sixt
2009-08-18 10:45 ` Sebastian Schuberth
2009-08-18 11:07   ` Junio C Hamano
2009-08-18 11:28     ` Sebastian Schuberth
2009-08-18 12:56   ` Artur Skawina
2009-08-18 13:17     ` Sebastian Schuberth
2009-08-18 13:39       ` Junio C Hamano
2009-08-18 15:40         ` Linus Torvalds [this message]
2009-08-18 16:08           ` Linus Torvalds
2009-08-18 16:23             ` Sebastian Schuberth
2009-08-18 16:43               ` Junio C Hamano
2009-08-18 16:30         ` Nicolas Pitre
2009-08-18 16:43           ` Nicolas Pitre
2009-08-18 16:50             ` Junio C Hamano
2009-08-18 18:01               ` Nicolas Pitre
2009-08-18 19:00                 ` Junio C Hamano
2009-08-18 19:22                   ` Nicolas Pitre
2009-08-18 19:26                     ` [PATCH] make sure byte swapping is optimal for git Nicolas Pitre
2009-08-18 19:37                     ` [PATCH] block-sha1: guard gcc extensions with __GNUC__ Nicolas Pitre
2009-08-18 19:40                   ` [PATCH] block-sha1: Windows declares ntohl() in winsock2.h Junio C Hamano
2009-08-18 19:56                   ` Brandon Casey
2009-08-18 20:10                     ` Nicolas Pitre
2009-08-18 20:25                       ` Linus Torvalds
2009-08-18 20:29                       ` Brandon Casey
2009-08-20  2:26                     ` Nicolas Pitre
2009-08-20  2:30                       ` Linus Torvalds
2009-08-20  2:45                       ` Brandon Casey
2009-08-18 16:59             ` Sebastian Schuberth
2009-08-18 17:05               ` Junio C Hamano
2009-08-18 18:16                 ` Nicolas Pitre
2009-08-18 20:17                   ` Junio C Hamano
2009-08-18 20:30                     ` Junio C Hamano
2009-08-18 20:49                       ` Nicolas Pitre
2009-08-18 18:10               ` Nicolas Pitre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.01.0908180836440.3162@localhost.localdomain \
    --to=torvalds@linux-foundation.org \
    --cc=art.08.09@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j.sixt@viscovery.net \
    --cc=msysgit@googlegroups.com \
    --cc=nico@cam.org \
    --cc=sschuberth@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox