Home | History | Annotate | Download | only in lib

Lines Matching defs:ts

441 void ts_normalize(struct timespec *ts)
443 if (ts == NULL) {
445 printf("ERROR in %s: ts is NULL\n", __FUNCTION__);
450 while (ts->tv_nsec > NS_PER_SEC) {
451 ts->tv_sec++;
452 ts->tv_nsec -= NS_PER_SEC;
454 while (ts->tv_nsec < -NS_PER_SEC) {
455 ts->tv_sec--;
456 ts->tv_nsec += NS_PER_SEC;
460 if (ts->tv_sec > 0 && ts->tv_nsec < 0) {
461 ts->tv_sec--;
462 ts->tv_nsec += NS_PER_SEC;
464 if (ts->tv_sec < 0 && ts->tv_nsec > 0) {
465 ts->tv_sec++;
466 ts->tv_nsec -= NS_PER_SEC;
470 int ts_to_nsec(struct timespec *ts, nsec_t * ns)
473 if (ts == NULL) {
475 printf("ERROR in %s: ts is NULL\n", __FUNCTION__);
478 t.tv_sec = ts->tv_sec;
479 t.tv_nsec = ts->tv_nsec;
483 printf("ERROR in %s: ts is negative\n", __FUNCTION__);
487 *ns = (nsec_t) ts->tv_sec * NS_PER_SEC + ts->tv_nsec;
491 void nsec_to_ts(nsec_t ns, struct timespec *ts)
493 if (ts == NULL) {
495 printf("ERROR in %s: ts is NULL\n", __FUNCTION__);
498 ts->tv_sec = ns / NS_PER_SEC;
499 ts->tv_nsec = ns % NS_PER_SEC;
545 struct timespec ts;
549 rc = clock_gettime(CLOCK_MONOTONIC, &ts);
557 ts_to_nsec(&ts, &ns);