mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-01 05:13:06 +02:00
Convert deprecated GTimeVal to GDateTime in tests/gio-test.c
This commit is contained in:
parent
dbe8e52bde
commit
38e0781ba7
@ -24,9 +24,6 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
@ -246,7 +243,7 @@ spawn_process (int children_nb)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
GTimeVal start, end;
|
gint64 start, end;
|
||||||
GPollFD pollfd;
|
GPollFD pollfd;
|
||||||
int pollresult;
|
int pollresult;
|
||||||
ATOM klass;
|
ATOM klass;
|
||||||
@ -331,17 +328,14 @@ spawn_process (int children_nb)
|
|||||||
close (pipe_from_sub[1]);
|
close (pipe_from_sub[1]);
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#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);
|
g_io_channel_win32_make_pollfd (my_read_channel, G_IO_IN, &pollfd);
|
||||||
pollresult = g_io_channel_win32_poll (&pollfd, 1, 100);
|
pollresult = g_io_channel_win32_poll (&pollfd, 1, 100);
|
||||||
g_get_current_time (&end);
|
end = g_get_monotonic_time();
|
||||||
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
|
|
||||||
|
|
||||||
|
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);
|
g_io_channel_unref (my_read_channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,22 +350,21 @@ static void
|
|||||||
run_process (int argc, char *argv[])
|
run_process (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int readfd, writefd;
|
int readfd, writefd;
|
||||||
GTimeVal tv;
|
gint64 dt;
|
||||||
char buf[BUFSIZE];
|
char buf[BUFSIZE];
|
||||||
int buflen, i, j, n;
|
int buflen, i, j, n;
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_get_current_time (&tv);
|
|
||||||
|
|
||||||
/* Extract parameters */
|
/* Extract parameters */
|
||||||
sscanf (argv[2], "%d:%d%n", &readfd, &writefd, &n);
|
sscanf (argv[2], "%d:%d%n", &readfd, &writefd, &n);
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
sscanf (argv[2] + n, ":0x%p", &hwnd);
|
sscanf (argv[2] + n, ":0x%p", &hwnd);
|
||||||
#endif
|
#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++)
|
for (i = 0; i < 20 + rand () % 10; i++)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user