pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: glib2 no longer works on NetBSD 5



On Sat, Sep 13, 2014 at 04:26:33PM +0000, John Klos wrote:
> Latest pkgsrc, netbsd-5 on multiple platforms:

Trying something like the attached patch.

Joerg
$NetBSD$

--- gthread-posix.c.orig        2014-09-13 16:36:49.000000000 +0000
+++ gthread-posix.c
@@ -644,6 +644,7 @@ g_cond_impl_new (void)
 #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");
+#elif defined (CLOCK_MONOTONIC)
 #else
 #error Cannot support GCond on your platform.
 #endif
@@ -892,6 +893,19 @@ g_cond_wait_until (GCond  *cond,
     if ((status = pthread_cond_timedwait (g_cond_get_impl (cond), 
g_mutex_get_impl (mutex), &ts)) == 0)
       return TRUE;
   }
+#elif defined (CLOCK_MONOTONIC)
+  {
+    struct timespec cur_time;
+    clock_gettime(CLOCK_MONOTONIC, &cur_time);
+    ts.tv_sec = end_time / 1000000 - cur_time.tv_sec;
+    ts.tv_nsec = (end_time % 1000000) * 1000 - cur_time.tv_nsec;
+    if (ts.tv_nsec < 0) {
+      ts.tv_nsec += 1000000000;
+      --ts.tv_sec;
+    }
+    if ((status = pthread_cond_timedwait (g_cond_get_impl (cond), 
g_mutex_get_impl (mutex), &ts)) == 0)
+      return TRUE;
+  }
 #else
 #error Cannot support GCond on your platform.
 #endif


Home | Main Index | Thread Index | Old Index