1 /*======================================================================*
2 * Copyright (C) 2008 Light Weight Event System *
3 * All rights reserved. *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
18 * Boston, MA 02110-1301 USA. *
19 *======================================================================*/
20 #include "lwes_time_functions.h"
26 #if HAVE_EXTERNAL_GETTIMEOFDAY
27 #include EXTERNAL_GETTIMEOFDAY_HEADER
31 #define GETTIMEOFDAY(t,tz) gettimeofday(t,tz)
35 LWES_INT_64
currentTimeMillisLongLong(void)
39 /* gettimeofday should ALWAYS return a value since the only possible error
40 * according to the FreeBSD and Linux man pages is EFAULT if you access
41 * invalid memory, this memory is on the stack so better be valid or we
42 * have bigger problems
46 return ((((LWES_INT_64
)t
.tv_sec
)*((LWES_INT_64
)1000)) +
47 (LWES_INT_64
)(t
.tv_usec
/1000));
50 void convertUnixLongLongTimeToTimeval(LWES_INT_64 timestamp
, struct timeval
*t
)
52 t
->tv_sec
= (long)(timestamp
/1000);
53 t
->tv_usec
= (long)((timestamp
%1000)*1000);