[tz] [PROPOSED 2/4] Port UINT_FAST64_MAX back to C89
Paul Eggert
eggert at cs.ucla.edu
Sat Nov 19 20:41:33 UTC 2022
The recent patch “Improve randomness of zic temp file names”
used UINT_FAST64_MAX, which assumes C99.
* private.h (UINT_FAST64_MAX): Define if not already defined.
Reorganize the fallback a bit, to prefer long to long long
if either will do.
---
private.h | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/private.h b/private.h
index b9d9765..aa6eb59 100644
--- a/private.h
+++ b/private.h
@@ -361,14 +361,13 @@ typedef unsigned long uint_fast32_t;
#endif
#ifndef UINT_FAST64_MAX
-# ifdef ULLONG_MAX
-typedef unsigned long long uint_fast64_t;
+# if 3 <= ULONG_MAX >> 31 >> 31
+typedef unsigned long uint_fast64_t;
+# define UINT_FAST64_MAX ULONG_MAX
# else
-# if ULONG_MAX >> 31 >> 1 < 0xffffffff
-Please use a compiler that supports a 64-bit integer type (or wider);
-you may need to compile with "-DHAVE_STDINT_H".
-# endif
-typedef unsigned long uint_fast64_t;
+/* If this fails, compile with -DHAVE_STDINT_H or with a better compiler. */
+typedef unsigned long long uint_fast64_t;
+# define UINT_FAST64_MAX ULLONG_MAX
# endif
#endif
--
2.38.1
More information about the tz
mailing list