Move stuff only needed by pthread-timers.c into pthread-timers.c.

Change-Id: I4915b3fff9c4f5a36b4f51027fb22019c11607b0
This commit is contained in:
Elliott Hughes 2013-07-19 16:42:27 -07:00
parent e8bd8c2ed9
commit 4cf1395217
2 changed files with 49 additions and 59 deletions

View File

@ -33,6 +33,12 @@
#include <stdio.h>
#include <string.h>
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*);

View File

@ -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();