Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Current state. See changelog, sorry, I'm out of time
[simgrid.git] / src / gras / Virtu / rl_time.c
1 /* $Id$ */
2
3 /* time - time related syscal wrappers                                      */
4
5 /* Authors: Martin Quinson                                                  */
6 /* Copyright (C) 2003,2004 da GRAS posse.                                   */
7
8 /* This program is free software; you can redistribute it and/or modify it
9    under the terms of the license (GNU LGPL) which comes with this package. */
10
11 #include "xbt/sysdep.h"
12 #include "gras/virtu.h"
13 #include <sys/time.h>   /* gettimeofday() */
14
15 double gras_os_time() {
16   struct timeval tv;
17
18   gettimeofday(&tv, NULL);
19
20   return (double)(tv.tv_sec * 1000000 + tv.tv_usec);
21 }
22  
23 void gras_os_sleep(unsigned long sec,unsigned long usec) {
24   sleep(sec);
25   if (usec/1000000) sleep(usec/1000000);
26
27 #ifdef HAVE_USLEEP
28   (void)usleep(usec % 1000000);
29 #endif /* ! HAVE_USLEEP */
30 }