summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--recipes/glib.recipe1
-rw-r--r--recipes/glib/0013-grand-Only-use-rand_s-when-targetting-Visual-Studio-.patch45
2 files changed, 46 insertions, 0 deletions
diff --git a/recipes/glib.recipe b/recipes/glib.recipe
index 3f7f76e6..751b5558 100644
--- a/recipes/glib.recipe
+++ b/recipes/glib.recipe
@@ -37,6 +37,7 @@ class Recipe(recipe.Recipe):
'glib/0011-networkmonitornetlink-IN6_IS_ADDR_MC_LINKLOCAL-is-on.patch',
'glib/0001-gdbus-codgen-Use-a-proper-shebang-in-the-generator.patch',
'glib/0012-gutils-Don-t-use-issetugid-on-Android.patch',
+ 'glib/0013-grand-Only-use-rand_s-when-targetting-Visual-Studio-.patch',
]
files_libs = [
diff --git a/recipes/glib/0013-grand-Only-use-rand_s-when-targetting-Visual-Studio-.patch b/recipes/glib/0013-grand-Only-use-rand_s-when-targetting-Visual-Studio-.patch
new file mode 100644
index 00000000..11d2be0a
--- /dev/null
+++ b/recipes/glib/0013-grand-Only-use-rand_s-when-targetting-Visual-Studio-.patch
@@ -0,0 +1,45 @@
+From 13799511a0e2044f8deb24aa95a4abd623c76c0f Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= <sebastian@centricular.com>
+Date: Sat, 13 Sep 2014 16:31:03 +0300
+Subject: [PATCH] grand: Only use rand_s() when targetting Visual Studio >=
+ 2005
+
+It did not exist before. Fall back to the current time plus
+process id on older targets. This makes GLib work again on
+Windows XP.
+
+https://bugzilla.gnome.org/show_bug.cgi?id=736458
+---
+ glib/grand.c | 12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+diff --git a/glib/grand.c b/glib/grand.c
+index 6262cd2..e5d681b 100644
+--- a/glib/grand.c
++++ b/glib/grand.c
+@@ -261,10 +261,22 @@ g_rand_new (void)
+ seed[3] = getppid ();
+ }
+ #else /* G_OS_WIN32 */
++ /* rand_s() is only available since Visual Studio 2005 */
++#if defined(_MSC_VER) && _MSC_VER >= 1400
+ gint i;
+
+ for (i = 0; i < G_N_ELEMENTS (seed); i++)
+ rand_s (&seed[i]);
++#else
++ GTimeVal now;
++
++ g_get_current_time (&now);
++ seed[0] = now.tv_sec;
++ seed[1] = now.tv_usec;
++ seed[2] = getpid ();
++ seed[3] = 0;
++#endif
++
+ #endif
+
+ return g_rand_new_with_seed_array (seed, 4);
+--
+2.1.0
+