diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2008-12-17 18:03:48 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2008-12-17 18:03:48 -0800 |
commit | 4e468ed2eb86a2406e14f1eca82072ee501d05fd (patch) | |
tree | 4e05b3c66eef86531e464521a3bf96a1864d4bf5 /libc/bionic/pthread_internal.h | |
parent | a27d2baa0c1a2ec70f47ea9199b1dd6762c8a349 (diff) | |
download | bionic-4e468ed2eb86a2406e14f1eca82072ee501d05fd.zip bionic-4e468ed2eb86a2406e14f1eca82072ee501d05fd.tar.gz bionic-4e468ed2eb86a2406e14f1eca82072ee501d05fd.tar.bz2 |
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'libc/bionic/pthread_internal.h')
-rw-r--r-- | libc/bionic/pthread_internal.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/libc/bionic/pthread_internal.h b/libc/bionic/pthread_internal.h index ac6a5cd..eb4e80c 100644 --- a/libc/bionic/pthread_internal.h +++ b/libc/bionic/pthread_internal.h @@ -48,6 +48,68 @@ typedef struct pthread_internal_t extern void _init_thread(pthread_internal_t * thread, pid_t kernel_id, pthread_attr_t * attr, void * stack_base); +/* 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); + __END_DECLS #endif /* _PTHREAD_INTERNAL_H_ */ |