From bb4e4543dbd9ffbc18e1ac7e803780b4401d55f0 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Tue, 22 Oct 2013 15:36:04 +0200 Subject: [PATCH] build: remove shl_timer.h This helper is now unused, remove it. Signed-off-by: David Herrmann --- Makefile.am | 1 - src/shl_timer.h | 130 -------------------------------------------------------- 2 files changed, 131 deletions(-) delete mode 100644 src/shl_timer.h diff --git a/Makefile.am b/Makefile.am index d5bc322..f1e872b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -98,7 +98,6 @@ libshl_la_SOURCES = \ src/shl_hashtable.h \ external/htable.h \ external/htable.c \ - src/shl_timer.h \ src/shl_llog.h \ src/shl_misc.h libshl_la_CPPFLAGS = $(AM_CPPFLAGS) diff --git a/src/shl_timer.h b/src/shl_timer.h deleted file mode 100644 index 177a383..0000000 --- a/src/shl_timer.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * shl - Timers - * - * Copyright (c) 2011-2013 David Herrmann - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files - * (the "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * Timers - */ - -#ifndef SHL_TIMER_H -#define SHL_TIMER_H - -#include -#include -#include -#include -#include - -struct shl_timer { - struct timespec start; - uint64_t elapsed; -}; - -static inline void shl_timer_reset(struct shl_timer *timer) -{ - if (!timer) - return; - - clock_gettime(CLOCK_MONOTONIC, &timer->start); - timer->elapsed = 0; -} - -static inline int shl_timer_new(struct shl_timer **out) -{ - struct shl_timer *timer; - - if (!out) - return -EINVAL; - - timer = malloc(sizeof(*timer)); - if (!timer) - return -ENOMEM; - memset(timer, 0, sizeof(*timer)); - shl_timer_reset(timer); - - *out = timer; - return 0; -} - -static inline void shl_timer_free(struct shl_timer *timer) -{ - if (!timer) - return; - - free(timer); -} - -static inline void shl_timer_start(struct shl_timer *timer) -{ - if (!timer) - return; - - clock_gettime(CLOCK_MONOTONIC, &timer->start); -} - -static inline uint64_t shl_timer_stop(struct shl_timer *timer) -{ - struct timespec spec; - int64_t off, nsec; - - if (!timer) - return 0; - - clock_gettime(CLOCK_MONOTONIC, &spec); - off = spec.tv_sec - timer->start.tv_sec; - nsec = spec.tv_nsec - timer->start.tv_nsec; - if (nsec < 0) { - --off; - nsec += 1000000000ULL; - } - off *= 1000000; - off += nsec / 1000; - - memcpy(&timer->start, &spec, sizeof(spec)); - timer->elapsed += off; - return timer->elapsed; -} - -static inline uint64_t shl_timer_elapsed(struct shl_timer *timer) -{ - struct timespec spec; - int64_t off, nsec; - - if (!timer) - return 0; - - clock_gettime(CLOCK_MONOTONIC, &spec); - off = spec.tv_sec - timer->start.tv_sec; - nsec = spec.tv_nsec - timer->start.tv_nsec; - if (nsec < 0) { - --off; - nsec += 1000000000ULL; - } - off *= 1000000; - off += nsec / 1000; - - return timer->elapsed + off; -} - -#endif /* SHL_TIMER_H */ -- 2.7.4