From 497521a2c29c0fa42f85c2986ba08ca71cb38e81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Sat, 14 Oct 2023 10:23:49 +0200 Subject: [PATCH] improve logs + docs --- demos/99-tls.c | 15 +++++++++++++++ engine/joint/v4k.h | 6 +++--- engine/split/v4k_system.h | 6 +++--- engine/v4k.h | 6 +++--- tools/docs/docs.c | 1 + 5 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 demos/99-tls.c diff --git a/demos/99-tls.c b/demos/99-tls.c new file mode 100644 index 0000000..47fab1b --- /dev/null +++ b/demos/99-tls.c @@ -0,0 +1,15 @@ +#include "v4k.h" // Minimal C sample + +__thread int foo=0; + +int worker(void *ud) { + printf("thread:%d\n", foo); + return 0; +} + +int main() { + foo=1; + printf("main:%d\n", foo); + thread_destroy(thread(worker, NULL)); + return 0; +} \ No newline at end of file diff --git a/engine/joint/v4k.h b/engine/joint/v4k.h index d238242..67b7d7d 100644 --- a/engine/joint/v4k.h +++ b/engine/joint/v4k.h @@ -17726,14 +17726,14 @@ API void trap_on_quit(int signal); // helper util API void trap_on_abort(int signal); // helper util API void trap_on_debug(int signal); // helper util -#define PANIC(...) PANIC(va(__VA_ARGS__), __FILE__, __LINE__) // die() ? +#define PANIC(...) PANIC(va(__VA_ARGS__), strrchr(__FILE__, '/')?(strrchr(__FILE__, '/')+2):__FILE__, __LINE__) // die() ? API int (PANIC)(const char *error, const char *file, int line); #if !ENABLE_RETAIL -#define PRINTF(...) PRINTF(va(__VA_ARGS__), 1[#__VA_ARGS__] == '!' ? callstack(+48) : "", __FILE__, __LINE__, __FUNCTION__) +#define PRINTF(...) PRINTF(va(__VA_ARGS__), 1[#__VA_ARGS__] == '!' ? callstack(+48) : "", strrchr(__FILE__, '/')?(strrchr(__FILE__, '/')+2):__FILE__, __LINE__, __FUNCTION__) API int (PRINTF)(const char *text, const char *stack, const char *file, int line, const char *function); -#define test(expr) test(__FILE__,__LINE__,#expr,!!(expr)) +#define test(expr) test(strrchr(__FILE__, '/')?(strrchr(__FILE__, '/')+2):__FILE__,__LINE__,#expr,!!(expr)) API int (test)(const char *file, int line, const char *expr, bool result); #else #define PRINTF(...) diff --git a/engine/split/v4k_system.h b/engine/split/v4k_system.h index 0cd30ed..e9c5753 100644 --- a/engine/split/v4k_system.h +++ b/engine/split/v4k_system.h @@ -59,14 +59,14 @@ API void trap_on_quit(int signal); // helper util API void trap_on_abort(int signal); // helper util API void trap_on_debug(int signal); // helper util -#define PANIC(...) PANIC(va(__VA_ARGS__), __FILE__, __LINE__) // die() ? +#define PANIC(...) PANIC(va(__VA_ARGS__), strrchr(__FILE__, '/')?(strrchr(__FILE__, '/')+2):__FILE__, __LINE__) // die() ? API int (PANIC)(const char *error, const char *file, int line); #if !ENABLE_RETAIL -#define PRINTF(...) PRINTF(va(__VA_ARGS__), 1[#__VA_ARGS__] == '!' ? callstack(+48) : "", __FILE__, __LINE__, __FUNCTION__) +#define PRINTF(...) PRINTF(va(__VA_ARGS__), 1[#__VA_ARGS__] == '!' ? callstack(+48) : "", strrchr(__FILE__, '/')?(strrchr(__FILE__, '/')+2):__FILE__, __LINE__, __FUNCTION__) API int (PRINTF)(const char *text, const char *stack, const char *file, int line, const char *function); -#define test(expr) test(__FILE__,__LINE__,#expr,!!(expr)) +#define test(expr) test(strrchr(__FILE__, '/')?(strrchr(__FILE__, '/')+2):__FILE__,__LINE__,#expr,!!(expr)) API int (test)(const char *file, int line, const char *expr, bool result); #else #define PRINTF(...) diff --git a/engine/v4k.h b/engine/v4k.h index 20c0359..e045064 100644 --- a/engine/v4k.h +++ b/engine/v4k.h @@ -3793,14 +3793,14 @@ API void trap_on_quit(int signal); // helper util API void trap_on_abort(int signal); // helper util API void trap_on_debug(int signal); // helper util -#define PANIC(...) PANIC(va(__VA_ARGS__), __FILE__, __LINE__) // die() ? +#define PANIC(...) PANIC(va(__VA_ARGS__), strrchr(__FILE__, '/')?(strrchr(__FILE__, '/')+2):__FILE__, __LINE__) // die() ? API int (PANIC)(const char *error, const char *file, int line); #if !ENABLE_RETAIL -#define PRINTF(...) PRINTF(va(__VA_ARGS__), 1[#__VA_ARGS__] == '!' ? callstack(+48) : "", __FILE__, __LINE__, __FUNCTION__) +#define PRINTF(...) PRINTF(va(__VA_ARGS__), 1[#__VA_ARGS__] == '!' ? callstack(+48) : "", strrchr(__FILE__, '/')?(strrchr(__FILE__, '/')+2):__FILE__, __LINE__, __FUNCTION__) API int (PRINTF)(const char *text, const char *stack, const char *file, int line, const char *function); -#define test(expr) test(__FILE__,__LINE__,#expr,!!(expr)) +#define test(expr) test(strrchr(__FILE__, '/')?(strrchr(__FILE__, '/')+2):__FILE__,__LINE__,#expr,!!(expr)) API int (test)(const char *file, int line, const char *expr, bool result); #else #define PRINTF(...) diff --git a/tools/docs/docs.c b/tools/docs/docs.c index 4d8ebeb..1634ecb 100644 --- a/tools/docs/docs.c +++ b/tools/docs/docs.c @@ -806,6 +806,7 @@ int main(int argc, char **argv) { // remove quotes if present char *p = &newfile[ newfile[0] == '\"' ]; if(strrchr(p, '\"')) *strrchr(p, '\"') = 0; + if(strrchr(p, '/')) p = strrchr(p, '/')+5; // store section = STRDUP(p); }