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
index 3426750..428d006 100644 (file)
@@ -1,6 +1,6 @@
 /* $Id$ */
 
-/* sysdep.h -- all system dependency                                        */
+/* sysdep.c -- all system dependency                                        */
 /*  no system header should be loaded out of this file so that we have only */
 /*  one file to check when porting to another OS                            */
 
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
 #include "xbt/error.h"
+#include "portable.h"
 
-#include <stdlib.h>
+/* \defgroup XBT_sysdep All system dependency
+ * \brief This section describes many macros/functions that can serve as
+ *  an OS abstraction.
+ */
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sysdep, xbt, "System dependency");
+double xbt_os_time(void) {
+#ifdef HAVE_GETTIMEOFDAY
+  struct timeval tv;
 
-/****
- **** Misc
- ****/
+  gettimeofday(&tv, NULL);
 
-void xbt_abort(void) {
-   abort();
+  return (double)(tv.tv_sec + tv.tv_usec / 1000000.0);
+#else
+  /* Poor resolution */
+  return (double)(time(NULL)); 
+#endif /* HAVE_GETTIMEOFDAY? */        
 }
+
+
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sysdep, xbt, "System dependency");
+