Commit 277a7b22 authored by Alex Brainman's avatar Alex Brainman

runtime: do not crash when GetQueuedCompletionStatusEx is missing

Fixes #7635

LGTM=minux.ma
R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/80390043
parent 0f272d13
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#pragma dynimport runtime·FreeEnvironmentStringsW FreeEnvironmentStringsW "kernel32.dll" #pragma dynimport runtime·FreeEnvironmentStringsW FreeEnvironmentStringsW "kernel32.dll"
#pragma dynimport runtime·GetEnvironmentStringsW GetEnvironmentStringsW "kernel32.dll" #pragma dynimport runtime·GetEnvironmentStringsW GetEnvironmentStringsW "kernel32.dll"
#pragma dynimport runtime·GetProcAddress GetProcAddress "kernel32.dll" #pragma dynimport runtime·GetProcAddress GetProcAddress "kernel32.dll"
#pragma dynimport runtime·GetQueuedCompletionStatusEx GetQueuedCompletionStatusEx "kernel32.dll"
#pragma dynimport runtime·GetStdHandle GetStdHandle "kernel32.dll" #pragma dynimport runtime·GetStdHandle GetStdHandle "kernel32.dll"
#pragma dynimport runtime·GetSystemInfo GetSystemInfo "kernel32.dll" #pragma dynimport runtime·GetSystemInfo GetSystemInfo "kernel32.dll"
#pragma dynimport runtime·GetSystemTimeAsFileTime GetSystemTimeAsFileTime "kernel32.dll" #pragma dynimport runtime·GetSystemTimeAsFileTime GetSystemTimeAsFileTime "kernel32.dll"
...@@ -54,7 +53,6 @@ extern void *runtime·ExitProcess; ...@@ -54,7 +53,6 @@ extern void *runtime·ExitProcess;
extern void *runtime·FreeEnvironmentStringsW; extern void *runtime·FreeEnvironmentStringsW;
extern void *runtime·GetEnvironmentStringsW; extern void *runtime·GetEnvironmentStringsW;
extern void *runtime·GetProcAddress; extern void *runtime·GetProcAddress;
extern void *runtime·GetQueuedCompletionStatusEx;
extern void *runtime·GetStdHandle; extern void *runtime·GetStdHandle;
extern void *runtime·GetSystemInfo; extern void *runtime·GetSystemInfo;
extern void *runtime·GetSystemTimeAsFileTime; extern void *runtime·GetSystemTimeAsFileTime;
...@@ -74,6 +72,8 @@ extern void *runtime·WaitForSingleObject; ...@@ -74,6 +72,8 @@ extern void *runtime·WaitForSingleObject;
extern void *runtime·WriteFile; extern void *runtime·WriteFile;
extern void *runtime·timeBeginPeriod; extern void *runtime·timeBeginPeriod;
void *runtime·GetQueuedCompletionStatusEx;
extern uintptr runtime·externalthreadhandlerp; extern uintptr runtime·externalthreadhandlerp;
void runtime·externalthreadhandler(void); void runtime·externalthreadhandler(void);
void runtime·sigtramp(void); void runtime·sigtramp(void);
...@@ -90,6 +90,8 @@ getproccount(void) ...@@ -90,6 +90,8 @@ getproccount(void)
void void
runtime·osinit(void) runtime·osinit(void)
{ {
void *kernel32;
runtime·externalthreadhandlerp = (uintptr)runtime·externalthreadhandler; runtime·externalthreadhandlerp = (uintptr)runtime·externalthreadhandler;
runtime·stdcall(runtime·AddVectoredExceptionHandler, 2, (uintptr)1, (uintptr)runtime·sigtramp); runtime·stdcall(runtime·AddVectoredExceptionHandler, 2, (uintptr)1, (uintptr)runtime·sigtramp);
...@@ -102,6 +104,11 @@ runtime·osinit(void) ...@@ -102,6 +104,11 @@ runtime·osinit(void)
// equivalent threads that all do a mix of GUI, IO, computations, etc. // equivalent threads that all do a mix of GUI, IO, computations, etc.
// In such context dynamic priority boosting does nothing but harm, so we turn it off. // In such context dynamic priority boosting does nothing but harm, so we turn it off.
runtime·stdcall(runtime·SetProcessPriorityBoost, 2, (uintptr)-1, (uintptr)1); runtime·stdcall(runtime·SetProcessPriorityBoost, 2, (uintptr)-1, (uintptr)1);
kernel32 = runtime·stdcall(runtime·LoadLibraryA, 1, "kernel32.dll");
if(kernel32 != nil) {
runtime·GetQueuedCompletionStatusEx = runtime·stdcall(runtime·GetProcAddress, 2, kernel32, "GetQueuedCompletionStatusEx");
}
} }
void void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment