-/* Copyright (C) 2002-2014 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
| PTHREAD_MUTEXATTR_PROTOCOL_MASK | PTHREAD_MUTEXATTR_PRIO_CEILING_MASK)
-/* Check whether rwlock prefers readers. */
-#define PTHREAD_RWLOCK_PREFER_READER_P(rwlock) \
- ((rwlock)->__data.__flags == 0)
+/* For the following, see pthread_rwlock_common.c. */
+#define PTHREAD_RWLOCK_WRPHASE 1
+#define PTHREAD_RWLOCK_WRLOCKED 2
+#define PTHREAD_RWLOCK_RWAITING 4
+#define PTHREAD_RWLOCK_READER_SHIFT 3
+#define PTHREAD_RWLOCK_READER_OVERFLOW ((unsigned int) 1 \
+ << (sizeof (unsigned int) * 8 - 1))
+#define PTHREAD_RWLOCK_WRHANDOVER ((unsigned int) 1 \
+ << (sizeof (unsigned int) * 8 - 1))
+#define PTHREAD_RWLOCK_FUTEX_USED 2
/* Bits used in robust mutex implementation. */
#define __PTHREAD_ONCE_FORK_GEN_INCR 4
+/* Condition variable definitions. See __pthread_cond_wait_common.
+ Need to be defined here so there is one place from which
+ nptl_lock_constants can grab them. */
+#define __PTHREAD_COND_CLOCK_MONOTONIC_MASK 2
+#define __PTHREAD_COND_SHARED_MASK 1
+
+
/* Internal variables. */
extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex);
extern int __pthread_mutex_trylock (pthread_mutex_t *_mutex);
extern int __pthread_mutex_lock (pthread_mutex_t *__mutex);
+extern int __pthread_mutex_timedlock (pthread_mutex_t *__mutex,
+ const struct timespec *__abstime);
extern int __pthread_mutex_cond_lock (pthread_mutex_t *__mutex)
attribute_hidden internal_function;
extern void __pthread_mutex_cond_lock_adjust (pthread_mutex_t *__mutex)
extern int __pthread_condattr_destroy (pthread_condattr_t *attr);
extern int __pthread_condattr_init (pthread_condattr_t *attr);
extern int __pthread_key_create (pthread_key_t *key, void (*destr) (void *));
+extern int __pthread_key_delete (pthread_key_t key);
extern void *__pthread_getspecific (pthread_key_t key);
extern int __pthread_setspecific (pthread_key_t key, const void *value);
extern int __pthread_once (pthread_once_t *once_control,
void (*child) (void));
extern pthread_t __pthread_self (void);
extern int __pthread_equal (pthread_t thread1, pthread_t thread2);
+extern int __pthread_detach (pthread_t th);
+extern int __pthread_cancel (pthread_t th);
extern int __pthread_kill (pthread_t threadid, int signo);
extern void __pthread_exit (void *value) __attribute__ ((__noreturn__));
+extern int __pthread_join (pthread_t threadid, void **thread_return);
extern int __pthread_setcanceltype (int type, int *oldtype);
extern int __pthread_enable_asynccancel (void) attribute_hidden;
extern void __pthread_disable_asynccancel (int oldtype)
internal_function attribute_hidden;
+extern void __pthread_testcancel (void);
#if IS_IN (libpthread)
hidden_proto (__pthread_mutex_init)
hidden_proto (__pthread_mutex_destroy)
hidden_proto (__pthread_mutex_lock)
+hidden_proto (__pthread_mutex_trylock)
hidden_proto (__pthread_mutex_unlock)
hidden_proto (__pthread_rwlock_rdlock)
hidden_proto (__pthread_rwlock_wrlock)
hidden_proto (__pthread_getspecific)
hidden_proto (__pthread_setspecific)
hidden_proto (__pthread_once)
+hidden_proto (__pthread_setcancelstate)
+hidden_proto (__pthread_testcancel)
+hidden_proto (__pthread_mutexattr_init)
+hidden_proto (__pthread_mutexattr_settype)
#endif
extern int __pthread_cond_broadcast_2_0 (pthread_cond_2_0_t *cond);
extern void __pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
void (*routine) (void *), void *arg)
attribute_hidden;
+
+/* Replace cleanup macros defined in <pthread.h> with internal
+ versions that don't depend on unwind info and better support
+ cancellation. */
# undef pthread_cleanup_push
-# define pthread_cleanup_push(routine,arg) \
- { struct _pthread_cleanup_buffer _buffer; \
- __pthread_cleanup_push (&_buffer, (routine), (arg));
+# define pthread_cleanup_push(routine,arg) \
+ { struct _pthread_cleanup_buffer _buffer; \
+ __pthread_cleanup_push (&_buffer, (routine), (arg));
extern void __pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer,
int execute) attribute_hidden;
# undef pthread_cleanup_pop
-# define pthread_cleanup_pop(execute) \
- __pthread_cleanup_pop (&_buffer, (execute)); }
+# define pthread_cleanup_pop(execute) \
+ __pthread_cleanup_pop (&_buffer, (execute)); }
#endif
extern void __pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer,
# define PTHREAD_STATIC_FN_REQUIRE(name) __asm (".globl " #name);
#endif
-/* Test if the mutex is suitable for the FUTEX_WAIT_REQUEUE_PI operation. */
-#if (defined lll_futex_wait_requeue_pi \
- && defined __ASSUME_REQUEUE_PI)
-# define USE_REQUEUE_PI(mut) \
- ((mut) && (mut) != (void *) ~0l \
- && (((mut)->__data.__kind \
- & (PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_NORMAL_NP)) \
- == PTHREAD_MUTEX_PRIO_INHERIT_NP))
-#else
-# define USE_REQUEUE_PI(mut) 0
-#endif
-
/* Returns 0 if POL is a valid scheduling policy. */
static inline int
check_sched_policy_attr (int pol)
return EINVAL;
}
-/* Defined in pthread_setaffinity.c. */
-extern size_t __kernel_cpumask_size attribute_hidden;
-extern int __determine_cpumask_size (pid_t tid);
-
-/* Returns 0 if CS and SZ are valid values for the cpuset and cpuset size
- respectively. Otherwise it returns an error number. */
-static inline int
-check_cpuset_attr (const cpu_set_t *cs, const size_t sz)
-{
- if (__kernel_cpumask_size == 0)
- {
- int res = __determine_cpumask_size (THREAD_SELF->tid);
- if (res)
- return res;
- }
-
- /* Check whether the new bitmask has any bit set beyond the
- last one the kernel accepts. */
- for (size_t cnt = __kernel_cpumask_size; cnt < sz; ++cnt)
- if (((char *) cs)[cnt] != '\0')
- /* Found a nonzero byte. This means the user request cannot be
- fulfilled. */
- return EINVAL;
-
- return 0;
-}
-
#endif /* pthreadP.h */