Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
86a61006bb22837871c8a0b2a77ad7727455824e
[simgrid.git] / src / gras / Virtu / rl_time.c
1 /* $Id$ */
2
3 /* time - time related syscal wrappers                                      */
4
5 /* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved.            */
6
7 /* This program is free software; you can redistribute it and/or modify it
8  * under the terms of the license (GNU LGPL) which comes with this package. */
9
10 #include "portable.h"
11
12 #include "xbt/sysdep.h"
13 #include "gras/virtu.h"
14
15
16 double gras_os_time() {
17 #ifdef HAVE_GETTIMEOFDAY
18   struct timeval tv;
19
20   gettimeofday(&tv, NULL);
21
22   return (double)(tv.tv_sec + tv.tv_usec / 1000000);
23 #else
24   /* Poor resolution */
25   return (double)(time(NULL)); 
26 #endif /* HAVE_GETTIMEOFDAY? */ 
27         
28 }
29  
30 void gras_os_sleep(unsigned long sec,unsigned long usec) {
31   sleep(sec);
32   if (usec/1000000) sleep(usec/1000000);
33
34 #ifdef HAVE_USLEEP
35   (void)usleep(usec % 1000000);
36 #endif /* ! HAVE_USLEEP */
37 }