+void timespec_add_msec(struct timespec *ts, unsigned int msec)
+{
+ uint64_t adj_nsec = 1000000ULL * msec;
+
+ ts->tv_nsec += adj_nsec;
+ if (adj_nsec >= 1000000000) {
+ uint64_t adj_sec = adj_nsec / 1000000000;
+
+ ts->tv_nsec -= adj_sec * 1000000000;
+ ts->tv_sec += adj_sec;
+ }
+ if (ts->tv_nsec >= 1000000000){
+ ts->tv_nsec -= 1000000000;
+ ts->tv_sec++;
+ }
+}
+