X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/bc48db087894fd960073b3120cebf90e6b2f8c02..4a69abcc786d029bd2962537f767d12a0f808d11:/src/xbt/xbt_os_time.c diff --git a/src/xbt/xbt_os_time.c b/src/xbt/xbt_os_time.c index 0994708ee5..0e8951f837 100644 --- a/src/xbt/xbt_os_time.c +++ b/src/xbt/xbt_os_time.c @@ -85,27 +85,29 @@ void xbt_os_sleep(double sec) #endif } -/* TSC (tick-level) timers are said to be unreliable on SMP hosts and thus - disabled in SDL source code */ - +/* TSC (tick-level) timers are said to be unreliable on SMP hosts and thus disabled in SDL source code */ /* \defgroup XBT_sysdep All system dependency - * \brief This section describes many macros/functions that can serve as - * an OS abstraction. + * \brief This section describes many macros/functions that can serve as an OS abstraction. */ - - struct s_xbt_os_timer { #if HAVE_POSIX_GETTIME - struct timespec start, stop, elapse; + struct timespec start; + struct timespec stop; + struct timespec elapse; #elif HAVE_GETTIMEOFDAY || defined(_WIN32) - struct timeval start, stop, elapse; + struct timeval start; + struct timeval stop; + struct timeval elapse; #else - unsigned long int start, stop, elapse; + unsigned long int start; + unsigned long int stop; + unsigned long int elapse; #endif }; -size_t xbt_os_timer_size(void){ +size_t xbt_os_timer_size(void) +{ return sizeof(struct s_xbt_os_timer); } @@ -122,18 +124,14 @@ void xbt_os_timer_free(xbt_os_timer_t timer) double xbt_os_timer_elapsed(xbt_os_timer_t timer) { #if HAVE_POSIX_GETTIME - return ((double) timer->stop.tv_sec) - ((double) timer->start.tv_sec) + - ((double) timer->elapse.tv_sec ) + - ((((double) timer->stop.tv_nsec) - - ((double) timer->start.tv_nsec) + ((double) timer->elapse.tv_nsec )) / 1e9); + return ((double) timer->stop.tv_sec) - ((double) timer->start.tv_sec) + ((double) timer->elapse.tv_sec ) + + ((((double) timer->stop.tv_nsec) - ((double) timer->start.tv_nsec) + ((double) timer->elapse.tv_nsec )) / 1e9); #elif HAVE_GETTIMEOFDAY || defined(_WIN32) - return ((double) timer->stop.tv_sec) - ((double) timer->start.tv_sec) - + ((double) timer->elapse.tv_sec ) + - ((((double) timer->stop.tv_usec) - - ((double) timer->start.tv_usec) + ((double) timer->elapse.tv_usec )) / 1000000.0); + return ((double) timer->stop.tv_sec) - ((double) timer->start.tv_sec) + ((double) timer->elapse.tv_sec ) + + ((((double) timer->stop.tv_usec) - ((double) timer->start.tv_usec) + ((double) timer->elapse.tv_usec )) / + 1000000.0); #else - return (double) timer->stop - (double) timer->start + (double) - timer->elapse; + return (double) timer->stop - (double) timer->start + (double) timer->elapse; #endif }