Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add xbt_os_time(). This functions returns the number of seconds since the Epoch ...
[simgrid.git] / src / xbt / sysdep.c
1 /* $Id$ */
2
3 /* sysdep.c -- all system dependency                                        */
4 /*  no system header should be loaded out of this file so that we have only */
5 /*  one file to check when porting to another OS                            */
6
7 /* Copyright (c) 2004 Martin Quinson. All rights reserved.                  */
8
9 /* This program is free software; you can redistribute it and/or modify it
10  * under the terms of the license (GNU LGPL) which comes with this package. */
11
12 #include "xbt/sysdep.h"
13 #include "xbt/log.h"
14 #include "xbt/error.h"
15 #include "portable.h"
16
17 /* \defgroup XBT_sysdep All system dependency
18  * \brief This section describes many macros/functions that can serve as
19  *  an OS abstraction.
20  */
21
22 double xbt_os_time(void) {
23 #ifdef HAVE_GETTIMEOFDAY
24   struct timeval tv;
25
26   gettimeofday(&tv, NULL);
27
28   return (double)(tv.tv_sec + tv.tv_usec / 1000000.0);
29 #else
30   /* Poor resolution */
31   return (double)(time(NULL)); 
32 #endif /* HAVE_GETTIMEOFDAY? */         
33 }
34
35
36 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sysdep, xbt, "System dependency");
37