From b5f49495975bfea1899c2836cd597688cd684c42 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 27 May 2019 10:13:33 -0700 Subject: [PATCH] Avoid using C features which depends on _Generic. --- wasmtime-wasi/sandboxed-system-primitives/src/posix.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wasmtime-wasi/sandboxed-system-primitives/src/posix.c b/wasmtime-wasi/sandboxed-system-primitives/src/posix.c index 5fc6e81e5b..e87fbd384b 100644 --- a/wasmtime-wasi/sandboxed-system-primitives/src/posix.c +++ b/wasmtime-wasi/sandboxed-system-primitives/src/posix.c @@ -2003,7 +2003,13 @@ static void convert_timestamp( in /= 1000000000; // Clamp to the maximum in case it would overflow our system's time_t. - out->tv_sec = in < NUMERIC_MAX(time_t) ? in : NUMERIC_MAX(time_t); + time_t time_max; + switch (sizeof(time_t)) { + case sizeof(int32_t): time_max = INT32_MAX; + case sizeof(int64_t): time_max = INT64_MAX; + default: assert(0 && "Unrecognized time_t type"); + } + out->tv_sec = in < time_max ? in : time_max; } // Converts the provided timestamps and flags to a set of arguments for