X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=glib%2Fglib-init.c;h=df812c7d0365ad7fd936cbca7fa0d3c91d205994;hb=7e3d32b7053b47ca7feecf185abac96b619770c2;hp=a03e918c3a8681522173800635b50f08486e7420;hpb=063f03fa761fe2e341e32ebec6ed7ff6732b5bb1;p=platform%2Fupstream%2Fglib.git diff --git a/glib/glib-init.c b/glib/glib-init.c index a03e918..df812c7 100644 --- a/glib/glib-init.c +++ b/glib/glib-init.c @@ -12,9 +12,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - * USA. + * License along with this library; if not, see . * * Author: Ryan Lortie */ @@ -23,19 +21,32 @@ #include "glib-init.h" +#include "glib-private.h" +#include "gtypes.h" #include "gutils.h" /* for GDebugKey */ #include "gconstructor.h" +#include "gmem.h" /* for g_mem_gc_friendly */ #include #include #include #include +/* This seems as good a place as any to make static assertions about platform + * assumptions we make throughout GLib. */ + +/* We assume that data pointers are the same size as function pointers... */ +G_STATIC_ASSERT (sizeof (gpointer) == sizeof (GFunc)); +G_STATIC_ASSERT (_g_alignof (gpointer) == _g_alignof (GFunc)); +/* ... and that all function pointers are the same size. */ +G_STATIC_ASSERT (sizeof (GFunc) == sizeof (GCompareDataFunc)); +G_STATIC_ASSERT (_g_alignof (GFunc) == _g_alignof (GCompareDataFunc)); + /** * g_mem_gc_friendly: * - * This variable is %TRUE if the G_DEBUG environment variable - * includes the key gc-friendly. + * This variable is %TRUE if the `G_DEBUG` environment variable + * includes the key `gc-friendly`. */ #ifdef ENABLE_GC_FRIENDLY_DEFAULT gboolean g_mem_gc_friendly = TRUE; @@ -70,19 +81,19 @@ debug_key_matches (const gchar *key, * commas, or %NULL. * @keys: (array length=nkeys): pointer to an array of #GDebugKey which associate * strings with bit flags. - * @nkeys: the number of #GDebugKeys in the array. + * @nkeys: the number of #GDebugKeys in the array. * * Parses a string containing debugging options * into a %guint containing bit flags. This is used * within GDK and GTK+ to parse the debug options passed on the * command line or through environment variables. * - * If @string is equal to "all", all flags are set. Any flags - * specified along with "all" in @string are inverted; thus, - * "all,foo,bar" or "foo,bar,all" sets all flags - * except those corresponding to "foo" and "bar". + * If @string is equal to "all", all flags are set. Any flags + * specified along with "all" in @string are inverted; thus, + * "all,foo,bar" or "foo,bar,all" sets all flags except those + * corresponding to "foo" and "bar". * - * If @string is equal to "help", all the available keys in @keys + * If @string is equal to "help", all the available keys in @keys * are printed out to standard error. * * Returns: the combined set of bit flags. @@ -159,7 +170,8 @@ g_parse_debug_string (const gchar *string, static guint g_parse_debug_envvar (const gchar *envvar, const GDebugKey *keys, - gint n_keys) + gint n_keys, + guint default_value) { const gchar *value; @@ -175,6 +187,9 @@ g_parse_debug_envvar (const gchar *envvar, value = getenv (envvar); #endif + if (value == NULL) + return default_value; + return g_parse_debug_string (value, keys, n_keys); } @@ -190,7 +205,7 @@ g_messages_prefixed_init (void) { "debug", G_LOG_LEVEL_DEBUG } }; - g_log_msg_prefix = g_parse_debug_envvar ("G_MESSAGES_PREFIXED", keys, G_N_ELEMENTS (keys)); + g_log_msg_prefix = g_parse_debug_envvar ("G_MESSAGES_PREFIXED", keys, G_N_ELEMENTS (keys), g_log_msg_prefix); } static void @@ -203,7 +218,7 @@ g_debug_init (void) }; GLogLevelFlags flags; - flags = g_parse_debug_envvar ("G_DEBUG", keys, G_N_ELEMENTS (keys)); + flags = g_parse_debug_envvar ("G_DEBUG", keys, G_N_ELEMENTS (keys), 0); g_log_always_fatal |= flags & G_LOG_LEVEL_MASK; @@ -219,6 +234,10 @@ glib_init (void) #if defined (G_OS_WIN32) +BOOL WINAPI DllMain (HINSTANCE hinstDLL, + DWORD fdwReason, + LPVOID lpvReserved); + HMODULE glib_dll; BOOL WINAPI @@ -231,12 +250,16 @@ DllMain (HINSTANCE hinstDLL, case DLL_PROCESS_ATTACH: glib_dll = hinstDLL; g_clock_win32_init (); +#ifdef THREADS_WIN32 g_thread_win32_init (); +#endif glib_init (); break; case DLL_THREAD_DETACH: +#ifdef THREADS_WIN32 g_thread_win32_thread_detach (); +#endif break; default: