Mercurial > hg > truffle
comparison src/os/windows/vm/os_windows.cpp @ 4988:eb5b24d1499f
Merge
author | Christian Haeubl <christian.haeubl@oracle.com> |
---|---|
date | Mon, 27 Feb 2012 15:06:36 -0800 |
parents | 18a5539bf19b |
children | 957c266d8bc5 |
comparison
equal
deleted
inserted
replaced
4987:f292f9c590ba | 4988:eb5b24d1499f |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
130 #endif | 130 #endif |
131 | 131 |
132 // save DLL module handle, used by GetModuleFileName | 132 // save DLL module handle, used by GetModuleFileName |
133 | 133 |
134 HINSTANCE vm_lib_handle; | 134 HINSTANCE vm_lib_handle; |
135 static int getLastErrorString(char *buf, size_t len); | |
136 | 135 |
137 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) { | 136 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) { |
138 switch (reason) { | 137 switch (reason) { |
139 case DLL_PROCESS_ATTACH: | 138 case DLL_PROCESS_ATTACH: |
140 vm_lib_handle = hinst; | 139 vm_lib_handle = hinst; |
405 int lgrp_id = os::numa_get_group_id(); | 404 int lgrp_id = os::numa_get_group_id(); |
406 if (lgrp_id != -1) { | 405 if (lgrp_id != -1) { |
407 thread->set_lgrp_id(lgrp_id); | 406 thread->set_lgrp_id(lgrp_id); |
408 } | 407 } |
409 } | 408 } |
409 | |
410 | 410 |
411 if (UseVectoredExceptions) { | 411 if (UseVectoredExceptions) { |
412 // If we are using vectored exception we don't need to set a SEH | 412 // If we are using vectored exception we don't need to set a SEH |
413 thread->run(); | 413 thread->run(); |
414 } | 414 } |
818 GetSystemTimeAsFileTime(&wt); | 818 GetSystemTimeAsFileTime(&wt); |
819 return windows_to_java_time(wt); | 819 return windows_to_java_time(wt); |
820 } | 820 } |
821 } | 821 } |
822 | 822 |
823 #define NANOS_PER_SEC CONST64(1000000000) | |
824 #define NANOS_PER_MILLISEC 1000000 | |
825 jlong os::javaTimeNanos() { | 823 jlong os::javaTimeNanos() { |
826 if (!has_performance_count) { | 824 if (!has_performance_count) { |
827 return javaTimeMillis() * NANOS_PER_MILLISEC; // the best we can do. | 825 return javaTimeMillis() * NANOSECS_PER_MILLISEC; // the best we can do. |
828 } else { | 826 } else { |
829 LARGE_INTEGER current_count; | 827 LARGE_INTEGER current_count; |
830 QueryPerformanceCounter(¤t_count); | 828 QueryPerformanceCounter(¤t_count); |
831 double current = as_long(current_count); | 829 double current = as_long(current_count); |
832 double freq = performance_frequency; | 830 double freq = performance_frequency; |
833 jlong time = (jlong)((current/freq) * NANOS_PER_SEC); | 831 jlong time = (jlong)((current/freq) * NANOSECS_PER_SEC); |
834 return time; | 832 return time; |
835 } | 833 } |
836 } | 834 } |
837 | 835 |
838 void os::javaTimeNanos_info(jvmtiTimerInfo *info_ptr) { | 836 void os::javaTimeNanos_info(jvmtiTimerInfo *info_ptr) { |
844 // this is a wall clock timer, so may skip | 842 // this is a wall clock timer, so may skip |
845 info_ptr->may_skip_backward = true; | 843 info_ptr->may_skip_backward = true; |
846 info_ptr->may_skip_forward = true; | 844 info_ptr->may_skip_forward = true; |
847 } else { | 845 } else { |
848 jlong freq = performance_frequency; | 846 jlong freq = performance_frequency; |
849 if (freq < NANOS_PER_SEC) { | 847 if (freq < NANOSECS_PER_SEC) { |
850 // the performance counter is 64 bits and we will | 848 // the performance counter is 64 bits and we will |
851 // be multiplying it -- so no wrap in 64 bits | 849 // be multiplying it -- so no wrap in 64 bits |
852 info_ptr->max_value = ALL_64_BITS; | 850 info_ptr->max_value = ALL_64_BITS; |
853 } else if (freq > NANOS_PER_SEC) { | 851 } else if (freq > NANOSECS_PER_SEC) { |
854 // use the max value the counter can reach to | 852 // use the max value the counter can reach to |
855 // determine the max value which could be returned | 853 // determine the max value which could be returned |
856 julong max_counter = (julong)ALL_64_BITS; | 854 julong max_counter = (julong)ALL_64_BITS; |
857 info_ptr->max_value = (jlong)(max_counter / (freq / NANOS_PER_SEC)); | 855 info_ptr->max_value = (jlong)(max_counter / (freq / NANOSECS_PER_SEC)); |
858 } else { | 856 } else { |
859 // the performance counter is 64 bits and we will | 857 // the performance counter is 64 bits and we will |
860 // be using it directly -- so no wrap in 64 bits | 858 // be using it directly -- so no wrap in 64 bits |
861 info_ptr->max_value = ALL_64_BITS; | 859 info_ptr->max_value = ALL_64_BITS; |
862 } | 860 } |
1391 } | 1389 } |
1392 } | 1390 } |
1393 | 1391 |
1394 bool os::dll_address_to_function_name(address addr, char *buf, | 1392 bool os::dll_address_to_function_name(address addr, char *buf, |
1395 int buflen, int *offset) { | 1393 int buflen, int *offset) { |
1396 if (Decoder::decode(addr, buf, buflen, offset) == Decoder::no_error) { | 1394 if (Decoder::decode(addr, buf, buflen, offset)) { |
1397 return true; | 1395 return true; |
1398 } | 1396 } |
1399 if (offset != NULL) *offset = -1; | 1397 if (offset != NULL) *offset = -1; |
1400 if (buf != NULL) buf[0] = '\0'; | 1398 if (buf != NULL) buf[0] = '\0'; |
1401 return false; | 1399 return false; |
1451 if (result != NULL) | 1449 if (result != NULL) |
1452 { | 1450 { |
1453 return result; | 1451 return result; |
1454 } | 1452 } |
1455 | 1453 |
1456 long errcode = GetLastError(); | 1454 DWORD errcode = GetLastError(); |
1457 if (errcode == ERROR_MOD_NOT_FOUND) { | 1455 if (errcode == ERROR_MOD_NOT_FOUND) { |
1458 strncpy(ebuf, "Can't find dependent libraries", ebuflen-1); | 1456 strncpy(ebuf, "Can't find dependent libraries", ebuflen-1); |
1459 ebuf[ebuflen-1]='\0'; | 1457 ebuf[ebuflen-1]='\0'; |
1460 return NULL; | 1458 return NULL; |
1461 } | 1459 } |
1462 | 1460 |
1463 // Parsing dll below | 1461 // Parsing dll below |
1464 // If we can read dll-info and find that dll was built | 1462 // If we can read dll-info and find that dll was built |
1465 // for an architecture other than Hotspot is running in | 1463 // for an architecture other than Hotspot is running in |
1466 // - then print to buffer "DLL was built for a different architecture" | 1464 // - then print to buffer "DLL was built for a different architecture" |
1467 // else call getLastErrorString to obtain system error message | 1465 // else call os::lasterror to obtain system error message |
1468 | 1466 |
1469 // Read system error message into ebuf | 1467 // Read system error message into ebuf |
1470 // It may or may not be overwritten below (in the for loop and just above) | 1468 // It may or may not be overwritten below (in the for loop and just above) |
1471 getLastErrorString(ebuf, (size_t) ebuflen); | 1469 lasterror(ebuf, (size_t) ebuflen); |
1472 ebuf[ebuflen-1]='\0'; | 1470 ebuf[ebuflen-1]='\0'; |
1473 int file_descriptor=::open(name, O_RDONLY | O_BINARY, 0); | 1471 int file_descriptor=::open(name, O_RDONLY | O_BINARY, 0); |
1474 if (file_descriptor<0) | 1472 if (file_descriptor<0) |
1475 { | 1473 { |
1476 return NULL; | 1474 return NULL; |
1499 ); | 1497 ); |
1500 | 1498 |
1501 ::close(file_descriptor); | 1499 ::close(file_descriptor); |
1502 if (failed_to_get_lib_arch) | 1500 if (failed_to_get_lib_arch) |
1503 { | 1501 { |
1504 // file i/o error - report getLastErrorString(...) msg | 1502 // file i/o error - report os::lasterror(...) msg |
1505 return NULL; | 1503 return NULL; |
1506 } | 1504 } |
1507 | 1505 |
1508 typedef struct | 1506 typedef struct |
1509 { | 1507 { |
1542 | 1540 |
1543 assert(running_arch_str, | 1541 assert(running_arch_str, |
1544 "Didn't find runing architecture code in arch_array"); | 1542 "Didn't find runing architecture code in arch_array"); |
1545 | 1543 |
1546 // If the architure is right | 1544 // If the architure is right |
1547 // but some other error took place - report getLastErrorString(...) msg | 1545 // but some other error took place - report os::lasterror(...) msg |
1548 if (lib_arch == running_arch) | 1546 if (lib_arch == running_arch) |
1549 { | 1547 { |
1550 return NULL; | 1548 return NULL; |
1551 } | 1549 } |
1552 | 1550 |
1774 } | 1772 } |
1775 | 1773 |
1776 // This method is a copy of JDK's sysGetLastErrorString | 1774 // This method is a copy of JDK's sysGetLastErrorString |
1777 // from src/windows/hpi/src/system_md.c | 1775 // from src/windows/hpi/src/system_md.c |
1778 | 1776 |
1779 size_t os::lasterror(char *buf, size_t len) { | 1777 size_t os::lasterror(char* buf, size_t len) { |
1780 long errval; | 1778 DWORD errval; |
1781 | 1779 |
1782 if ((errval = GetLastError()) != 0) { | 1780 if ((errval = GetLastError()) != 0) { |
1783 /* DOS error */ | 1781 // DOS error |
1784 int n = (int)FormatMessage( | 1782 size_t n = (size_t)FormatMessage( |
1785 FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, | 1783 FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, |
1786 NULL, | 1784 NULL, |
1787 errval, | 1785 errval, |
1788 0, | 1786 0, |
1789 buf, | 1787 buf, |
1790 (DWORD)len, | 1788 (DWORD)len, |
1791 NULL); | 1789 NULL); |
1792 if (n > 3) { | 1790 if (n > 3) { |
1793 /* Drop final '.', CR, LF */ | 1791 // Drop final '.', CR, LF |
1794 if (buf[n - 1] == '\n') n--; | 1792 if (buf[n - 1] == '\n') n--; |
1795 if (buf[n - 1] == '\r') n--; | 1793 if (buf[n - 1] == '\r') n--; |
1796 if (buf[n - 1] == '.') n--; | 1794 if (buf[n - 1] == '.') n--; |
1797 buf[n] = '\0'; | 1795 buf[n] = '\0'; |
1798 } | 1796 } |
1799 return n; | 1797 return n; |
1800 } | 1798 } |
1801 | 1799 |
1802 if (errno != 0) { | 1800 if (errno != 0) { |
1803 /* C runtime error that has no corresponding DOS error code */ | 1801 // C runtime error that has no corresponding DOS error code |
1804 const char *s = strerror(errno); | 1802 const char* s = strerror(errno); |
1805 size_t n = strlen(s); | 1803 size_t n = strlen(s); |
1806 if (n >= len) n = len - 1; | 1804 if (n >= len) n = len - 1; |
1807 strncpy(buf, s, n); | 1805 strncpy(buf, s, n); |
1808 buf[n] = '\0'; | 1806 buf[n] = '\0'; |
1809 return n; | 1807 return n; |
1810 } | 1808 } |
1809 | |
1811 return 0; | 1810 return 0; |
1811 } | |
1812 | |
1813 int os::get_last_error() { | |
1814 DWORD error = GetLastError(); | |
1815 if (error == 0) | |
1816 error = errno; | |
1817 return (int)error; | |
1812 } | 1818 } |
1813 | 1819 |
1814 // sun.misc.Signal | 1820 // sun.misc.Signal |
1815 // NOTE that this is a workaround for an apparent kernel bug where if | 1821 // NOTE that this is a workaround for an apparent kernel bug where if |
1816 // a signal handler for SIGBREAK is installed then that signal handler | 1822 // a signal handler for SIGBREAK is installed then that signal handler |
2080 #ifdef _M_IA64 | 2086 #ifdef _M_IA64 |
2081 assert(0, "Fix Handle_IDiv_Exception"); | 2087 assert(0, "Fix Handle_IDiv_Exception"); |
2082 #elif _M_AMD64 | 2088 #elif _M_AMD64 |
2083 PCONTEXT ctx = exceptionInfo->ContextRecord; | 2089 PCONTEXT ctx = exceptionInfo->ContextRecord; |
2084 address pc = (address)ctx->Rip; | 2090 address pc = (address)ctx->Rip; |
2085 NOT_PRODUCT(Events::log("idiv overflow exception at " INTPTR_FORMAT , pc)); | 2091 #ifndef GRAAL |
2086 //assert(pc[0] == 0xF7 || (pc[1] == 0xF7 && (pc[0] == 0x41 || pc[0] == 0x49)), "not an idiv opcode"); | 2092 assert(pc[0] == 0xF7, "not an idiv opcode"); |
2087 //assert((pc[1] & ~0x7) == 0xF8, "cannot handle non-register operands"); | 2093 assert((pc[1] & ~0x7) == 0xF8, "cannot handle non-register operands"); |
2088 //assert((long)ctx->Rax == (long)min_jint || pc[0] == 0x49, "unexpected idiv exception"); | 2094 assert(ctx->Rax == min_jint, "unexpected idiv exception"); |
2095 #endif | |
2089 // set correct result values and continue after idiv instruction | 2096 // set correct result values and continue after idiv instruction |
2090 ctx->Rip = (DWORD)pc + 2; // idiv reg, reg is 2 bytes | 2097 ctx->Rip = (DWORD)pc + 2; // idiv reg, reg is 2 bytes |
2091 ctx->Rax = (DWORD)min_jint; // result | 2098 ctx->Rax = (DWORD)min_jint; // result |
2092 ctx->Rdx = (DWORD)0; // remainder | 2099 ctx->Rdx = (DWORD)0; // remainder |
2093 // Continue the execution | 2100 // Continue the execution |
2094 #else | 2101 #else |
2095 PCONTEXT ctx = exceptionInfo->ContextRecord; | 2102 PCONTEXT ctx = exceptionInfo->ContextRecord; |
2096 address pc = (address)ctx->Eip; | 2103 address pc = (address)ctx->Eip; |
2097 NOT_PRODUCT(Events::log("idiv overflow exception at " INTPTR_FORMAT , pc)); | |
2098 assert(pc[0] == 0xF7, "not an idiv opcode"); | 2104 assert(pc[0] == 0xF7, "not an idiv opcode"); |
2099 assert((pc[1] & ~0x7) == 0xF8, "cannot handle non-register operands"); | 2105 assert((pc[1] & ~0x7) == 0xF8, "cannot handle non-register operands"); |
2100 assert(ctx->Eax == min_jint, "unexpected idiv exception"); | 2106 assert(ctx->Eax == min_jint, "unexpected idiv exception"); |
2101 // set correct result values and continue after idiv instruction | 2107 // set correct result values and continue after idiv instruction |
2102 ctx->Eip = (DWORD)pc + 2; // idiv reg, reg is 2 bytes | 2108 ctx->Eip = (DWORD)pc + 2; // idiv reg, reg is 2 bytes |
3129 DWORD old_status; | 3135 DWORD old_status; |
3130 return VirtualProtect(addr, bytes, PAGE_READWRITE, &old_status) != 0; | 3136 return VirtualProtect(addr, bytes, PAGE_READWRITE, &old_status) != 0; |
3131 } | 3137 } |
3132 | 3138 |
3133 void os::realign_memory(char *addr, size_t bytes, size_t alignment_hint) { } | 3139 void os::realign_memory(char *addr, size_t bytes, size_t alignment_hint) { } |
3134 void os::free_memory(char *addr, size_t bytes) { } | 3140 void os::free_memory(char *addr, size_t bytes, size_t alignment_hint) { } |
3135 void os::numa_make_global(char *addr, size_t bytes) { } | 3141 void os::numa_make_global(char *addr, size_t bytes) { } |
3136 void os::numa_make_local(char *addr, size_t bytes, int lgrp_hint) { } | 3142 void os::numa_make_local(char *addr, size_t bytes, int lgrp_hint) { } |
3137 bool os::numa_topology_changed() { return false; } | 3143 bool os::numa_topology_changed() { return false; } |
3138 size_t os::numa_get_groups_num() { return MAX2(numa_node_list_holder.get_count(), 1); } | 3144 size_t os::numa_get_groups_num() { return MAX2(numa_node_list_holder.get_count(), 1); } |
3139 int os::numa_get_group_id() { return 0; } | 3145 int os::numa_get_group_id() { return 0; } |
3288 | 3294 |
3289 // Win32 only gives you access to seven real priorities at a time, | 3295 // Win32 only gives you access to seven real priorities at a time, |
3290 // so we compress Java's ten down to seven. It would be better | 3296 // so we compress Java's ten down to seven. It would be better |
3291 // if we dynamically adjusted relative priorities. | 3297 // if we dynamically adjusted relative priorities. |
3292 | 3298 |
3293 int os::java_to_os_priority[MaxPriority + 1] = { | 3299 int os::java_to_os_priority[CriticalPriority + 1] = { |
3294 THREAD_PRIORITY_IDLE, // 0 Entry should never be used | 3300 THREAD_PRIORITY_IDLE, // 0 Entry should never be used |
3295 THREAD_PRIORITY_LOWEST, // 1 MinPriority | 3301 THREAD_PRIORITY_LOWEST, // 1 MinPriority |
3296 THREAD_PRIORITY_LOWEST, // 2 | 3302 THREAD_PRIORITY_LOWEST, // 2 |
3297 THREAD_PRIORITY_BELOW_NORMAL, // 3 | 3303 THREAD_PRIORITY_BELOW_NORMAL, // 3 |
3298 THREAD_PRIORITY_BELOW_NORMAL, // 4 | 3304 THREAD_PRIORITY_BELOW_NORMAL, // 4 |
3299 THREAD_PRIORITY_NORMAL, // 5 NormPriority | 3305 THREAD_PRIORITY_NORMAL, // 5 NormPriority |
3300 THREAD_PRIORITY_NORMAL, // 6 | 3306 THREAD_PRIORITY_NORMAL, // 6 |
3301 THREAD_PRIORITY_ABOVE_NORMAL, // 7 | 3307 THREAD_PRIORITY_ABOVE_NORMAL, // 7 |
3302 THREAD_PRIORITY_ABOVE_NORMAL, // 8 | 3308 THREAD_PRIORITY_ABOVE_NORMAL, // 8 |
3303 THREAD_PRIORITY_HIGHEST, // 9 NearMaxPriority | 3309 THREAD_PRIORITY_HIGHEST, // 9 NearMaxPriority |
3304 THREAD_PRIORITY_HIGHEST // 10 MaxPriority | 3310 THREAD_PRIORITY_HIGHEST, // 10 MaxPriority |
3311 THREAD_PRIORITY_HIGHEST // 11 CriticalPriority | |
3305 }; | 3312 }; |
3306 | 3313 |
3307 int prio_policy1[MaxPriority + 1] = { | 3314 int prio_policy1[CriticalPriority + 1] = { |
3308 THREAD_PRIORITY_IDLE, // 0 Entry should never be used | 3315 THREAD_PRIORITY_IDLE, // 0 Entry should never be used |
3309 THREAD_PRIORITY_LOWEST, // 1 MinPriority | 3316 THREAD_PRIORITY_LOWEST, // 1 MinPriority |
3310 THREAD_PRIORITY_LOWEST, // 2 | 3317 THREAD_PRIORITY_LOWEST, // 2 |
3311 THREAD_PRIORITY_BELOW_NORMAL, // 3 | 3318 THREAD_PRIORITY_BELOW_NORMAL, // 3 |
3312 THREAD_PRIORITY_BELOW_NORMAL, // 4 | 3319 THREAD_PRIORITY_BELOW_NORMAL, // 4 |
3313 THREAD_PRIORITY_NORMAL, // 5 NormPriority | 3320 THREAD_PRIORITY_NORMAL, // 5 NormPriority |
3314 THREAD_PRIORITY_ABOVE_NORMAL, // 6 | 3321 THREAD_PRIORITY_ABOVE_NORMAL, // 6 |
3315 THREAD_PRIORITY_ABOVE_NORMAL, // 7 | 3322 THREAD_PRIORITY_ABOVE_NORMAL, // 7 |
3316 THREAD_PRIORITY_HIGHEST, // 8 | 3323 THREAD_PRIORITY_HIGHEST, // 8 |
3317 THREAD_PRIORITY_HIGHEST, // 9 NearMaxPriority | 3324 THREAD_PRIORITY_HIGHEST, // 9 NearMaxPriority |
3318 THREAD_PRIORITY_TIME_CRITICAL // 10 MaxPriority | 3325 THREAD_PRIORITY_TIME_CRITICAL, // 10 MaxPriority |
3326 THREAD_PRIORITY_TIME_CRITICAL // 11 CriticalPriority | |
3319 }; | 3327 }; |
3320 | 3328 |
3321 static int prio_init() { | 3329 static int prio_init() { |
3322 // If ThreadPriorityPolicy is 1, switch tables | 3330 // If ThreadPriorityPolicy is 1, switch tables |
3323 if (ThreadPriorityPolicy == 1) { | 3331 if (ThreadPriorityPolicy == 1) { |
3324 int i; | 3332 int i; |
3325 for (i = 0; i < MaxPriority + 1; i++) { | 3333 for (i = 0; i < CriticalPriority + 1; i++) { |
3326 os::java_to_os_priority[i] = prio_policy1[i]; | 3334 os::java_to_os_priority[i] = prio_policy1[i]; |
3327 } | 3335 } |
3336 } | |
3337 if (UseCriticalJavaThreadPriority) { | |
3338 os::java_to_os_priority[MaxPriority] = os::java_to_os_priority[CriticalPriority] ; | |
3328 } | 3339 } |
3329 return 0; | 3340 return 0; |
3330 } | 3341 } |
3331 | 3342 |
3332 OSReturn os::set_native_priority(Thread* thread, int priority) { | 3343 OSReturn os::set_native_priority(Thread* thread, int priority) { |
4745 tty->print_cr("C heap has been corrupted (time: %d allocations)", mallocDebugCounter); | 4756 tty->print_cr("C heap has been corrupted (time: %d allocations)", mallocDebugCounter); |
4746 tty->print_cr("corrupted block near address %#x, length %d", phe.lpData, phe.cbData); | 4757 tty->print_cr("corrupted block near address %#x, length %d", phe.lpData, phe.cbData); |
4747 fatal("corrupted C heap"); | 4758 fatal("corrupted C heap"); |
4748 } | 4759 } |
4749 } | 4760 } |
4750 int err = GetLastError(); | 4761 DWORD err = GetLastError(); |
4751 if (err != ERROR_NO_MORE_ITEMS && err != ERROR_CALL_NOT_IMPLEMENTED) { | 4762 if (err != ERROR_NO_MORE_ITEMS && err != ERROR_CALL_NOT_IMPLEMENTED) { |
4752 fatal(err_msg("heap walk aborted with error %d", err)); | 4763 fatal(err_msg("heap walk aborted with error %d", err)); |
4753 } | 4764 } |
4754 HeapUnlock(heap); | 4765 HeapUnlock(heap); |
4755 } | 4766 } |
4776 return EXCEPTION_CONTINUE_EXECUTION; | 4787 return EXCEPTION_CONTINUE_EXECUTION; |
4777 } | 4788 } |
4778 | 4789 |
4779 return EXCEPTION_CONTINUE_SEARCH; | 4790 return EXCEPTION_CONTINUE_SEARCH; |
4780 } | 4791 } |
4781 | |
4782 static int getLastErrorString(char *buf, size_t len) | |
4783 { | |
4784 long errval; | |
4785 | |
4786 if ((errval = GetLastError()) != 0) | |
4787 { | |
4788 /* DOS error */ | |
4789 size_t n = (size_t)FormatMessage( | |
4790 FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, | |
4791 NULL, | |
4792 errval, | |
4793 0, | |
4794 buf, | |
4795 (DWORD)len, | |
4796 NULL); | |
4797 if (n > 3) { | |
4798 /* Drop final '.', CR, LF */ | |
4799 if (buf[n - 1] == '\n') n--; | |
4800 if (buf[n - 1] == '\r') n--; | |
4801 if (buf[n - 1] == '.') n--; | |
4802 buf[n] = '\0'; | |
4803 } | |
4804 return (int)n; | |
4805 } | |
4806 | |
4807 if (errno != 0) | |
4808 { | |
4809 /* C runtime error that has no corresponding DOS error code */ | |
4810 const char *s = strerror(errno); | |
4811 size_t n = strlen(s); | |
4812 if (n >= len) n = len - 1; | |
4813 strncpy(buf, s, n); | |
4814 buf[n] = '\0'; | |
4815 return (int)n; | |
4816 } | |
4817 return 0; | |
4818 } | |
4819 | |
4820 | 4792 |
4821 // We don't build a headless jre for Windows | 4793 // We don't build a headless jre for Windows |
4822 bool os::is_headless_jre() { return false; } | 4794 bool os::is_headless_jre() { return false; } |
4823 | 4795 |
4824 | 4796 |
4848 } | 4820 } |
4849 sock_initialized = TRUE; | 4821 sock_initialized = TRUE; |
4850 ::mutexUnlock(&sockFnTableMutex); | 4822 ::mutexUnlock(&sockFnTableMutex); |
4851 } | 4823 } |
4852 | 4824 |
4853 struct hostent* os::get_host_by_name(char* name) { | 4825 struct hostent* os::get_host_by_name(char* name) { |
4854 if (!sock_initialized) { | 4826 if (!sock_initialized) { |
4855 initSock(); | 4827 initSock(); |
4856 } | 4828 } |
4857 if (!os::WinSock2Dll::WinSock2Available()) { | 4829 if (!os::WinSock2Dll::WinSock2Available()) { |
4858 return NULL; | 4830 return NULL; |
4879 int os::listen(int fd, int count) { | 4851 int os::listen(int fd, int count) { |
4880 ShouldNotReachHere(); | 4852 ShouldNotReachHere(); |
4881 return 0; | 4853 return 0; |
4882 } | 4854 } |
4883 | 4855 |
4884 int os::connect(int fd, struct sockaddr *him, int len) { | 4856 int os::connect(int fd, struct sockaddr* him, socklen_t len) { |
4885 ShouldNotReachHere(); | 4857 ShouldNotReachHere(); |
4886 return 0; | 4858 return 0; |
4887 } | 4859 } |
4888 | 4860 |
4889 int os::accept(int fd, struct sockaddr *him, int *len) { | 4861 int os::accept(int fd, struct sockaddr* him, socklen_t* len) { |
4890 ShouldNotReachHere(); | 4862 ShouldNotReachHere(); |
4891 return 0; | 4863 return 0; |
4892 } | 4864 } |
4893 | 4865 |
4894 int os::sendto(int fd, char *buf, int len, int flags, | 4866 int os::sendto(int fd, char* buf, size_t len, uint flags, |
4895 struct sockaddr *to, int tolen) { | 4867 struct sockaddr* to, socklen_t tolen) { |
4896 ShouldNotReachHere(); | 4868 ShouldNotReachHere(); |
4897 return 0; | 4869 return 0; |
4898 } | 4870 } |
4899 | 4871 |
4900 int os::recvfrom(int fd, char *buf, int nBytes, int flags, | 4872 int os::recvfrom(int fd, char *buf, size_t nBytes, uint flags, |
4901 sockaddr *from, int *fromlen) { | 4873 sockaddr* from, socklen_t* fromlen) { |
4902 ShouldNotReachHere(); | 4874 ShouldNotReachHere(); |
4903 return 0; | 4875 return 0; |
4904 } | 4876 } |
4905 | 4877 |
4906 int os::recv(int fd, char *buf, int nBytes, int flags) { | 4878 int os::recv(int fd, char* buf, size_t nBytes, uint flags) { |
4907 ShouldNotReachHere(); | 4879 ShouldNotReachHere(); |
4908 return 0; | 4880 return 0; |
4909 } | 4881 } |
4910 | 4882 |
4911 int os::send(int fd, char *buf, int nBytes, int flags) { | 4883 int os::send(int fd, char* buf, size_t nBytes, uint flags) { |
4912 ShouldNotReachHere(); | 4884 ShouldNotReachHere(); |
4913 return 0; | 4885 return 0; |
4914 } | 4886 } |
4915 | 4887 |
4916 int os::raw_send(int fd, char *buf, int nBytes, int flags) { | 4888 int os::raw_send(int fd, char* buf, size_t nBytes, uint flags) { |
4917 ShouldNotReachHere(); | 4889 ShouldNotReachHere(); |
4918 return 0; | 4890 return 0; |
4919 } | 4891 } |
4920 | 4892 |
4921 int os::timeout(int fd, long timeout) { | 4893 int os::timeout(int fd, long timeout) { |
4931 int os::socket_shutdown(int fd, int howto) { | 4903 int os::socket_shutdown(int fd, int howto) { |
4932 ShouldNotReachHere(); | 4904 ShouldNotReachHere(); |
4933 return 0; | 4905 return 0; |
4934 } | 4906 } |
4935 | 4907 |
4936 int os::bind(int fd, struct sockaddr *him, int len) { | 4908 int os::bind(int fd, struct sockaddr* him, socklen_t len) { |
4937 ShouldNotReachHere(); | 4909 ShouldNotReachHere(); |
4938 return 0; | 4910 return 0; |
4939 } | 4911 } |
4940 | 4912 |
4941 int os::get_sock_name(int fd, struct sockaddr *him, int *len) { | 4913 int os::get_sock_name(int fd, struct sockaddr* him, socklen_t* len) { |
4942 ShouldNotReachHere(); | 4914 ShouldNotReachHere(); |
4943 return 0; | 4915 return 0; |
4944 } | 4916 } |
4945 | 4917 |
4946 int os::get_sock_opt(int fd, int level, int optname, | 4918 int os::get_sock_opt(int fd, int level, int optname, |
4947 char *optval, int* optlen) { | 4919 char* optval, socklen_t* optlen) { |
4948 ShouldNotReachHere(); | 4920 ShouldNotReachHere(); |
4949 return 0; | 4921 return 0; |
4950 } | 4922 } |
4951 | 4923 |
4952 int os::set_sock_opt(int fd, int level, int optname, | 4924 int os::set_sock_opt(int fd, int level, int optname, |
4953 const char *optval, int optlen) { | 4925 const char* optval, socklen_t optlen) { |
4954 ShouldNotReachHere(); | 4926 ShouldNotReachHere(); |
4955 return 0; | 4927 return 0; |
4956 } | 4928 } |
4957 | 4929 |
4958 | 4930 |
5362 _OpenProcessToken != NULL && | 5334 _OpenProcessToken != NULL && |
5363 _LookupPrivilegeValue != NULL; | 5335 _LookupPrivilegeValue != NULL; |
5364 } | 5336 } |
5365 | 5337 |
5366 #endif | 5338 #endif |
5367 |