cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomidnl * how large time_t values does gmtime() accept?
cca227d2929386ee11e4aa23464681ef35eb9679Aki TuomiAC_DEFUN([DOVECOT_GMTIME_MAX], [
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi AC_CACHE_CHECK([how large time_t values gmtime() accepts],i_cv_gmtime_max_time_t,[
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi AC_RUN_IFELSE([AC_LANG_SOURCE([[
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi int main() {
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi for (bits = 1; bits < sizeof(time_t)*8; bits++) {
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi time_t t = ((time_t)1 << bits) - 1;
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi if (gmtime(&t) == NULL) {
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi if (bits > 40) {
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi /* Solaris 9 breaks after 55 bits. Perhaps other systems break earlier.
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi Let's just do the same as Cyrus folks and limit it to 40 bits. */
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi f = fopen("conftest.temp", "w");
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi if (f == NULL) {
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi perror("fopen()");
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi fprintf(f, "%d", bits);
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi i_cv_gmtime_max_time_t=`cat conftest.temp`
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi printf "check failed, assuming "
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi i_cv_gmtime_max_time_t=31
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi AC_DEFINE_UNQUOTED(TIME_T_MAX_BITS, $i_cv_gmtime_max_time_t, [max. time_t bits gmtime() can handle])