shl: move timer to shl_timer_*
authorDavid Herrmann <dh.herrmann@googlemail.com>
Sun, 16 Sep 2012 15:08:21 +0000 (17:08 +0200)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Sun, 16 Sep 2012 15:08:21 +0000 (17:08 +0200)
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 <dh.herrmann@googlemail.com>
24 files changed:
Makefile.am
src/console.c
src/main.c
src/shl_timer.h [moved from src/static_misc.c with 79% similarity]
src/static_misc.h [deleted file]
src/terminal.c
src/text.c
src/text_bblit.c
src/text_bbulk.c
src/text_font.c
src/text_font_freetype2.c
src/text_font_pango.c
src/text_gltex.c
src/ui.c
src/unicode.c
src/uterm_input.c
src/uterm_input.h
src/uterm_monitor.c
src/uterm_video.c
src/uterm_video.h
src/uterm_video_drm.c
src/uterm_video_dumb.c
src/uterm_video_fbdev.c
src/uterm_vt.c

index 1be31b1..ebf4407 100644 (file)
@@ -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 = \
index 90810f2..7cb8338 100644 (file)
@@ -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;
        }
index 9f4de6d..048ff41 100644 (file)
@@ -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"
similarity index 79%
rename from src/static_misc.c
rename to src/shl_timer.h
index 928e81b..8df17b6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * kmscon - Miscellaneous Helpers
+ * shl - Timers
  *
  * Copyright (c) 2011-2012 David Herrmann <dh.herrmann@googlemail.com>
  * Copyright (c) 2011 University of Tuebingen
  */
 
 /*
- * 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 <errno.h>
 #include <stdbool.h>
+#include <stddef.h>
 #include <stdint.h>
 #include <stdlib.h>
-#include <string.h>
 #include <time.h>
-#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 (file)
index 9332a87..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * kmscon - Miscellaneous Helpers
- *
- * Copyright (c) 2011-2012 David Herrmann <dh.herrmann@googlemail.com>
- * 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 <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <stdlib.h>
-#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 */
index c0218c7..52311f8 100644 (file)
@@ -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"
index e831c6e..fa1c301 100644 (file)
@@ -37,7 +37,6 @@
 #include <string.h>
 #include "log.h"
 #include "shl_dlist.h"
-#include "static_misc.h"
 #include "text.h"
 #include "uterm.h"
 
index 35b2c63..211cf9b 100644 (file)
@@ -37,7 +37,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include "log.h"
-#include "static_misc.h"
 #include "text.h"
 #include "unicode.h"
 #include "uterm.h"
index dd6954d..47a4636 100644 (file)
@@ -37,7 +37,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include "log.h"
-#include "static_misc.h"
 #include "text.h"
 #include "unicode.h"
 #include "uterm.h"
index 9d15f59..bff6ee3 100644 (file)
@@ -58,7 +58,6 @@
 #include <string.h>
 #include "log.h"
 #include "shl_dlist.h"
-#include "static_misc.h"
 #include "text.h"
 #include "uterm.h"
 
index aa6c9eb..0c78e5d 100644 (file)
@@ -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"
index 75630a6..125db86 100644 (file)
@@ -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"
index 004e945..90f1102 100644 (file)
@@ -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"
index 41c7b2d..972e4ef 100644 (file)
--- 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"
index d0077e5..464b7a5 100644 (file)
@@ -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"
index 2a55318..c5e6f1e 100644 (file)
@@ -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"
 
index b5cd2df..16061b8 100644 (file)
@@ -33,7 +33,6 @@
 #include <stdbool.h>
 #include <stdlib.h>
 #include "eloop.h"
-#include "static_misc.h"
 #include "uterm.h"
 
 struct kbd_desc;
index 2176dec..7a8789c 100644 (file)
@@ -39,7 +39,6 @@
 #include <string.h>
 #include "log.h"
 #include "shl_dlist.h"
-#include "static_misc.h"
 #include "uterm.h"
 
 #ifdef UTERM_HAVE_SYSTEMD
index 24c5b4f..33c32c6 100644 (file)
@@ -37,7 +37,7 @@
 #include <unistd.h>
 #include "eloop.h"
 #include "log.h"
-#include "static_misc.h"
+#include "static_hook.h"
 #include "uterm.h"
 #include "uterm_video.h"
 
index 16a89df..e666852 100644 (file)
@@ -33,7 +33,7 @@
 #include <stdbool.h>
 #include <stdlib.h>
 #include "eloop.h"
-#include "static_misc.h"
+#include "static_hook.h"
 #include "uterm.h"
 
 /* backend-operations */
index eb367ab..1259145 100644 (file)
@@ -46,7 +46,6 @@
 #include <xf86drmMode.h>
 #include "eloop.h"
 #include "log.h"
-#include "static_misc.h"
 #include "uterm.h"
 #include "uterm_video.h"
 
index f60db13..c3c4506 100644 (file)
@@ -39,7 +39,6 @@
 #include <xf86drmMode.h>
 #include "eloop.h"
 #include "log.h"
-#include "static_misc.h"
 #include "uterm.h"
 #include "uterm_video.h"
 
index 864a787..b6263d4 100644 (file)
@@ -37,7 +37,6 @@
 #include <sys/mman.h>
 #include <unistd.h>
 #include "log.h"
-#include "static_misc.h"
 #include "uterm.h"
 #include "uterm_video.h"
 
index a0e4a2c..27947f0 100644 (file)
@@ -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"