1 /*======================================================================*
2 * Copyright (c) 2008, Yahoo! Inc. All rights reserved. *
4 * Licensed under the New BSD License (the "License"); you may not use *
5 * this file except in compliance with the License. Unless required *
6 * by applicable law or agreed to in writing, software distributed *
7 * under the License is distributed on an "AS IS" BASIS, WITHOUT *
8 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
9 * See the License for the specific language governing permissions and *
10 * limitations under the License. See accompanying LICENSE file. *
11 *======================================================================*/
13 #include "lwes_time_functions.h"
19 #if HAVE_EXTERNAL_GETTIMEOFDAY
20 #include EXTERNAL_GETTIMEOFDAY_HEADER
24 #define GETTIMEOFDAY(t,tz) gettimeofday(t,tz)
28 LWES_INT_64
currentTimeMillisLongLong(void)
32 /* gettimeofday should ALWAYS return a value since the only possible error
33 * according to the FreeBSD and Linux man pages is EFAULT if you access
34 * invalid memory, this memory is on the stack so better be valid or we
35 * have bigger problems
39 return ((((LWES_INT_64
)t
.tv_sec
)*((LWES_INT_64
)1000)) +
40 (LWES_INT_64
)(t
.tv_usec
/1000));
43 void convertUnixLongLongTimeToTimeval(LWES_INT_64 timestamp
, struct timeval
*t
)
45 t
->tv_sec
= (long)(timestamp
/1000);
46 t
->tv_usec
= (long)((timestamp
%1000)*1000);