comparison src/os/windows/vm/os_windows.cpp @ 8880:0ca3dd0ffaba

Merge
author bharadwaj
date Thu, 04 Apr 2013 17:01:34 -0700
parents 754c24457b20 53028d751155
children b9a918201d47 8be1318fbe77
comparison
equal deleted inserted replaced
8859:0c039865ef2b 8880:0ca3dd0ffaba
3771 static void perfMemory_exit_helper() { 3771 static void perfMemory_exit_helper() {
3772 perfMemory_exit(); 3772 perfMemory_exit();
3773 } 3773 }
3774 } 3774 }
3775 3775
3776 static jint initSock();
3777
3776 // this is called _after_ the global arguments have been parsed 3778 // this is called _after_ the global arguments have been parsed
3777 jint os::init_2(void) { 3779 jint os::init_2(void) {
3778 // Allocate a single page and mark it as readable for safepoint polling 3780 // Allocate a single page and mark it as readable for safepoint polling
3779 address polling_page = (address)VirtualAlloc(NULL, os::vm_page_size(), MEM_RESERVE, PAGE_READONLY); 3781 address polling_page = (address)VirtualAlloc(NULL, os::vm_page_size(), MEM_RESERVE, PAGE_READONLY);
3780 guarantee( polling_page != NULL, "Reserve Failed for polling page"); 3782 guarantee( polling_page != NULL, "Reserve Failed for polling page");
3899 3901
3900 if (UseNUMAInterleaving) { 3902 if (UseNUMAInterleaving) {
3901 // first check whether this Windows OS supports VirtualAllocExNuma, if not ignore this flag 3903 // first check whether this Windows OS supports VirtualAllocExNuma, if not ignore this flag
3902 bool success = numa_interleaving_init(); 3904 bool success = numa_interleaving_init();
3903 if (!success) UseNUMAInterleaving = false; 3905 if (!success) UseNUMAInterleaving = false;
3906 }
3907
3908 if (initSock() != JNI_OK) {
3909 return JNI_ERR;
3904 } 3910 }
3905 3911
3906 return JNI_OK; 3912 return JNI_OK;
3907 } 3913 }
3908 3914
4897 } 4903 }
4898 4904
4899 // We don't build a headless jre for Windows 4905 // We don't build a headless jre for Windows
4900 bool os::is_headless_jre() { return false; } 4906 bool os::is_headless_jre() { return false; }
4901 4907
4902 4908 static jint initSock() {
4903 typedef CRITICAL_SECTION mutex_t;
4904 #define mutexInit(m) InitializeCriticalSection(m)
4905 #define mutexDestroy(m) DeleteCriticalSection(m)
4906 #define mutexLock(m) EnterCriticalSection(m)
4907 #define mutexUnlock(m) LeaveCriticalSection(m)
4908
4909 static bool sock_initialized = FALSE;
4910 static mutex_t sockFnTableMutex;
4911
4912 static void initSock() {
4913 WSADATA wsadata; 4909 WSADATA wsadata;
4914 4910
4915 if (!os::WinSock2Dll::WinSock2Available()) { 4911 if (!os::WinSock2Dll::WinSock2Available()) {
4916 jio_fprintf(stderr, "Could not load Winsock 2 (error: %d)\n", 4912 jio_fprintf(stderr, "Could not load Winsock (error: %d)\n",
4917 ::GetLastError()); 4913 ::GetLastError());
4918 return; 4914 return JNI_ERR;
4919 } 4915 }
4920 if (sock_initialized == TRUE) return; 4916
4921 4917 if (os::WinSock2Dll::WSAStartup(MAKEWORD(2,2), &wsadata) != 0) {
4922 ::mutexInit(&sockFnTableMutex); 4918 jio_fprintf(stderr, "Could not initialize Winsock (error: %d)\n",
4923 ::mutexLock(&sockFnTableMutex); 4919 ::GetLastError());
4924 if (os::WinSock2Dll::WSAStartup(MAKEWORD(1,1), &wsadata) != 0) { 4920 return JNI_ERR;
4925 jio_fprintf(stderr, "Could not initialize Winsock\n"); 4921 }
4926 } 4922 return JNI_OK;
4927 sock_initialized = TRUE;
4928 ::mutexUnlock(&sockFnTableMutex);
4929 } 4923 }
4930 4924
4931 struct hostent* os::get_host_by_name(char* name) { 4925 struct hostent* os::get_host_by_name(char* name) {
4932 if (!sock_initialized) {
4933 initSock();
4934 }
4935 if (!os::WinSock2Dll::WinSock2Available()) {
4936 return NULL;
4937 }
4938 return (struct hostent*)os::WinSock2Dll::gethostbyname(name); 4926 return (struct hostent*)os::WinSock2Dll::gethostbyname(name);
4939 } 4927 }
4940 4928
4941 int os::socket_close(int fd) { 4929 int os::socket_close(int fd) {
4942 return ::closesocket(fd); 4930 return ::closesocket(fd);