From 0a112c3f0964e4be0bab7148538656173768c3b7 Mon Sep 17 00:00:00 2001 From: Mitya Selivanov Date: Fri, 8 Sep 2023 21:34:37 +0200 Subject: Refactor kit_test to header-only library --- source/kit_test/shared.inl.h | 80 -------------------------------------------- 1 file changed, 80 deletions(-) delete mode 100644 source/kit_test/shared.inl.h (limited to 'source/kit_test/shared.inl.h') diff --git a/source/kit_test/shared.inl.h b/source/kit_test/shared.inl.h deleted file mode 100644 index 11b42bb..0000000 --- a/source/kit_test/shared.inl.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef KIT_TEST_SHARED_INL_H -#define KIT_TEST_SHARED_INL_H - -// kit/time.h -// -#ifndef KIT_TIME_H -# define KIT_TIME_H - -# ifndef _GNU_SOURCE -# define _GNU_SOURCE -# endif - -# include - -# ifndef TIME_UTC -# define TIME_UTC 1 -# endif - -# ifdef __MINGW32__ -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN 1 -# endif -# include - -# define KIT_TIMESPEC_IMPL_UNIX_EPOCH_IN_TICKS \ - 116444736000000000ull -# define KIT_TIMESPEC_IMPL_TICKS_PER_SECONDS 10000000ull - -static int timespec_get(struct timespec *ts, int base) { - if (ts == NULL || base != TIME_UTC) - return 0; - - FILETIME ft; - ULARGE_INTEGER date; - LONGLONG ticks; - - GetSystemTimeAsFileTime(&ft); - date.HighPart = ft.dwHighDateTime; - date.LowPart = ft.dwLowDateTime; - ticks = (LONGLONG) (date.QuadPart - - KIT_TIMESPEC_IMPL_UNIX_EPOCH_IN_TICKS); - ts->tv_sec = ticks / KIT_TIMESPEC_IMPL_TICKS_PER_SECONDS; - ts->tv_nsec = (ticks % KIT_TIMESPEC_IMPL_TICKS_PER_SECONDS) * 100; - - return base; -} -# endif - -#endif // kit/time.h - -#include -#include -#include -#include -#include - -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]); -} - -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" -}; - -#endif -- cgit v1.2.3