Skip to content

Commit

Permalink
8197859: VS2017 Complains about UINTPTR_MAX definition in globalDefin…
Browse files Browse the repository at this point in the history
…itions_VisCPP.hpp

Use <stdint.h> and <inttypes.h> on Windows instead of emulation.

Reviewed-by: phh
Backport-of: b8ab854bdcf625772e965a5e476e0a9db1b91f3f
  • Loading branch information
Alexey Pavlyutkin authored and Yuri Nesterenko committed Nov 17, 2022
1 parent 7ae002c commit b98d485
Showing 1 changed file with 13 additions and 41 deletions.
54 changes: 13 additions & 41 deletions hotspot/src/share/vm/utilities/globalDefinitions_visCPP.hpp
Expand Up @@ -35,13 +35,17 @@
# include <string.h>
# include <stdarg.h>
# include <stdlib.h>
# include <stdint.h>
# include <stddef.h>// for offsetof
# include <io.h> // for stream.cpp
# include <float.h> // for _isnan
# include <stdio.h> // for va_list
# include <time.h>
# include <fcntl.h>
# include <limits.h>
#if _MSC_VER >= 1800
# include <inttypes.h>
#endif
// Need this on windows to get the math constants (e.g., M_PI).
#define _USE_MATH_DEFINES
# include <math.h>
Expand Down Expand Up @@ -77,53 +81,19 @@
// pointer is stored as integer value.
#define NULL_WORD NULL

// Some MS Visual Studio versions do not seem to have INT64_C and UINT64_C
// even with __STDC_CONSTANT_MACROS defined.
#ifndef INT64_C
#define INT64_C(c) (c ## i64)
#endif
#ifndef UINT64_C
#define UINT64_C(c) (c ## ui64)
#endif

// Compiler-specific primitive types
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;

#ifdef _WIN64
typedef unsigned __int64 uintptr_t;
#else
typedef unsigned int uintptr_t;
#endif
typedef signed __int8 int8_t;
typedef signed __int16 int16_t;
typedef signed __int32 int32_t;
typedef signed __int64 int64_t;
#ifdef _WIN64
typedef signed __int64 intptr_t;
typedef signed __int64 ssize_t;
typedef int64_t ssize_t;
#else
typedef signed int intptr_t;
typedef signed int ssize_t;
#endif

#ifndef UINTPTR_MAX
#ifdef _WIN64
#define UINTPTR_MAX _UI64_MAX
#else
#define UINTPTR_MAX _UI32_MAX
#endif
typedef int32_t ssize_t;
#endif

//----------------------------------------------------------------------------------------------------
// Additional Java basic types

typedef unsigned char jubyte;
typedef unsigned short jushort;
typedef unsigned int juint;
typedef unsigned __int64 julong;
typedef uint8_t jubyte;
typedef uint16_t jushort;
typedef uint32_t juint;
typedef uint64_t julong;


//----------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -210,8 +180,9 @@ const jlong max_jlong = CONST64(0x7fffffffffffffff);
// Formatting.
#define FORMAT64_MODIFIER "I64"

// Visual Studio doesn't provide inttypes.h so provide appropriate definitions here.
// Visual Studio 2010-2012 doesn't provide inttypes.h so provide appropriate definitions here.
// The 32 bits ones might need I32 but seem to work ok without it.
#if _MSC_VER < 1800
#define PRId32 "d"
#define PRIu32 "u"
#define PRIx32 "x"
Expand All @@ -229,6 +200,7 @@ const jlong max_jlong = CONST64(0x7fffffffffffffff);
#define PRIuPTR "u"
#define PRIxPTR "x"
#endif
#endif

#define offset_of(klass,field) offsetof(klass,field)

Expand Down

1 comment on commit b98d485

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.