glib: Stop using g_get_current_time() in various places 15/213615/1 accepted/tizen_5.5_unified_mobile_hotfix sandbox/hj0426.kim/glib_2.52.2 tizen_5.5_mobile_hotfix tizen_5.5_tv accepted/tizen/5.5/unified/20191031.010124 accepted/tizen/5.5/unified/mobile/hotfix/20201027.063256 accepted/tizen/unified/20190911.111745 submit/tizen/20190909.072243 submit/tizen_5.5/20191031.000006 submit/tizen_5.5_mobile_hotfix/20201026.185106 tizen_5.5.m2_release
authorPhilip Withnall <withnall@endlessm.com>
Wed, 24 Jul 2019 13:17:02 +0000 (14:17 +0100)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 9 Sep 2019 07:17:03 +0000 (16:17 +0900)
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Change-Id: I5baa3ebebdfd84b94fb32633c990905213421fa6
Helps: #1438
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
glib/gfileutils.c
glib/grand.c
glib/gslice.c

index ea3806e..7913ca9 100644 (file)
@@ -1280,7 +1280,7 @@ get_tmp_file (gchar            *tmpl,
     "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
   static const int NLETTERS = sizeof (letters) - 1;
   glong value;
-  GTimeVal tv;
+  gint64 now_us;
   static int counter = 0;
 
   g_return_val_if_fail (tmpl != NULL, -1);
@@ -1295,8 +1295,8 @@ get_tmp_file (gchar            *tmpl,
     }
 
   /* Get some more or less random data.  */
-  g_get_current_time (&tv);
-  value = (tv.tv_usec ^ tv.tv_sec) + counter++;
+  now_us = g_get_real_time ();
+  value = ((now_us % G_USEC_PER_SEC) ^ (now_us / G_USEC_PER_SEC)) + counter++;
 
   for (count = 0; count < 100; value += 7777, ++count)
     {
index 0cb833e..cb31b06 100644 (file)
@@ -49,6 +49,7 @@
 #include "gmem.h"
 #include "gtestutils.h"
 #include "gthread.h"
+#include "gtimer.h"
 
 #ifdef G_OS_UNIX
 #include <unistd.h>
@@ -220,7 +221,6 @@ g_rand_new (void)
   guint32 seed[4];
 #ifdef G_OS_UNIX
   static gboolean dev_urandom_exists = TRUE;
-  GTimeVal now;
 
   if (dev_urandom_exists)
     {
@@ -254,10 +254,10 @@ g_rand_new (void)
     }
 
   if (!dev_urandom_exists)
-    {  
-      g_get_current_time (&now);
-      seed[0] = now.tv_sec;
-      seed[1] = now.tv_usec;
+    {
+      gint64 now_us = g_get_real_time ();
+      seed[0] = now_us / G_USEC_PER_SEC;
+      seed[1] = now_us % G_USEC_PER_SEC;
       seed[2] = getpid ();
       seed[3] = getppid ();
     }
index 9022062..f201e6f 100644 (file)
@@ -596,9 +596,8 @@ magazine_cache_update_stamp (void)
 {
   if (allocator->stamp_counter >= MAX_STAMP_COUNTER)
     {
-      GTimeVal tv;
-      g_get_current_time (&tv);
-      allocator->last_stamp = tv.tv_sec * 1000 + tv.tv_usec / 1000; /* milli seconds */
+      gint64 now_us = g_get_real_time ();
+      allocator->last_stamp = now_us / 1000; /* milli seconds */
       allocator->stamp_counter = 0;
     }
   else