| 42 | #define OSVR_USEC_PER_SEC 1000000; |
| 43 | |
| 44 | void osvrTimeValueNormalize(OSVR_INOUT_PTR OSVR_TimeValue *tv) { |
| 45 | if (!tv) { |
| 46 | return; |
| 47 | } |
| 48 | const OSVR_TimeValue_Microseconds rem = |
| 49 | tv->microseconds / OSVR_USEC_PER_SEC; |
| 50 | tv->seconds += rem; |
| 51 | tv->microseconds -= rem * OSVR_USEC_PER_SEC; |
| 52 | /* By here, abs(microseconds) < OSVR_USEC_PER_SEC: |
| 53 | now let's get signs the same. */ |
| 54 | if (tv->seconds > 0 && tv->microseconds < 0) { |
| 55 | tv->seconds--; |
| 56 | tv->microseconds += OSVR_USEC_PER_SEC; |
| 57 | } else if (tv->seconds < 0 && tv->microseconds > 0) { |
| 58 | tv->seconds++; |
| 59 | tv->microseconds -= OSVR_USEC_PER_SEC; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | void osvrTimeValueSum(OSVR_INOUT_PTR OSVR_TimeValue *tvA, |
| 64 | OSVR_IN_PTR const OSVR_TimeValue *tvB) { |
no outgoing calls
no test coverage detected