git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* [PATCH] compat/bswap.h: don't assume MSVC is little-endian
@ 2020-11-11  8:32 Daniel Gurney
  2020-11-11 16:23 ` Johannes Schindelin
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Gurney @ 2020-11-11  8:32 UTC (permalink / raw)
  To: git
  Cc: Johannes.Schindelin, Daniel Gurney, brian m . carlson, Jeff King,
	Junio C Hamano

In 1af265f0 (compat/bswap.h: simplify MSVC endianness
detection, 2020-11-08) we attempted to simplify code by assuming MSVC
builds will be for little-endian machines, since only unusably old
versions of MSVC supported big-endian MIPS and m68k architectures.

However, it's possible that MSVC could be ported to build for a
big-endian architecture again, so the simplification wasn't as
future-proof as hoped.

So let's go back to the old way of detecting MSVC, and then checking
architecture from a list of little-endian architecture macros.

Note that MSVC does not treat ARM64 as bi-endian, so we can safely treat
it as little-endian.

Helped-by: brian m. carlson <sandals@crustytoothpaste.net>
Helped-by: Jeff King <peff@peff.net>
Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Daniel Gurney <dgurney99@gmail.com>
---
 compat/bswap.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compat/bswap.h b/compat/bswap.h
index 72f225eaa8..512f6f4b99 100644
--- a/compat/bswap.h
+++ b/compat/bswap.h
@@ -74,7 +74,7 @@ static inline uint64_t git_bswap64(uint64_t x)
 }
 #endif
 
-#elif defined(_MSC_VER)
+#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM64))
 
 #include <stdlib.h>
 
-- 
2.29.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] compat/bswap.h: don't assume MSVC is little-endian
  2020-11-11  8:32 [PATCH] compat/bswap.h: don't assume MSVC is little-endian Daniel Gurney
@ 2020-11-11 16:23 ` Johannes Schindelin
  2020-11-11 16:40   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Schindelin @ 2020-11-11 16:23 UTC (permalink / raw)
  To: Daniel Gurney; +Cc: git, brian m . carlson, Jeff King, Junio C Hamano

Hi Daniel,

On Wed, 11 Nov 2020, Daniel Gurney wrote:

> In 1af265f0 (compat/bswap.h: simplify MSVC endianness
> detection, 2020-11-08) we attempted to simplify code by assuming MSVC
> builds will be for little-endian machines, since only unusably old
> versions of MSVC supported big-endian MIPS and m68k architectures.
>
> However, it's possible that MSVC could be ported to build for a
> big-endian architecture again, so the simplification wasn't as
> future-proof as hoped.
>
> So let's go back to the old way of detecting MSVC, and then checking
> architecture from a list of little-endian architecture macros.
>
> Note that MSVC does not treat ARM64 as bi-endian, so we can safely treat
> it as little-endian.
>
> Helped-by: brian m. carlson <sandals@crustytoothpaste.net>
> Helped-by: Jeff King <peff@peff.net>
> Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
> Helped-by: Junio C Hamano <gitster@pobox.com>
> Signed-off-by: Daniel Gurney <dgurney99@gmail.com>

ACK!

Thank you so much,
Dscho

> ---
>  compat/bswap.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/compat/bswap.h b/compat/bswap.h
> index 72f225eaa8..512f6f4b99 100644
> --- a/compat/bswap.h
> +++ b/compat/bswap.h
> @@ -74,7 +74,7 @@ static inline uint64_t git_bswap64(uint64_t x)
>  }
>  #endif
>
> -#elif defined(_MSC_VER)
> +#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM64))
>
>  #include <stdlib.h>
>
> --
> 2.29.2
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] compat/bswap.h: don't assume MSVC is little-endian
  2020-11-11 16:23 ` Johannes Schindelin
@ 2020-11-11 16:40   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2020-11-11 16:40 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Daniel Gurney, git, brian m . carlson, Jeff King

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

>> ...
>> So let's go back to the old way of detecting MSVC, and then checking
>> architecture from a list of little-endian architecture macros.
>>
>> Note that MSVC does not treat ARM64 as bi-endian, so we can safely treat
>> it as little-endian.
>>
>> Helped-by: brian m. carlson <sandals@crustytoothpaste.net>
>> Helped-by: Jeff King <peff@peff.net>
>> Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
>> Helped-by: Junio C Hamano <gitster@pobox.com>
>> Signed-off-by: Daniel Gurney <dgurney99@gmail.com>
>
> ACK!
>
> Thank you so much,
> Dscho

Thanks, all.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-11 16:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-11  8:32 [PATCH] compat/bswap.h: don't assume MSVC is little-endian Daniel Gurney
2020-11-11 16:23 ` Johannes Schindelin
2020-11-11 16:40   ` Junio C Hamano

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git