Skip to content
Myr

Clean up compile warnings on macOS

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by William Langford · committed by William Langford · parent e660003 · Browse files · 4 files+48 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+48 added−5 removed

  • other:+48 added−5 removed

4 files+48 added−5 removed

modified:src/builtin.c+38 added
104 unmodified lines
105 return type_error2(a, b, "cannot be added");106 }107}108109#ifdef __APPLE__110// macOS has a bunch of libm deprecation warnings, so let's clean those up111#ifdef HAVE_TGAMMA112#define gamma tgamma113#endif114#ifdef HAVE___EXP10115#define exp10 __exp10116#endif117#ifdef HAVE_REMAINDER118#define drem remainder119#endif120121// We replace significand with our own, since there's not a rename-replacement122#ifdef HAVE_FREXP123#define HAVE_CUSTOM_SIGNIFICAND124static double __jq_significand(double x) {125 int z;126 return 2*frexp(x, &z);127}128#define significand __jq_significand129#elif defined(HAVE_SCALBN) && defined(HAVE_ILOGB)130#define HAVE_CUSTOM_SIGNIFICAND131static double __jq_significand(double x) {132 return scalbn(x, -ilogb(x));133}134#define significand __jq_significand135#endif136137#endif // ifdef __APPLE__138139#define LIBM_DD(name) \140static jv f_ ## name(jq_state *jq, jv input) { \141 if (jv_get_kind(input) != JV_KIND_NUMBER) { \142 return type_error(input, "number required"); \
54 unmodified lines
197#undef LIBM_DDDD198#undef LIBM_DDD199#undef LIBM_DD200201#ifdef __APPLE__ // Clean up after ourselves202#undef HAVE_CUSTOM_SIGNIFICAND203#undef gamma204#undef drem205#undef significand206#undef exp10207#endif208209#ifdef HAVE_FREXP210static jv f_frexp(jq_state *jq, jv input) {211 if (jv_get_kind(input) != JV_KIND_NUMBER) {212 return type_error(input, "number required");
1644 unmodified lines
modified:src/jv_dtoa_tsd.c+2 added-2 removed
8 unmodified lines
910static pthread_key_t dtoa_ctx_key;11static pthread_once_t dtoa_ctx_once = PTHREAD_ONCE_INIT;1213static void tsd_dtoa_ctx_dtor(struct dtoa_context *ctx) {13static void tsd_dtoa_ctx_dtor(void *ctx) {14 if (ctx) {15 jvp_dtoa_context_free(ctx);15 jvp_dtoa_context_free((struct dtoa_context *)ctx);16 jv_mem_free(ctx);17 }18}19
27 unmodified lines
modified:src/libm.h+3 added-3 removed
172 unmodified lines
173LIBM_DD(erfc)174#else175LIBM_DD_NO(erfc)176#endif177#if defined(HAVE_EXP10) && !defined(WIN32)177#if (defined(HAVE_EXP10) && !defined(WIN32)) || (defined(__APPLE__) && defined(HAVE___EXP10))178LIBM_DD(exp10)179#else180LIBM_DD_NO(exp10)181#endif
31 unmodified lines
213LIBM_DDD(fmod)214#else215LIBM_DDD_NO(fmod)216#endif217#ifdef HAVE_GAMMA217#if defined(HAVE_GAMMA)218LIBM_DD(gamma)219#else220LIBM_DD_NO(gamma)221#endif
51 unmodified lines
273LIBM_DDD(scalbln)274#else275LIBM_DDD_NO(scalbln)276#endif277#if defined(HAVE_SIGNIFICAND) && !defined(WIN32)277#if defined(HAVE_CUSTOM_SIGNIFICAND) || (defined(HAVE_SIGNIFICAND) && !defined(WIN32))278LIBM_DD(significand)279#else280LIBM_DD_NO(significand)281#endif
10 unmodified lines
modified:configure.ac+5 added
172 unmodified lines
173AC_CHECK_MATH_FUNC(drem)174AC_CHECK_MATH_FUNC(erf)175AC_CHECK_MATH_FUNC(erfc)176AC_CHECK_MATH_FUNC(exp10)177AC_CHECK_MATH_FUNC(__exp10) dnl macOS has an __exp10178AC_CHECK_MATH_FUNC(exp2)179AC_CHECK_MATH_FUNC(exp)180AC_CHECK_MATH_FUNC(expm1)181AC_CHECK_MATH_FUNC(fabs)
28 unmodified lines
210AC_CHECK_MATH_FUNC(round)211AC_CHECK_MATH_FUNC(scalb)212AC_CHECK_MATH_FUNC(scalbln)213AC_CHECK_MATH_FUNC(significand)214dnl scalbn and ilogb are used on macos to replace significand if we don't have frexp215AC_CHECK_MATH_FUNC(scalbn)216AC_CHECK_MATH_FUNC(ilogb)217218AC_CHECK_MATH_FUNC(sin)219AC_CHECK_MATH_FUNC(sinh)220AC_CHECK_MATH_FUNC(sqrt)221AC_CHECK_MATH_FUNC(tan)
77 unmodified lines