Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8311380: Prepare java.desktop for C++17 #14795

Closed
wants to merge 17 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -23,8 +23,8 @@
* questions.
*/

#include <cmath>
#include <malloc.h>
#include <math.h>
#include <jlong.h>

#include "sun_java2d_d3d_D3DTextRenderer.h"
Original file line number Diff line number Diff line change
@@ -23,12 +23,12 @@
* questions.
*/

#include <cmath>

#include "D3DPipeline.h"
#include "D3DVertexCacher.h"
#include "D3DPaints.h"

#include "math.h"

// non-texturized macros

#define ADD_VERTEX_XYC(X, Y, VCOLOR) \
Original file line number Diff line number Diff line change
@@ -23,6 +23,8 @@
* questions.
*/

#include <cmath> /* for cos(), sin(), etc */

#include "jni_util.h"
#include "awt.h"
#include "sun_java2d_windows_GDIRenderer.h"
@@ -35,8 +37,6 @@

#include "GraphicsPrimitiveMgr.h"

#include <math.h> /* for cos(), sin(), etc */

#define MAX_CLAMP_BND (1<<26)
#define MIN_CLAMP_BND (-MAX_CLAMP_BND)

Original file line number Diff line number Diff line change
@@ -23,13 +23,13 @@
* questions.
*/

#include <cmath>

#include "sun_awt_windows_ThemeReader.h"

#include "awt.h"
#include "awt_Toolkit.h"

#include "math.h"

#include <uxtheme.h>

#define ALPHA_MASK 0xff000000
22 changes: 9 additions & 13 deletions src/java.desktop/windows/native/libawt/windows/alloc.h
Original file line number Diff line number Diff line change
@@ -88,14 +88,14 @@ ExceptionOccurred_Instead
// These three functions throw std::bad_alloc in an out of memory condition
// instead of returning 0. safe_Realloc will return 0 if memblock is not
// NULL and size is 0. safe_Malloc and safe_Calloc will never return 0.
void *safe_Malloc(size_t size) throw (std::bad_alloc);
void *safe_Calloc(size_t num, size_t size) throw (std::bad_alloc);
void *safe_Realloc(void *memblock, size_t size) throw (std::bad_alloc);
void *safe_Malloc(size_t size);
void *safe_Calloc(size_t num, size_t size);
void *safe_Realloc(void *memblock, size_t size);

// This function should be called instead of ExceptionOccurred. It throws
// std::bad_alloc if a java.lang.OutOfMemoryError is currently pending
// on the calling thread.
jthrowable safe_ExceptionOccurred(JNIEnv *env) throw (std::bad_alloc);
jthrowable safe_ExceptionOccurred(JNIEnv *env);

// This function is called at the beginning of an entry point.
// Entry points are functions which are declared:
@@ -111,7 +111,7 @@ void entry_point(void);
void hang_if_shutdown(void);

// This function throws awt_toolkit_shutdown if the Toolkit is not active
void throw_if_shutdown(void) throw (awt_toolkit_shutdown);
void throw_if_shutdown(void);

// This function is called when a std::bad_alloc exception is caught
void handle_bad_alloc(void);
@@ -120,14 +120,10 @@ void handle_bad_alloc(void);
// #define OUTOFMEM_TEST

#ifdef OUTOFMEM_TEST
void *safe_Malloc_outofmem(size_t size, const char *, int)
throw (std::bad_alloc);
void *safe_Calloc_outofmem(size_t num, size_t size, const char *, int)
throw (std::bad_alloc);
void *safe_Realloc_outofmem(void *memblock, size_t size, const char *, int)
throw (std::bad_alloc);
void * CDECL operator new(size_t size, const char *, int)
throw (std::bad_alloc);
void *safe_Malloc_outofmem(size_t size, const char *, int);
void *safe_Calloc_outofmem(size_t num, size_t size, const char *, int);
void *safe_Realloc_outofmem(void *memblock, size_t size, const char *, int);
void * CDECL operator new(size_t size, const char *, int);

