Patchwork util.h: add stdint basic type definitions

login
register
mail settings
Submitter elson.wei@gmail.com
Date Sept. 12, 2013, 9:10 a.m.
Message ID <ca63ac781bf24e47995c.1378977040@ElsonWei-NB.PrimeVOLT>
Download mbox | patch
Permalink /patch/2430/
State Superseded
Commit 7999f4fa155a30e9c7a28fe775d1d7a75c7711a0
Headers show

Comments

elson.wei@gmail.com - Sept. 12, 2013, 9:10 a.m.
# HG changeset patch
# User Wei, Elson <elson.wei@gmail.com>
# Date 1378977006 -28800
#      Thu Sep 12 17:10:06 2013 +0800
# Node ID ca63ac781bf24e47995cc7d76b694e2cf50f05d6
# Parent  d69e06724b96a985f29fd493a5dfe356a75af387
util.h: add stdint basic type definitions

MSVC v15 doesn't have stdint.h. Add basic int types those are defined in
stdint.h.
Isaac Jurado - Sept. 12, 2013, 1:28 p.m.
On Thu, Sep 12, 2013 at 11:10 AM,  <elson.wei@gmail.com> wrote:
> # HG changeset patch
> # User Wei, Elson <elson.wei@gmail.com>
> # Date 1378977006 -28800
> #      Thu Sep 12 17:10:06 2013 +0800
> # Node ID ca63ac781bf24e47995cc7d76b694e2cf50f05d6
> # Parent  d69e06724b96a985f29fd493a5dfe356a75af387
> util.h: add stdint basic type definitions
>
> MSVC v15 doesn't have stdint.h. Add basic int types those are defined in
> stdint.h.
>
> diff --git a/mercurial/util.h b/mercurial/util.h
> --- a/mercurial/util.h
> +++ b/mercurial/util.h
> @@ -121,9 +121,14 @@
>  #ifdef _MSC_VER
>  /* msvc 6.0 has problems */
>  #define inline __inline
> -typedef unsigned char uint8_t;
> -typedef unsigned long uint32_t;
> -typedef unsigned __int64 uint64_t;
> +typedef signed char        int8_t;
> +typedef short              int16_t;
> +typedef long               int32_t;
> +typedef __int64            int64_t;

What is sizeof(long) with MSVC on 64-bit Windows?  Is it 4 bytes too?

> +typedef unsigned char      uint8_t;
> +typedef unsigned short     uint16_t;
> +typedef unsigned long      uint32_t;
> +typedef unsigned __int64   uint64_t;

This is just patch noise because of extra spacing.  You should stick
to the existing spacing policy unless you have a good reason.  That
way the patch will be much easier to read.

Best regards.
Adrian Buehlmann - Sept. 12, 2013, 1:48 p.m.
On 2013-09-12 15:28, Isaac Jurado wrote:
> What is sizeof(long) with MSVC on 64-bit Windows?  Is it 4 bytes too?

x64 Windows uses the LLP64 data model.

In the LLP64 data model, only pointers expand to 64 bits; all other
basic data types (integer and long) remain 32 bits in length.

Patch

diff --git a/mercurial/util.h b/mercurial/util.h
--- a/mercurial/util.h
+++ b/mercurial/util.h
@@ -121,9 +121,14 @@ 
 #ifdef _MSC_VER
 /* msvc 6.0 has problems */
 #define inline __inline
-typedef unsigned char uint8_t;
-typedef unsigned long uint32_t;
-typedef unsigned __int64 uint64_t;
+typedef signed char        int8_t;
+typedef short              int16_t;
+typedef long               int32_t;
+typedef __int64            int64_t;
+typedef unsigned char      uint8_t;
+typedef unsigned short     uint16_t;
+typedef unsigned long      uint32_t;
+typedef unsigned __int64   uint64_t;
 #else
 #include <stdint.h>
 #endif