summaryrefslogtreecommitdiffstats
path: root/m4/gmtime_max.m4
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:51:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:51:24 +0000
commitf7548d6d28c313cf80e6f3ef89aed16a19815df1 (patch)
treea3f6f2a3f247293bee59ecd28e8cd8ceb6ca064a /m4/gmtime_max.m4
parentInitial commit. (diff)
downloaddovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.tar.xz
dovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.zip
Adding upstream version 1:2.3.19.1+dfsg1.upstream/1%2.3.19.1+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'm4/gmtime_max.m4')
-rw-r--r--m4/gmtime_max.m442
1 files changed, 42 insertions, 0 deletions
diff --git a/m4/gmtime_max.m4 b/m4/gmtime_max.m4
new file mode 100644
index 0000000..1613cb2
--- /dev/null
+++ b/m4/gmtime_max.m4
@@ -0,0 +1,42 @@
+dnl * how large time_t values does gmtime() accept?
+AC_DEFUN([DOVECOT_GMTIME_MAX], [
+ AC_CACHE_CHECK([how large time_t values gmtime() accepts],i_cv_gmtime_max_time_t,[
+ AC_RUN_IFELSE([AC_LANG_SOURCE([[
+ #include <stdio.h>
+ #include <time.h>
+ int main() {
+ FILE *f;
+ int bits;
+
+ for (bits = 1; bits < sizeof(time_t)*8; bits++) {
+ time_t t = ((time_t)1 << bits) - 1;
+ if (gmtime(&t) == NULL) {
+ bits--;
+ break;
+ }
+ }
+ if (bits > 40) {
+ /* Solaris 9 breaks after 55 bits. Perhaps other systems break earlier.
+ Let's just do the same as Cyrus folks and limit it to 40 bits. */
+ bits = 40;
+ }
+
+ f = fopen("conftest.temp", "w");
+ if (f == NULL) {
+ perror("fopen()");
+ return 1;
+ }
+ fprintf(f, "%d", bits);
+ fclose(f);
+ return 0;
+ }
+ ]])],[
+ i_cv_gmtime_max_time_t=`cat conftest.temp`
+ rm -f conftest.temp
+ ], [
+ printf "check failed, assuming "
+ i_cv_gmtime_max_time_t=31
+ ],[])
+ ])
+ AC_DEFINE_UNQUOTED(TIME_T_MAX_BITS, $i_cv_gmtime_max_time_t, [max. time_t bits gmtime() can handle])
+])