diff options
| author | Ron Yorston <rmy@pobox.com> | 2024-08-14 12:52:56 +0100 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2024-08-14 13:10:19 +0100 |
| commit | 6481bb22b5e6d60909d09cf6179412c4f34b9b3c (patch) | |
| tree | 63265600738004f99ad1afcae54d209405bc604d /include | |
| parent | 6e82b6c6a0b55fdc156f7065d177e530e417520c (diff) | |
| download | busybox-w32-6481bb22b5e6d60909d09cf6179412c4f34b9b3c.tar.gz busybox-w32-6481bb22b5e6d60909d09cf6179412c4f34b9b3c.tar.bz2 busybox-w32-6481bb22b5e6d60909d09cf6179412c4f34b9b3c.zip | |
win32: use 64-bit time on 32-bit platforms
To avoid problems with dates in 2038 and beyond use 64-bit time
values on 32-bit platforms.
- Mostly this just requires a few preprocessor macros to choose
the appropriate functions, structs and typedefs.
- We have our own implementations of nanosleep(), clock_gettime()
and clock_settime(). Omit the Windows include file that declares
them.
- Apply the hack for struct timeval in the 'ts' applet on 32-bit.
Adds 1624 bytes on 32-bit, none on 64-bit.
(GitHub issue #446)
Diffstat (limited to 'include')
| -rw-r--r-- | include/libbb.h | 6 | ||||
| -rw-r--r-- | include/mingw.h | 14 |
2 files changed, 20 insertions, 0 deletions
diff --git a/include/libbb.h b/include/libbb.h index e5000831f..17fb6fae6 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
| @@ -10,6 +10,12 @@ | |||
| 10 | #ifndef LIBBB_H | 10 | #ifndef LIBBB_H |
| 11 | #define LIBBB_H 1 | 11 | #define LIBBB_H 1 |
| 12 | 12 | ||
| 13 | #if ENABLE_PLATFORM_MINGW32 | ||
| 14 | /* We have our own nanosleep(), clock_gettime() and clock_settime(). */ | ||
| 15 | /* Skip the Windows include file that declares them. */ | ||
| 16 | # define WIN_PTHREADS_TIME_H | ||
| 17 | #endif | ||
| 18 | |||
| 13 | #include "platform.h" | 19 | #include "platform.h" |
| 14 | 20 | ||
| 15 | #include <ctype.h> | 21 | #include <ctype.h> |
diff --git a/include/mingw.h b/include/mingw.h index 7a07de619..104ca3b2e 100644 --- a/include/mingw.h +++ b/include/mingw.h | |||
| @@ -2,6 +2,17 @@ | |||
| 2 | #define NOIMPL(name,...) static inline int name(__VA_ARGS__) { errno = ENOSYS; return -1; } | 2 | #define NOIMPL(name,...) static inline int name(__VA_ARGS__) { errno = ENOSYS; return -1; } |
| 3 | #define IMPL(name,ret,retval,...) static inline ret name(__VA_ARGS__) { return retval; } | 3 | #define IMPL(name,ret,retval,...) static inline ret name(__VA_ARGS__) { return retval; } |
| 4 | 4 | ||
| 5 | /* Use 64-bit time on 32-bit platforms. */ | ||
| 6 | #if !defined(_WIN64) | ||
| 7 | # define time_t __time64_t | ||
| 8 | # define ctime(t) _ctime64(t) | ||
| 9 | # define localtime(t) _localtime64(t) | ||
| 10 | # define time(t) _time64(t) | ||
| 11 | # define gmtime(t) _gmtime64(t) | ||
| 12 | # define mktime(t) _mktime64(t) | ||
| 13 | # define timespec _timespec64 | ||
| 14 | #endif | ||
| 15 | |||
| 5 | /* | 16 | /* |
| 6 | * sys/types.h | 17 | * sys/types.h |
| 7 | */ | 18 | */ |
| @@ -297,6 +308,9 @@ struct timespec { | |||
| 297 | }; | 308 | }; |
| 298 | #endif | 309 | #endif |
| 299 | 310 | ||
| 311 | typedef int clockid_t; | ||
| 312 | #define CLOCK_REALTIME 0 | ||
| 313 | |||
| 300 | time_t timegm(struct tm *tm); | 314 | time_t timegm(struct tm *tm); |
| 301 | 315 | ||
| 302 | int nanosleep(const struct timespec *req, struct timespec *rem); | 316 | int nanosleep(const struct timespec *req, struct timespec *rem); |
