diff options
author | John-Mark Bell <jmb@netsurf-browser.org> | 2022-06-02 23:33:20 +0100 |
---|---|---|
committer | John-Mark Bell <jmb@netsurf-browser.org> | 2022-06-02 23:33:20 +0100 |
commit | 294770f746d4bf95d04d8dce39ed05a03b2b0b29 (patch) | |
tree | 243991faf3b56d71c5631680deeb710d5d4a8120 /src | |
parent | a25da61adc32f94cd304d6465cb1423723b31564 (diff) | |
download | librufl-294770f746d4bf95d04d8dce39ed05a03b2b0b29.tar.gz librufl-294770f746d4bf95d04d8dce39ed05a03b2b0b29.tar.bz2 |
Modernize logging
Ensure that only one copy of the storage for the log state is
needed (previously, it injected these into every compilation unit,
which now results in compiler warnings).
Replace __PRETTY_FUNCTION__ with the standardised __func__. The
output is the same in either case in our usage here (and testing
all the way back to GCC 3.4.6 yields no difference in output).
This also fixes compilation with GCC 10 (which warns about the
use of __PRETTY_FUNCTION__ in -pedantic mode).
Diffstat (limited to 'src')
-rw-r--r-- | src/rufl_init.c | 4 | ||||
-rw-r--r-- | src/rufl_internal.h | 18 |
2 files changed, 12 insertions, 10 deletions
diff --git a/src/rufl_init.c b/src/rufl_init.c index 6c06a8f..a4fe618 100644 --- a/src/rufl_init.c +++ b/src/rufl_init.c @@ -45,6 +45,10 @@ bool rufl_old_font_manager = false; static bool rufl_broken_font_enumerate_characters = false; wimp_w rufl_status_w = 0; char rufl_status_buffer[80]; +#if 1 /* ndef NDEBUG */ +bool rufl_log_got_start_time; +time_t rufl_log_start_time; +#endif /** An entry in rufl_weight_table. */ struct rufl_weight_table_entry { diff --git a/src/rufl_internal.h b/src/rufl_internal.h index 8438bd8..42ed5c4 100644 --- a/src/rufl_internal.h +++ b/src/rufl_internal.h @@ -250,22 +250,20 @@ extern const size_t rufl_glyph_map_size; #if 1 /*ndef NDEBUG*/ -#ifdef __CC_NORCROFT -#define __PRETTY_FUNCTION__ __func__ -#endif #include <time.h> -bool log_got_start_time; -time_t log_start_time; +extern bool rufl_log_got_start_time; +extern time_t rufl_log_start_time; #define LOG(format, ...) \ do { \ - if (log_got_start_time == false) { \ - log_start_time = time(NULL); \ - log_got_start_time = true; \ + if (rufl_log_got_start_time == false) { \ + rufl_log_start_time = time(NULL); \ + rufl_log_got_start_time = true; \ } \ \ fprintf(stderr,"(%.6fs) " __FILE__ " %s %i: ", \ - difftime(time(NULL), log_start_time), \ - __PRETTY_FUNCTION__, __LINE__); \ + difftime(time(NULL), \ + rufl_log_start_time), \ + __func__, __LINE__); \ fprintf(stderr, format, __VA_ARGS__); \ fprintf(stderr, "\n"); \ } while (0) |