From 1c5f6313c58187ce7682058057b63e14ae6f70e5 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 12 Apr 2013 09:50:06 +0200 Subject: Bug #681837 - Make enum type registration thread safe --- Makefile.am | 2 ++ e-util/Makefile.am | 15 +++++++----- e-util/e-util-enumtypes.c.template | 38 ----------------------------- e-util/e-util-enumtypes.h.template | 27 -------------------- enumtypes.c.template | 37 ++++++++++++++++++++++++++++ enumtypes.h.template | 24 ++++++++++++++++++ libemail-engine/Makefile.am | 18 +++++++------- libemail-engine/e-mail-enumtypes.c.template | 38 ----------------------------- libemail-engine/e-mail-enumtypes.h.template | 27 -------------------- shell/Makefile.am | 15 +++++++----- shell/e-shell-enumtypes.c.template | 38 ----------------------------- shell/e-shell-enumtypes.h.template | 27 -------------------- 12 files changed, 90 insertions(+), 216 deletions(-) delete mode 100644 e-util/e-util-enumtypes.c.template delete mode 100644 e-util/e-util-enumtypes.h.template create mode 100644 enumtypes.c.template create mode 100644 enumtypes.h.template delete mode 100644 libemail-engine/e-mail-enumtypes.c.template delete mode 100644 libemail-engine/e-mail-enumtypes.h.template delete mode 100644 shell/e-shell-enumtypes.c.template delete mode 100644 shell/e-shell-enumtypes.h.template diff --git a/Makefile.am b/Makefile.am index 888734a783..856e459102 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,6 +25,8 @@ EXTRA_DIST = \ MAINTAINERS \ NEWS \ NEWS-1.0 \ + enumtypes.c.template \ + enumtypes.h.template \ marshal.mk \ iconv-detect.c \ plugin.mk \ diff --git a/e-util/Makefile.am b/e-util/Makefile.am index 5e974f20bc..367add596b 100644 --- a/e-util/Makefile.am +++ b/e-util/Makefile.am @@ -6,11 +6,16 @@ ruledir = $(privdatadir) ENUM_TYPES = e-util-enums.h -e-util-enumtypes.h: e-util-enumtypes.h.template $(ENUM_TYPES) - $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template e-util-enumtypes.h.template $(ENUM_TYPES)) > $@ +e-util-enumtypes.h: $(top_srcdir)/enumtypes.h.template $(ENUM_TYPES) + $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template $(top_srcdir)/enumtypes.h.template \ + --fhead "#ifndef E_UTIL_ENUMTYPES_H\n#define E_UTIL_ENUMTYPES_H\n" \ + --ftail "#endif /* E_UTIL_ENUMTYPES_H */\n" \ + $(ENUM_TYPES)) > $@ -e-util-enumtypes.c: e-util-enumtypes.c.template $(ENUM_TYPES) - $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template e-util-enumtypes.c.template $(ENUM_TYPES)) > $@ +e-util-enumtypes.c: $(top_srcdir)/enumtypes.c.template $(ENUM_TYPES) + $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template $(top_srcdir)/enumtypes.c.template \ + --fhead "#include \"e-util-enumtypes.h\"" \ + $(ENUM_TYPES)) > $@ e-marshal.h: e-marshal.list $(AM_V_GEN) $(GLIB_GENMARSHAL) --header --prefix=e_marshal $^ > e-marshal.h.tmp && \ @@ -648,8 +653,6 @@ test_source_selector_SOURCES = test-source-selector.c test_source_selector_LDADD = $(TEST_LDADD) EXTRA_DIST = \ - e-util-enumtypes.h.template \ - e-util-enumtypes.c.template \ e-system.error.xml \ filter.error.xml \ widgets.error.xml \ diff --git a/e-util/e-util-enumtypes.c.template b/e-util/e-util-enumtypes.c.template deleted file mode 100644 index cb2634790c..0000000000 --- a/e-util/e-util-enumtypes.c.template +++ /dev/null @@ -1,38 +0,0 @@ -/*** BEGIN file-header ***/ -#include "e-util-enumtypes.h" - -/*** END file-header ***/ - -/*** BEGIN file-production ***/ -/* enumerations from "@filename@" */ -#include "@filename@" - -/*** END file-production ***/ - -/*** BEGIN value-header ***/ -GType -@enum_name@_get_type (void) -{ - static GType the_type = 0; - - if (the_type == 0) { - static const G@Type@Value values[] = { -/*** END value-header ***/ - -/*** BEGIN value-production ***/ - { @VALUENAME@, - "@VALUENAME@", - "@valuenick@" }, -/*** END value-production ***/ - -/*** BEGIN value-tail ***/ - { 0, NULL, NULL } - }; - the_type = g_@type@_register_static ( - g_intern_static_string ("@EnumName@"), - values); - } - return the_type; -} - -/*** END value-tail ***/ diff --git a/e-util/e-util-enumtypes.h.template b/e-util/e-util-enumtypes.h.template deleted file mode 100644 index c5bfa9c2c1..0000000000 --- a/e-util/e-util-enumtypes.h.template +++ /dev/null @@ -1,27 +0,0 @@ -/*** BEGIN file-header ***/ -#ifndef E_UTIL_ENUMTYPES_H -#define E_UTIL_ENUMTYPES_H - -#include - -G_BEGIN_DECLS - -/*** END file-header ***/ - -/*** BEGIN file-production ***/ -/* Enumerations from "@filename@" */ - -/*** END file-production ***/ - -/*** BEGIN enumeration-production ***/ -#define E_TYPE_@ENUMSHORT@ (@enum_name@_get_type()) -GType @enum_name@_get_type (void) G_GNUC_CONST; - -/*** END enumeration-production ***/ - -/*** BEGIN file-tail ***/ -G_END_DECLS - -#endif /* E_UTIL_ENUMTYPES_H */ -/*** END file-tail ***/ - diff --git a/enumtypes.c.template b/enumtypes.c.template new file mode 100644 index 0000000000..0a9912166c --- /dev/null +++ b/enumtypes.c.template @@ -0,0 +1,37 @@ +/*** BEGIN file-header ***/ +/*** END file-header ***/ + +/*** BEGIN file-production ***/ +/* enumerations from "@filename@" */ +#include "@filename@" + +/*** END file-production ***/ + +/*** BEGIN value-header ***/ +GType +@enum_name@_get_type (void) +{ + static volatile gsize the_type__volatile = 0; + + if (g_once_init_enter (&the_type__volatile)) { + static const G@Type@Value values[] = { +/*** END value-header ***/ + +/*** BEGIN value-production ***/ + { @VALUENAME@, + "@VALUENAME@", + "@valuenick@" }, +/*** END value-production ***/ + +/*** BEGIN value-tail ***/ + { 0, NULL, NULL } + }; + GType the_type = g_@type@_register_static ( + g_intern_static_string ("@EnumName@"), + values); + g_once_init_leave (&the_type__volatile, the_type); + } + return the_type__volatile; +} + +/*** END value-tail ***/ diff --git a/enumtypes.h.template b/enumtypes.h.template new file mode 100644 index 0000000000..e421eddbe7 --- /dev/null +++ b/enumtypes.h.template @@ -0,0 +1,24 @@ +/*** BEGIN file-header ***/ +/*** END file-header ***/ + +/*** BEGIN file-production ***/ + +#include + +G_BEGIN_DECLS + +/* Enumerations from "@filename@" */ + +/*** END file-production ***/ + +/*** BEGIN enumeration-production ***/ +#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type()) +GType @enum_name@_get_type (void) G_GNUC_CONST; + +/*** END enumeration-production ***/ + +/*** BEGIN file-tail ***/ +G_END_DECLS + +/*** END file-tail ***/ + diff --git a/libemail-engine/Makefile.am b/libemail-engine/Makefile.am index 60a8437c6e..d8f8207323 100644 --- a/libemail-engine/Makefile.am +++ b/libemail-engine/Makefile.am @@ -4,11 +4,16 @@ privsolib_LTLIBRARIES = libemail-engine.la ENUM_TYPES = e-mail-enums.h -e-mail-enumtypes.h: e-mail-enumtypes.h.template $(ENUM_TYPES) - $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template e-mail-enumtypes.h.template $(ENUM_TYPES)) > $@ +e-mail-enumtypes.h: $(top_srcdir)/enumtypes.h.template $(ENUM_TYPES) + $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template $(top_srcdir)/enumtypes.h.template \ + --fhead "#ifndef E_MAIL_ENUMTYPES_H\n#define E_MAIL_ENUMTYPES_H\n" \ + --ftail "#endif /* E_MAIL_ENUMTYPES_H */\n" \ + $(ENUM_TYPES)) > $@ -e-mail-enumtypes.c: e-mail-enumtypes.c.template $(ENUM_TYPES) - $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template e-mail-enumtypes.c.template $(ENUM_TYPES)) > $@ +e-mail-enumtypes.c: $(top_srcdir)/enumtypes.c.template $(ENUM_TYPES) + $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template $(top_srcdir)/enumtypes.c.template \ + --fhead "#include \"e-mail-enumtypes.h\"" \ + $(ENUM_TYPES)) > $@ ENUM_GENERATED = e-mail-enumtypes.h e-mail-enumtypes.c @@ -86,11 +91,6 @@ BUILT_SOURCES = $(ENUM_GENERATED) CLEANFILES = $(BUILT_SOURCES) DISTCLEANFILES = $(pkgconfig_DATA) -EXTRA_DIST = \ - e-mail-enumtypes.h.template \ - e-mail-enumtypes.c.template \ - $(NULL) - dist-hook: cd $(distdir); rm -f $(BUILT_SOURCES) diff --git a/libemail-engine/e-mail-enumtypes.c.template b/libemail-engine/e-mail-enumtypes.c.template deleted file mode 100644 index db4f2a4503..0000000000 --- a/libemail-engine/e-mail-enumtypes.c.template +++ /dev/null @@ -1,38 +0,0 @@ -/*** BEGIN file-header ***/ -#include "e-mail-enumtypes.h" - -/*** END file-header ***/ - -/*** BEGIN file-production ***/ -/* enumerations from "@filename@" */ -#include "@filename@" - -/*** END file-production ***/ - -/*** BEGIN value-header ***/ -GType -@enum_name@_get_type (void) -{ - static GType the_type = 0; - - if (the_type == 0) { - static const G@Type@Value values[] = { -/*** END value-header ***/ - -/*** BEGIN value-production ***/ - { @VALUENAME@, - "@VALUENAME@", - "@valuenick@" }, -/*** END value-production ***/ - -/*** BEGIN value-tail ***/ - { 0, NULL, NULL } - }; - the_type = g_@type@_register_static ( - g_intern_static_string ("@EnumName@"), - values); - } - return the_type; -} - -/*** END value-tail ***/ diff --git a/libemail-engine/e-mail-enumtypes.h.template b/libemail-engine/e-mail-enumtypes.h.template deleted file mode 100644 index d983a72d5c..0000000000 --- a/libemail-engine/e-mail-enumtypes.h.template +++ /dev/null @@ -1,27 +0,0 @@ -/*** BEGIN file-header ***/ -#ifndef E_MAIL_ENUMTYPES_H -#define E_MAIL_ENUMTYPES_H - -#include - -G_BEGIN_DECLS - -/*** END file-header ***/ - -/*** BEGIN file-production ***/ -/* Enumerations from "@filename@" */ - -/*** END file-production ***/ - -/*** BEGIN enumeration-production ***/ -#define E_TYPE_@ENUMSHORT@ (@enum_name@_get_type()) -GType @enum_name@_get_type (void) G_GNUC_CONST; - -/*** END enumeration-production ***/ - -/*** BEGIN file-tail ***/ -G_END_DECLS - -#endif /* E_MAIL_ENUMTYPES_H */ -/*** END file-tail ***/ - diff --git a/shell/Makefile.am b/shell/Makefile.am index 355ec69fad..d36547e609 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -8,11 +8,16 @@ eshellincludedir = $(privincludedir)/shell ENUM_TYPES = e-shell.h -e-shell-enumtypes.h: e-shell-enumtypes.h.template $(ENUM_TYPES) - $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template e-shell-enumtypes.h.template $(ENUM_TYPES)) > $@ +e-shell-enumtypes.h: $(top_srcdir)/enumtypes.h.template $(ENUM_TYPES) + $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template $(top_srcdir)/enumtypes.h.template \ + --fhead "#ifndef E_SHELL_ENUMTYPES_H\n#define E_SHELL_ENUMTYPES_H\n" \ + --ftail "#endif /* E_SHELL_ENUMTYPES_H */\n" \ + $(ENUM_TYPES)) > $@ -e-shell-enumtypes.c: e-shell-enumtypes.c.template $(ENUM_TYPES) - $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template e-shell-enumtypes.c.template $(ENUM_TYPES)) > $@ +e-shell-enumtypes.c: $(top_srcdir)/enumtypes.c.template $(ENUM_TYPES) + $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template $(top_srcdir)/enumtypes.c.template \ + --fhead "#include \"e-shell-enumtypes.h\"" \ + $(ENUM_TYPES)) > $@ ENUM_GENERATED = e-shell-enumtypes.h e-shell-enumtypes.c @@ -165,8 +170,6 @@ errordir = $(privdatadir)/errors EXTRA_DIST = \ evo-version.h.in \ - e-shell-enumtypes.h.template \ - e-shell-enumtypes.c.template \ shell.error.xml \ evolution-icon.rc \ evolution.ico \ diff --git a/shell/e-shell-enumtypes.c.template b/shell/e-shell-enumtypes.c.template deleted file mode 100644 index 4d30900611..0000000000 --- a/shell/e-shell-enumtypes.c.template +++ /dev/null @@ -1,38 +0,0 @@ -/*** BEGIN file-header ***/ -#include "e-shell-enumtypes.h" - -/*** END file-header ***/ - -/*** BEGIN file-production ***/ -/* enumerations from "@filename@" */ -#include "@filename@" - -/*** END file-production ***/ - -/*** BEGIN value-header ***/ -GType -@enum_name@_get_type (void) -{ - static GType the_type = 0; - - if (the_type == 0) { - static const G@Type@Value values[] = { -/*** END value-header ***/ - -/*** BEGIN value-production ***/ - { @VALUENAME@, - "@VALUENAME@", - "@valuenick@" }, -/*** END value-production ***/ - -/*** BEGIN value-tail ***/ - { 0, NULL, NULL } - }; - the_type = g_@type@_register_static ( - g_intern_static_string ("@EnumName@"), - values); - } - return the_type; -} - -/*** END value-tail ***/ diff --git a/shell/e-shell-enumtypes.h.template b/shell/e-shell-enumtypes.h.template deleted file mode 100644 index 76ff677384..0000000000 --- a/shell/e-shell-enumtypes.h.template +++ /dev/null @@ -1,27 +0,0 @@ -/*** BEGIN file-header ***/ -#ifndef E_SHELL_ENUMTYPES_H -#define E_SHELL_ENUMTYPES_H - -#include - -G_BEGIN_DECLS - -/*** END file-header ***/ - -/*** BEGIN file-production ***/ -/* Enumerations from "@filename@" */ - -/*** END file-production ***/ - -/*** BEGIN enumeration-production ***/ -#define E_TYPE_@ENUMSHORT@ (@enum_name@_get_type()) -GType @enum_name@_get_type (void) G_GNUC_CONST; - -/*** END enumeration-production ***/ - -/*** BEGIN file-tail ***/ -G_END_DECLS - -#endif /* E_SHELL_ENUMTYPES_H */ -/*** END file-tail ***/ - -- cgit v1.2.3