X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b4da4acca8a5b5e43c3bdda26ea8ab2b1e802f1e..97ba095764fbd852783e6a6dfe40da2fdd3f1f25:/src/gras/Virtu/rl_time.c diff --git a/src/gras/Virtu/rl_time.c b/src/gras/Virtu/rl_time.c index eeb782b2e9..e9d07b29e3 100644 --- a/src/gras/Virtu/rl_time.c +++ b/src/gras/Virtu/rl_time.c @@ -7,11 +7,15 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#include "math.h" /* floor */ + #include "portable.h" #include "xbt/sysdep.h" #include "gras/virtu.h" +XBT_LOG_EXTERNAL_CATEGORY(virtu); +XBT_LOG_DEFAULT_CATEGORY(virtu); double gras_os_time() { #ifdef HAVE_GETTIMEOFDAY @@ -27,11 +31,16 @@ double gras_os_time() { } -void gras_os_sleep(unsigned long sec,unsigned long usec) { +void gras_os_sleep(double sec) { + DEBUG1("Do sleep %d sec", (int)sec); sleep(sec); - if (usec/1000000) sleep(usec/1000000); #ifdef HAVE_USLEEP - (void)usleep(usec % 1000000); + DEBUG1("Do sleep %d usec", (int) ((sec - floor(sec)) * 1000000 )); + (void)usleep( (sec - floor(sec)) * 1000000); +#else + if ( ((int) sec) == 0) { + WARN0("This platform does not implement usleep. Cannot sleep less than one second"); + } #endif /* ! HAVE_USLEEP */ }