Implement drem with remainder on all platforms (#3704)

The static i386 libm of glibc 2.43 does not define drem, so linking jq
with --enable-all-static on Ubuntu 26.04 failed.

Call remainder for drem wherever it is available, as jq already did on
macOS. drem is an obsolete name for remainder, so the results do not
change, and jq no longer depends on the legacy symbol.
This commit is contained in:
itchyny authored and GitHub committed 2026-11-01 19:57:43 +09:00
1 parent 58c0d615c7
commit 77953d8c8d
1 file changed
+8 -5
+8 -5
View File
@@ -106,6 +106,13 @@ jv binop_plus(jv a, jv b) {
}
}
// drem is an obsolete alias of remainder, and is missing from the static
// libm of some platforms (e.g. i386 glibc 2.43), so use remainder instead
#ifdef HAVE_REMAINDER
#define HAVE_DREM 1
#define drem remainder
#endif
#ifdef __APPLE__
// macOS has a bunch of libm deprecation warnings, so let's clean those up
#ifdef HAVE_TGAMMA
@@ -116,10 +123,6 @@ jv binop_plus(jv a, jv b) {
#define HAVE_EXP10
#define exp10 __exp10
#endif
#ifdef HAVE_REMAINDER
#define HAVE_DREM
#define drem remainder
#endif
// We replace significand with our own, since there's not a rename-replacement
#ifdef HAVE_FREXP
@@ -236,9 +239,9 @@ static jv f_ ## name(jq_state *jq, jv input) { \
#undef LIBM_DD
#undef LIBM_DA
#undef drem
#ifdef __APPLE__
#undef gamma
#undef drem
#undef significand
#undef exp10
#endif