diff options
Diffstat (limited to 'src/diagnostic')
-rw-r--r-- | src/diagnostic/diagnostic.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/diagnostic/diagnostic.c b/src/diagnostic/diagnostic.c index a5d7149..e7e7645 100644 --- a/src/diagnostic/diagnostic.c +++ b/src/diagnostic/diagnostic.c @@ -31,7 +31,6 @@ static const char default_format[] = "C:F:mn"; static const char valid_format[] = "CFtTn:m"; static struct iostate { - char pidconv[8]; struct timespec start; FILE *err; FILE *warn; @@ -66,14 +65,7 @@ void rin_diag_cleanup(void) void rin_diag_init(void) { - static const char convstr[8] = "%04hx:"; - clock_gettime(RIN_CLOCK_WALL_COUNTER, &state.start); - - if (sizeof(pid_t) == 4) { - memcpy(state.pidconv, convstr, sizeof(convstr)); - } - atexit(rin_diag_cleanup); } @@ -204,7 +196,13 @@ static void __rin_msg(FILE *stream, const char *prefix, const char *func_name, c fprintf(stream, "%s", func_name); break; case 't': - fprintf(stream, state.pidconv, gettid()); + /* gettid returns pid_t, which is a "signed integer type" + * there is no clean way to detect its actual size, + * so promote it to long it, if smaller and print THAT. + * So far we can semi-safely assume it is not going to be + * bigger than 8 hex digits. + */ + fprintf(stream, "%08lx", (long int) gettid()); break; case 'T': if (!gottime) { |