{"thread":{"id":"21282","subject":"[PATCH] Use faster byte swapping when compiling with MSVC","startedAt":"2009-10-19T16:37:05Z","lastAt":"2009-10-20T16:55:41Z","messageCount":7,"participants":["Sebastian Schuberth","Junio C Hamano","Johannes Schindelin","Ludvig Strigeus","Erik Faye-Lund"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"125397","messageId":"hbi4mt$tjt$1@ger.gmane.org","threadId":"21282","inReplyTo":null,"subject":"[PATCH] Use faster byte swapping when compiling with MSVC","fromName":"Sebastian Schuberth","fromEmail":"sschuberth@gmail.com","sentAt":"2009-10-19T16:37:05Z","receivedAt":"2009-10-19T16:37:05Z","isPatch":true,"sender":{"key":"sschuberth@gmail.com","avatar":"https://avatars.githubusercontent.com/u/349154?v=4"},"body":"When compiling with MSVC on x86-compatible, use an intrinsic for byte swapping.\nIn contrast to the GCC path, we do not prefer inline assembly here as it is not\nsupported for the x64 platform.\n\nSigned-off-by: Sebastian Schuberth <sschuberth@gmail.com>\n---\n compat/bswap.h |   10 ++++++++++\n 1 files changed, 10 insertions(+), 0 deletions(-)\n\ndiff --git a/compat/bswap.h b/compat/bswap.h\nindex 5cc4acb..279e0b4 100644\n--- a/compat/bswap.h\n+++ b/compat/bswap.h\n@@ -28,6 +28,16 @@ static inline uint32_t default_swab32(uint32_t val)\n \t} \\\n \t__res; })\n \n+#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))\n+\n+#include <stdlib.h>\n+\n+#define bswap32(x) _byteswap_ulong(x)\n+\n+#endif\n+\n+#ifdef bswap32\n+\n #undef ntohl\n #undef htonl\n #define ntohl(x) bswap32(x)\n-- \n1.6.5.rc2.13.g1be2\n"},{"id":"125450","messageId":"7vzl7mr1f5.fsf@alter.siamese.dyndns.org","threadId":"21282","inReplyTo":"hbi4mt$tjt$1@ger.gmane.org","subject":"Re: [PATCH] Use faster byte swapping when compiling with MSVC","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-10-20T07:04:46Z","receivedAt":"2009-10-20T07:04:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sebastian Schuberth <sschuberth@gmail.com> writes:\n\n> When compiling with MSVC on x86-compatible, use an intrinsic for byte swapping.\n> In contrast to the GCC path, we do not prefer inline assembly here as it is not\n> supported for the x64 platform.\n>\n> Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>\n\nUnlike the other one this is not Acked by Marius, Dscho, or J6t; should I\npick this up myself, or should I wait to be fed by one of msysgit people?\n\n\n> ---\n>  compat/bswap.h |   10 ++++++++++\n>  1 files changed, 10 insertions(+), 0 deletions(-)\n>\n> diff --git a/compat/bswap.h b/compat/bswap.h\n> index 5cc4acb..279e0b4 100644\n> --- a/compat/bswap.h\n> +++ b/compat/bswap.h\n> @@ -28,6 +28,16 @@ static inline uint32_t default_swab32(uint32_t val)\n>  \t} \\\n>  \t__res; })\n>  \n> +#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))\n> +\n> +#include <stdlib.h>\n> +\n> +#define bswap32(x) _byteswap_ulong(x)\n> +\n> +#endif\n> +\n> +#ifdef bswap32\n> +\n>  #undef ntohl\n>  #undef htonl\n>  #define ntohl(x) bswap32(x)\n> -- \n> 1.6.5.rc2.13.g1be2\n"},{"id":"125456","messageId":"bdca99240910200156x48511478w9eaa2239eb8342b4@mail.gmail.com","threadId":"21282","inReplyTo":"7vzl7mr1f5.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Use faster byte swapping when compiling with MSVC","fromName":"Sebastian Schuberth","fromEmail":"sschuberth@gmail.com","sentAt":"2009-10-20T08:56:39Z","receivedAt":"2009-10-20T08:56:39Z","isPatch":true,"sender":{"key":"sschuberth@gmail.com","avatar":"https://avatars.githubusercontent.com/u/349154?v=4"},"body":"On Tue, Oct 20, 2009 at 09:04, Junio C Hamano <gitster@pobox.com> wrote:\n\n>> When compiling with MSVC on x86-compatible, use an intrinsic for byte swapping.\n>> In contrast to the GCC path, we do not prefer inline assembly here as it is not\n>> supported for the x64 platform.\n>>\n>> Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>\n>\n> Unlike the other one this is not Acked by Marius, Dscho, or J6t; should I\n> pick this up myself, or should I wait to be fed by one of msysgit people?\n\nWell, in fact I am one of the msysgit poeple, although I mostly worked\non the installer until now. In general, I like my patches to be\nreviewed, but this one is rather uncritical, I guess. So it's up to\nyou, Junio, I'm perfectly OK with waiting for an ACK.\n\n-- \nSebastian Schuberth\n"},{"id":"125462","messageId":"alpine.DEB.1.00.0910201149020.4985@pacific.mpi-cbg.de","threadId":"21282","inReplyTo":"bdca99240910200156x48511478w9eaa2239eb8342b4@mail.gmail.com","subject":"Re: [PATCH] Use faster byte swapping when compiling with MSVC","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-10-20T09:53:03Z","receivedAt":"2009-10-20T09:53:03Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 20 Oct 2009, Sebastian Schuberth wrote:\n\n> On Tue, Oct 20, 2009 at 09:04, Junio C Hamano <gitster@pobox.com> wrote:\n> \n> >> When compiling with MSVC on x86-compatible, use an intrinsic for byte \n> >> swapping. In contrast to the GCC path, we do not prefer inline \n> >> assembly here as it is not supported for the x64 platform.\n> >>\n> >> Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>\n> >\n> > Unlike the other one this is not Acked by Marius, Dscho, or J6t; \n> > should I pick this up myself, or should I wait to be fed by one of \n> > msysgit people?\n> \n> Well, in fact I am one of the msysgit poeple, although I mostly worked \n> on the installer until now. In general, I like my patches to be \n> reviewed, but this one is rather uncritical, I guess. So it's up to you, \n> Junio, I'm perfectly OK with waiting for an ACK.\n\nApart from the fact that I do not have MSVC (and I don't want it, either), \nthere is another strong reason why I think Sebastian does not need ACKs or \nSOBs on MSVC patches: he has plenty of experience as a maintainer of a \nrather big (commercial) software that has to compile on Windows, MacOSX \nand several Unix-type OSes (and it is known that Sebastian is a Windows \nguy).\n\nSo I would trust Sebastian's patches (at least when it comes to MSVC) \nwithout even reviewing them.\n\nCiao,\nDscho\n"},{"id":"125472","messageId":"loom.20091020T141138-782@post.gmane.org","threadId":"21282","inReplyTo":"hbi4mt$tjt$1@ger.gmane.org","subject":"Re: [PATCH] Use faster byte swapping when compiling with MSVC","fromName":"Ludvig Strigeus","fromEmail":"ludde@spotify.com","sentAt":"2009-10-20T12:20:00Z","receivedAt":"2009-10-20T12:20:00Z","isPatch":true,"sender":{"key":"ludde@spotify.com","avatar":null},"body":"Sebastian Schuberth <sschuberth <at> gmail.com> writes:\n> \n> When compiling with MSVC on x86-compatible, use an intrinsic for byte swapping.\n> In contrast to the GCC path, we do not prefer inline assembly here as it is not\n> supported for the x64 platform.\n> \n>  \n> +#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))\n> +\n> +#include <stdlib.h>\n> +\n> +#define bswap32(x) _byteswap_ulong(x)\n> +\n> +#endif\n\nunsigned long (as used by _byteswap_ulong) is 64 bits on x64, right? Then it\ndoesn't make sense to use _byteswap_ulong to swap 32-bit quantities (assuming\nthat's what bswap32 does) would it?\n\n/Ludde\n"},{"id":"125473","messageId":"40aa078e0910200544i3d8aadc1ud62cf62a6964dd5@mail.gmail.com","threadId":"21282","inReplyTo":"loom.20091020T141138-782@post.gmane.org","subject":"Re: [PATCH] Use faster byte swapping when compiling with MSVC","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2009-10-20T12:44:10Z","receivedAt":"2009-10-20T12:44:10Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Tue, Oct 20, 2009 at 2:20 PM, Ludvig Strigeus <ludde@spotify.com> wrote:\n> unsigned long (as used by _byteswap_ulong) is 64 bits on x64, right? Then it\n> doesn't make sense to use _byteswap_ulong to swap 32-bit quantities (assuming\n> that's what bswap32 does) would it?\n\nNo, unsigned long is 32bit on x64 on Windows.\n\n--->8---\n#include <stdio.h>\n#include <stdlib.h>\n\nint main(int argc, char *argv[])\n{\n  printf(\"sizeof(void *) = %d\\n\", sizeof(void *));\n  printf(\"sizeof(unsigned long) = %d\\n\", sizeof(unsigned long));\n  return 0;\n}\n--->8---\nsizeof(void *) = 8\nsizeof(unsigned long) = 4\n\n-- \nErik \"kusma\" Faye-Lund\n"},{"id":"125495","messageId":"7v4opuovhu.fsf@alter.siamese.dyndns.org","threadId":"21282","inReplyTo":"alpine.DEB.1.00.0910201149020.4985@pacific.mpi-cbg.de","subject":"Re: [PATCH] Use faster byte swapping when compiling with MSVC","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-10-20T16:55:41Z","receivedAt":"2009-10-20T16:55:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n>> Well, in fact I am one of the msysgit poeple, although I mostly worked \n>> on the installer until now. In general, I like my patches to be \n>> reviewed, but this one is rather uncritical, I guess. So it's up to you, \n>> Junio, I'm perfectly OK with waiting for an ACK.\n>\n> Apart from the fact that I do not have MSVC (and I don't want it, either), \n> there is another strong reason why I think Sebastian does not need ACKs or \n> SOBs on MSVC patches: he has plenty of experience as a maintainer of a \n> rather big (commercial) software that has to compile on Windows, MacOSX \n> and several Unix-type OSes (and it is known that Sebastian is a Windows \n> guy).\n>\n> So I would trust Sebastian's patches (at least when it comes to MSVC) \n> without even reviewing them.\n\nI very appreciate a strong Ack in a specific area like this.  I do skim\nmsysgit list from time to time, and in retrospect I realize I _could_ have\nrecognized Sebastian's name but somehow it didn't click.\n\nI guess I should apply both patches to 'master', then.  Thanks.\n"}]}