#define safe_Malloc(size) \
safe_Malloc_outofmem(size, __FILE__, __LINE__)
Original file line number Diff line number Diff line change
@@ -23,6 +23,8 @@
* questions.
*/

#include <cmath>

#include "awt.h"

#include <windowsx.h>
@@ -47,7 +49,6 @@
#include "awt_Win32GraphicsDevice.h"
#include "Hashtable.h"
#include "ComCtl32Util.h"
#include "math.h"

#include <Region.h>

Original file line number Diff line number Diff line change
@@ -23,6 +23,8 @@
* questions.
*/

#include <cmath>

#include "awt.h"
#include "mmsystem.h"
#include "jlong.h"
@@ -35,8 +37,6 @@
#include <shellapi.h>
#include <shlobj.h>

#include "math.h"

// WDesktopProperties fields
jfieldID AwtDesktopProperties::pDataID = 0;
jmethodID AwtDesktopProperties::setBooleanPropertyID = 0;
Original file line number Diff line number Diff line change
@@ -23,8 +23,8 @@
* questions.
*/

#include <cmath>
#include "awt.h"
#include <math.h>
#include <strsafe.h>
#include "jlong.h"
#include "awt_Font.h"
Original file line number Diff line number Diff line change
@@ -23,13 +23,13 @@
* questions.
*/

#include <cmath>
#include <cfloat>
#include "awt_Component.h"
#include "awt_PrintControl.h"
#include "awt.h"
#include "awt_PrintDialog.h"
#include <winspool.h>
#include <float.h>
#include <math.h>

#define ROUNDTOINT(x) ((int)((x)+0.5))
static const int DEFAULT_RES = 72;
Original file line number Diff line number Diff line change
@@ -23,9 +23,9 @@
* questions.
*/

#include <cmath>
#include "awt.h"
#include <strsafe.h>
#include <math.h>
#include <windef.h>
#include <wtypes.h>
#include <winuser.h>
Original file line number Diff line number Diff line change
@@ -1988,7 +1988,7 @@ void AwtToolkit::SetHeapCheck(long flag) {
}
}

void throw_if_shutdown(void) throw (awt_toolkit_shutdown)
void throw_if_shutdown(void)
{
AwtToolkit::GetInstance().VerifyActive();
}
Original file line number Diff line number Diff line change
@@ -37,16 +37,15 @@
* array index.
*/

#include <cmath> // ceil()
#include <awt.h>
#include <sun_awt_Win32GraphicsDevice.h>
#include "awt_Canvas.h"
#include "awt_Win32GraphicsDevice.h"
#include "awt_Window.h"
#include "java_awt_Transparency.h"
#include "java_awt_color_ColorSpace.h"
#include "sun_awt_Win32GraphicsDevice.h"
#include "java_awt_image_DataBuffer.h"
#include "dither.h"
#include "img_util_md.h"
#include "Devices.h"
#include "systemScale.h"
4 changes: 2 additions & 2 deletions src/java.desktop/windows/native/libawt/windows/awt_Window.cpp
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@
* questions.
*/

#include <cmath>
#include "awt.h"
#include <jlong.h>

@@ -45,9 +46,8 @@
#include "sun_awt_windows_WCanvasPeer.h"

#include <windowsx.h>
#include <math.h>
#if !defined(__int3264)
typedef __int32 LONG_PTR;
typedef int32_t LONG_PTR;
#endif // __int3264

