Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
x/sys/windows: Consider exporting kernel32 *LazyDLL #15702
Currently all libraries needing more procedures load the libraries by hand using either syscall or x/sys/windows. The most common DLL by a large margin used in this fashion appears to be kernel32.dll.
This means that in larger applications there are half-a-dozen libraries loading kernel32.dll. They could use a shared copy since *LazyDLL is safe for concurrent use.
from x/sys/windows would enable sharing this for applications.
x/sys/windows loads a copy of kernel32.dll in any case (modkernel32).
If needed I can write a proposal or a patch.
Underneath Windows does reference counting of the DLLs loaded so calling LoadLibrary("kernel32.dll") multiple times results in only a single copy of the library in the address space. So the saving is a little bit of memory and few less syscalls.
I don't see any benefit here. It is just few more calls into LoadLibrary. It is not slow code. And average app calls LoadLibrary just couple of times. And since I use $GOROOT/src/syscall/mksyscall_windows.go to generate my syscalls, I don't even have to write that code.
It is not worth the trouble.