LRN 2014-03-21 16:29:

This function should be trivial to implement, AFAIU, and it'll be
needed for newer versions of glib (when compiling with POSIX threads).

Hi,

Please see in attachment, need a review.


--
Regards, niXman
___________________________________________________
Dual-target(32 & 64-bit) MinGW-W64 compilers for 32 and 64-bit Windows:
http://sourceforge.net/projects/mingw-w64/
___________________________________________________
Another online IDE: http://liveworkspace.org/
Index: mingw-w64-libraries/winpthreads/include/pthread.h
===================================================================
--- mingw-w64-libraries/winpthreads/include/pthread.h	(revision 6530)
+++ mingw-w64-libraries/winpthreads/include/pthread.h	(working copy)
@@ -331,6 +331,7 @@
 int WINPTHREAD_API pthread_cond_broadcast (pthread_cond_t *cv);
 int WINPTHREAD_API pthread_cond_wait (pthread_cond_t *cv, pthread_mutex_t *external_mutex);
 int WINPTHREAD_API pthread_cond_timedwait(pthread_cond_t *cv, pthread_mutex_t *external_mutex, const struct timespec *t);
+int WINPTHREAD_API pthread_cond_timedwait_relative(pthread_cond_t *cv, pthread_mutex_t *external_mutex, const struct timespec *t);
 
 int WINPTHREAD_API pthread_mutex_lock(pthread_mutex_t *m);
 int WINPTHREAD_API pthread_mutex_timedlock(pthread_mutex_t *m, const struct timespec *ts);
Index: mingw-w64-libraries/winpthreads/src/cond.c
===================================================================
--- mingw-w64-libraries/winpthreads/src/cond.c	(revision 6530)
+++ mingw-w64-libraries/winpthreads/src/cond.c	(working copy)
@@ -456,7 +456,7 @@
 }
 
 int
-pthread_cond_timedwait (pthread_cond_t *c, pthread_mutex_t *external_mutex, const struct timespec *t)
+pthread_cond_timedwait_impl (pthread_cond_t *c, pthread_mutex_t *external_mutex, const struct timespec *t, int rel)
 {
   sCondWaitHelper ch;
   DWORD dwr;
@@ -477,7 +477,15 @@
   } else if ((_c)->valid != (unsigned int)LIFE_COND)
     return EINVAL;
 
-  dwr = dwMilliSecs(_pthread_rel_time_in_ms(t));
+  if (rel == 0)
+  {
+    dwr = dwMilliSecs(_pthread_rel_time_in_ms(t));
+  }
+  else
+  {
+    dwr = dwMilliSecs(_pthread_time_in_ms_from_timespec(t));
+  }
+
   r = do_sema_b_wait (_c->sema_b, 0, INFINITE,&_c->waiters_b_lock_,&_c->value_b);
   if (r != 0)
     return r;
@@ -489,7 +497,7 @@
   ch.c = _c;
   ch.r = &r;
   ch.external_mutex = external_mutex;
-  { 
+  {
     pthread_cleanup_push(cleanup_wait, (void *) &ch);
 
     r = pthread_mutex_unlock(external_mutex);
@@ -501,6 +509,18 @@
   return r;
 }
 
+int
+pthread_cond_timedwait(pthread_cond_t *c, pthread_mutex_t *m, const struct timespec *t)
+{
+  return pthread_cond_timedwait_impl(c, m, t, 0);
+}
+
+int
+pthread_cond_timedwait_relative(pthread_cond_t *c, pthread_mutex_t *m, const struct timespec *t)
+{
+  return pthread_cond_timedwait_impl(c, m, t, 1);
+}
+
 static void
 cleanup_wait (void *arg)
 {
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to