[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH]: glthread cond win32 compilation problem
From: |
Bruno Haible |
Subject: |
Re: [PATCH]: glthread cond win32 compilation problem |
Date: |
Fri, 12 Sep 2008 02:50:56 +0200 |
User-agent: |
KMail/1.5.4 |
Yoann Vandoorselaere wrote:
> Attached are a few patch that fixes ... glthread/cond modules
> compilation problem under MinGW.
I'm applying the first hunk:
2008-09-11 Yoann Vandoorselaere <address@hidden>
* lib/glthread/cond.h: Use dummy implementation also if
USE_WIN32_THREADS.
--- a/lib/glthread/cond.h
+++ b/lib/glthread/cond.h
@@ -269,7 +269,7 @@ typedef pthread_cond_t gl_cond_t;
/* ========================================================================= */
-#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS ||
USE_WIN32_THREADS)
+#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS)
/* Provide dummy implementation if threads are not supported. */
-----------------------------------------------------------------------------
About the second hunk, the problem is more general: not only on mingw,
but on all platforms which lack ETIMEDOUT, one needs a substitute. It
can be a random positive number. I propose this patch instead.
2008-09-11 Yoann Vandoorselaere <address@hidden>
Bruno Haible <address@hidden>
* lib/glthread/cond.h (ETIMEDOUT): Define to a fallback value if not
defined by <errno.h>.
*** lib/glthread/cond.h.orig 2008-09-12 02:38:56.000000000 +0200
--- lib/glthread/cond.h 2008-09-12 02:38:31.000000000 +0200
***************
*** 283,288 ****
--- 283,294 ----
# define glthread_cond_broadcast(COND) 0
# define glthread_cond_destroy(COND) 0
+ /* Possible return value of glthread_cond_timedwait.
+ Use a random value as fallback replacement. */
+ # ifndef ETIMEDOUT
+ # define ETIMEDOUT 1789
+ # endif
+
#endif
/* =========================================================================
*/
-----------------------------------------------------------------------------
Additionally, the use of "#define ETIMEDOUT ETIME" in the Solaris case is
incorrect: Solaris has ETIMEDOUT, and it's a no-no to redefine errno
values in header files that user code may include. I propose this instead:
2008-09-11 Bruno Haible <address@hidden>
* lib/glthread/cond.h [USE_SOLARIS_THREADS]
(ETIMEDOUT): Remove macro.
(glthread_cond_timedwait_multithreaded): New declaration.
(glthread_cond_timedwait): Use it.
* lib/glthread/cond.c [USE_SOLARIS_THREADS]
(glthread_cond_timedwait_multithreaded): New function.
*** lib/glthread/cond.h.orig 2008-09-12 02:49:46.000000000 +0200
--- lib/glthread/cond.h 2008-09-12 02:49:41.000000000 +0200
***************
*** 239,246 ****
/* -------------------------- gl_cond_t datatype -------------------------- */
- #define ETIMEDOUT ETIME
-
typedef pthread_cond_t gl_cond_t;
# define gl_cond_define(STORAGECLASS, NAME) \
STORAGECLASS cond_t NAME;
--- 239,244 ----
***************
*** 253,265 ****
# define glthread_cond_wait(COND, LOCK) \
(pthread_in_use () ? cond_wait (COND, LOCK) : 0)
# define glthread_cond_timedwait(COND, LOCK, ABSTIME) \
! (pthread_in_use () ? cond_timedwait (COND, LOCK, ABSTIME) : 0)
# define glthread_cond_signal(COND) \
(pthread_in_use () ? cond_signal (COND) : 0)
# define glthread_cond_broadcast(COND) \
(pthread_in_use () ? cond_broadcast (COND) : 0)
# define glthread_cond_destroy(COND) \
(pthread_in_use () ? cond_destroy (COND) : 0)
# ifdef __cplusplus
}
--- 251,264 ----
# define glthread_cond_wait(COND, LOCK) \
(pthread_in_use () ? cond_wait (COND, LOCK) : 0)
# define glthread_cond_timedwait(COND, LOCK, ABSTIME) \
! (pthread_in_use () ? glthread_cond_timedwait_multithreaded (COND, LOCK,
ABSTIME) : 0)
# define glthread_cond_signal(COND) \
(pthread_in_use () ? cond_signal (COND) : 0)
# define glthread_cond_broadcast(COND) \
(pthread_in_use () ? cond_broadcast (COND) : 0)
# define glthread_cond_destroy(COND) \
(pthread_in_use () ? cond_destroy (COND) : 0)
+ extern int glthread_cond_timedwait_multithreaded (gl_cond_t *cond, gl_lock_t
*lock, struct timespec *abstime);
# ifdef __cplusplus
}
*** lib/glthread/cond.c.orig 2008-09-12 02:49:46.000000000 +0200
--- lib/glthread/cond.c 2008-09-12 02:43:34.000000000 +0200
***************
*** 50,52 ****
--- 50,73 ----
#endif
/* =========================================================================
*/
+
+ #if USE_SOLARIS_THREADS
+
+ /* -------------------------- gl_cond_t datatype -------------------------- */
+
+ int
+ glthread_cond_timedwait_multithreaded (gl_cond_t *cond,
+ gl_lock_t *lock,
+ struct timespec *abstime)
+ {
+ int ret;
+
+ ret = cond_timedwait (cond, lock, abstime);
+ if (ret == ETIME)
+ return ETIMEDOUT;
+ return ret;
+ }
+
+ #endif
+
+ /* =========================================================================
*/