mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-05 10:38:08 +01:00
glib: Stop using g_get_current_time() in various places
Signed-off-by: Philip Withnall <withnall@endlessm.com> Helps: #1438
This commit is contained in:
parent
c0f958de5b
commit
82e3e109dd
@ -1318,7 +1318,7 @@ get_tmp_file (gchar *tmpl,
|
|||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||||
static const int NLETTERS = sizeof (letters) - 1;
|
static const int NLETTERS = sizeof (letters) - 1;
|
||||||
glong value;
|
glong value;
|
||||||
GTimeVal tv;
|
gint64 now_us;
|
||||||
static int counter = 0;
|
static int counter = 0;
|
||||||
|
|
||||||
g_return_val_if_fail (tmpl != NULL, -1);
|
g_return_val_if_fail (tmpl != NULL, -1);
|
||||||
@ -1333,8 +1333,8 @@ get_tmp_file (gchar *tmpl,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Get some more or less random data. */
|
/* Get some more or less random data. */
|
||||||
g_get_current_time (&tv);
|
now_us = g_get_real_time ();
|
||||||
value = (tv.tv_usec ^ tv.tv_sec) + counter++;
|
value = ((now_us % G_USEC_PER_SEC) ^ (now_us / G_USEC_PER_SEC)) + counter++;
|
||||||
|
|
||||||
for (count = 0; count < 100; value += 7777, ++count)
|
for (count = 0; count < 100; value += 7777, ++count)
|
||||||
{
|
{
|
||||||
|
10
glib/grand.c
10
glib/grand.c
@ -49,6 +49,7 @@
|
|||||||
#include "gmem.h"
|
#include "gmem.h"
|
||||||
#include "gtestutils.h"
|
#include "gtestutils.h"
|
||||||
#include "gthread.h"
|
#include "gthread.h"
|
||||||
|
#include "gtimer.h"
|
||||||
|
|
||||||
#ifdef G_OS_UNIX
|
#ifdef G_OS_UNIX
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -220,7 +221,6 @@ g_rand_new (void)
|
|||||||
guint32 seed[4];
|
guint32 seed[4];
|
||||||
#ifdef G_OS_UNIX
|
#ifdef G_OS_UNIX
|
||||||
static gboolean dev_urandom_exists = TRUE;
|
static gboolean dev_urandom_exists = TRUE;
|
||||||
GTimeVal now;
|
|
||||||
|
|
||||||
if (dev_urandom_exists)
|
if (dev_urandom_exists)
|
||||||
{
|
{
|
||||||
@ -254,10 +254,10 @@ g_rand_new (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!dev_urandom_exists)
|
if (!dev_urandom_exists)
|
||||||
{
|
{
|
||||||
g_get_current_time (&now);
|
gint64 now_us = g_get_real_time ();
|
||||||
seed[0] = now.tv_sec;
|
seed[0] = now_us / G_USEC_PER_SEC;
|
||||||
seed[1] = now.tv_usec;
|
seed[1] = now_us % G_USEC_PER_SEC;
|
||||||
seed[2] = getpid ();
|
seed[2] = getpid ();
|
||||||
seed[3] = getppid ();
|
seed[3] = getppid ();
|
||||||
}
|
}
|
||||||
|
@ -595,9 +595,8 @@ magazine_cache_update_stamp (void)
|
|||||||
{
|
{
|
||||||
if (allocator->stamp_counter >= MAX_STAMP_COUNTER)
|
if (allocator->stamp_counter >= MAX_STAMP_COUNTER)
|
||||||
{
|
{
|
||||||
GTimeVal tv;
|
gint64 now_us = g_get_real_time ();
|
||||||
g_get_current_time (&tv);
|
allocator->last_stamp = now_us / 1000; /* milli seconds */
|
||||||
allocator->last_stamp = tv.tv_sec * 1000 + tv.tv_usec / 1000; /* milli seconds */
|
|
||||||
allocator->stamp_counter = 0;
|
allocator->stamp_counter = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user