Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
c65d26157c76995b5c3bd782b61b93deb5888abf
[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 "gras_private.h"
12 #include <sys/time.h>   /* gettimeofday() */
13
14 double gras_time() {
15   struct timeval tv;
16
17   gettimeofday(&tv, NULL);
18
19   return (double)(tv.tv_sec * 1000000 + tv.tv_usec);
20 }
21  
22 void gras_sleep(unsigned long sec,unsigned long usec) {
23   sleep(sec);
24   if (usec/1000000) sleep(usec/1000000);
25
26 #ifdef HAVE_USLEEP
27   (void)usleep(usec % 1000000);
28 #endif /* ! HAVE_USLEEP */
29 }