Clean up compile warnings on macOS
This commit is contained in:
1 parent
e660003abf
commit
77417c1335
4 files changed
+48
-5
No files matched your search
@@ -174,6 +174,7 @@ AC_CHECK_MATH_FUNC(drem)
|
||||
AC_CHECK_MATH_FUNC(erf)
|
||||
AC_CHECK_MATH_FUNC(erfc)
|
||||
AC_CHECK_MATH_FUNC(exp10)
|
||||
AC_CHECK_MATH_FUNC(__exp10) dnl macOS has an __exp10
|
||||
AC_CHECK_MATH_FUNC(exp2)
|
||||
AC_CHECK_MATH_FUNC(exp)
|
||||
AC_CHECK_MATH_FUNC(expm1)
|
||||
@@ -210,6 +211,10 @@ AC_CHECK_MATH_FUNC(round)
|
||||
AC_CHECK_MATH_FUNC(scalb)
|
||||
AC_CHECK_MATH_FUNC(scalbln)
|
||||
AC_CHECK_MATH_FUNC(significand)
|
||||
dnl scalbn and ilogb are used on macos to replace significand if we don't have frexp
|
||||
AC_CHECK_MATH_FUNC(scalbn)
|
||||
AC_CHECK_MATH_FUNC(ilogb)
|
||||
|
||||
AC_CHECK_MATH_FUNC(sin)
|
||||
AC_CHECK_MATH_FUNC(sinh)
|
||||
AC_CHECK_MATH_FUNC(sqrt)
|
||||
|
||||
@@ -106,6 +106,36 @@ static jv f_plus(jq_state *jq, jv input, jv a, jv b) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
// macOS has a bunch of libm deprecation warnings, so let's clean those up
|
||||
#ifdef HAVE_TGAMMA
|
||||
#define gamma tgamma
|
||||
#endif
|
||||
#ifdef HAVE___EXP10
|
||||
#define exp10 __exp10
|
||||
#endif
|
||||
#ifdef HAVE_REMAINDER
|
||||
#define drem remainder
|
||||
#endif
|
||||
|
||||
// We replace significand with our own, since there's not a rename-replacement
|
||||
#ifdef HAVE_FREXP
|
||||
#define HAVE_CUSTOM_SIGNIFICAND
|
||||
static double __jq_significand(double x) {
|
||||
int z;
|
||||
return 2*frexp(x, &z);
|
||||
}
|
||||
#define significand __jq_significand
|
||||
#elif defined(HAVE_SCALBN) && defined(HAVE_ILOGB)
|
||||
#define HAVE_CUSTOM_SIGNIFICAND
|
||||
static double __jq_significand(double x) {
|
||||
return scalbn(x, -ilogb(x));
|
||||
}
|
||||
#define significand __jq_significand
|
||||
#endif
|
||||
|
||||
#endif // ifdef __APPLE__
|
||||
|
||||
#define LIBM_DD(name) \
|
||||
static jv f_ ## name(jq_state *jq, jv input) { \
|
||||
if (jv_get_kind(input) != JV_KIND_NUMBER) { \
|
||||
@@ -168,6 +198,14 @@ static jv f_ ## name(jq_state *jq, jv input, jv a, jv b, jv c) { \
|
||||
#undef LIBM_DDD
|
||||
#undef LIBM_DD
|
||||
|
||||
#ifdef __APPLE__ // Clean up after ourselves
|
||||
#undef HAVE_CUSTOM_SIGNIFICAND
|
||||
#undef gamma
|
||||
#undef drem
|
||||
#undef significand
|
||||
#undef exp10
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FREXP
|
||||
static jv f_frexp(jq_state *jq, jv input) {
|
||||
if (jv_get_kind(input) != JV_KIND_NUMBER) {
|
||||
|
||||
+2
-2
@@ -10,9 +10,9 @@
|
||||
static pthread_key_t dtoa_ctx_key;
|
||||
static pthread_once_t dtoa_ctx_once = PTHREAD_ONCE_INIT;
|
||||
|
||||
static void tsd_dtoa_ctx_dtor(struct dtoa_context *ctx) {
|
||||
static void tsd_dtoa_ctx_dtor(void *ctx) {
|
||||
if (ctx) {
|
||||
jvp_dtoa_context_free(ctx);
|
||||
jvp_dtoa_context_free((struct dtoa_context *)ctx);
|
||||
jv_mem_free(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -174,7 +174,7 @@ LIBM_DD(erfc)
|
||||
#else
|
||||
LIBM_DD_NO(erfc)
|
||||
#endif
|
||||
#if defined(HAVE_EXP10) && !defined(WIN32)
|
||||
#if (defined(HAVE_EXP10) && !defined(WIN32)) || (defined(__APPLE__) && defined(HAVE___EXP10))
|
||||
LIBM_DD(exp10)
|
||||
#else
|
||||
LIBM_DD_NO(exp10)
|
||||
@@ -214,7 +214,7 @@ LIBM_DDD(fmod)
|
||||
#else
|
||||
LIBM_DDD_NO(fmod)
|
||||
#endif
|
||||
#ifdef HAVE_GAMMA
|
||||
#if defined(HAVE_GAMMA)
|
||||
LIBM_DD(gamma)
|
||||
#else
|
||||
LIBM_DD_NO(gamma)
|
||||
@@ -274,7 +274,7 @@ LIBM_DDD(scalbln)
|
||||
#else
|
||||
LIBM_DDD_NO(scalbln)
|
||||
#endif
|
||||
#if defined(HAVE_SIGNIFICAND) && !defined(WIN32)
|
||||
#if defined(HAVE_CUSTOM_SIGNIFICAND) || (defined(HAVE_SIGNIFICAND) && !defined(WIN32))
|
||||
LIBM_DD(significand)
|
||||
#else
|
||||
LIBM_DD_NO(significand)
|
||||
|
||||
Reference in new issue
Block a user