# endif
#endif
+#ifdef __has_attribute
+# if __has_attribute(__always_inline__)
+# define __GTHREAD_ALWAYS_INLINE __attribute__((__always_inline__))
+# endif
+#endif
+#ifndef __GTHREAD_ALWAYS_INLINE
+# define __GTHREAD_ALWAYS_INLINE
+#endif
+
+#ifdef __cplusplus
+# define __GTHREAD_INLINE inline __GTHREAD_ALWAYS_INLINE
+#else
+# define __GTHREAD_INLINE static inline
+#endif
+
typedef pthread_t __gthread_t;
typedef pthread_key_t __gthread_key_t;
typedef pthread_once_t __gthread_once_t;
#if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__))
-static volatile int __gthread_active = -1;
+#pragma GCC visibility push(hidden)
+__GTHREAD_INLINE volatile int *
+__gthread_active (void)
+{
+ static volatile int __gthread_active_var = -1;
+ return &__gthread_active_var;
+}
+#pragma GCC visibility pop
-static void
+__GTHREAD_INLINE void
__gthread_trigger (void)
{
- __gthread_active = 1;
+ *__gthread_active () = 1;
}
-static inline int
+#pragma GCC visibility push(hidden)
+__GTHREAD_INLINE int
__gthread_active_p (void)
{
static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT;
/* Avoid reading __gthread_active twice on the main code path. */
- int __gthread_active_latest_value = __gthread_active;
+ int __gthread_active_latest_value = *__gthread_active ();
/* This test is not protected to avoid taking a lock on the main code
path so every update of __gthread_active in a threaded program must
}
/* Make sure we'll never enter this block again. */
- if (__gthread_active < 0)
- __gthread_active = 0;
+ if (*__gthread_active () < 0)
+ *__gthread_active () = 0;
- __gthread_active_latest_value = __gthread_active;
+ __gthread_active_latest_value = *__gthread_active ();
}
return __gthread_active_latest_value != 0;
}
+#pragma GCC visibility pop
#else /* neither FreeBSD nor Solaris */
# define GTHR_ACTIVE_PROXY __gthrw_(pthread_cancel)
#endif
-static inline int
+#pragma GCC visibility push(hidden)
+__GTHREAD_INLINE int
__gthread_active_p (void)
{
static void *const __gthread_active_ptr
= __extension__ (void *) >HR_ACTIVE_PROXY;
return __gthread_active_ptr != 0;
}
+#pragma GCC visibility pop
#endif /* FreeBSD or Solaris */
#if defined(__hppa__) && defined(__hpux__)
-static volatile int __gthread_active = -1;
+#pragma GCC visibility push(hidden)
+__GTHREAD_INLINE volatile int *
+__gthread_active (void)
+{
+ static volatile int __gthread_active_var = -1;
+ return &__gthread_active_var;
+}
+#pragma GCC visibility pop
-static inline int
+__GTHREAD_INLINE int
__gthread_active_p (void)
{
/* Avoid reading __gthread_active twice on the main code path. */
- int __gthread_active_latest_value = __gthread_active;
+ int __gthread_active_latest_value = *__gthread_active ();
size_t __s;
if (__builtin_expect (__gthread_active_latest_value < 0, 0))
{
pthread_default_stacksize_np (0, &__s);
- __gthread_active = __s ? 1 : 0;
- __gthread_active_latest_value = __gthread_active;
+ *__gthread_active () = __s ? 1 : 0;
+ __gthread_active_latest_value = *__gthread_active ();
}
return __gthread_active_latest_value != 0;
#else /* not hppa-hpux */
-static inline int
+__GTHREAD_INLINE int
__gthread_active_p (void)
{
return 1;
#else /* _LIBOBJC */
-static inline int
+__GTHREAD_INLINE int
__gthread_create (__gthread_t *__threadid, void *(*__func) (void*),
void *__args)
{
return __gthrw_(pthread_create) (__threadid, NULL, __func, __args);
}
-static inline int
+__GTHREAD_INLINE int
__gthread_join (__gthread_t __threadid, void **__value_ptr)
{
return __gthrw_(pthread_join) (__threadid, __value_ptr);
}
-static inline int
+__GTHREAD_INLINE int
__gthread_detach (__gthread_t __threadid)
{
return __gthrw_(pthread_detach) (__threadid);
}
-static inline int
+__GTHREAD_INLINE int
__gthread_equal (__gthread_t __t1, __gthread_t __t2)
{
return __gthrw_(pthread_equal) (__t1, __t2);
}
-static inline __gthread_t
+__GTHREAD_INLINE __gthread_t
__gthread_self (void)
{
return __gthrw_(pthread_self) ();
}
-static inline int
+__GTHREAD_INLINE int
__gthread_yield (void)
{
return __gthrw_(sched_yield) ();
}
-static inline int
+__GTHREAD_INLINE int
__gthread_once (__gthread_once_t *__once, void (*__func) (void))
{
if (__gthread_active_p ())
return -1;
}
-static inline int
+__GTHREAD_INLINE int
__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *))
{
return __gthrw_(pthread_key_create) (__key, __dtor);
}
-static inline int
+__GTHREAD_INLINE int
__gthread_key_delete (__gthread_key_t __key)
{
return __gthrw_(pthread_key_delete) (__key);
}
-static inline void *
+__GTHREAD_INLINE void *
__gthread_getspecific (__gthread_key_t __key)
{
return __gthrw_(pthread_getspecific) (__key);
}
-static inline int
+__GTHREAD_INLINE int
__gthread_setspecific (__gthread_key_t __key, const void *__ptr)
{
return __gthrw_(pthread_setspecific) (__key, __ptr);
}
-static inline void
+__GTHREAD_INLINE void
__gthread_mutex_init_function (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())
__gthrw_(pthread_mutex_init) (__mutex, NULL);
}
-static inline int
+__GTHREAD_INLINE int
__gthread_mutex_destroy (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())
return 0;
}
-static inline int
+__GTHREAD_INLINE int
__gthread_mutex_lock (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())
return 0;
}
-static inline int
+__GTHREAD_INLINE int
__gthread_mutex_trylock (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())
}
#if _GTHREAD_USE_MUTEX_TIMEDLOCK
-static inline int
+__GTHREAD_INLINE int
__gthread_mutex_timedlock (__gthread_mutex_t *__mutex,
const __gthread_time_t *__abs_timeout)
{
}
#endif
-static inline int
+__GTHREAD_INLINE int
__gthread_mutex_unlock (__gthread_mutex_t *__mutex)
{
if (__gthread_active_p ())
#if !defined( PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) \
|| defined(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC)
-static inline int
+__GTHREAD_INLINE int
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex)
{
if (__gthread_active_p ())
}
#endif
-static inline int
+__GTHREAD_INLINE int
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_lock (__mutex);
}
-static inline int
+__GTHREAD_INLINE int
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_trylock (__mutex);
}
#if _GTHREAD_USE_MUTEX_TIMEDLOCK
-static inline int
+__GTHREAD_INLINE int
__gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex,
const __gthread_time_t *__abs_timeout)
{
}
#endif
-static inline int
+__GTHREAD_INLINE int
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_unlock (__mutex);
}
-static inline int
+__GTHREAD_INLINE int
__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_destroy (__mutex);
}
#ifdef _GTHREAD_USE_COND_INIT_FUNC
-static inline void
+__GTHREAD_INLINE void
__gthread_cond_init_function (__gthread_cond_t *__cond)
{
if (__gthread_active_p ())
}
#endif
-static inline int
+__GTHREAD_INLINE int
__gthread_cond_broadcast (__gthread_cond_t *__cond)
{
return __gthrw_(pthread_cond_broadcast) (__cond);
}
-static inline int
+__GTHREAD_INLINE int
__gthread_cond_signal (__gthread_cond_t *__cond)
{
return __gthrw_(pthread_cond_signal) (__cond);
}
-static inline int
+__GTHREAD_INLINE int
__gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex)
{
return __gthrw_(pthread_cond_wait) (__cond, __mutex);
}
-static inline int
+__GTHREAD_INLINE int
__gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex,
const __gthread_time_t *__abs_timeout)
{
return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout);
}
-static inline int
+__GTHREAD_INLINE int
__gthread_cond_wait_recursive (__gthread_cond_t *__cond,
__gthread_recursive_mutex_t *__mutex)
{
return __gthread_cond_wait (__cond, __mutex);
}
-static inline int
+__GTHREAD_INLINE int
__gthread_cond_destroy (__gthread_cond_t* __cond)
{
return __gthrw_(pthread_cond_destroy) (__cond);
}
#ifndef __cplusplus
-static inline int
+__GTHREAD_INLINE int
__gthread_rwlock_rdlock (__gthread_rwlock_t *__rwlock)
{
if (__gthread_active_p ())
return 0;
}
-static inline int
+__GTHREAD_INLINE int
__gthread_rwlock_tryrdlock (__gthread_rwlock_t *__rwlock)
{
if (__gthread_active_p ())
return 0;
}
-static inline int
+__GTHREAD_INLINE int
__gthread_rwlock_wrlock (__gthread_rwlock_t *__rwlock)
{
if (__gthread_active_p ())
return 0;
}
-static inline int
+__GTHREAD_INLINE int
__gthread_rwlock_trywrlock (__gthread_rwlock_t *__rwlock)
{
if (__gthread_active_p ())
return 0;
}
-static inline int
+__GTHREAD_INLINE int
__gthread_rwlock_unlock (__gthread_rwlock_t *__rwlock)
{
if (__gthread_active_p ())
#endif /* _LIBOBJC */
+#undef __GTHREAD_INLINE
+#undef __GTHREAD_ALWAYS_INLINE
+
#endif /* ! GCC_GTHR_POSIX_H */
#define __GTHREAD_MUTEX_INIT_FUNCTION(mx) do {} while (0)
#define __GTHREAD_RECURSIVE_MUTEX_INIT 0
+#ifdef __has_attribute
+# if __has_attribute(__always_inline__)
+# define __GTHREAD_ALWAYS_INLINE __attribute__((__always_inline__))
+# endif
+#endif
+#ifndef __GTHREAD_ALWAYS_INLINE
+# define __GTHREAD_ALWAYS_INLINE
+#endif
+
+#ifdef __cplusplus
+# define __GTHREAD_INLINE inline __GTHREAD_ALWAYS_INLINE
+#else
+# define __GTHREAD_INLINE static inline
+#endif
+
#define UNUSED __attribute__((__unused__))
#ifdef _LIBOBJC
#else /* _LIBOBJC */
-static inline int
+__GTHREAD_INLINE int
__gthread_active_p (void)
{
return 0;
}
-static inline int
+__GTHREAD_INLINE int
__gthread_once (__gthread_once_t *__once UNUSED, void (*__func) (void) UNUSED)
{
return 0;
}
-static inline int UNUSED
+__GTHREAD_INLINE int UNUSED
__gthread_key_create (__gthread_key_t *__key UNUSED, void (*__func) (void *) UNUSED)
{
return 0;
}
-static int UNUSED
+__GTHREAD_INLINE int UNUSED
__gthread_key_delete (__gthread_key_t __key UNUSED)
{
return 0;
}
-static inline void *
+__GTHREAD_INLINE void *
__gthread_getspecific (__gthread_key_t __key UNUSED)
{
return 0;
}
-static inline int
+__GTHREAD_INLINE int
__gthread_setspecific (__gthread_key_t __key UNUSED, const void *__v UNUSED)
{
return 0;
}
-static inline int
+__GTHREAD_INLINE int
__gthread_mutex_destroy (__gthread_mutex_t *__mutex UNUSED)
{
return 0;
}
-static inline int
+__GTHREAD_INLINE int
__gthread_mutex_lock (__gthread_mutex_t *__mutex UNUSED)
{
return 0;
}
-static inline int
+__GTHREAD_INLINE int
__gthread_mutex_trylock (__gthread_mutex_t *__mutex UNUSED)
{
return 0;
}
-static inline int
+__GTHREAD_INLINE int
__gthread_mutex_unlock (__gthread_mutex_t *__mutex UNUSED)
{
return 0;
}
-static inline int
+__GTHREAD_INLINE int
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_lock (__mutex);
}
-static inline int
+__GTHREAD_INLINE int
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_trylock (__mutex);
}
-static inline int
+__GTHREAD_INLINE int
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_unlock (__mutex);
}
-static inline int
+__GTHREAD_INLINE int
__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_destroy (__mutex);
#endif /* _LIBOBJC */
#undef UNUSED
+#undef __GTHREAD_INLINE
+#undef __GTHREAD_ALWAYS_INLINE
#endif /* ! GCC_GTHR_SINGLE_H */
#ifdef __gthrw
#define _GLIBCXX_GTHRW(name) \
__gthrw(pthread_ ## name); \
- static inline int \
+ inline int \
__glibcxx_ ## name (pthread_rwlock_t *__rwlock) \
{ \
if (__gthread_active_p ()) \
# ifndef PTHREAD_RWLOCK_INITIALIZER
_GLIBCXX_GTHRW(rwlock_destroy)
__gthrw(pthread_rwlock_init);
- static inline int
+ inline int
__glibcxx_rwlock_init (pthread_rwlock_t *__rwlock)
{
if (__gthread_active_p ())
# endif
# if _GTHREAD_USE_MUTEX_TIMEDLOCK
__gthrw(pthread_rwlock_timedrdlock);
- static inline int
+ inline int
__glibcxx_rwlock_timedrdlock (pthread_rwlock_t *__rwlock,
const timespec *__ts)
{
return 0;
}
__gthrw(pthread_rwlock_timedwrlock);
- static inline int
+ inline int
__glibcxx_rwlock_timedwrlock (pthread_rwlock_t *__rwlock,
const timespec *__ts)
{
}
# endif
#else
- static inline int
+ inline int
__glibcxx_rwlock_rdlock (pthread_rwlock_t *__rwlock)
{ return pthread_rwlock_rdlock (__rwlock); }
- static inline int
+ inline int
__glibcxx_rwlock_tryrdlock (pthread_rwlock_t *__rwlock)
{ return pthread_rwlock_tryrdlock (__rwlock); }
- static inline int
+ inline int
__glibcxx_rwlock_wrlock (pthread_rwlock_t *__rwlock)
{ return pthread_rwlock_wrlock (__rwlock); }
- static inline int
+ inline int
__glibcxx_rwlock_trywrlock (pthread_rwlock_t *__rwlock)
{ return pthread_rwlock_trywrlock (__rwlock); }
- static inline int
+ inline int
__glibcxx_rwlock_unlock (pthread_rwlock_t *__rwlock)
{ return pthread_rwlock_unlock (__rwlock); }
- static inline int
+ inline int
__glibcxx_rwlock_destroy(pthread_rwlock_t *__rwlock)
{ return pthread_rwlock_destroy (__rwlock); }
- static inline int
+ inline int
__glibcxx_rwlock_init(pthread_rwlock_t *__rwlock)
{ return pthread_rwlock_init (__rwlock, NULL); }
# if _GTHREAD_USE_MUTEX_TIMEDLOCK
- static inline int
+ inline int
__glibcxx_rwlock_timedrdlock (pthread_rwlock_t *__rwlock,
const timespec *__ts)
{ return pthread_rwlock_timedrdlock (__rwlock, __ts); }
- static inline int
+ inline int
__glibcxx_rwlock_timedwrlock (pthread_rwlock_t *__rwlock,
const timespec *__ts)
{ return pthread_rwlock_timedwrlock (__rwlock, __ts); }