From 4cf13952175a793fed4646d7d7396364874b0909 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 19 Jul 2013 16:42:27 -0700 Subject: [PATCH] Move stuff only needed by pthread-timers.c into pthread-timers.c. Change-Id: I4915b3fff9c4f5a36b4f51027fb22019c11607b0 --- libc/bionic/pthread-timers.c | 49 ++++++++++++++++++++++++++++ libc/bionic/pthread_internal.h | 59 ---------------------------------- 2 files changed, 49 insertions(+), 59 deletions(-) diff --git a/libc/bionic/pthread-timers.c b/libc/bionic/pthread-timers.c index 2ad0b9033..d81bfef22 100644 --- a/libc/bionic/pthread-timers.c +++ b/libc/bionic/pthread-timers.c @@ -33,6 +33,12 @@ #include #include +extern int __pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, const struct timespec*, + clockid_t); + +extern int __pthread_cond_timedwait_relative(pthread_cond_t*, pthread_mutex_t*, + const struct timespec*); + // Normal (i.e. non-SIGEV_THREAD) timers are created directly by the kernel // and are passed as is to/from the caller. // @@ -279,6 +285,49 @@ thr_timer_unlock( thr_timer_t* t ) pthread_mutex_unlock(&t->mutex); } + +static __inline__ void timespec_add(struct timespec* a, const struct timespec* b) { + a->tv_sec += b->tv_sec; + a->tv_nsec += b->tv_nsec; + if (a->tv_nsec >= 1000000000) { + a->tv_nsec -= 1000000000; + a->tv_sec += 1; + } +} + +static __inline__ void timespec_sub(struct timespec* a, const struct timespec* b) { + a->tv_sec -= b->tv_sec; + a->tv_nsec -= b->tv_nsec; + if (a->tv_nsec < 0) { + a->tv_nsec += 1000000000; + a->tv_sec -= 1; + } +} + +static __inline__ void timespec_zero(struct timespec* a) { + a->tv_sec = a->tv_nsec = 0; +} + +static __inline__ int timespec_is_zero(const struct timespec* a) { + return (a->tv_sec == 0 && a->tv_nsec == 0); +} + +static __inline__ int timespec_cmp(const struct timespec* a, const struct timespec* b) { + if (a->tv_sec < b->tv_sec) return -1; + if (a->tv_sec > b->tv_sec) return +1; + if (a->tv_nsec < b->tv_nsec) return -1; + if (a->tv_nsec > b->tv_nsec) return +1; + return 0; +} + +static __inline__ int timespec_cmp0(const struct timespec* a) { + if (a->tv_sec < 0) return -1; + if (a->tv_sec > 0) return +1; + if (a->tv_nsec < 0) return -1; + if (a->tv_nsec > 0) return +1; + return 0; +} + /** POSIX TIMERS APIs */ extern int __timer_create(clockid_t, struct sigevent*, timer_t*); diff --git a/libc/bionic/pthread_internal.h b/libc/bionic/pthread_internal.h index 98199d3ac..31b8ca7f1 100644 --- a/libc/bionic/pthread_internal.h +++ b/libc/bionic/pthread_internal.h @@ -80,65 +80,6 @@ __LIBC_HIDDEN__ void _pthread_internal_remove_locked(pthread_internal_t* thread) __LIBC_HIDDEN__ extern pthread_internal_t* gThreadList; __LIBC_HIDDEN__ extern pthread_mutex_t gThreadListLock; -/* needed by posix-timers.c */ - -static __inline__ void timespec_add( struct timespec* a, const struct timespec* b ) -{ - a->tv_sec += b->tv_sec; - a->tv_nsec += b->tv_nsec; - if (a->tv_nsec >= 1000000000) { - a->tv_nsec -= 1000000000; - a->tv_sec += 1; - } -} - -static __inline__ void timespec_sub( struct timespec* a, const struct timespec* b ) -{ - a->tv_sec -= b->tv_sec; - a->tv_nsec -= b->tv_nsec; - if (a->tv_nsec < 0) { - a->tv_nsec += 1000000000; - a->tv_sec -= 1; - } -} - -static __inline__ void timespec_zero( struct timespec* a ) -{ - a->tv_sec = a->tv_nsec = 0; -} - -static __inline__ int timespec_is_zero( const struct timespec* a ) -{ - return (a->tv_sec == 0 && a->tv_nsec == 0); -} - -static __inline__ int timespec_cmp( const struct timespec* a, const struct timespec* b ) -{ - if (a->tv_sec < b->tv_sec) return -1; - if (a->tv_sec > b->tv_sec) return +1; - if (a->tv_nsec < b->tv_nsec) return -1; - if (a->tv_nsec > b->tv_nsec) return +1; - return 0; -} - -static __inline__ int timespec_cmp0( const struct timespec* a ) -{ - if (a->tv_sec < 0) return -1; - if (a->tv_sec > 0) return +1; - if (a->tv_nsec < 0) return -1; - if (a->tv_nsec > 0) return +1; - return 0; -} - -extern int __pthread_cond_timedwait(pthread_cond_t*, - pthread_mutex_t*, - const struct timespec*, - clockid_t); - -extern int __pthread_cond_timedwait_relative(pthread_cond_t*, - pthread_mutex_t*, - const struct timespec*); - /* needed by fork.c */ extern void __timer_table_start_stop(int stop); extern void __bionic_atfork_run_prepare();