Comment 167 for bug 1160569

Revision history for this message
In , Mh+mozilla (mh+mozilla) wrote :

(In reply to Karl Tomlinson (ni?:karlt) from comment #122)
> Comment on attachment 8630422
> Replace g_slice_set_config() with G_SLICE environment variable
>
> The g_type_init() call has been dropped.
> I don't know of a static constructor using GSlice in GLib 2.32.

Yeah, I was mistaken, I thought there was, but there isn't. Only g_thread is initialized, not g_slice.

> >+#if defined(MOZ_WIDGET_GTK)
> >+#if !GLIB_CHECK_VERSION(2, 32, 0)
>
> The compile time glib version check is contrary to our goal of compiling the
> same code irrespective of the compile environment.

I thought that too, and then I found a bunch of preprocessor glib version checks (various GLIB_CHECK_VERSION in harfbuzz, and various GLIB_MAJOR/MINOR_VERSION checks here and there, although, looking at them, they are actually useless because they're for versions even older than what we support ; harfbuzz does check for versions well above 2.18).

> Can this just be "if MOZ_WIDGET_GTK == 2" ?

sure

> I'd also be happy to drop support for G_SLICE=always-malloc on versions prior
> to 2.32 if that makes the g_thread_init situation simpler. However, I don't
> know whether it is acceptable to call g_thread_init after g_type_init in
> versions prior to 2.24.

g_thread_init can be called multiple times in versions >= 2.24, and gtype.c says, about g_type_init, "Since version 2.24 this also initializes the thread system". So if we're okay with dropping G_SLICE=always-malloc for versions 2.18 to 2.23 included, we should be able to get away with only calling g_type_init. Another option would be to just call g_slice_alloc/g_slice_free1, which will obviously initialize gslice, and after all, sounds much simpler.

Thoughts?