summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2023-07-21 21:06:32 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2023-07-21 21:06:32 (GMT)
commit7e24016de07abbcfa239c1c467bc9204849a54bd (patch)
treed5a0375ac01987fa34399c4258537815b78ffd68 /unix
parent65d2ef9c4d45929310f90b8faf8fce23dea1be07 (diff)
downloadtk-7e24016de07abbcfa239c1c467bc9204849a54bd.zip
tk-7e24016de07abbcfa239c1c467bc9204849a54bd.tar.gz
tk-7e24016de07abbcfa239c1c467bc9204849a54bd.tar.bz2
Experimental fix for [https://core.tcl-lang.org/tcl/tktview/d40b9c8503|d40b9c8503]: Enforcing 64-bit time_t?
Since Tk uses time() too, and should support years > 2038
Diffstat (limited to 'unix')
-rwxr-xr-xunix/configure121
-rw-r--r--unix/tcl.m429
-rw-r--r--unix/tkConfig.h.in6
3 files changed, 154 insertions, 2 deletions
diff --git a/unix/configure b/unix/configure
index e06493c..8e3baaf 100755
--- a/unix/configure
+++ b/unix/configure
@@ -6406,6 +6406,58 @@ printf "%s\n" "#define _ISOC99_SOURCE 1" >>confdefs.h
tcl_flags="$tcl_flags _ISOC99_SOURCE"
fi
+ if test "${TCL_MAJOR_VERSION}" -ne 8 ; then
+
+ if test ${tcl_cv_flag__file_offset_bits+y}
+then :
+ printf %s "(cached) " >&6
+else $as_nop
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <sys/stat.h>
+int
+main (void)
+{
+switch (0) { case 0: case (sizeof(off_t)==sizeof(long long)): ; }
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+ tcl_cv_flag__file_offset_bits=no
+else $as_nop
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#define _FILE_OFFSET_BITS 64
+#include <sys/stat.h>
+int
+main (void)
+{
+switch (0) { case 0: case (sizeof(off_t)==sizeof(long long)): ; }
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+ tcl_cv_flag__file_offset_bits=yes
+else $as_nop
+ tcl_cv_flag__file_offset_bits=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+ if test "x${tcl_cv_flag__file_offset_bits}" = "xyes" ; then
+
+printf "%s\n" "#define _FILE_OFFSET_BITS 64" >>confdefs.h
+
+ tcl_flags="$tcl_flags _FILE_OFFSET_BITS"
+ fi
+
+ fi
if test ${tcl_cv_flag__largefile64_source+y}
then :
@@ -6507,6 +6559,75 @@ printf "%s\n" "yes" >&6; }
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
# Now check for auxiliary declarations
+ if test "${TCL_MAJOR_VERSION}" -ne 8 ; then
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for 64-bit time_t" >&5
+printf %s "checking for 64-bit time_t... " >&6; }
+if test ${tcl_cv_time_t_64+y}
+then :
+ printf %s "(cached) " >&6
+else $as_nop
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <sys/types.h>
+int
+main (void)
+{
+switch (0) {case 0: case (sizeof(time_t)==sizeof(long long)): ;}
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+ tcl_cv_time_t_64=yes
+else $as_nop
+ tcl_cv_time_t_64=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_time_t_64" >&5
+printf "%s\n" "$tcl_cv_time_t_64" >&6; }
+ if test "x${tcl_cv_time_t_64}" = "xno" ; then
+ # Note that _TIME_BITS=64 requires _FILE_OFFSET_BITS=64
+ # which SC_TCL_EARLY_FLAGS has defined if necessary.
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if _TIME_BITS=64 enables 64-bit time_t" >&5
+printf %s "checking if _TIME_BITS=64 enables 64-bit time_t... " >&6; }
+if test ${tcl_cv__time_bits+y}
+then :
+ printf %s "(cached) " >&6
+else $as_nop
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#define _TIME_BITS 64
+#include <sys/types.h>
+int
+main (void)
+{
+switch (0) {case 0: case (sizeof(time_t)==sizeof(long long)): ;}
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+ tcl_cv__time_bits=yes
+else $as_nop
+ tcl_cv__time_bits=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv__time_bits" >&5
+printf "%s\n" "$tcl_cv__time_bits" >&6; }
+ if test "x${tcl_cv__time_bits}" = "xyes" ; then
+
+printf "%s\n" "#define _TIME_BITS 64" >>confdefs.h
+
+ fi
+ fi
+ fi
+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for struct dirent64" >&5
printf %s "checking for struct dirent64... " >&6; }
if test ${tcl_cv_struct_dirent64+y}
diff --git a/unix/tcl.m4 b/unix/tcl.m4
index fc0cfb7..15cb760 100644
--- a/unix/tcl.m4
+++ b/unix/tcl.m4
@@ -2294,6 +2294,7 @@ AC_DEFUN([SC_TCL_LINK_LIBS], [
#
# Might define the following vars:
# _ISOC99_SOURCE
+# _FILE_OFFSET_BITS
# _LARGEFILE64_SOURCE
#
#--------------------------------------------------------------------
@@ -2301,12 +2302,12 @@ AC_DEFUN([SC_TCL_LINK_LIBS], [
AC_DEFUN([SC_TCL_EARLY_FLAG],[
AC_CACHE_VAL([tcl_cv_flag_]translit($1,[A-Z],[a-z]),
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$2]], [[$3]])],
- [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no,[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[[#define ]$1[ 1
+ [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no,[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[[#define ]$1[ ]m4_default([$4],[1])[
]$2]], [[$3]])],
[tcl_cv_flag_]translit($1,[A-Z],[a-z])=yes,
[tcl_cv_flag_]translit($1,[A-Z],[a-z])=no)]))
if test ["x${tcl_cv_flag_]translit($1,[A-Z],[a-z])[}" = "xyes"] ; then
- AC_DEFINE($1, 1, [Add the ]$1[ flag when building])
+ AC_DEFINE($1, m4_default([$4],[1]), [Add the ]$1[ flag when building])
tcl_flags="$tcl_flags $1"
fi
])
@@ -2316,6 +2317,10 @@ AC_DEFUN([SC_TCL_EARLY_FLAGS],[
tcl_flags=""
SC_TCL_EARLY_FLAG(_ISOC99_SOURCE,[#include <stdlib.h>],
[char *p = (char *)strtoll; char *q = (char *)strtoull;])
+ if test "${TCL_MAJOR_VERSION}" -ne 8 ; then
+ SC_TCL_EARLY_FLAG(_FILE_OFFSET_BITS,[#include <sys/stat.h>],
+ [switch (0) { case 0: case (sizeof(off_t)==sizeof(long long)): ; }],64)
+ fi
SC_TCL_EARLY_FLAG(_LARGEFILE64_SOURCE,[#include <sys/stat.h>],
[struct stat64 buf; int i = stat64("/", &buf);])
if test "x${tcl_flags}" = "x" ; then
@@ -2340,6 +2345,7 @@ AC_DEFUN([SC_TCL_EARLY_FLAGS],[
# HAVE_STRUCT_DIRENT64, HAVE_DIR64
# HAVE_STRUCT_STAT64
# HAVE_TYPE_OFF64_T
+# _TIME_BITS
#
#--------------------------------------------------------------------
@@ -2359,6 +2365,25 @@ AC_DEFUN([SC_TCL_64BIT_FLAGS], [
else
AC_MSG_RESULT([no])
# Now check for auxiliary declarations
+ if test "${TCL_MAJOR_VERSION}" -ne 8 ; then
+ AC_CACHE_CHECK([for 64-bit time_t], tcl_cv_time_t_64,[
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>]],
+ [[switch (0) {case 0: case (sizeof(time_t)==sizeof(long long)): ;}]])],
+ [tcl_cv_time_t_64=yes],[tcl_cv_time_t_64=no])])
+ if test "x${tcl_cv_time_t_64}" = "xno" ; then
+ # Note that _TIME_BITS=64 requires _FILE_OFFSET_BITS=64
+ # which SC_TCL_EARLY_FLAGS has defined if necessary.
+ AC_CACHE_CHECK([if _TIME_BITS=64 enables 64-bit time_t], tcl_cv__time_bits,[
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#define _TIME_BITS 64
+#include <sys/types.h>]],
+ [[switch (0) {case 0: case (sizeof(time_t)==sizeof(long long)): ;}]])],
+ [tcl_cv__time_bits=yes],[tcl_cv__time_bits=no])])
+ if test "x${tcl_cv__time_bits}" = "xyes" ; then
+ AC_DEFINE(_TIME_BITS, 64, [_TIME_BITS=64 enables 64-bit time_t.])
+ fi
+ fi
+ fi
+
AC_CACHE_CHECK([for struct dirent64], tcl_cv_struct_dirent64,[
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
#include <dirent.h>]], [[struct dirent64 p;]])],
diff --git a/unix/tkConfig.h.in b/unix/tkConfig.h.in
index 19de439..cdf6175 100644
--- a/unix/tkConfig.h.in
+++ b/unix/tkConfig.h.in
@@ -186,6 +186,9 @@
/* Are Darwin SUSv3 extensions available? */
#undef _DARWIN_C_SOURCE
+/* Add the _FILE_OFFSET_BITS flag when building */
+#undef _FILE_OFFSET_BITS
+
/* Add the _ISOC99_SOURCE flag when building */
#undef _ISOC99_SOURCE
@@ -201,6 +204,9 @@
/* Do we want the reentrant OS API? */
#undef _REENTRANT
+/* _TIME_BITS=64 enables 64-bit time_t. */
+#undef _TIME_BITS
+
/* Do we want to use the XOPEN network library? */
#undef _XOPEN_SOURCE