/* Threads compatibility routines for libgcc2 and libobjc. */
/* Compile this one with gcc. */
/* Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
- 2008, 2009, 2010 Free Software Foundation, Inc.
+ 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
This file is part of GCC.
#endif
#include <pthread.h>
-#include <unistd.h>
+
+#if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \
+ || !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK))
+# include <unistd.h>
+# if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0
+# define _GTHREAD_USE_MUTEX_TIMEDLOCK 1
+# else
+# define _GTHREAD_USE_MUTEX_TIMEDLOCK 0
+# endif
+#endif
typedef pthread_t __gthread_t;
typedef pthread_key_t __gthread_key_t;
__gthrw3(pthread_mutex_lock)
__gthrw3(pthread_mutex_trylock)
-#ifdef _POSIX_TIMEOUTS
-#if _POSIX_TIMEOUTS >= 0
+#if _GTHREAD_USE_MUTEX_TIMEDLOCK
__gthrw3(pthread_mutex_timedlock)
#endif
-#endif /* _POSIX_TIMEOUTS */
__gthrw3(pthread_mutex_unlock)
__gthrw3(pthread_mutex_init)
__gthrw3(pthread_mutex_destroy)
__gthrw(pthread_mutex_lock)
__gthrw(pthread_mutex_trylock)
-#ifdef _POSIX_TIMEOUTS
-#if _POSIX_TIMEOUTS >= 0
+#if _GTHREAD_USE_MUTEX_TIMEDLOCK
__gthrw(pthread_mutex_timedlock)
#endif
-#endif /* _POSIX_TIMEOUTS */
__gthrw(pthread_mutex_unlock)
__gthrw(pthread_mutex_init)
__gthrw(pthread_mutex_destroy)
static inline int
__gthread_active_p (void)
{
- static void *const __gthread_active_ptr
- = __extension__ (void *) &__gthrw_(
/* Android's C library does not provide pthread_cancel, check for
`pthread_create' instead. */
#ifndef __BIONIC__
- pthread_cancel
+ static void *const __gthread_active_ptr
+ = __extension__ (void *) &__gthrw_(pthread_cancel);
#else
- pthread_create
+ static void *const __gthread_active_ptr
+ = __extension__ (void *) &__gthrw_(pthread_create);
#endif
- );
return __gthread_active_ptr != 0;
}
return 0;
}
-#ifdef _POSIX_TIMEOUTS
-#if _POSIX_TIMEOUTS >= 0
+#if _GTHREAD_USE_MUTEX_TIMEDLOCK
static inline int
__gthread_mutex_timedlock (__gthread_mutex_t *__mutex,
const __gthread_time_t *__abs_timeout)
return 0;
}
#endif
-#endif
static inline int
__gthread_mutex_unlock (__gthread_mutex_t *__mutex)
return __gthread_mutex_trylock (__mutex);
}
-#ifdef _POSIX_TIMEOUTS
-#if _POSIX_TIMEOUTS >= 0
+#if _GTHREAD_USE_MUTEX_TIMEDLOCK
static inline int
__gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex,
const __gthread_time_t *__abs_timeout)
return __gthread_mutex_timedlock (__mutex, __abs_timeout);
}
#endif
-#endif
static inline int
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)