8150688: Fix os_windows siglabel

Change types to eliminate implicit narrowing, and other cleanups.

Reviewed-by: dholmes, tbenson
This commit is contained in:
Kim Barrett 2016-03-09 11:03:45 -05:00
parent 90586a424c
commit 8b6631e5a2

View File

@ -2186,13 +2186,6 @@ extern "C" void events();
// 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 @@ struct siglabel {
#define EXCEPTION_UNCAUGHT_CXX_EXCEPTION 0xE06D7363
#define def_excpt(val) { #val, (val) }
struct siglabel exceptlabels[] = {
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 @@ struct siglabel exceptlabels[] = {
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 @@ int os::get_signal_number(const char* name) {
"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;
}