X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/a7729514e277aabe9422a2626541f889ad1af08b..24738931e11d38749f48fb869338c5c6fcd9a8f5:/src/gras/Virtu/rl_time.c diff --git a/src/gras/Virtu/rl_time.c b/src/gras/Virtu/rl_time.c index c65d26157c..b7e6292dfc 100644 --- a/src/gras/Virtu/rl_time.c +++ b/src/gras/Virtu/rl_time.c @@ -2,28 +2,36 @@ /* time - time related syscal wrappers */ -/* Authors: Martin Quinson */ -/* Copyright (C) 2003,2004 da GRAS posse. */ +/* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved. */ /* 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. */ + * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "gras_private.h" -#include /* gettimeofday() */ +#include "math.h" /* floor */ -double gras_time() { - struct timeval tv; +#include "portable.h" - gettimeofday(&tv, NULL); +#include "xbt/sysdep.h" +#include "gras/virtu.h" +#include "xbt/xbt_portability.h" /* private */ - return (double)(tv.tv_sec * 1000000 + tv.tv_usec); +XBT_LOG_EXTERNAL_CATEGORY(virtu); +XBT_LOG_DEFAULT_CATEGORY(virtu); + +double gras_os_time() { + return xbt_os_time(); } -void gras_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 */ }