diff options
author | Alexander Barkov <bar@mysql.com> | 2010-02-17 12:24:47 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mysql.com> | 2010-02-17 12:24:47 +0400 |
commit | 8780277b83f06c64922120f89c6e25b490c463cb (patch) | |
tree | 470d806f908f42a4eaf28d397f33be1e76b383a3 /include/my_pthread.h | |
parent | cf718fe9b77e97e641bddbb1438ed5d60c455e2e (diff) | |
parent | ab293e26c385d3dfc1b51923b50fd5f2ac158ee0 (diff) | |
download | mariadb-git-8780277b83f06c64922120f89c6e25b490c463cb.tar.gz |
Merging from mysql-next-mr
Diffstat (limited to 'include/my_pthread.h')
-rw-r--r-- | include/my_pthread.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/include/my_pthread.h b/include/my_pthread.h index 343bff6ba72..5402d3929de 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -102,6 +102,19 @@ struct timespec { (ABSTIME).max_timeout_msec= (long)((NSEC)/1000000); \ } +/** + Compare two timespec structs. + + @retval 1 If TS1 ends after TS2. + + @retval 0 If TS1 is equal to TS2. + + @retval -1 If TS1 ends before TS2. +*/ +#define cmp_timespec(TS1, TS2) \ + ((TS1.tv.i64 > TS2.tv.i64) ? 1 : \ + ((TS1.tv.i64 < TS2.tv.i64) ? -1 : 0)) + int win_pthread_mutex_trylock(pthread_mutex_t *mutex); int pthread_create(pthread_t *, const pthread_attr_t *, pthread_handler, void *); @@ -414,6 +427,33 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex); #endif /* !set_timespec_nsec */ #endif /* HAVE_TIMESPEC_TS_SEC */ +/** + Compare two timespec structs. + + @retval 1 If TS1 ends after TS2. + + @retval 0 If TS1 is equal to TS2. + + @retval -1 If TS1 ends before TS2. +*/ +#ifdef HAVE_TIMESPEC_TS_SEC +#ifndef cmp_timespec +#define cmp_timespec(TS1, TS2) \ + ((TS1.ts_sec > TS2.ts_sec || \ + (TS1.ts_sec == TS2.ts_sec && TS1.ts_nsec > TS2.ts_nsec)) ? 1 : \ + ((TS1.ts_sec < TS2.ts_sec || \ + (TS1.ts_sec == TS2.ts_sec && TS1.ts_nsec < TS2.ts_nsec)) ? -1 : 0)) +#endif /* !cmp_timespec */ +#else +#ifndef cmp_timespec +#define cmp_timespec(TS1, TS2) \ + ((TS1.tv_sec > TS2.tv_sec || \ + (TS1.tv_sec == TS2.tv_sec && TS1.tv_nsec > TS2.tv_nsec)) ? 1 : \ + ((TS1.tv_sec < TS2.tv_sec || \ + (TS1.tv_sec == TS2.tv_sec && TS1.tv_nsec < TS2.tv_nsec)) ? -1 : 0)) +#endif /* !cmp_timespec */ +#endif /* HAVE_TIMESPEC_TS_SEC */ + /* safe_mutex adds checking to mutex for easier debugging */ #if defined(__NETWARE__) && !defined(SAFE_MUTEX_DETECT_DESTROY) |