reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
ResipHep.cxx
Go to the documentation of this file.
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
4
6
7#include "rutil/ResipAssert.h"
8
9// Under Windows we use FILETIME, whose epoch is 1601-01-01 00:00:00 UTC.
10// To obtain Unix timestamp we must calculate difference with Unix epoc,
11// that is 1970-01-01 00:00:00 UTC.
12// In this way we obtain: ((1970 - 1601) * 365 + 89) * 24 * 60 * 60 * 1000 * 1000,
13// where 89 is the number of leap year days between 1601 and 1970:
14// (1970 - 1601) / 4 excluding 1700, 1800, and 1900.
15#define EPOCH_DIFFERENCE 11644473600000000LL
16
17// Returns microseconds since Unix epoch time (UTC)
19{
20 resip_assert(sizeof(uint64_t) == 64/8);
21
22 uint64_t time = 0;
23
24#if defined(WIN32) || defined(UNDER_CE)
26
27#ifdef UNDER_CE
31#else // UNDER_CE
33#endif // UNDER_CE
34
36 li.LowPart = ft.dwLowDateTime;
37 li.HighPart = ft.dwHighDateTime;
38
39 // divide by 10 to convert 100-nanoseconds to microseconds,
40 // then subtract EPOCH_DIFFERENCE to obtain microseconds
41 // from Unix epoch time
42 time = (li.QuadPart / 10) - EPOCH_DIFFERENCE;
43
44#else // #if defined(WIN32) || defined(UNDER_CE)
45
46 struct timeval now;
47 gettimeofday(&now , NULL);
48
49 time = now.tv_sec;
50 time = time * 1000000;
51 time += now.tv_usec;
52
53#endif // #if defined(WIN32) || defined(UNDER_CE)
54
55 return time;
56}
57
58/* ====================================================================
59*
60* Copyright 2016 Dario Bozzali - IFM Infomaster All rights reserved.
61*
62* Redistribution and use in source and binary forms, with or without
63* modification, are permitted provided that the following conditions
64* are met:
65*
66* 1. Redistributions of source code must retain the above copyright
67* notice, this list of conditions and the following disclaimer.
68*
69* 2. Redistributions in binary form must reproduce the above copyright
70* notice, this list of conditions and the following disclaimer in
71* the documentation and/or other materials provided with the
72* distribution.
73*
74* 3. Neither the name of the author(s) nor the names of any contributors
75* may be used to endorse or promote products derived from this software
76* without specific prior written permission.
77*
78* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS "AS IS" AND
79* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
80* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
81* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE
82* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
83* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
84* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
85* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
86* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
87* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
88* SUCH DAMAGE.
89*
90* ====================================================================
91*
92*
93*/
#define resip_assert(x)
This file needs to work for both C and C++ code.
#define EPOCH_DIFFERENCE
Definition ResipHep.cxx:15
uint64_t hepUnixTimestamp()
Definition ResipHep.cxx:18
unsigned __int64 uint64_t
Definition stdint.h:95
void list()
Definition userAdmin.cxx:66