From 835e1fcd131c63ee2b3b647e327b33a3bfb369e3 Mon Sep 17 00:00:00 2001 From: Mitya Selivanov Date: Sat, 2 Sep 2023 20:59:29 +0200 Subject: [Linux] Change build system; Remove CMake --- source/kit_test/bench.c | 39 +++++---------------------------------- 1 file changed, 5 insertions(+), 34 deletions(-) (limited to 'source/kit_test/bench.c') diff --git a/source/kit_test/bench.c b/source/kit_test/bench.c index 9d439c3..dcf7249 100644 --- a/source/kit_test/bench.c +++ b/source/kit_test/bench.c @@ -1,12 +1,6 @@ #include "bench.h" -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include +#include "shared.inl.h" kit_benchs_list_t kit_benchs_list = { 0 }; @@ -57,17 +51,6 @@ static void bench_end(int i) { kit_benchs_list.v[i].duration_nsec[n] = sec * 1000000000 + nsec; } -enum { white, blue, light, yellow, red, green }; - -static char const *const color_codes[] = { - [white] = "\x1b[38m", [blue] = "\x1b[34m", [light] = "\x1b[37m", - [yellow] = "\x1b[33m", [red] = "\x1b[31m", [green] = "\x1b[32m" -}; - -static int print_color(int c) { - return printf("%s", color_codes[c]); -} - void kit_bench_register(char const *name, char const *file, kit_bench_run_fn fn) { int n = kit_benchs_list.size++; @@ -84,23 +67,11 @@ void kit_bench_register(char const *name, char const *file, static jmp_buf kit_bench_restore_execution; -static int const signums[] = { SIGINT, SIGILL, SIGABRT, - SIGFPE, SIGSEGV, SIGTERM }; - -static char const *const signames[] = { - [SIGINT] = "Interactive attention signal", - [SIGILL] = "Illegal instruction", - [SIGABRT] = "Abnormal termination", - [SIGFPE] = "Erroneous arithmetic operation", - [SIGSEGV] = "Invalid access to storage", - [SIGTERM] = "Termination request" -}; - -static void handle_signal(int signum) { +static void kit_bench_handle_signal(int signum) { longjmp(kit_bench_restore_execution, signum); } -static void setup_signals() { +static void kit_bench_setup_signals() { int i; for (i = 0; i < sizeof signums / sizeof *signums; i++) { @@ -110,7 +81,7 @@ static void setup_signals() { #else struct sigaction action; memset(&action, 0, sizeof action); - action.sa_handler = handle_signal; + action.sa_handler = kit_bench_handle_signal; sigaction(signums[i], &action, NULL); #endif @@ -151,7 +122,7 @@ int kit_run_benchmarks(int argc, char **argv) { char const *specific_bench = NULL; - setup_signals(); + kit_bench_setup_signals(); for (int i = 0; i < argc; i++) if (strcmp("--no-term-color", argv[i]) == 0) -- cgit v1.2.3