From 93c553c1bcb02a1f3d7a8b9f95ae4a6452b241af Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sun, 16 Sep 2012 17:08:21 +0200 Subject: [PATCH] shl: move timer to shl_timer_* This moves the timers to SHL and removes the old static_misc header and source. They are no longer needed. Signed-off-by: David Herrmann --- Makefile.am | 7 ++--- src/console.c | 22 ++++++++-------- src/main.c | 1 - src/{static_misc.c => shl_timer.h} | 49 ++++++++++++++++++----------------- src/static_misc.h | 53 -------------------------------------- src/terminal.c | 1 - src/text.c | 1 - src/text_bblit.c | 1 - src/text_bbulk.c | 1 - src/text_font.c | 1 - src/text_font_freetype2.c | 1 - src/text_font_pango.c | 1 - src/text_gltex.c | 1 - src/ui.c | 1 - src/unicode.c | 1 - src/uterm_input.c | 2 +- src/uterm_input.h | 1 - src/uterm_monitor.c | 1 - src/uterm_video.c | 2 +- src/uterm_video.h | 2 +- src/uterm_video_drm.c | 1 - src/uterm_video_dumb.c | 1 - src/uterm_video_fbdev.c | 1 - src/uterm_vt.c | 1 - 24 files changed, 43 insertions(+), 111 deletions(-) rename src/{static_misc.c => shl_timer.h} (79%) delete mode 100644 src/static_misc.h diff --git a/Makefile.am b/Makefile.am index 1be31b1..ebf4407 100644 --- a/Makefile.am +++ b/Makefile.am @@ -89,6 +89,8 @@ SHL_HASHTABLE = \ external/htable.c SHL_RING = \ src/shl_ring.h +SHL_TIMER = \ + src/shl_timer.h # # libeloop @@ -260,6 +262,7 @@ libkmscon_core_la_SOURCES = \ $(SHL_ARRAY) \ $(SHL_HASHTABLE) \ $(SHL_RING) \ + $(SHL_TIMER) \ src/main.h \ src/conf.c src/conf.h \ src/ui.c src/ui.h \ @@ -335,9 +338,7 @@ libkmscon_core_la_LIBADD = \ libkmscon_static_la_SOURCES = \ src/static_llog.h \ - src/static_hook.h \ - src/static_misc.h \ - src/static_misc.c + src/static_hook.h nodist_libkmscon_static_la_SOURCES = libkmscon_static_la_CPPFLAGS = \ diff --git a/src/console.c b/src/console.c index 90810f2..7cb8338 100644 --- a/src/console.c +++ b/src/console.c @@ -38,7 +38,7 @@ #include "console.h" #include "log.h" #include "main.h" -#include "static_misc.h" +#include "shl_timer.h" #include "unicode.h" #define LOG_SUBSYSTEM "console" @@ -59,7 +59,7 @@ struct line { struct kmscon_console { size_t ref; unsigned int flags; - struct kmscon_timer *timer; + struct shl_timer *timer; /* default attributes for new cells */ struct kmscon_console_attr def_attr; @@ -404,7 +404,7 @@ int kmscon_console_new(struct kmscon_console **out) con->def_attr.fg = 255; con->def_attr.fb = 255; - ret = kmscon_timer_new(&con->timer); + ret = shl_timer_new(&con->timer); if (ret) goto err_free; @@ -418,7 +418,7 @@ int kmscon_console_new(struct kmscon_console **out) return 0; err_timer: - kmscon_timer_free(con->timer); + shl_timer_free(con->timer); for (i = 0; i < con->line_num; ++i) line_free(con->lines[i]); free(con->lines); @@ -449,7 +449,7 @@ void kmscon_console_unref(struct kmscon_console *con) line_free(con->lines[i]); free(con->lines); free(con->tab_ruler); - kmscon_timer_free(con->timer); + shl_timer_free(con->timer); free(con); } @@ -1270,7 +1270,7 @@ void kmscon_console_draw(struct kmscon_console *con, if (prepare_cb) { if (kmscon_conf.render_timing) - kmscon_timer_reset(con->timer); + shl_timer_reset(con->timer); ret = prepare_cb(con, data); if (ret) { @@ -1279,7 +1279,7 @@ void kmscon_console_draw(struct kmscon_console *con, } if (kmscon_conf.render_timing) - time_prep = kmscon_timer_elapsed(con->timer); + time_prep = shl_timer_elapsed(con->timer); } else { time_prep = 0; } @@ -1287,7 +1287,7 @@ void kmscon_console_draw(struct kmscon_console *con, /* push each character into rendering pipeline */ if (kmscon_conf.render_timing) - kmscon_timer_reset(con->timer); + shl_timer_reset(con->timer); iter = con->sb_pos; k = 0; @@ -1338,20 +1338,20 @@ void kmscon_console_draw(struct kmscon_console *con, } if (kmscon_conf.render_timing) - time_draw = kmscon_timer_elapsed(con->timer); + time_draw = shl_timer_elapsed(con->timer); /* perform final rendering steps */ if (render_cb) { if (kmscon_conf.render_timing) - kmscon_timer_reset(con->timer); + shl_timer_reset(con->timer); ret = render_cb(con, data); if (ret) log_warning("cannot render via text-renderer"); if (kmscon_conf.render_timing) - time_rend = kmscon_timer_elapsed(con->timer); + time_rend = shl_timer_elapsed(con->timer); } else { time_rend = 0; } diff --git a/src/main.c b/src/main.c index 9f4de6d..048ff41 100644 --- a/src/main.c +++ b/src/main.c @@ -36,7 +36,6 @@ #include "log.h" #include "main.h" #include "shl_dlist.h" -#include "static_misc.h" #include "text.h" #include "ui.h" #include "uterm.h" diff --git a/src/static_misc.c b/src/shl_timer.h similarity index 79% rename from src/static_misc.c rename to src/shl_timer.h index 928e81b..8df17b6 100644 --- a/src/static_misc.c +++ b/src/shl_timer.h @@ -1,5 +1,5 @@ /* - * kmscon - Miscellaneous Helpers + * shl - Timers * * Copyright (c) 2011-2012 David Herrmann * Copyright (c) 2011 University of Tuebingen @@ -25,28 +25,36 @@ */ /* - * Miscellaneous Helpers - * Rings: Rings are used to buffer a byte-stream of data. It works like a FIFO - * queue but in-memory. + * Timers */ +#ifndef SHL_TIMER_H +#define SHL_TIMER_H + #include #include +#include #include #include -#include #include -#include "htable.h" -#include "static_misc.h" -struct kmscon_timer { +struct shl_timer { struct timespec start; uint64_t elapsed; }; -int kmscon_timer_new(struct kmscon_timer **out) +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 kmscon_timer *timer; + struct shl_timer *timer; if (!out) return -EINVAL; @@ -55,13 +63,13 @@ int kmscon_timer_new(struct kmscon_timer **out) if (!timer) return -ENOMEM; memset(timer, 0, sizeof(*timer)); - kmscon_timer_reset(timer); + shl_timer_reset(timer); *out = timer; return 0; } -void kmscon_timer_free(struct kmscon_timer *timer) +static inline void shl_timer_free(struct shl_timer *timer) { if (!timer) return; @@ -69,24 +77,15 @@ void kmscon_timer_free(struct kmscon_timer *timer) free(timer); } -void kmscon_timer_reset(struct kmscon_timer *timer) +static inline void shl_timer_start(struct shl_timer *timer) { if (!timer) return; clock_gettime(CLOCK_MONOTONIC, &timer->start); - timer->elapsed = 0; } -void kmscon_timer_start(struct kmscon_timer *timer) -{ - if (!timer) - return; - - clock_gettime(CLOCK_MONOTONIC, &timer->start); -} - -uint64_t kmscon_timer_stop(struct kmscon_timer *timer) +static inline uint64_t shl_timer_stop(struct shl_timer *timer) { struct timespec spec; int64_t off, nsec; @@ -109,7 +108,7 @@ uint64_t kmscon_timer_stop(struct kmscon_timer *timer) return timer->elapsed; } -uint64_t kmscon_timer_elapsed(struct kmscon_timer *timer) +static inline uint64_t shl_timer_elapsed(struct shl_timer *timer) { struct timespec spec; int64_t off, nsec; @@ -129,3 +128,5 @@ uint64_t kmscon_timer_elapsed(struct kmscon_timer *timer) return timer->elapsed + off; } + +#endif /* SHL_TIMER_H */ diff --git a/src/static_misc.h b/src/static_misc.h deleted file mode 100644 index 9332a87..0000000 --- a/src/static_misc.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * kmscon - Miscellaneous Helpers - * - * Copyright (c) 2011-2012 David Herrmann - * Copyright (c) 2011 University of Tuebingen - * - * 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. - */ - -/* - * Miscellaneous Helpers - * This provides several helper objects like memory-rings or similar. - */ - -#ifndef KMSCON_MISC_H -#define KMSCON_MISC_H - -#include -#include -#include -#include -#include "static_hook.h" - -/* time measurement */ - -struct kmscon_timer; - -int kmscon_timer_new(struct kmscon_timer **out); -void kmscon_timer_free(struct kmscon_timer *timer); - -void kmscon_timer_reset(struct kmscon_timer *timer); -void kmscon_timer_start(struct kmscon_timer *timer); -uint64_t kmscon_timer_stop(struct kmscon_timer *timer); -uint64_t kmscon_timer_elapsed(struct kmscon_timer *timer); - -#endif /* KMSCON_MISC_H */ diff --git a/src/terminal.c b/src/terminal.c index c0218c7..52311f8 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -39,7 +39,6 @@ #include "main.h" #include "pty.h" #include "shl_dlist.h" -#include "static_misc.h" #include "terminal.h" #include "text.h" #include "unicode.h" diff --git a/src/text.c b/src/text.c index e831c6e..fa1c301 100644 --- a/src/text.c +++ b/src/text.c @@ -37,7 +37,6 @@ #include #include "log.h" #include "shl_dlist.h" -#include "static_misc.h" #include "text.h" #include "uterm.h" diff --git a/src/text_bblit.c b/src/text_bblit.c index 35b2c63..211cf9b 100644 --- a/src/text_bblit.c +++ b/src/text_bblit.c @@ -37,7 +37,6 @@ #include #include #include "log.h" -#include "static_misc.h" #include "text.h" #include "unicode.h" #include "uterm.h" diff --git a/src/text_bbulk.c b/src/text_bbulk.c index dd6954d..47a4636 100644 --- a/src/text_bbulk.c +++ b/src/text_bbulk.c @@ -37,7 +37,6 @@ #include #include #include "log.h" -#include "static_misc.h" #include "text.h" #include "unicode.h" #include "uterm.h" diff --git a/src/text_font.c b/src/text_font.c index 9d15f59..bff6ee3 100644 --- a/src/text_font.c +++ b/src/text_font.c @@ -58,7 +58,6 @@ #include #include "log.h" #include "shl_dlist.h" -#include "static_misc.h" #include "text.h" #include "uterm.h" diff --git a/src/text_font_freetype2.c b/src/text_font_freetype2.c index aa6c9eb..0c78e5d 100644 --- a/src/text_font_freetype2.c +++ b/src/text_font_freetype2.c @@ -47,7 +47,6 @@ #include "log.h" #include "shl_dlist.h" #include "shl_hashtable.h" -#include "static_misc.h" #include "text.h" #include "unicode.h" #include "uterm.h" diff --git a/src/text_font_pango.c b/src/text_font_pango.c index 75630a6..125db86 100644 --- a/src/text_font_pango.c +++ b/src/text_font_pango.c @@ -54,7 +54,6 @@ #include "log.h" #include "shl_dlist.h" #include "shl_hashtable.h" -#include "static_misc.h" #include "text.h" #include "unicode.h" #include "uterm.h" diff --git a/src/text_gltex.c b/src/text_gltex.c index 004e945..90f1102 100644 --- a/src/text_gltex.c +++ b/src/text_gltex.c @@ -49,7 +49,6 @@ #include "shl_dlist.h" #include "shl_hashtable.h" #include "static_gl.h" -#include "static_misc.h" #include "text.h" #include "unicode.h" #include "uterm.h" diff --git a/src/ui.c b/src/ui.c index 41c7b2d..972e4ef 100644 --- a/src/ui.c +++ b/src/ui.c @@ -34,7 +34,6 @@ #include "eloop.h" #include "log.h" #include "shl_dlist.h" -#include "static_misc.h" #include "terminal.h" #include "ui.h" #include "uterm.h" diff --git a/src/unicode.c b/src/unicode.c index d0077e5..464b7a5 100644 --- a/src/unicode.c +++ b/src/unicode.c @@ -62,7 +62,6 @@ #include "log.h" #include "shl_array.h" #include "shl_hashtable.h" -#include "static_misc.h" #include "unicode.h" #define LOG_SUBSYSTEM "unicode" diff --git a/src/uterm_input.c b/src/uterm_input.c index 2a55318..c5e6f1e 100644 --- a/src/uterm_input.c +++ b/src/uterm_input.c @@ -39,7 +39,7 @@ #include "eloop.h" #include "log.h" #include "shl_dlist.h" -#include "static_misc.h" +#include "static_hook.h" #include "uterm.h" #include "uterm_input.h" diff --git a/src/uterm_input.h b/src/uterm_input.h index b5cd2df..16061b8 100644 --- a/src/uterm_input.h +++ b/src/uterm_input.h @@ -33,7 +33,6 @@ #include #include #include "eloop.h" -#include "static_misc.h" #include "uterm.h" struct kbd_desc; diff --git a/src/uterm_monitor.c b/src/uterm_monitor.c index 2176dec..7a8789c 100644 --- a/src/uterm_monitor.c +++ b/src/uterm_monitor.c @@ -39,7 +39,6 @@ #include #include "log.h" #include "shl_dlist.h" -#include "static_misc.h" #include "uterm.h" #ifdef UTERM_HAVE_SYSTEMD diff --git a/src/uterm_video.c b/src/uterm_video.c index 24c5b4f..33c32c6 100644 --- a/src/uterm_video.c +++ b/src/uterm_video.c @@ -37,7 +37,7 @@ #include #include "eloop.h" #include "log.h" -#include "static_misc.h" +#include "static_hook.h" #include "uterm.h" #include "uterm_video.h" diff --git a/src/uterm_video.h b/src/uterm_video.h index 16a89df..e666852 100644 --- a/src/uterm_video.h +++ b/src/uterm_video.h @@ -33,7 +33,7 @@ #include #include #include "eloop.h" -#include "static_misc.h" +#include "static_hook.h" #include "uterm.h" /* backend-operations */ diff --git a/src/uterm_video_drm.c b/src/uterm_video_drm.c index eb367ab..1259145 100644 --- a/src/uterm_video_drm.c +++ b/src/uterm_video_drm.c @@ -46,7 +46,6 @@ #include #include "eloop.h" #include "log.h" -#include "static_misc.h" #include "uterm.h" #include "uterm_video.h" diff --git a/src/uterm_video_dumb.c b/src/uterm_video_dumb.c index f60db13..c3c4506 100644 --- a/src/uterm_video_dumb.c +++ b/src/uterm_video_dumb.c @@ -39,7 +39,6 @@ #include #include "eloop.h" #include "log.h" -#include "static_misc.h" #include "uterm.h" #include "uterm_video.h" diff --git a/src/uterm_video_fbdev.c b/src/uterm_video_fbdev.c index 864a787..b6263d4 100644 --- a/src/uterm_video_fbdev.c +++ b/src/uterm_video_fbdev.c @@ -37,7 +37,6 @@ #include #include #include "log.h" -#include "static_misc.h" #include "uterm.h" #include "uterm_video.h" diff --git a/src/uterm_vt.c b/src/uterm_vt.c index a0e4a2c..27947f0 100644 --- a/src/uterm_vt.c +++ b/src/uterm_vt.c @@ -43,7 +43,6 @@ #include "eloop.h" #include "log.h" #include "shl_dlist.h" -#include "static_misc.h" #include "uterm.h" #define LOG_SUBSYSTEM "vt" -- 2.7.4