From 74104582e27ef76790c9d954464b53b0e45a2b43 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 17 Mar 2011 12:00:33 -0400 Subject: Minor formatting and style fixes. --- src/Makefile.am | 2 +- src/sandglass-impl.h | 46 +++++++++++++++++++++++++++++++++++++++++++ src/sandglass.c | 5 +++-- src/sandglass_impl.h | 46 ------------------------------------------- src/timespec.c | 10 +++++----- src/tsc.c | 2 +- tests/introspective-cputime.c | 2 +- tests/introspective-system.c | 2 +- tests/monotonic-cputime.c | 2 +- tests/monotonic-realticks.c | 2 +- tests/monotonic-system.c | 2 +- tests/noprecache.c | 2 +- 12 files changed, 62 insertions(+), 61 deletions(-) create mode 100644 src/sandglass-impl.h delete mode 100644 src/sandglass_impl.h diff --git a/src/Makefile.am b/src/Makefile.am index b228b83..12ebf1a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -22,7 +22,7 @@ lib_LTLIBRARIES = libsandglass.la nobase_include_HEADERS = sandglass.h libsandglass_la_SOURCES = sandglass.h \ - sandglass_impl.h \ + sandglass-impl.h \ sandglass.c \ timespec.c diff --git a/src/sandglass-impl.h b/src/sandglass-impl.h new file mode 100644 index 0000000..e10562f --- /dev/null +++ b/src/sandglass-impl.h @@ -0,0 +1,46 @@ +/************************************************************************* + * Copyright (C) 2008 Tavian Barnes * + * * + * This file is part of The Sandglass Library. * + * * + * The Sandglass Library is free software; you can redistribute it * + * and/or modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either version * + * 3 of the License, or (at your option) any later version. * + * * + * The Sandglass Library is distributed in the hope that it will be * + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this program. If not, see * + * . * + *************************************************************************/ + +/* + * Internal libsandglass API + */ + +#ifndef SANDGLASS_IMPL_H_INCLUDED +#define SANDGLASS_IMPL_H_INCLUDED + +#include "sandglass.h" +#include + +#if SANDGLASS_TSC +/* Read the time stamp counter */ +long sandglass_get_tsc(); +/* Get the frequency of the TSC */ +double sandglass_tsc_freq(); +/* Get the necessary number of loops for sandglass_bench_fine() */ +unsigned int sandglass_tsc_loops(); +#endif + +void sandglass_get_currtime(struct timespec *ts); +void sandglass_timespec_add(struct timespec *ts, const struct timespec *d); +void sandglass_timespec_sub(struct timespec *ts, const struct timespec *d); +int sandglass_timespec_cmp(const struct timespec *a, const struct timespec *b); +void sandglass_spin(const struct timespec *ts); + +#endif /* SANDGLASS_IMPL_H_INCLUDED */ diff --git a/src/sandglass.c b/src/sandglass.c index 0710788..a056980 100644 --- a/src/sandglass.c +++ b/src/sandglass.c @@ -18,7 +18,7 @@ * . * *************************************************************************/ -#include "sandglass_impl.h" +#include "sandglass-impl.h" #include "sandglass.h" #include #include @@ -164,7 +164,8 @@ sandglass_real_gettime(sandglass_t *sandglass) break; case SANDGLASS_SYSTEM: - if ((clock_ticks = clock()) == -1) + clock_ticks = clock(); + if (clock_ticks == -1) return -1; sandglass->grains = clock_ticks; break; diff --git a/src/sandglass_impl.h b/src/sandglass_impl.h deleted file mode 100644 index e10562f..0000000 --- a/src/sandglass_impl.h +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************* - * Copyright (C) 2008 Tavian Barnes * - * * - * This file is part of The Sandglass Library. * - * * - * The Sandglass Library is free software; you can redistribute it * - * and/or modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either version * - * 3 of the License, or (at your option) any later version. * - * * - * The Sandglass Library is distributed in the hope that it will be * - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with this program. If not, see * - * . * - *************************************************************************/ - -/* - * Internal libsandglass API - */ - -#ifndef SANDGLASS_IMPL_H_INCLUDED -#define SANDGLASS_IMPL_H_INCLUDED - -#include "sandglass.h" -#include - -#if SANDGLASS_TSC -/* Read the time stamp counter */ -long sandglass_get_tsc(); -/* Get the frequency of the TSC */ -double sandglass_tsc_freq(); -/* Get the necessary number of loops for sandglass_bench_fine() */ -unsigned int sandglass_tsc_loops(); -#endif - -void sandglass_get_currtime(struct timespec *ts); -void sandglass_timespec_add(struct timespec *ts, const struct timespec *d); -void sandglass_timespec_sub(struct timespec *ts, const struct timespec *d); -int sandglass_timespec_cmp(const struct timespec *a, const struct timespec *b); -void sandglass_spin(const struct timespec *ts); - -#endif /* SANDGLASS_IMPL_H_INCLUDED */ diff --git a/src/timespec.c b/src/timespec.c index c077f8b..1353076 100644 --- a/src/timespec.c +++ b/src/timespec.c @@ -18,7 +18,7 @@ * . * *************************************************************************/ -#include "sandglass_impl.h" +#include "sandglass-impl.h" #include "sandglass.h" #include #include @@ -75,18 +75,18 @@ sandglass_timespec_sub(struct timespec *ts, const struct timespec *d) int sandglass_timespec_cmp(const struct timespec *a, const struct timespec *b) { - if (a->tv_sec > b->tv_sec) + if (a->tv_sec > b->tv_sec) { return 1; - else if (a->tv_sec == b->tv_sec) { + } else if (a->tv_sec == b->tv_sec) { if (a->tv_nsec > b->tv_nsec) return 1; else if (a->tv_nsec == b->tv_nsec) return 0; else return -1; - } - else + } else { return -1; + } } /* Spins for the time interval specified by ts */ diff --git a/src/tsc.c b/src/tsc.c index 713008c..ae31701 100644 --- a/src/tsc.c +++ b/src/tsc.c @@ -18,7 +18,7 @@ * . * *************************************************************************/ -#include "sandglass_impl.h" +#include "sandglass-impl.h" #include "sandglass.h" #include #include diff --git a/tests/introspective-cputime.c b/tests/introspective-cputime.c index 7ebf041..dd76d67 100644 --- a/tests/introspective-cputime.c +++ b/tests/introspective-cputime.c @@ -18,7 +18,7 @@ * . * *************************************************************************/ -#include "../src/sandglass_impl.h" +#include "../src/sandglass-impl.h" #include "../src/sandglass.h" #include #include diff --git a/tests/introspective-system.c b/tests/introspective-system.c index 8ed6441..3ebc007 100644 --- a/tests/introspective-system.c +++ b/tests/introspective-system.c @@ -18,7 +18,7 @@ * . * *************************************************************************/ -#include "../src/sandglass_impl.h" +#include "../src/sandglass-impl.h" #include "../src/sandglass.h" #include #include diff --git a/tests/monotonic-cputime.c b/tests/monotonic-cputime.c index 3f59a3f..3e30dd8 100644 --- a/tests/monotonic-cputime.c +++ b/tests/monotonic-cputime.c @@ -18,7 +18,7 @@ * . * *************************************************************************/ -#include "../src/sandglass_impl.h" +#include "../src/sandglass-impl.h" #include "../src/sandglass.h" #include #include diff --git a/tests/monotonic-realticks.c b/tests/monotonic-realticks.c index 1e48ca5..e6fbcee 100644 --- a/tests/monotonic-realticks.c +++ b/tests/monotonic-realticks.c @@ -18,7 +18,7 @@ * . * *************************************************************************/ -#include "../src/sandglass_impl.h" +#include "../src/sandglass-impl.h" #include "../src/sandglass.h" #include #include diff --git a/tests/monotonic-system.c b/tests/monotonic-system.c index 1fb1c1c..6216fdb 100644 --- a/tests/monotonic-system.c +++ b/tests/monotonic-system.c @@ -18,7 +18,7 @@ * . * *************************************************************************/ -#include "../src/sandglass_impl.h" +#include "../src/sandglass-impl.h" #include "../src/sandglass.h" #include #include diff --git a/tests/noprecache.c b/tests/noprecache.c index 937b0a1..9762250 100644 --- a/tests/noprecache.c +++ b/tests/noprecache.c @@ -18,7 +18,7 @@ * . * *************************************************************************/ -#include "../src/sandglass_impl.h" +#include "../src/sandglass-impl.h" #include "../src/sandglass.h" #include #include -- cgit v1.2.3