[glib: 2/5] Convert deprecated GTimeVal to GDateTime in tests/gio-test.c
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 2/5] Convert deprecated GTimeVal to GDateTime in tests/gio-test.c
- Date: Mon, 16 May 2022 12:34:34 +0000 (UTC)
commit 38e0781ba75972b38650176106b4a1624cee8321
Author: Emmanuel Fleury <emmanuel fleury gmail com>
Date: Wed Mar 9 18:27:02 2022 +0100
Convert deprecated GTimeVal to GDateTime in tests/gio-test.c
tests/gio-test.c | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
---
diff --git a/tests/gio-test.c b/tests/gio-test.c
index 3bab515eba..e26ebdb3d8 100644
--- a/tests/gio-test.c
+++ b/tests/gio-test.c
@@ -24,9 +24,6 @@
#include <glib.h>
#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
#ifdef G_OS_WIN32
#include <io.h>
@@ -246,7 +243,7 @@ spawn_process (int children_nb)
int i;
#ifdef G_OS_WIN32
- GTimeVal start, end;
+ gint64 start, end;
GPollFD pollfd;
int pollresult;
ATOM klass;
@@ -331,17 +328,14 @@ spawn_process (int children_nb)
close (pipe_from_sub[1]);
#ifdef G_OS_WIN32
- g_get_current_time (&start);
+ start = g_get_monotonic_time();
g_io_channel_win32_make_pollfd (my_read_channel, G_IO_IN, &pollfd);
pollresult = g_io_channel_win32_poll (&pollfd, 1, 100);
- g_get_current_time (&end);
- if (end.tv_usec < start.tv_usec)
- end.tv_sec--, end.tv_usec += 1000000;
- g_print ("gio-test: had to wait %ld.%03ld s, result:%d\n",
- end.tv_sec - start.tv_sec,
- (end.tv_usec - start.tv_usec) / 1000, pollresult);
-#endif
+ end = g_get_monotonic_time();
+ g_print ("gio-test: had to wait %" G_GINT64_FORMAT "s, result:%d\n",
+ (end - start) / 1000000, pollresult);
+#endif
g_io_channel_unref (my_read_channel);
}
@@ -356,22 +350,21 @@ static void
run_process (int argc, char *argv[])
{
int readfd, writefd;
- GTimeVal tv;
+ gint64 dt;
char buf[BUFSIZE];
int buflen, i, j, n;
#ifdef G_OS_WIN32
HWND hwnd;
#endif
- g_get_current_time (&tv);
-
/* Extract parameters */
sscanf (argv[2], "%d:%d%n", &readfd, &writefd, &n);
#ifdef G_OS_WIN32
sscanf (argv[2] + n, ":0x%p", &hwnd);
#endif
- srand (tv.tv_sec ^ (tv.tv_usec / 1000) ^ readfd ^ (writefd << 4));
+ dt = g_get_monotonic_time();
+ srand (dt ^ (dt / 1000) ^ readfd ^ (writefd << 4));
for (i = 0; i < 20 + rand () % 10; i++)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]