// Used for Swing's Menu/Tooltip animation Support
51 changes: 21 additions & 30 deletions src/java.desktop/windows/native/libawt/windows/awt_new.cpp
Original file line number Diff line number Diff line change
@@ -81,37 +81,37 @@ NewHandler::handler(size_t) {
// These three functions throw std::bad_alloc in an out of memory condition
// instead of returning 0. safe_Realloc will return 0 if memblock is not
// NULL and size is 0. safe_Malloc and safe_Calloc will never return 0.
void *safe_Malloc(size_t size) throw (std::bad_alloc) {
register void *ret_val = malloc(size);
if (ret_val == NULL) {
void *safe_Malloc(size_t size) {
void *ptr = malloc(size);
if (ptr == nullptr) {
throw std::bad_alloc();
}

return ret_val;
return ptr;
}

void *safe_Calloc(size_t num, size_t size) throw (std::bad_alloc) {
register void *ret_val = calloc(num, size);
if (ret_val == NULL) {
void *safe_Calloc(size_t num, size_t size) {
void *ptr = calloc(num, size);
if (ptr == nullptr) {
throw std::bad_alloc();
}

return ret_val;
return ptr;
}

void *safe_Realloc(void *memblock, size_t size) throw (std::bad_alloc) {
register void *ret_val = realloc(memblock, size);
void *safe_Realloc(void *memblock, size_t size) {
void *ptr = realloc(memblock, size);

// Special case for realloc.
if (memblock != NULL && size == 0) {
return ret_val; // even if it's NULL
if (memblock != nullptr && size == 0) {
return ptr; // even if it's NULL
}

if (ret_val == NULL) {
if (ptr == nullptr) {
throw std::bad_alloc();
}

return ret_val;
return ptr;
}

#if !defined(DEBUG)
@@ -120,7 +120,7 @@ void *safe_Realloc(void *memblock, size_t size) throw (std::bad_alloc) {
// std::bad_alloc in an out of memory situation. Instead, VC++ 5.0 returns 0.
//
// This function can be safely removed when the problem is corrected.
void * CDECL operator new(size_t size) throw (std::bad_alloc) {
void * CDECL operator new(size_t size) {
return safe_Malloc(size);
}
#endif
@@ -160,7 +160,7 @@ handle_bad_alloc(void) {
// std::bad_alloc if a java.lang.OutOfMemoryError is currently pending
// on the calling thread.
jthrowable
safe_ExceptionOccurred(JNIEnv *env) throw (std::bad_alloc) {
safe_ExceptionOccurred(JNIEnv *env) {
jthrowable xcp = env->ExceptionOccurred();
if (xcp != NULL) {
env->ExceptionClear(); // if we don't do this, isInstanceOf will fail
@@ -188,8 +188,7 @@ safe_ExceptionOccurred(JNIEnv *env) throw (std::bad_alloc) {
#include <limits.h>

static void
rand_alloc_fail(const char *file, int line) throw (std::bad_alloc)
{
rand_alloc_fail(const char *file, int line) {
if (alloc_lock == NULL) { // Not yet initialized
return;
}
@@ -213,31 +212,23 @@ rand_alloc_fail(const char *file, int line) throw (std::bad_alloc)
}
}

void *safe_Malloc_outofmem(size_t size, const char *file, int line)
throw (std::bad_alloc)
{
void *safe_Malloc_outofmem(size_t size, const char *file, int line) {
rand_alloc_fail(file, line);
return safe_Malloc(size);
}

void *safe_Calloc_outofmem(size_t num, size_t size, const char *file, int line)
throw (std::bad_alloc)
{
void *safe_Calloc_outofmem(size_t num, size_t size, const char *file, int line) {
rand_alloc_fail(file, line);
return safe_Calloc(num, size);
}

void *safe_Realloc_outofmem(void *memblock, size_t size, const char *file,
int line)
throw (std::bad_alloc)
{
int line) {
rand_alloc_fail(file, line);
return safe_Realloc(memblock, size);
}

void * CDECL operator new(size_t size, const char *file, int line)
throw (std::bad_alloc)
{
void * CDECL operator new(size_t size, const char *file, int line) {
rand_alloc_fail(file, line);
return operator new(size);
}