Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[teshsuite/simdag/platforms] fix compilation on MAC OSX
authorQuintin Jean-Noël <quintinjean-noel@bibi.lan>
Sat, 30 Jul 2011 09:06:48 +0000 (11:06 +0200)
committerQuintin Jean-Noël <quintinjean-noel@bibi.lan>
Sat, 30 Jul 2011 09:06:48 +0000 (11:06 +0200)
    CLOCK_REALTIME is not available on MAC OSX

teshsuite/simdag/platforms/Evaluate_get_route_time.c
teshsuite/simdag/platforms/Evaluate_parse_time.c

index 828b4ca..a307d79 100644 (file)
@@ -36,7 +36,15 @@ int main(int argc, char **argv)
 
        unsigned int seed;
        struct timespec time;
 
        unsigned int seed;
        struct timespec time;
-       clock_gettime( CLOCK_REALTIME, &time);
+       //clock_gettime( CLOCK_REALTIME, &time);
+#if _POSIX_TIMERS > 0
+      clock_gettime(CLOCK_REALTIME, &time);
+#else
+      struct timeval tv;
+      gettimeofday(&tv, NULL);
+      time.tv_sec = tv.tv_sec;
+      time.tv_nsec = tv.tv_usec*1000;
+#endif
        seed = time.tv_nsec;
 
        srand(seed);
        seed = time.tv_nsec;
 
        srand(seed);
@@ -50,17 +58,29 @@ int main(int argc, char **argv)
        w2 = workstations[j];
        printf("%d\tand\t%d\t\t",i,j);
 
        w2 = workstations[j];
        printf("%d\tand\t%d\t\t",i,j);
 
+#if _POSIX_TIMERS > 0
        if( clock_gettime( CLOCK_REALTIME, &start) == -1 ) {
        perror( "clock gettime" );
        return EXIT_FAILURE;
        }
        if( clock_gettime( CLOCK_REALTIME, &start) == -1 ) {
        perror( "clock gettime" );
        return EXIT_FAILURE;
        }
+#else
+      gettimeofday(&tv, NULL);
+      start.tv_sec = tv.tv_sec;
+      start.tv_nsec = tv.tv_usec*1000;
+#endif
 
        SD_route_get_list(w1, w2);
 
 
        SD_route_get_list(w1, w2);
 
+#if _POSIX_TIMERS > 0
        if( clock_gettime( CLOCK_REALTIME, &stop) == -1 ) {
        perror( "clock gettime" );
        return EXIT_FAILURE;
        }
        if( clock_gettime( CLOCK_REALTIME, &stop) == -1 ) {
        perror( "clock gettime" );
        return EXIT_FAILURE;
        }
+#else
+      gettimeofday(&tv, NULL);
+      stop.tv_sec = tv.tv_sec;
+      stop.tv_nsec = tv.tv_usec*1000;
+#endif
 
        accum = ( stop.tv_sec - start.tv_sec )
           + (double)( stop.tv_nsec - start.tv_nsec )
 
        accum = ( stop.tv_sec - start.tv_sec )
           + (double)( stop.tv_nsec - start.tv_nsec )
index 11ffd3d..3340d38 100644 (file)
@@ -23,18 +23,30 @@ int main(int argc, char **argv)
        /* initialisation of SD */
        SD_init(&argc, argv);
 
        /* initialisation of SD */
        SD_init(&argc, argv);
 
+#if _POSIX_TIMERS > 0
        if( clock_gettime( CLOCK_REALTIME, &start) == -1 ) {
        perror( "clock gettime" );
        return EXIT_FAILURE;
        }
        if( clock_gettime( CLOCK_REALTIME, &start) == -1 ) {
        perror( "clock gettime" );
        return EXIT_FAILURE;
        }
-
+#else
+      struct timeval tv;
+      gettimeofday(&tv, NULL);
+      start.tv_sec = tv.tv_sec;
+      start.tv_nsec = tv.tv_usec*1000;
+#endif
        /* creation of the environment */
        SD_create_environment(argv[1]);
 
        /* creation of the environment */
        SD_create_environment(argv[1]);
 
+#if _POSIX_TIMERS > 0
        if( clock_gettime( CLOCK_REALTIME, &stop) == -1 ) {
        perror( "clock gettime" );
        return EXIT_FAILURE;
        }
        if( clock_gettime( CLOCK_REALTIME, &stop) == -1 ) {
        perror( "clock gettime" );
        return EXIT_FAILURE;
        }
+#else
+      gettimeofday(&tv, NULL);
+      stop.tv_sec = tv.tv_sec;
+      stop.tv_nsec = tv.tv_usec*1000;
+#endif
 
        accum = ( stop.tv_sec - start.tv_sec )
                   + (double)( stop.tv_nsec - start.tv_nsec )
 
        accum = ( stop.tv_sec - start.tv_sec )
                   + (double)( stop.tv_nsec - start.tv_nsec )