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
Provenance
- Commit
77417c1- Tree
38bf324- Author
William Langford <wlangfor@gmail.com>- Committer
William Langford <wlangfor@gmail.com>- Parent
e660003
4 files changed+48 added−5 removed
modified:src/builtin.c+38 added
104 unmodified lines105 return type_error2(a, b, "cannot be added");106 }107 }108 109+#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+#endif120+121+// We replace significand with our own, since there's not a rename-replacement122+#ifdef HAVE_FREXP123+#define HAVE_CUSTOM_SIGNIFICAND124+static 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_SIGNIFICAND131+static double __jq_significand(double x) {132+ return scalbn(x, -ilogb(x));133+}134+#define significand __jq_significand135+#endif136+137+#endif // ifdef __APPLE__138+139 #define LIBM_DD(name) \140 static 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 lines197 #undef LIBM_DDDD198 #undef LIBM_DDD199 #undef LIBM_DD200 201+#ifdef __APPLE__ // Clean up after ourselves202+#undef HAVE_CUSTOM_SIGNIFICAND203+#undef gamma204+#undef drem205+#undef significand206+#undef exp10207+#endif208+209 #ifdef HAVE_FREXP210 static 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 linesmodified:src/jv_dtoa_tsd.c+2 added-2 removed
8 unmodified lines9 10 static pthread_key_t dtoa_ctx_key;11 static pthread_once_t dtoa_ctx_once = PTHREAD_ONCE_INIT;12 13-static void tsd_dtoa_ctx_dtor(struct dtoa_context *ctx) {13+static 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 linesmodified:src/libm.h+3 added-3 removed
172 unmodified lines173 LIBM_DD(erfc)174 #else175 LIBM_DD_NO(erfc)176 #endif177-#if defined(HAVE_EXP10) && !defined(WIN32)177+#if (defined(HAVE_EXP10) && !defined(WIN32)) || (defined(__APPLE__) && defined(HAVE___EXP10))178 LIBM_DD(exp10)179 #else180 LIBM_DD_NO(exp10)181 #endif31 unmodified lines213 LIBM_DDD(fmod)214 #else215 LIBM_DDD_NO(fmod)216 #endif217-#ifdef HAVE_GAMMA217+#if defined(HAVE_GAMMA)218 LIBM_DD(gamma)219 #else220 LIBM_DD_NO(gamma)221 #endif51 unmodified lines273 LIBM_DDD(scalbln)274 #else275 LIBM_DDD_NO(scalbln)276 #endif277-#if defined(HAVE_SIGNIFICAND) && !defined(WIN32)277+#if defined(HAVE_CUSTOM_SIGNIFICAND) || (defined(HAVE_SIGNIFICAND) && !defined(WIN32))278 LIBM_DD(significand)279 #else280 LIBM_DD_NO(significand)281 #endif10 unmodified linesmodified:configure.ac+5 added
172 unmodified lines173 AC_CHECK_MATH_FUNC(drem)174 AC_CHECK_MATH_FUNC(erf)175 AC_CHECK_MATH_FUNC(erfc)176 AC_CHECK_MATH_FUNC(exp10)177+AC_CHECK_MATH_FUNC(__exp10) dnl macOS has an __exp10178 AC_CHECK_MATH_FUNC(exp2)179 AC_CHECK_MATH_FUNC(exp)180 AC_CHECK_MATH_FUNC(expm1)181 AC_CHECK_MATH_FUNC(fabs)28 unmodified lines210 AC_CHECK_MATH_FUNC(round)211 AC_CHECK_MATH_FUNC(scalb)212 AC_CHECK_MATH_FUNC(scalbln)213 AC_CHECK_MATH_FUNC(significand)214+dnl scalbn and ilogb are used on macos to replace significand if we don't have frexp215+AC_CHECK_MATH_FUNC(scalbn)216+AC_CHECK_MATH_FUNC(ilogb)217+218 AC_CHECK_MATH_FUNC(sin)219 AC_CHECK_MATH_FUNC(sinh)220 AC_CHECK_MATH_FUNC(sqrt)221 AC_CHECK_MATH_FUNC(tan)77 unmodified lines