[Gc] Patch for WinCE: a change in WinMain redirection

Ivan Maidanski ivmai at mail.ru
Thu Sep 17 10:25:57 PDT 2009


Hi!

This patch (ivmai145.diff) comes from my following conclusions (for WinCE):
- WinMain (without GC_ prefix) exported from gc.lib may result in a linker symbols collision;
- sometimes it's needed to tune GC before calling GC_INIT() (so, it's impossible relay on WinMain supplied by GC).

It seems that a WinCE application could be built in the same same style as a Win32 one, i.e. only have GC_INIT() (without create a separate thread for GC_WinMain) at start-up and without GC locks obligatory freeing, but the experimentation isn't done yet.

In this patch, GC_WINMAIN_REDIRECT macro is introduced (only if Win32 threads):
- at build, if it's defined then WinMain is exported from GC, otherwise not (this doesn't depend on MSWINCE macro);
- at import, this only defines WinMain as GC_WinMain (this doesn't depend on MSWINCE macro neither).

So, if someone wants the old behavior (for WinCE) then he should explicitly pass -D GC_WINMAIN_REDIRECT (both at build and use) thus confirming he wants WinMain redirection. (This approach is similar to the story of DllMain-based registration which had been implicit earlier and then the behavior changed requiring GC_use_DllMain() to be called to act in the old style.)

Any opinion? (Greatly appreciated.)

ChangeLog entries:

	* Makefile.direct (GC_WINMAIN_REDIRECT): Add the comment for.
	* Makefile.direct (NO_GETENV): Update the comment.
	* include/gc.h (GC_WINMAIN_WINCE_LPTSTR): Remove macro.
	* include/gc.h (GC_WinMain): Remove declaration.
	* include/gc.h (WinMain): Define (as GC_WinMain) if and only if
	GC_WINMAIN_REDIRECT.
	* tests/test.c (GC_COND_INIT): Define as GC_INIT() also in case of
	WinCE target unless GC_WINMAIN_REDIRECT is defined.
	* tests/test.c (WINMAIN_LPTSTR): New macro.
	* tests/test.c (WinMain): Use WINMAIN_LPTSTR instead of LP[W]STR
	and GC_WINMAIN_WINCE_LPTSTR.
	* win32_threads.c (start_mark_threads): Add the comment for
	MARK_THREAD_STACK_SIZE.
	* win32_threads.c: Recognize new GC_WINMAIN_REDIRECT macro.
	* win32_threads.c (WINMAIN_LPTSTR, WINMAIN_THREAD_STACK_SIZE): New
	macro (only if GC_WINMAIN_REDIRECT).
	* win32_threads.c: Undefine WinMain macro if GC_WINMAIN_REDIRECT.
	* win32_threads.c (GC_WinMain): Add prototype (only if
	GC_WINMAIN_REDIRECT).
	* win32_threads.c (main_thread_args, WinMain): Rename
	GC_WINMAIN_WINCE_LPTSTR to WINMAIN_LPTSTR.
	* win32_threads.c (WinMain): Call GC_INIT() instead of GC_init();
	use WINMAIN_THREAD_STACK_SIZE.
	* win32_threads.c (WinMain): Call GC_deinit() and
	DeleteCriticalSection() only if WinCE; add FIXME.

Bye.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ivmai145.diff
Type: application/octet-stream
Size: 7012 bytes
Desc: not available
Url : http://napali.hpl.hp.com/pipermail/gc/attachments/20090917/3e7c466d/ivmai145-0001.obj


More information about the Gc mailing list