From b87545bcfb634bc8e3f94bf232b865a1446d3060 Mon Sep 17 00:00:00 2001
From: "Peter W. Draper" <p.w.draper@durham.ac.uk>
Date: Thu, 3 Mar 2016 15:33:14 +0000
Subject: [PATCH] Use standard formatting

---
 src/clocks.c | 37 +++++++++++++++----------------------
 src/clocks.h |  4 ++--
 2 files changed, 17 insertions(+), 24 deletions(-)

diff --git a/src/clocks.c b/src/clocks.c
index 3a04d1b508..48d52b7c42 100644
--- a/src/clocks.c
+++ b/src/clocks.c
@@ -64,8 +64,7 @@ void clocks_gettime(struct clocks_time *time) {
  *
  * @return the difference in milli-secinds.
  */
-double clocks_diff(struct clocks_time *start, struct clocks_time *end)
-{
+double clocks_diff(struct clocks_time *start, struct clocks_time *end) {
 #ifdef HAVE_CLOCK_GETTIME
   struct timespec temp;
   if ((end->time.tv_nsec - start->time.tv_nsec) < 0) {
@@ -77,9 +76,8 @@ double clocks_diff(struct clocks_time *start, struct clocks_time *end)
   }
   return (double)temp.tv_sec * 1000.0 + (double)temp.tv_nsec * 1.0E-6;
 #else
-  return elapsed(end->time, start-time) / clocks_get_cpufreq() * 1000;
+  return elapsed(end->time, start->time) / clocks_get_cpufreq() * 1000;
 #endif
-
 }
 
 /**
@@ -91,10 +89,10 @@ double clocks_diff(struct clocks_time *start, struct clocks_time *end)
  * @param freq the CPU frequency in Hz or 0 to estimate one.
  */
 void clocks_set_cpufreq(unsigned long long freq) {
-  if ( freq > 0 ) {
+  if (freq > 0) {
     clocks_cpufreq = freq;
   } else {
-      clocks_estimate_cpufreq();
+    clocks_estimate_cpufreq();
   }
 }
 
@@ -105,13 +103,11 @@ void clocks_set_cpufreq(unsigned long long freq) {
  */
 unsigned long long clocks_get_cpufreq() {
 
-  if (clocks_cpufreq > 0)
-    return clocks_cpufreq;
+  if (clocks_cpufreq > 0) return clocks_cpufreq;
 
   /* It not already set estimate it. */
   clocks_estimate_cpufreq();
   return clocks_cpufreq;
-
 }
 
 /**
@@ -145,14 +141,15 @@ static void clocks_estimate_cpufreq() {
   ticks toc = getticks();
   double realsleep = clocks_diff(&time1, &time2);
 
-  clocks_cpufreq = (signed long long) (double)(toc - tic) * 1.0/realsleep * 1000.0;
+  clocks_cpufreq =
+      (signed long long)(double)(toc - tic) * 1.0 / realsleep * 1000.0;
 #endif
 
-  /* Look for the system value, if available. Tends to be too large. */
+/* Look for the system value, if available. Tends to be too large. */
 #ifdef __linux__
   if (clocks_cpufreq == 0) {
-    FILE *file = fopen("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq",
-                       "r");
+    FILE *file =
+        fopen("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq", "r");
     if (file != NULL) {
       unsigned long long maxfreq;
       if (fscanf(file, "%llu", &maxfreq) == 1) {
@@ -163,15 +160,13 @@ static void clocks_estimate_cpufreq() {
   }
 #endif
 
-  /* Nearly final attempt */
+/* Nearly final attempt */
 #ifdef CPU_TPS
-  if (clocks_cpufreq == 0)
-    clocks_cpufreq = CPU_TPS;
+  if (clocks_cpufreq == 0) clocks_cpufreq = CPU_TPS;
 #endif
 
   /* If all fails just report ticks in any times. */
-  if (clocks_cpufreq == 0)
-    clocks_cpufreq = 1;
+  if (clocks_cpufreq == 0) clocks_cpufreq = 1;
 }
 
 /**
@@ -186,8 +181,7 @@ static void clocks_estimate_cpufreq() {
  *
  * @result the absolute difference in approximated seconds.
  */
-double clocks_diff_ticks(ticks tic, ticks toc)
-{
+double clocks_diff_ticks(ticks tic, ticks toc) {
   return clocks_from_ticks(tic - toc);
 }
 
@@ -202,7 +196,6 @@ double clocks_diff_ticks(ticks tic, ticks toc)
  *
  * @result the approximated seconds.
  */
-double clocks_from_ticks(ticks tics)
-{
+double clocks_from_ticks(ticks tics) {
   return ((double)tics / (double)clocks_get_cpufreq() * 1000.0);
 }
diff --git a/src/clocks.h b/src/clocks.h
index 2520e9b14b..a87ab38b0e 100644
--- a/src/clocks.h
+++ b/src/clocks.h
@@ -25,9 +25,9 @@
 /* Struct to record a time for the clocks functions. */
 struct clocks_time {
 #ifdef HAVE_CLOCK_GETTIME
-    struct timespec time;
+  struct timespec time;
 #else
-    ticks time;
+  ticks time;
 #endif
 };
 
-- 
GitLab