WIP: glib-init: Prefer constructors, only define DLLMain for DLLs
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:
-
Destructor, see https://bugzilla.gnome.org/show_bug.cgi?id=698118#c7. -
g_thread_win32_process_detach()
andg_crash_handler_win32_deinit()
are not called any more. -
CI