1 /* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * gthread.c: posix thread system implementation
5 * Copyright 1998 Sebastian Wilhelmi; University of Karlsruhe
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
24 * Modified by the GLib Team and others 1997-2000. See the AUTHORS
25 * file for a list of people on the GLib Team. See the ChangeLog
26 * files for a list of changes. These files are distributed with
27 * GLib at ftp://ftp.gtk.org/pub/gtk/.
30 /* The GMutex, GCond and GPrivate implementations in this file are some
31 * of the lowest-level code in GLib. All other parts of GLib (messages,
32 * memory, slices, etc) assume that they can freely use these facilities
33 * without risking recursion.
35 * As such, these functions are NOT permitted to call any other part of
38 * The thread manipulation functions (create, exit, join, etc.) have
39 * more freedom -- they can do as they please.
46 #include "gthreadprivate.h"
48 #include "gmessages.h"
49 #include "gstrfuncs.h"
57 #ifdef HAVE_SYS_TIME_H
58 # include <sys/time.h>
69 g_thread_abort (gint status,
70 const gchar *function)
72 fprintf (stderr, "GLib (gthread-posix.c): Unexpected error from C library during '%s': %s. Aborting.\n",
73 strerror (status), function);
82 * Initializer for statically allocated #GMutexes.
83 * Alternatively, g_mutex_init() can be used.
86 * GMutex mutex = G_MUTEX_INIT;
94 * @mutex: an uninitialized #GMutex
96 * Initializes a #GMutex so that it can be used.
98 * This function is useful to initialize a mutex that has been
99 * allocated on the stack, or as part of a larger structure.
100 * It is not necessary to initialize a mutex that has been
101 * created with g_mutex_new(). Also see #G_MUTEX_INIT for an
102 * alternative way to initialize statically allocated mutexes.
112 * b = g_new (Blob, 1);
113 * g_mutex_init (&b->m);
116 * To undo the effect of g_mutex_init() when a mutex is no longer
117 * needed, use g_mutex_clear().
119 * Calling g_mutex_init() on an already initialized #GMutex leads
120 * to undefined behaviour.
125 g_mutex_init (GMutex *mutex)
128 pthread_mutexattr_t *pattr = NULL;
129 #ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
130 pthread_mutexattr_t attr;
131 pthread_mutexattr_init (&attr);
132 pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_ADAPTIVE_NP);
136 if G_UNLIKELY ((status = pthread_mutex_init (&mutex->impl, pattr)) != 0)
137 g_thread_abort (status, "pthread_mutex_init");
139 #ifdef PTHREAD_ADAPTIVE_MUTEX_NP
140 pthread_mutexattr_destroy (&attr);
146 * @mutex: an initialized #GMutex
148 * Frees the resources allocated to a mutex with g_mutex_init().
150 * #GMutexes that have have been created with g_mutex_new() should
151 * be freed with g_mutex_free() instead.
153 * Calling g_mutex_clear() on a locked mutex leads to undefined
159 g_mutex_clear (GMutex *mutex)
163 if G_UNLIKELY ((status = pthread_mutex_destroy (&mutex->impl)) != 0)
164 g_thread_abort (status, "pthread_mutex_destroy");
171 * Locks @mutex. If @mutex is already locked by another thread, the
172 * current thread will block until @mutex is unlocked by the other
175 * This function can be used even if g_thread_init() has not yet been
176 * called, and, in that case, will do nothing.
178 * <note>#GMutex is neither guaranteed to be recursive nor to be
179 * non-recursive, i.e. a thread could deadlock while calling
180 * g_mutex_lock(), if it already has locked @mutex. Use
181 * #GRecMutex if you need recursive mutexes.</note>
184 g_mutex_lock (GMutex *mutex)
188 if G_UNLIKELY ((status = pthread_mutex_lock (&mutex->impl)) != 0)
189 g_thread_abort (status, "pthread_mutex_lock");
196 * Unlocks @mutex. If another thread is blocked in a g_mutex_lock()
197 * call for @mutex, it will become unblocked and can lock @mutex itself.
199 * Calling g_mutex_unlock() on a mutex that is not locked by the
200 * current thread leads to undefined behaviour.
202 * This function can be used even if g_thread_init() has not yet been
203 * called, and, in that case, will do nothing.
206 g_mutex_unlock (GMutex *mutex)
210 if G_UNLIKELY ((status = pthread_mutex_unlock (&mutex->impl)) != 0)
211 g_thread_abort (status, "pthread_mutex_lock");
218 * Tries to lock @mutex. If @mutex is already locked by another thread,
219 * it immediately returns %FALSE. Otherwise it locks @mutex and returns
222 * This function can be used even if g_thread_init() has not yet been
223 * called, and, in that case, will immediately return %TRUE.
225 * <note>#GMutex is neither guaranteed to be recursive nor to be
226 * non-recursive, i.e. the return value of g_mutex_trylock() could be
227 * both %FALSE or %TRUE, if the current thread already has locked
228 * @mutex. Use #GRecMutex if you need recursive mutexes.</note>
230 * Returns: %TRUE if @mutex could be locked
233 g_mutex_trylock (GMutex *mutex)
237 if G_LIKELY ((status = pthread_mutex_trylock (&mutex->impl)) == 0)
240 if G_UNLIKELY (status != EBUSY)
241 g_thread_abort (status, "pthread_mutex_trylock");
251 * The GRecMutex struct is an opaque data structure to represent a
252 * recursive mutex. It is similar to a #GMutex with the difference
253 * that it is possible to lock a GRecMutex multiple times in the same
254 * thread without deadlock. When doing so, care has to be taken to
255 * unlock the recursive mutex as often as it has been locked.
257 * A GRecMutex should only be accessed with the
258 * <function>g_rec_mutex_</function> functions. Before a GRecMutex
259 * can be used, it has to be initialized with #G_REC_MUTEX_INIT or
260 * g_rec_mutex_init().
265 static pthread_mutex_t *
266 g_rec_mutex_impl_new (void)
268 pthread_mutexattr_t attr;
269 pthread_mutex_t *mutex;
271 mutex = g_slice_new (pthread_mutex_t);
272 pthread_mutexattr_init (&attr);
273 pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
274 pthread_mutex_init (mutex, &attr);
275 pthread_mutexattr_destroy (&attr);
281 g_rec_mutex_impl_free (pthread_mutex_t *mutex)
283 pthread_mutex_destroy (mutex);
284 g_slice_free (pthread_mutex_t, mutex);
287 static pthread_mutex_t *
288 g_rec_mutex_get_impl (GRecMutex *mutex)
290 pthread_mutex_t *impl = mutex->impl;
292 if G_UNLIKELY (mutex->impl == NULL)
294 impl = g_rec_mutex_impl_new ();
295 if (!g_atomic_pointer_compare_and_exchange (&mutex->impl, NULL, impl))
296 g_rec_mutex_impl_free (impl);
306 * Initializer for statically allocated #GRecMutexes.
307 * Alternatively, g_rec_mutex_init() can be used.
310 * GRecMutex mutex = G_REC_MUTEX_INIT;
318 * @rec_mutex: an uninitialized #GRecMutex
320 * Initializes a #GRecMutex so that it can be used.
322 * This function is useful to initialize a recursive mutex
323 * that has been allocated on the stack, or as part of a larger
325 * It is not necessary to initialize a recursive mutex that has
326 * been created with g_rec_mutex_new(). Also see #G_REC_MUTEX_INIT
327 * for an alternative way to initialize statically allocated
338 * b = g_new (Blob, 1);
339 * g_rec_mutex_init (&b->m);
342 * Calling g_rec_mutex_init() on an already initialized #GRecMutex
343 * leads to undefined behaviour.
345 * To undo the effect of g_rec_mutex_init() when a recursive mutex
346 * is no longer needed, use g_rec_mutex_clear().
351 g_rec_mutex_init (GRecMutex *rec_mutex)
353 rec_mutex->impl = g_rec_mutex_impl_new ();
358 * @rec_mutex: an initialized #GRecMutex
360 * Frees the resources allocated to a recursive mutex with
361 * g_rec_mutex_init().
363 * #GRecMutexes that have have been created with g_rec_mutex_new()
364 * should be freed with g_rec_mutex_free() instead.
366 * Calling g_rec_mutex_clear() on a locked recursive mutex leads
367 * to undefined behaviour.
372 g_rec_mutex_clear (GRecMutex *rec_mutex)
375 g_rec_mutex_impl_free (rec_mutex->impl);
380 * @rec_mutex: a #GRecMutex
382 * Locks @rec_mutex. If @rec_mutex is already locked by another
383 * thread, the current thread will block until @rec_mutex is
384 * unlocked by the other thread. If @rec_mutex is already locked
385 * by the current thread, the 'lock count' of @rec_mutex is increased.
386 * The mutex will only become available again when it is unlocked
387 * as many times as it has been locked.
392 g_rec_mutex_lock (GRecMutex *mutex)
394 pthread_mutex_lock (g_rec_mutex_get_impl (mutex));
398 * g_rec_mutex_unlock:
399 * @rec_mutex: a #RecGMutex
401 * Unlocks @rec_mutex. If another thread is blocked in a
402 * g_rec_mutex_lock() call for @rec_mutex, it will become unblocked
403 * and can lock @rec_mutex itself.
405 * Calling g_rec_mutex_unlock() on a recursive mutex that is not
406 * locked by the current thread leads to undefined behaviour.
411 g_rec_mutex_unlock (GRecMutex *rec_mutex)
413 pthread_mutex_unlock (rec_mutex->impl);
417 * g_rec_mutex_trylock:
418 * @rec_mutex: a #GRecMutex
420 * Tries to lock @rec_mutex. If @rec_mutex is already locked
421 * by another thread, it immediately returns %FALSE. Otherwise
422 * it locks @rec_mutex and returns %TRUE.
424 * Returns: %TRUE if @rec_mutex could be locked
429 g_rec_mutex_trylock (GRecMutex *rec_mutex)
431 if (pthread_mutex_trylock (g_rec_mutex_get_impl (rec_mutex)) != 0)
442 * The GRWLock struct is an opaque data structure to represent a
443 * reader-writer lock. It is similar to a #GMutex in that it allows
444 * multiple threads to coordinate access to a shared resource.
446 * The difference to a mutex is that a reader-writer lock discriminates
447 * between read-only ('reader') and full ('writer') access. While only
448 * one thread at a time is allowed write access (by holding the 'writer'
449 * lock via g_rw_lock_writer_lock()), multiple threads can gain
450 * simultaneous read-only access (by holding the 'reader' lock via
451 * g_rw_lock_reader_lock()).
454 * <title>An array with access functions</title>
456 * GRWLock lock = G_RW_LOCK_INIT;
460 * my_array_get (guint index)
462 * gpointer retval = NULL;
467 * g_rw_lock_reader_lock (&lock);
468 * if (index < array->len)
469 * retval = g_ptr_array_index (array, index);
470 * g_rw_lock_reader_unlock (&lock);
476 * my_array_set (guint index, gpointer data)
478 * g_rw_lock_writer_lock (&lock);
481 * array = g_ptr_array_new (<!-- -->);
483 * if (index >= array->len)
484 * g_ptr_array_set_size (array, index+1);
485 * g_ptr_array_index (array, index) = data;
487 * g_rw_lock_writer_unlock (&lock);
491 * This example shows an array which can be accessed by many readers
492 * (the <function>my_array_get()</function> function) simultaneously,
493 * whereas the writers (the <function>my_array_set()</function>
494 * function) will only be allowed once at a time and only if no readers
495 * currently access the array. This is because of the potentially
496 * dangerous resizing of the array. Using these functions is fully
497 * multi-thread safe now.
501 * A GRWLock should only be accessed with the
502 * <function>g_rw_lock_</function> functions. Before it can be used,
503 * it has to be initialized with #G_RW_LOCK_INIT or g_rw_lock_init().
511 * Initializer for statically allocated #GRWLocks.
512 * Alternatively, g_rw_lock_init_init() can be used.
515 * GRWLock lock = G_RW_LOCK_INIT;
523 * @lock: an uninitialized #GRWLock
525 * Initializes a #GRWLock so that it can be used.
527 * This function is useful to initialize a lock that has been
528 * allocated on the stack, or as part of a larger structure.
529 * Also see #G_RW_LOCK_INIT for an alternative way to initialize
530 * statically allocated locks.
540 * b = g_new (Blob, 1);
541 * g_rw_lock_init (&b->l);
544 * To undo the effect of g_rw_lock_init() when a lock is no longer
545 * needed, use g_rw_lock_clear().
547 * Calling g_rw_lock_init() on an already initialized #GRWLock leads
548 * to undefined behaviour.
553 g_rw_lock_init (GRWLock *lock)
555 pthread_rwlock_init (&lock->impl, NULL);
560 * @lock: an initialized #GRWLock
562 * Frees the resources allocated to a lock with g_rw_lock_init().
564 * Calling g_rw_lock_clear() when any thread holds the lock
565 * leads to undefined behaviour.
570 g_rw_lock_clear (GRWLock *lock)
572 pthread_rwlock_destroy (&lock->impl);
576 * g_rw_lock_writer_lock:
579 * Obtain a write lock on @lock. If any thread already holds
580 * a read or write lock on @lock, the current thread will block
581 * until all other threads have dropped their locks on @lock.
586 g_rw_lock_writer_lock (GRWLock *lock)
588 pthread_rwlock_wrlock (&lock->impl);
592 * g_rw_lock_writer_trylock:
595 * Tries to obtain a write lock on @lock. If any other thread holds
596 * a read or write lock on @lock, it immediately returns %FALSE.
597 * Otherwise it locks @lock and returns %TRUE.
599 * Returns: %TRUE if @lock could be locked
604 g_rw_lock_writer_trylock (GRWLock *lock)
606 if (pthread_rwlock_trywrlock (&lock->impl) != 0)
613 * g_rw_lock_writer_unlock:
616 * Release a write lock on @lock.
618 * Calling g_rw_lock_writer_unlock() on a lock that is not held
619 * by the current thread leads to undefined behaviour.
624 g_rw_lock_writer_unlock (GRWLock *lock)
626 pthread_rwlock_unlock (&lock->impl);
630 * g_rw_lock_reader_lock:
633 * Obtain a read lock on @lock. If another thread currently holds
634 * the write lock on @lock or blocks waiting for it, the current
635 * thread will block. Read locks can be taken recursively.
637 * It is implementation-defined how many threads are allowed to
638 * hold read locks on the same lock simultaneously.
643 g_rw_lock_reader_lock (GRWLock *lock)
645 pthread_rwlock_rdlock (&lock->impl);
649 * g_rw_lock_reader_trylock:
652 * Tries to obtain a read lock on @lock and returns %TRUE if
653 * the read lock was successfully obtained. Otherwise it
656 * Returns: %TRUE if @lock could be locked
661 g_rw_lock_reader_trylock (GRWLock *lock)
663 if (pthread_rwlock_tryrdlock (&lock->impl) != 0)
670 * g_rw_lock_reader_unlock:
673 * Release a read lock on @lock.
675 * Calling g_rw_lock_reader_unlock() on a lock that is not held
676 * by the current thread leads to undefined behaviour.
681 g_rw_lock_reader_unlock (GRWLock *lock)
683 pthread_rwlock_unlock (&lock->impl);
691 * Initializer for statically allocated #GConds.
692 * Alternatively, g_cond_init() can be used.
695 * GCond cond = G_COND_INIT;
703 * @cond: an uninitialized #GCond
705 * Initialized a #GCond so that it can be used.
707 * This function is useful to initialize a #GCond that has been
708 * allocated on the stack, or as part of a larger structure.
709 * It is not necessary to initialize a #GCond that has been
710 * created with g_cond_new(). Also see #G_COND_INIT for an
711 * alternative way to initialize statically allocated #GConds.
713 * To undo the effect of g_cond_init() when a #GCond is no longer
714 * needed, use g_cond_clear().
716 * Calling g_cond_init() on an already initialized #GCond leads
717 * to undefined behaviour.
722 g_cond_init (GCond *cond)
726 if G_UNLIKELY ((status = pthread_cond_init (&cond->impl, NULL)) != 0)
727 g_thread_abort (status, "pthread_cond_init");
732 * @cond: an initialized #GCond
734 * Frees the resources allocated to a #GCond with g_cond_init().
736 * #GConds that have been created with g_cond_new() should
737 * be freed with g_cond_free() instead.
739 * Calling g_cond_clear() for a #GCond on which threads are
740 * blocking leads to undefined behaviour.
745 g_cond_clear (GCond *cond)
749 if G_UNLIKELY ((status = pthread_cond_destroy (&cond->impl)) != 0)
750 g_thread_abort (status, "pthread_cond_destroy");
756 * @mutex: a #GMutex that is currently locked
758 * Waits until this thread is woken up on @cond. The @mutex is unlocked
759 * before falling asleep and locked again before resuming.
761 * This function can be used even if g_thread_init() has not yet been
762 * called, and, in that case, will immediately return.
765 g_cond_wait (GCond *cond,
770 if G_UNLIKELY ((status = pthread_cond_wait (&cond->impl, &mutex->impl)) != 0)
771 g_thread_abort (status, "pthread_cond_wait");
778 * If threads are waiting for @cond, at least one of them is unblocked.
779 * If no threads are waiting for @cond, this function has no effect.
780 * It is good practice to hold the same lock as the waiting thread
781 * while calling this function, though not required.
783 * This function can be used even if g_thread_init() has not yet been
784 * called, and, in that case, will do nothing.
787 g_cond_signal (GCond *cond)
791 if G_UNLIKELY ((status = pthread_cond_signal (&cond->impl)) != 0)
792 g_thread_abort (status, "pthread_cond_signal");
799 * If threads are waiting for @cond, all of them are unblocked.
800 * If no threads are waiting for @cond, this function has no effect.
801 * It is good practice to lock the same mutex as the waiting threads
802 * while calling this function, though not required.
804 * This function can be used even if g_thread_init() has not yet been
805 * called, and, in that case, will do nothing.
808 g_cond_broadcast (GCond *cond)
812 if G_UNLIKELY ((status = pthread_cond_broadcast (&cond->impl)) != 0)
813 g_thread_abort (status, "pthread_cond_broadcast");
819 * @mutex: a #GMutex that is currently locked
820 * @abs_time: a #GTimeVal, determining the final time
822 * Waits until this thread is woken up on @cond, but not longer than
823 * until the time specified by @abs_time. The @mutex is unlocked before
824 * falling asleep and locked again before resuming.
826 * If @abs_time is %NULL, g_cond_timed_wait() acts like g_cond_wait().
828 * This function can be used even if g_thread_init() has not yet been
829 * called, and, in that case, will immediately return %TRUE.
831 * To easily calculate @abs_time a combination of g_get_current_time()
832 * and g_time_val_add() can be used.
834 * Returns: %TRUE if @cond was signalled, or %FALSE on timeout
837 g_cond_timed_wait (GCond *cond,
841 struct timespec end_time;
844 if (abs_time == NULL)
846 g_cond_wait (cond, mutex);
850 end_time.tv_sec = abs_time->tv_sec;
851 end_time.tv_nsec = abs_time->tv_usec * 1000;
853 if ((status = pthread_cond_timedwait (&cond->impl, &mutex->impl, &end_time)) == 0)
856 if G_UNLIKELY (status != ETIMEDOUT)
857 g_thread_abort (status, "pthread_cond_timedwait");
865 * @mutex: a #GMutex that is currently locked
866 * @abs_time: the final time, in microseconds
868 * A variant of g_cond_timed_wait() that takes @abs_time
869 * as a #gint64 instead of a #GTimeVal.
870 * See g_cond_timed_wait() for details.
872 * Returns: %TRUE if @cond was signalled, or %FALSE on timeout
877 g_cond_timedwait (GCond *cond,
881 struct timespec end_time;
884 end_time.tv_sec = abs_time / 1000000;
885 end_time.tv_nsec = (abs_time % 1000000) * 1000;
887 if ((status = pthread_cond_timedwait (&cond->impl, &mutex->impl, &end_time)) == 0)
890 if G_UNLIKELY (status != ETIMEDOUT)
891 g_thread_abort (status, "pthread_cond_timedwait");
899 g_private_init (GPrivate *key,
900 GDestroyNotify notify)
902 pthread_key_create (&key->key, notify);
908 * @private_key: a #GPrivate
910 * Returns the pointer keyed to @private_key for the current thread. If
911 * g_private_set() hasn't been called for the current @private_key and
912 * thread yet, this pointer will be %NULL.
914 * This function can be used even if g_thread_init() has not yet been
915 * called, and, in that case, will return the value of @private_key
916 * casted to #gpointer. Note however, that private data set
917 * <emphasis>before</emphasis> g_thread_init() will
918 * <emphasis>not</emphasis> be retained <emphasis>after</emphasis> the
919 * call. Instead, %NULL will be returned in all threads directly after
920 * g_thread_init(), regardless of any g_private_set() calls issued
921 * before threading system initialization.
923 * Returns: the corresponding pointer
926 g_private_get (GPrivate *key)
929 return key->single_value;
931 /* quote POSIX: No errors are returned from pthread_getspecific(). */
932 return pthread_getspecific (key->key);
937 * @private_key: a #GPrivate
938 * @data: the new pointer
940 * Sets the pointer keyed to @private_key for the current thread.
942 * This function can be used even if g_thread_init() has not yet been
943 * called, and, in that case, will set @private_key to @data casted to
944 * #GPrivate*. See g_private_get() for resulting caveats.
947 g_private_set (GPrivate *key,
954 key->single_value = value;
958 if G_UNLIKELY ((status = pthread_setspecific (key->key, value)) != 0)
959 g_thread_abort (status, "pthread_setspecific");
964 #define posix_check_err(err, name) G_STMT_START{ \
967 g_error ("file %s: line %d (%s): error '%s' during '%s'", \
968 __FILE__, __LINE__, G_STRFUNC, \
969 g_strerror (error), name); \
972 #define posix_check_cmd(cmd) posix_check_err (cmd, #cmd)
975 g_system_thread_create (GThreadFunc thread_func,
985 g_return_if_fail (thread_func);
987 posix_check_cmd (pthread_attr_init (&attr));
989 #ifdef HAVE_PTHREAD_ATTR_SETSTACKSIZE
992 #ifdef _SC_THREAD_STACK_MIN
993 stack_size = MAX (sysconf (_SC_THREAD_STACK_MIN), stack_size);
994 #endif /* _SC_THREAD_STACK_MIN */
995 /* No error check here, because some systems can't do it and
996 * we simply don't want threads to fail because of that. */
997 pthread_attr_setstacksize (&attr, stack_size);
999 #endif /* HAVE_PTHREAD_ATTR_SETSTACKSIZE */
1001 posix_check_cmd (pthread_attr_setdetachstate (&attr,
1002 joinable ? PTHREAD_CREATE_JOINABLE : PTHREAD_CREATE_DETACHED));
1004 ret = pthread_create (thread, &attr, (void* (*)(void*))thread_func, arg);
1006 posix_check_cmd (pthread_attr_destroy (&attr));
1010 g_set_error (error, G_THREAD_ERROR, G_THREAD_ERROR_AGAIN,
1011 "Error creating thread: %s", g_strerror (ret));
1015 posix_check_err (ret, "pthread_create");
1021 * Gives way to other threads waiting to be scheduled.
1023 * This function is often used as a method to make busy wait less evil.
1024 * But in most cases you will encounter, there are better methods to do
1025 * that. So in general you shouldn't use this function.
1028 g_thread_yield (void)
1034 g_system_thread_join (gpointer thread)
1037 posix_check_cmd (pthread_join (*(pthread_t*)thread, &ignore));
1041 g_system_thread_exit (void)
1043 pthread_exit (NULL);
1047 g_system_thread_self (gpointer thread)
1049 *(pthread_t*)thread = pthread_self();
1053 g_system_thread_equal (gpointer thread1,
1056 return (pthread_equal (*(pthread_t*)thread1, *(pthread_t*)thread2) != 0);
1060 /* vim:set foldmethod=marker: */