[go: up one dir, main page]

File: win_time.cpp

package info (click to toggle)
srt 1.4.2-1.3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,648 kB
  • sloc: cpp: 42,817; ansic: 4,060; tcl: 916; sh: 146; python: 87; makefile: 49
file content (37 lines) | stat: -rw-r--r-- 1,027 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * SRT - Secure, Reliable, Transport
 * Copyright (c) 2018 Haivision Systems Inc.
 * 
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 * 
 */

/*****************************************************************************
written by
   Haivision Systems Inc.
 *****************************************************************************/

#include "win/wintime.h"
#include <sys/timeb.h>

void SRTCompat_timeradd(struct timeval *a, struct timeval *b, struct timeval *result)
{
    result->tv_sec  = a->tv_sec + b->tv_sec;
    result->tv_usec = a->tv_usec + b->tv_usec;
    if (result->tv_usec >= 1000000)
    {
        result->tv_sec++;
        result->tv_usec -= 1000000;
    }
}

int SRTCompat_gettimeofday(struct timeval* tp, struct timezone*)
{
    struct timeb tb;
    ftime(&tb);
    tp->tv_sec  = (long)tb.time;
    tp->tv_usec = 1000*tb.millitm;
    return 0;
}