]> granicus.if.org Git - libatomic_ops/commitdiff
Eliminate 'ISO C90 does not support long long' compiler pedantic warning
authorIvan Maidanski <ivmai@mail.ru>
Tue, 11 Oct 2016 14:52:54 +0000 (17:52 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 12 Oct 2016 06:35:55 +0000 (09:35 +0300)
Long (32-bit) type is sufficient to represent time delta (duration)
in test_stack.

* tests/test_stack.c (get_msecs): Change return type from long long
to unsigned long (use lowest 32 bits of time value).
* tests/test_stack.c (main): Change type of start_time local variable
to unsigned long; remove redundant type cast.

tests/test_stack.c

index 0da83478fb1389e2a40751548bad6ce63642104d..c21a8814e987afd78f5f466ccffe82a7ecfece0c 100644 (file)
 # define get_msecs() 0
 #elif defined(USE_WINTHREADS) || defined(AO_USE_WIN32_PTHREADS)
 # include <sys/timeb.h>
-  long long get_msecs(void)
+  unsigned long get_msecs(void)
   {
     struct timeb tb;
 
     ftime(&tb);
-    return (long long)tb.time * 1000 + tb.millitm;
+    return (unsigned long)tb.time * 1000 + tb.millitm;
   }
 #else /* Unix */
 # include <time.h>
 # include <sys/time.h>
-  /* Need 64-bit long long support */
-  long long get_msecs(void)
+  unsigned long get_msecs(void)
   {
     struct timeval tv;
 
     gettimeofday(&tv, 0);
-    return (long long)tv.tv_sec * 1000 + tv.tv_usec/1000;
+    return (unsigned long)tv.tv_sec * 1000 + tv.tv_usec/1000;
   }
 #endif /* !NO_TIMES */
 
@@ -244,7 +243,7 @@ int main(int argc, char **argv)
           pthread_t thread[MAX_NTHREADS];
 #       endif
         int list_length = nthreads*(nthreads+1)/2;
-        long long start_time;
+        unsigned long start_time;
         list_element * le;
 
 #       ifdef VERBOSE
@@ -292,7 +291,7 @@ int main(int argc, char **argv)
             abort();
           }
         }
-        times[nthreads][exper_n] = (unsigned long)(get_msecs() - start_time);
+        times[nthreads][exper_n] = get_msecs() - start_time;
   #     ifdef VERBOSE
           printf("nthreads=%d, time_ms=%lu\n",
                  nthreads, times[nthreads][exper_n]);