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 <dh.herrmann@googlemail.com>
This commit is contained in:
parent
04e3bcc652
commit
93c553c1bc
@ -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 = \
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
@ -25,51 +25,25 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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)
|
||||
{
|
||||
struct kmscon_timer *timer;
|
||||
|
||||
if (!out)
|
||||
return -EINVAL;
|
||||
|
||||
timer = malloc(sizeof(*timer));
|
||||
if (!timer)
|
||||
return -ENOMEM;
|
||||
memset(timer, 0, sizeof(*timer));
|
||||
kmscon_timer_reset(timer);
|
||||
|
||||
*out = timer;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void kmscon_timer_free(struct kmscon_timer *timer)
|
||||
{
|
||||
if (!timer)
|
||||
return;
|
||||
|
||||
free(timer);
|
||||
}
|
||||
|
||||
void kmscon_timer_reset(struct kmscon_timer *timer)
|
||||
static inline void shl_timer_reset(struct shl_timer *timer)
|
||||
{
|
||||
if (!timer)
|
||||
return;
|
||||
@ -78,7 +52,32 @@ void kmscon_timer_reset(struct kmscon_timer *timer)
|
||||
timer->elapsed = 0;
|
||||
}
|
||||
|
||||
void kmscon_timer_start(struct kmscon_timer *timer)
|
||||
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;
|
||||
@ -86,7 +85,7 @@ void kmscon_timer_start(struct kmscon_timer *timer)
|
||||
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 */
|
@ -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 */
|
@ -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"
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include <string.h>
|
||||
#include "log.h"
|
||||
#include "shl_dlist.h"
|
||||
#include "static_misc.h"
|
||||
#include "text.h"
|
||||
#include "uterm.h"
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -58,7 +58,6 @@
|
||||
#include <string.h>
|
||||
#include "log.h"
|
||||
#include "shl_dlist.h"
|
||||
#include "static_misc.h"
|
||||
#include "text.h"
|
||||
#include "uterm.h"
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
1
src/ui.c
1
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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include "eloop.h"
|
||||
#include "static_misc.h"
|
||||
#include "uterm.h"
|
||||
|
||||
struct kbd_desc;
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -46,7 +46,6 @@
|
||||
#include <xf86drmMode.h>
|
||||
#include "eloop.h"
|
||||
#include "log.h"
|
||||
#include "static_misc.h"
|
||||
#include "uterm.h"
|
||||
#include "uterm_video.h"
|
||||
|
||||
|
@ -39,7 +39,6 @@
|
||||
#include <xf86drmMode.h>
|
||||
#include "eloop.h"
|
||||
#include "log.h"
|
||||
#include "static_misc.h"
|
||||
#include "uterm.h"
|
||||
#include "uterm_video.h"
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user