Merge "Make it harder to use a broken legacy function by accident."

This commit is contained in:
Elliott Hughes 2016-04-05 00:36:08 +00:00 committed by Gerrit Code Review
commit 5b528c0832
2 changed files with 12 additions and 13 deletions

View File

@ -51,13 +51,3 @@ void timeval_from_timespec(timeval& tv, const timespec& ts) {
tv.tv_sec = ts.tv_sec; tv.tv_sec = ts.tv_sec;
tv.tv_usec = ts.tv_nsec / 1000; tv.tv_usec = ts.tv_nsec / 1000;
} }
void absolute_timespec_from_timespec(timespec& abs_ts, const timespec& ts, clockid_t clock) {
clock_gettime(clock, &abs_ts);
abs_ts.tv_sec += ts.tv_sec;
abs_ts.tv_nsec += ts.tv_nsec;
if (abs_ts.tv_nsec >= NS_PER_S) {
abs_ts.tv_nsec -= NS_PER_S;
abs_ts.tv_sec++;
}
}

View File

@ -42,9 +42,6 @@ __LIBC_HIDDEN__ void timespec_from_ms(timespec& ts, const int ms);
__LIBC_HIDDEN__ void timeval_from_timespec(timeval& tv, const timespec& ts); __LIBC_HIDDEN__ void timeval_from_timespec(timeval& tv, const timespec& ts);
__LIBC_HIDDEN__ void absolute_timespec_from_timespec(timespec& abs_ts, const timespec& ts,
clockid_t clock);
__END_DECLS __END_DECLS
static inline int check_timespec(const timespec* ts, bool null_allowed) { static inline int check_timespec(const timespec* ts, bool null_allowed) {
@ -62,4 +59,16 @@ static inline int check_timespec(const timespec* ts, bool null_allowed) {
return 0; return 0;
} }
#if !defined(__LP64__)
static inline void absolute_timespec_from_timespec(timespec& abs_ts, const timespec& ts, clockid_t clock) {
clock_gettime(clock, &abs_ts);
abs_ts.tv_sec += ts.tv_sec;
abs_ts.tv_nsec += ts.tv_nsec;
if (abs_ts.tv_nsec >= NS_PER_S) {
abs_ts.tv_nsec -= NS_PER_S;
abs_ts.tv_sec++;
}
}
#endif
#endif #endif