diff --git a/src/include/musl/limits.h b/src/include/musl/limits.h new file mode 100644 index 0000000000..9620a3b0ac --- /dev/null +++ b/src/include/musl/limits.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#include_next /* IWYU pragma: export */ + +#include +#include + +/* musl defines SSIZE_MAX as LONG_MAX, so its type is always long. However, on 32-bit architectures, musl + * defines ssize_t as int. Strictly speaking, this is not a bug in musl. POSIX only requires SSIZE_MAX to + * evaluate to the maximum value representable by ssize_t; it does not require SSIZE_MAX itself to have type + * ssize_t. However, our code assumes that SSIZE_MAX has type ssize_t, as is the case with glibc. Cast the + * value explicitly so that SSIZE_MAX has type ssize_t. */ +static_assert(SSIZE_MAX == LONG_MAX, ""); +#undef SSIZE_MAX +#define SSIZE_MAX ((ssize_t) LONG_MAX)