unicode: Update test data files for unicode 7.0.0
[platform/upstream/glib.git] / tests / timeloop.c
index d81922a..a1f69ef 100644 (file)
@@ -1,3 +1,6 @@
+#undef G_DISABLE_ASSERT
+#undef G_LOG_DOMAIN
+
 #include <errno.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -12,7 +15,7 @@ static int n_active_children;
 static int n_iters = 10000;
 static GMainLoop *loop;
 
-void
+static void
 io_pipe (GIOChannel **channels)
 {
   int fds[2];
@@ -27,11 +30,11 @@ io_pipe (GIOChannel **channels)
   channels[1] = g_io_channel_unix_new (fds[1]);
 }
 
-gboolean
+static gboolean
 read_all (GIOChannel *channel, char *buf, int len)
 {
-  int bytes_read = 0;
-  int count;
+  gsize bytes_read = 0;
+  gsize count;
   GIOError err;
 
   while (bytes_read < len)
@@ -51,11 +54,11 @@ read_all (GIOChannel *channel, char *buf, int len)
   return TRUE;
 }
 
-gboolean
+static gboolean
 write_all (GIOChannel *channel, char *buf, int len)
 {
-  int bytes_written = 0;
-  int count;
+  gsize bytes_written = 0;
+  gsize count;
   GIOError err;
 
   while (bytes_written < len)
@@ -70,7 +73,7 @@ write_all (GIOChannel *channel, char *buf, int len)
   return TRUE;
 }
 
-void
+static void
 run_child (GIOChannel *in_channel, GIOChannel *out_channel)
 {
   int i;
@@ -94,7 +97,7 @@ run_child (GIOChannel *in_channel, GIOChannel *out_channel)
   exit (0);
 }
 
-gboolean
+static gboolean
 input_callback (GIOChannel   *source,
                GIOCondition  condition,
                gpointer      data)
@@ -124,14 +127,14 @@ input_callback (GIOChannel   *source,
 
       n_active_children--;
       if (n_active_children == 0)
-       g_main_quit (loop);
+       g_main_loop_quit (loop);
       
       return FALSE;
     }
 }
 
-void
-create_child ()
+static void
+create_child (void)
 {
   int pid;
   GIOChannel *in_channels[2];
@@ -145,7 +148,9 @@ create_child ()
   if (pid > 0)                 /* Parent */
     {
       g_io_channel_close (in_channels[0]);
+      g_io_channel_unref (in_channels[0]);
       g_io_channel_close (out_channels[1]);
+      g_io_channel_unref (out_channels[1]);
 
       g_io_add_watch (out_channels[0], G_IO_IN | G_IO_HUP,
                      input_callback, in_channels[1]);
@@ -193,8 +198,8 @@ main (int argc, char **argv)
     create_child ();
 
   getrusage (RUSAGE_SELF, &old_usage);
-  loop = g_main_new (FALSE);
-  g_main_run (loop);
+  loop = g_main_loop_new (NULL, FALSE);
+  g_main_loop_run (loop);
   getrusage (RUSAGE_SELF, &new_usage);
 
   printf ("Elapsed user: %g\n",
@@ -209,5 +214,6 @@ main (int argc, char **argv)
           difftimeval (&old_usage.ru_stime, &new_usage.ru_stime)) /
          (n_iters * n_children));
 
+  g_main_loop_unref (loop);
   return 0;
 }