glib 2.59.0 WIP

onre

SYS 64738
Feb 8, 2019
123
72
28
Toijala, Finland
This particular version was chosen because it's the last one that can be built without meson and ninja.

I wanted to fix GCond and came up with this. The unit test passes and I think it should work in almost all cases - save for a case where user changes the system clock time while a wait_until is active. However, I can't think of any way of avoiding this with the functions available in IRIX as we can't wait on the monotonic clock time.

Code:
--- ../dist/glib-2.59.0/glib/gthread-posix.c    2018-12-23 09:10:41.000000000 +0000
+++ glib/gthread-posix.c        2019-07-23 10:50:39.642914228 +0000
@@ -656,12 +656,12 @@

   pthread_condattr_init (&attr);

-#ifdef HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP
+#if defined (HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP) || defined(__sgi)
#elif defined (HAVE_PTHREAD_CONDATTR_SETCLOCK) && defined (CLOCK_MONOTONIC)
   if G_UNLIKELY ((status = pthread_condattr_setclock (&attr, CLOCK_MONOTONIC)) != 0)
     g_thread_abort (status, "pthread_condattr_setclock");
#else
-#error Cannot support GCond on your platform.
+#error Cannot support GCond on your platform.
#endif

   cond = malloc (sizeof (pthread_cond_t));
@@ -874,7 +874,6 @@
{
   struct timespec ts;
   gint status;
-
#ifdef HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP
   /* end_time is given relative to the monotonic clock as returned by
    * g_get_monotonic_time().
@@ -896,6 +895,24 @@
     if ((status = pthread_cond_timedwait_relative_np (g_cond_get_impl (cond), g_mutex_get_impl (mutex), &ts)) == 0)
       return TRUE;
   }
+#elif defined (__sgi)
+  /* Required functionality missing, this is the closest we can get.
+   */
+  {
+    gint64 now = g_get_monotonic_time ();
+    gint64 absendtime;
+
+    if (end_time <= now)
+      return FALSE;
+
+    absendtime = g_get_real_time () + (end_time - now);
+
+    ts.tv_sec = absendtime / 1000000;
+    ts.tv_nsec = (absendtime % 1000000) * 1000;
+
+    if ((status = pthread_cond_timedwait (g_cond_get_impl (cond), g_mutex_get_impl (mutex), &ts)) == 0)
+      return TRUE;
+  }
#elif defined (HAVE_PTHREAD_CONDATTR_SETCLOCK) && defined (CLOCK_MONOTONIC)
   /* This is the exact check we used during init to set the clock to
    * monotonic, so if we're in this branch, timedwait() will already be
 
  • Like
Reactions: Elf

About us

  • Silicon Graphics User Group (SGUG) is a community for users, developers, and admirers of Silicon Graphics (SGI) products. We aim to be a friendly hobbyist community for discussing all aspects of SGIs, including use, software development, the IRIX Operating System, and troubleshooting, as well as facilitating hardware exchange.

User Menu