summaryrefslogtreecommitdiff
path: root/gthread
diff options
context:
space:
mode:
authorSebastian Wilhelmi <wilhelmi@ira.uka.de>1999-03-11 17:38:51 +0000
committerSebastian Wilhelmi <wilhelmi@src.gnome.org>1999-03-11 17:38:51 +0000
commit4c63008b6cd4e3a9a81ff96ab195d23fc84a4515 (patch)
treeeb254cd2add542f5b3dc0a0a9060f20abdb042ab /gthread
parentfd7ba69e32a926b0bb5b769a11893bbbd2440e89 (diff)
downloadglib-4c63008b6cd4e3a9a81ff96ab195d23fc84a4515.tar.gz
Revamped the thread configure stuff. Now dce threads (old posix draft) are
1999-03-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * configure.in: Revamped the thread configure stuff. Now dce threads (old posix draft) are recogniced. This is necessary, because dce threads are in fact working quite differently from posix threads. Also changed the conditions for checking for MT safe functions a bit, because G_THREADS_IMPL_NONE still have to compile thread safe. * gthread/gthread-posix.c: Now handle both dce and posix threads. They are sufficently equal. NOTE: Please do not commit my change to glib-1-2/{acconfig.h,configure.in,config.h.win32} from 1999-03-03, as the current change will take care of that too.
Diffstat (limited to 'gthread')
-rw-r--r--gthread/ChangeLog7
-rw-r--r--gthread/gthread-posix.c39
2 files changed, 37 insertions, 9 deletions
diff --git a/gthread/ChangeLog b/gthread/ChangeLog
index 953ed86c5..d733de78d 100644
--- a/gthread/ChangeLog
+++ b/gthread/ChangeLog
@@ -1,3 +1,10 @@
+1999-03-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
+
+ * gthread-posix.c: Now handle both dce and posix threads. They are
+ sufficently equal. Please do not commit my change to
+ glib-1-2/gthread/gthread-posix.c from 1999-03-03, as the current
+ change will take care of that too.
+
1999-02-15 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* testgthread.c (test_mutexes): Use new signature of
diff --git a/gthread/gthread-posix.c b/gthread/gthread-posix.c
index f45ae178c..a18a8b5e2 100644
--- a/gthread/gthread-posix.c
+++ b/gthread/gthread-posix.c
@@ -43,10 +43,18 @@
__FILE__, __LINE__, G_GNUC_PRETTY_FUNCTION, \
g_strerror((num)), #name )
-#define posix_check_for_error( what ) G_STMT_START{ \
- int error = (what); \
- if( error ) { posix_print_error( what, error ); } \
- }G_STMT_END
+#if defined(G_THREADS_IMPL_POSIX)
+# define posix_check_for_error( what ) G_STMT_START{ \
+ int error = (what); \
+ if( error ) { posix_print_error( what, error ); } \
+ }G_STMT_END
+#elif defined(G_THREADS_IMPL_DCE)
+# define posix_check_for_error( what ) G_STMT_START{ \
+ if( (what) == -1 ) { posix_print_error( what, errno ); } \
+ }G_STMT_END
+#else /* neither G_THREADS_IMPL_POSIX nor G_THREADS_IMPL_DCE are defined */
+# error This should not happen. Contact the GLb team.
+#endif
static GMutex *
g_mutex_new_posix_impl (void)
@@ -76,8 +84,14 @@ g_mutex_trylock_posix_impl (GMutex * mutex)
int result;
result = pthread_mutex_trylock ((pthread_mutex_t *) mutex);
- if (result != EBUSY)
+
+#ifdef G_THREADS_IMPL_POSIX
+ if (result == EBUSY)
return FALSE;
+#else /* G_THREADS_IMPL_DCE */
+ if (result == 0)
+ return FALSE;
+#endif
posix_check_for_error (result);
return TRUE;
@@ -123,7 +137,13 @@ g_cond_timed_wait_posix_impl (GCond * cond,
result = pthread_cond_timedwait ((pthread_cond_t *) cond,
(pthread_mutex_t *) entered_mutex,
&end_time);
+
+#ifdef G_THREADS_IMPL_POSIX
timed_out = (result == ETIMEDOUT);
+#else /* G_THREADS_IMPL_DCE */
+ timed_out = (result == -1) && (errno = EAGAIN);
+#endif
+
if (!timed_out)
posix_check_for_error (result);
return !timed_out;
@@ -162,15 +182,16 @@ g_private_get_posix_impl (GPrivate * private_key)
{
if (!private_key)
return NULL;
-#ifdef HAVE_PTHREAD_GETSPECIFIC_POSIX
+#ifdef G_THREADS_IMPL_POSIX
return pthread_getspecific (*(pthread_key_t *) private_key);
-#else /* HAVE_PTHREAD_GETSPECIFIC_POSIX */
+#else /* G_THREADS_IMPL_DCE */
{
void* data;
- pthread_getspecific (*(pthread_key_t *) private_key, &data);
+ posix_check_for_error (pthread_getspecific (*(pthread_key_t *)
+ private_key, &data);
return data;
}
-#endif /* HAVE_PTHREAD_GETSPECIFIC_POSIX */
+#endif
}
static GThreadFunctions g_thread_functions_for_glib_use_default =