Implement POSIX pthread_mutex_timedlock.

This replaces the non-standard pthread_mutex_lock_timeout_np, which we have
to keep around on LP32 for binary compatibility.

Change-Id: I098dc7cd38369f0c1bec1fac35687fbd27392e00
This commit is contained in:
Elliott Hughes
2014-03-03 16:42:47 -08:00
parent 8e541b1223
commit 0e714a5b41
6 changed files with 141 additions and 137 deletions

View File

@@ -174,7 +174,7 @@ int pthread_mutexattr_settype(pthread_mutexattr_t*, int) __nonnull((1));
int pthread_mutex_destroy(pthread_mutex_t*) __nonnull((1));
int pthread_mutex_init(pthread_mutex_t*, const pthread_mutexattr_t*) __nonnull((1));
int pthread_mutex_lock(pthread_mutex_t*) __nonnull((1));
int pthread_mutex_timedlock(pthread_mutex_t*, struct timespec*) __nonnull((1, 2));
int pthread_mutex_timedlock(pthread_mutex_t*, const struct timespec*) __nonnull((1, 2));
int pthread_mutex_trylock(pthread_mutex_t*) __nonnull((1));
int pthread_mutex_unlock(pthread_mutex_t*) __nonnull((1));
@@ -245,23 +245,11 @@ int pthread_cond_timedwait_monotonic_np(pthread_cond_t*, pthread_mutex_t*, const
int pthread_cond_timedwait_monotonic(pthread_cond_t*, pthread_mutex_t*, const struct timespec*);
#define HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC 1
/*
* Like pthread_cond_timedwait except 'reltime' is relative to the current time.
* TODO: not like glibc; include in LP64?
*/
int pthread_cond_timedwait_relative_np(pthread_cond_t*, pthread_mutex_t*, const struct timespec*);
#define HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE 1
int pthread_cond_timedwait_relative_np(pthread_cond_t*, pthread_mutex_t*, const struct timespec*) /* TODO: __attribute__((deprecated("use pthread_cond_timedwait instead")))*/;
#define HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE 1 /* TODO: stop defining this to push LP32 off this API sooner. */
int pthread_cond_timeout_np(pthread_cond_t*, pthread_mutex_t*, unsigned) /* TODO: __attribute__((deprecated("use pthread_cond_timedwait instead")))*/;
/* TODO: not like glibc; include in LP64? */
int pthread_cond_timeout_np(pthread_cond_t*, pthread_mutex_t*, unsigned);
/* Like pthread_mutex_lock(), but will wait up to 'msecs' milli-seconds
* before returning. Same return values as pthread_mutex_trylock though, i.e.
* returns EBUSY if the lock could not be acquired after the timeout expired.
*
* TODO: replace with pthread_mutex_timedlock_np for LP64.
*/
int pthread_mutex_lock_timeout_np(pthread_mutex_t*, unsigned);
int pthread_mutex_lock_timeout_np(pthread_mutex_t*, unsigned) __attribute__((deprecated("use pthread_mutex_timedlock instead")));
#endif /* !defined(__LP64__) */