Skip to content

Commit 28f4aee

Browse files
dschogitster
authored andcommitted
use uintmax_t for timestamps
Previously, we used `unsigned long` for timestamps. This was only a good choice on Linux, where we know implicitly that `unsigned long` is what is used for `time_t`. However, we want to use a different data type for timestamps for two reasons: - there is nothing that says that `unsigned long` should be the same data type as `time_t`, and indeed, on 64-bit Windows for example, it is not: `unsigned long` is 32-bit but `time_t` is 64-bit. - even on 32-bit Linux, where `unsigned long` (and thereby `time_t`) is 32-bit, we *want* to be able to encode timestamps in Git that are currently absurdly far in the future, *even if* the system library is not able to format those timestamps into date strings. So let's just switch to the maximal integer type available, which should be at least 64-bit for all practical purposes these days. It certainly cannot be worse than `unsigned long`, so... Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1e65a98 commit 28f4aee

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

git-compat-util.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,10 @@ extern char *gitdirname(char *);
319319
#define PRIo32 "o"
320320
#endif
321321

322-
typedef unsigned long timestamp_t;
323-
#define PRItime "lu"
324-
#define parse_timestamp strtoul
325-
#define TIME_MAX ULONG_MAX
322+
typedef uintmax_t timestamp_t;
323+
#define PRItime PRIuMAX
324+
#define parse_timestamp strtoumax
325+
#define TIME_MAX UINTMAX_MAX
326326

327327
#ifndef PATH_SEP
328328
#define PATH_SEP ':'

0 commit comments

Comments
 (0)