mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Compile debugging code for time always
This commit is contained in:
parent
ef59a781d7
commit
4b6347ab39
Notes:
git
2021-02-10 19:45:35 +09:00
1 changed files with 26 additions and 14 deletions
40
time.c
40
time.c
|
@ -2998,24 +2998,35 @@ timegm_noleapsecond(struct tm *tm)
|
||||||
#define DEBUG_GUESSRANGE
|
#define DEBUG_GUESSRANGE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static const bool debug_guessrange =
|
||||||
#ifdef DEBUG_GUESSRANGE
|
#ifdef DEBUG_GUESSRANGE
|
||||||
#define DEBUG_REPORT_GUESSRANGE fprintf(stderr, "find time guess range: %ld - %ld : %"PRI_TIMET_PREFIX"u\n", guess_lo, guess_hi, (unsigned_time_t)(guess_hi-guess_lo))
|
true;
|
||||||
#else
|
#else
|
||||||
#define DEBUG_REPORT_GUESSRANGE
|
false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define DEBUG_REPORT_GUESSRANGE (void)\
|
||||||
|
(debug_guessrange ? \
|
||||||
|
fprintf(stderr, "find time guess range: %ld - %ld : %"PRI_TIMET_PREFIX"u\n", \
|
||||||
|
guess_lo, guess_hi, (unsigned_time_t)(guess_hi-guess_lo)) : 0)
|
||||||
|
|
||||||
|
static const bool debug_find_time_numguess =
|
||||||
#ifdef DEBUG_FIND_TIME_NUMGUESS
|
#ifdef DEBUG_FIND_TIME_NUMGUESS
|
||||||
#define DEBUG_FIND_TIME_NUMGUESS_INC find_time_numguess++,
|
true;
|
||||||
|
#else
|
||||||
|
false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DEBUG_FIND_TIME_NUMGUESS_INC \
|
||||||
|
(void)(debug_find_time_numguess && find_time_numguess++),
|
||||||
static unsigned long long find_time_numguess;
|
static unsigned long long find_time_numguess;
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
find_time_numguess_getter(ID name, VALUE *data)
|
find_time_numguess_getter(ID name, VALUE *data)
|
||||||
{
|
{
|
||||||
return ULL2NUM(find_time_numguess);
|
unsigned long long *numguess = (void *)data;
|
||||||
|
return ULL2NUM(*numguess);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
#define DEBUG_FIND_TIME_NUMGUESS_INC
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
find_time_t(struct tm *tptr, int utc_p, time_t *tp)
|
find_time_t(struct tm *tptr, int utc_p, time_t *tp)
|
||||||
|
@ -3163,10 +3174,10 @@ find_time_t(struct tm *tptr, int utc_p, time_t *tp)
|
||||||
}
|
}
|
||||||
if (guess <= guess_lo || guess_hi <= guess) {
|
if (guess <= guess_lo || guess_hi <= guess) {
|
||||||
/* Previous guess is invalid. try binary search. */
|
/* Previous guess is invalid. try binary search. */
|
||||||
#ifdef DEBUG_GUESSRANGE
|
if (debug_guessrange) {
|
||||||
if (guess <= guess_lo) fprintf(stderr, "too small guess: %ld <= %ld\n", guess, guess_lo);
|
if (guess <= guess_lo) fprintf(stderr, "too small guess: %ld <= %ld\n", guess, guess_lo);
|
||||||
if (guess_hi <= guess) fprintf(stderr, "too big guess: %ld <= %ld\n", guess_hi, guess);
|
if (guess_hi <= guess) fprintf(stderr, "too big guess: %ld <= %ld\n", guess_hi, guess);
|
||||||
#endif
|
}
|
||||||
status = 0;
|
status = 0;
|
||||||
goto binsearch;
|
goto binsearch;
|
||||||
}
|
}
|
||||||
|
@ -5808,9 +5819,10 @@ Init_Time(void)
|
||||||
rb_define_private_method(rb_cTime, "marshal_load", time_mload, 1);
|
rb_define_private_method(rb_cTime, "marshal_load", time_mload, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG_FIND_TIME_NUMGUESS
|
if (debug_find_time_numguess) {
|
||||||
rb_define_virtual_variable("$find_time_numguess", find_time_numguess_getter, NULL);
|
rb_define_hooked_variable("$find_time_numguess", (VALUE *)&find_time_numguess,
|
||||||
#endif
|
find_time_numguess_getter, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
rb_cTimeTM = Init_tm(rb_cTime, "tm");
|
rb_cTimeTM = Init_tm(rb_cTime, "tm");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue