8197859: VS2017 Complains about UINTPTR_MAX definition in globalDefinitions_VisCPP.hpp

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

Reviewed-by: coleenp, lfoltan, gtriantafill
This commit is contained in:
Kim Barrett 2018-02-21 23:30:01 -05:00
parent bc472b0530
commit b8ab854bdc

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -35,6 +35,7 @@
# include <string.h> # include <string.h>
# include <stdarg.h> # include <stdarg.h>
# include <stdlib.h> # include <stdlib.h>
# include <stdint.h>
# include <stddef.h>// for offsetof # include <stddef.h>// for offsetof
# include <io.h> // for stream.cpp # include <io.h> // for stream.cpp
# include <float.h> // for _isnan # include <float.h> // for _isnan
@ -42,6 +43,7 @@
# include <time.h> # include <time.h>
# include <fcntl.h> # include <fcntl.h>
# include <limits.h> # include <limits.h>
# include <inttypes.h>
// Need this on windows to get the math constants (e.g., M_PI). // Need this on windows to get the math constants (e.g., M_PI).
#define _USE_MATH_DEFINES #define _USE_MATH_DEFINES
# include <math.h> # include <math.h>
@ -77,43 +79,18 @@
// pointer is stored as integer value. // pointer is stored as integer value.
#define NULL_WORD NULL #define NULL_WORD NULL
// 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 #ifdef _WIN64
typedef unsigned __int64 uintptr_t; typedef int64_t ssize_t;
#else #else
typedef unsigned int uintptr_t; typedef int32_t ssize_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;
#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
#endif #endif
// Additional Java basic types // Additional Java basic types
typedef unsigned char jubyte; typedef uint8_t jubyte;
typedef unsigned short jushort; typedef uint16_t jushort;
typedef unsigned int juint; typedef uint32_t juint;
typedef unsigned __int64 julong; typedef uint64_t julong;
// Non-standard stdlib-like stuff: // Non-standard stdlib-like stuff:
inline int strcasecmp(const char *s1, const char *s2) { return _stricmp(s1,s2); } inline int strcasecmp(const char *s1, const char *s2) { return _stricmp(s1,s2); }
@ -187,26 +164,6 @@ inline int vsnprintf(char* buf, size_t count, const char* fmt, va_list argptr) {
// Formatting. // Formatting.
#define FORMAT64_MODIFIER "I64" #define FORMAT64_MODIFIER "I64"
// Visual Studio doesn't provide inttypes.h so provide appropriate definitions here.
// The 32 bits ones might need I32 but seem to work ok without it.
#define PRId32 "d"
#define PRIu32 "u"
#define PRIx32 "x"
#define PRId64 "I64d"
#define PRIu64 "I64u"
#define PRIx64 "I64x"
#ifdef _LP64
#define PRIdPTR "I64d"
#define PRIuPTR "I64u"
#define PRIxPTR "I64x"
#else
#define PRIdPTR "d"
#define PRIuPTR "u"
#define PRIxPTR "x"
#endif
#define offset_of(klass,field) offsetof(klass,field) #define offset_of(klass,field) offsetof(klass,field)
#ifndef USE_LIBRARY_BASED_TLS_ONLY #ifndef USE_LIBRARY_BASED_TLS_ONLY