--- a/hotspot/src/os/windows/vm/os_windows.cpp Wed Mar 09 11:08:49 2016 -0800
+++ b/hotspot/src/os/windows/vm/os_windows.cpp Wed Mar 09 20:37:04 2016 +0000
@@ -2186,13 +2186,6 @@
// Windows Vista/2008 heap corruption check
#define EXCEPTION_HEAP_CORRUPTION 0xC0000374
-#define def_excpt(val) #val, val
-
-struct siglabel {
- char *name;
- int number;
-};
-
// All Visual C++ exceptions thrown from code generated by the Microsoft Visual
// C++ compiler contain this error code. Because this is a compiler-generated
// error, the code is not listed in the Win32 API header files.
@@ -2202,8 +2195,9 @@
#define EXCEPTION_UNCAUGHT_CXX_EXCEPTION 0xE06D7363
-
-struct siglabel exceptlabels[] = {
+#define def_excpt(val) { #val, (val) }
+
+static const struct { char* name; uint number; } exceptlabels[] = {
def_excpt(EXCEPTION_ACCESS_VIOLATION),
def_excpt(EXCEPTION_DATATYPE_MISALIGNMENT),
def_excpt(EXCEPTION_BREAKPOINT),
@@ -2228,16 +2222,18 @@
def_excpt(EXCEPTION_GUARD_PAGE),
def_excpt(EXCEPTION_INVALID_HANDLE),
def_excpt(EXCEPTION_UNCAUGHT_CXX_EXCEPTION),
- def_excpt(EXCEPTION_HEAP_CORRUPTION),
+ def_excpt(EXCEPTION_HEAP_CORRUPTION)
#ifdef _M_IA64
- def_excpt(EXCEPTION_REG_NAT_CONSUMPTION),
+ , def_excpt(EXCEPTION_REG_NAT_CONSUMPTION)
#endif
- NULL, 0
};
+#undef def_excpt
+
const char* os::exception_name(int exception_code, char *buf, size_t size) {
- for (int i = 0; exceptlabels[i].name != NULL; i++) {
- if (exceptlabels[i].number == exception_code) {
+ uint code = static_cast<uint>(exception_code);
+ for (uint i = 0; i < ARRAY_SIZE(exceptlabels); ++i) {
+ if (exceptlabels[i].number == code) {
jio_snprintf(buf, size, "%s", exceptlabels[i].name);
return buf;
}
@@ -5638,9 +5634,11 @@
"TERM", SIGTERM, // software term signal from kill
"BREAK", SIGBREAK, // Ctrl-Break sequence
"ILL", SIGILL}; // illegal instruction
- for(int i=0;i<sizeof(siglabels)/sizeof(struct siglabel);i++)
- if(!strcmp(name, siglabels[i].name))
+ for (unsigned i = 0; i < ARRAY_SIZE(siglabels); ++i) {
+ if (strcmp(name, siglabels[i].name) == 0) {
return siglabels[i].number;
+ }
+ }
return -1;
}