| 1 |
/* |
| 2 |
* SRT - Secure, Reliable, Transport |
| 3 |
* Copyright (c) 2018 Haivision Systems Inc. |
| 4 |
* |
| 5 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 6 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 7 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 8 |
* |
| 9 |
*/ |
| 10 |
|
| 11 |
/***************************************************************************** |
| 12 |
written by |
| 13 |
Haivision Systems Inc. |
| 14 |
*****************************************************************************/ |
| 15 |
|
| 16 |
#include "win/wintime.h" |
| 17 |
#include <sys/timeb.h> |
| 18 |
|
| 19 |
void SRTCompat_timeradd(struct timeval *a, struct timeval *b, struct timeval *result) |
| 20 |
{ |
| 21 |
result->tv_sec = a->tv_sec + b->tv_sec; |
| 22 |
result->tv_usec = a->tv_usec + b->tv_usec; |
| 23 |
if (result->tv_usec >= 1000000) |
| 24 |
{ |
| 25 |
result->tv_sec++; |
| 26 |
result->tv_usec -= 1000000; |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
int SRTCompat_gettimeofday(struct timeval* tp, struct timezone*) |
| 31 |
{ |
| 32 |
struct timeb tb; |
| 33 |
ftime(&tb); |
| 34 |
tp->tv_sec = (long)tb.time; |
| 35 |
tp->tv_usec = 1000*tb.millitm; |
| 36 |
return 0; |
| 37 |
} |