diff options
author | Alistair Francis <alistair.francis@wdc.com> | 2019-09-18 09:28:50 -0700 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-10-08 16:31:54 +0200 |
commit | 902d3992922fc8db8495d5fb30a4581711b60c62 (patch) | |
tree | 530d1a3a8d51229c2382c4b922ee286a49470b70 | |
parent | b7b7452f292f03eefafa6fd1da9bcfc933dee15a (diff) | |
download | busybox-w32-902d3992922fc8db8495d5fb30a4581711b60c62.tar.gz busybox-w32-902d3992922fc8db8495d5fb30a4581711b60c62.tar.bz2 busybox-w32-902d3992922fc8db8495d5fb30a4581711b60c62.zip |
time: Use 64 prefix syscall if we have to
Some 32-bit architectures no longer have the 32-bit time_t syscalls.
Instead they have suffixed syscalls that returns a 64-bit time_t. If
the architecture doesn't have the non-suffixed syscall and is using a
64-bit time_t let's use the suffixed syscall instead.
This fixes build issues when building for RISC-V 32-bit with 5.1+ kernel
headers.
If an architecture only supports the suffixed syscalls, but is still
using a 32-bit time_t report a compilation error. This avoids us have to
deal with converting between 64-bit and 32-bit values. There are
currently no architectures where this is the case.
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | libbb/time.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libbb/time.c b/libbb/time.c index cab0ad602..b6fcae28b 100644 --- a/libbb/time.c +++ b/libbb/time.c | |||
@@ -257,7 +257,14 @@ char* FAST_FUNC strftime_YYYYMMDDHHMMSS(char *buf, unsigned len, time_t *tp) | |||
257 | * typically requiring -lrt. We just skip all this mess */ | 257 | * typically requiring -lrt. We just skip all this mess */ |
258 | static void get_mono(struct timespec *ts) | 258 | static void get_mono(struct timespec *ts) |
259 | { | 259 | { |
260 | #if defined(__NR_clock_gettime) | ||
260 | if (syscall(__NR_clock_gettime, CLOCK_MONOTONIC, ts)) | 261 | if (syscall(__NR_clock_gettime, CLOCK_MONOTONIC, ts)) |
262 | #elif __TIMESIZE == 64 | ||
263 | if (syscall(__NR_clock_gettime64, CLOCK_MONOTONIC, ts)) | ||
264 | #else | ||
265 | # error "We currently don't support architectures without " \ | ||
266 | "the __NR_clock_gettime syscall and 32-bit time_t" | ||
267 | #endif | ||
261 | bb_simple_error_msg_and_die("clock_gettime(MONOTONIC) failed"); | 268 | bb_simple_error_msg_and_die("clock_gettime(MONOTONIC) failed"); |
262 | } | 269 | } |
263 | unsigned long long FAST_FUNC monotonic_ns(void) | 270 | unsigned long long FAST_FUNC monotonic_ns(void) |