[Gc] Improving perfs on a multi CPU windows system

Emmanuel Stapf [ES] manus@eiffel.com
Thu, 4 Sep 2003 12:27:52 -0700

> We could dynamically test what the target OS is, and issue 
> the right call. That would require some sort of "weak symbol" 
> ability so that we can run with an undefined (but unused) 
> reference.  Does such a thing exist on Windows?

At runtime initialization, you could try to do something like:

HMODULE module;
FARPROC init_critical_section;

module = LoadLibrary ("kernel32.dll")
init_critical_section = GetProcAddress (module,

if (init_critical_section) {
	(BOOL (_stdcall *) (LPCRITICALSECTION, DWORD)) init_critical_section (cs,
} else {
	InitializeCriticalSection (cs);

The code needs to be tested, but that the idea.