WIP: glib-init: Prefer constructors, only define DLLMain for DLLs

Xavier Claessens requested to merge xclaesse/glib:windows-static into master

gcc-2.7+ and msvc support C constructors/destructors, so we should prefer them over DLLMain for initialization/deinitialization on Windows. Especially since DLLMain will only work with DLLs and hence will never work if one statically links GLib on Windows.

The threading/locking initialization for Windows also needs to happen during gobject initialization because the order in which constructors are called is not guaranteed, and the gobject initctor needs working locking. Hence, we make g_thread_win32_init() idempotent so it can be called multiple times, and call it from both the gobject init constructor and the glib init constructor.

An alternative is to implement ordering for constructors, but that's non-trivial since the way in which ordering must be implemented for gcc, msvc, and the SUN compiler are different.

-- TODO:

Edited by Philip Withnall

Merge request reports