SHA256
1
0
forked from pool/file
file/file-5.45-type_t.dif

43 lines
1.4 KiB
Plaintext
Raw Normal View History

---
configure.ac | 12 ++++++++++++
src/file.h | 6 ++++--
2 files changed, 16 insertions(+), 2 deletions(-)
--- src/file.h
+++ src/file.h 2023-07-28 14:37:17.000000000 +0000
@@ -159,9 +159,11 @@
/*
* Dec 31, 23:59:59 9999
* we need to make sure that we don't exceed 9999 because some libc
- * implementations like muslc crash otherwise
+ * implementations like muslc crash otherwise. If you are unlucky
+ * to be running on a system with a 32 bit time_t, then it is even less.
*/
-#define MAX_CTIME CAST(time_t, 0x3afff487cfULL)
+#define MAX_CTIME \
+ CAST(time_t, sizeof(time_t) > 4 ? 0x3afff487cfULL : 0x7fffffffULL)
#define FILE_BADSIZE CAST(size_t, ~0ul)
#define MAXDESC 64 /* max len of text description/MIME type */
--- configure.ac
+++ configure.ac 2023-07-31 06:45:39.269468700 +0000
@@ -152,6 +152,18 @@ AC_TYPE_UINT64_T
AC_TYPE_INT64_T
AC_TYPE_INTPTR_T
AC_TYPE_UINTPTR_T
+m4_ifdef([AC_SYS_YEAR2038], [AC_SYS_YEAR2038], [
+# GNU libc only allows setting _TIME_BITS when FILE_OFFSET_BITS is also set.
+# GNU libc defines __TIMESIZE on systems where _TIME_BITS can be set.
+AS_IF([test X"$ac_cv_sys_file_offset_bits" = X"64"], [
+ AC_CHECK_DECL(__TIMESIZE, [
+ AC_DEFINE([_TIME_BITS], [64], [Number of bits in a timestamp, on hosts where this is settable.])
+ ], [], [
+AC_INCLUDES_DEFAULT
+#include <time.h>
+ ])
+ ])
+])
AC_FUNC_MMAP
AC_FUNC_FORK
AC_FUNC_MBRTOWC