Skip to content

Commit 668607e

Browse files
itchynynicowilliams
authored andcommitted
Enable gamma, drem on macOS
1 parent a1e791a commit 668607e

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/builtin.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,28 +107,31 @@ static jv f_plus(jq_state *jq, jv input, jv a, jv b) {
107107
#ifdef __APPLE__
108108
// macOS has a bunch of libm deprecation warnings, so let's clean those up
109109
#ifdef HAVE_TGAMMA
110+
#define HAVE_GAMMA
110111
#define gamma tgamma
111112
#endif
112113
#ifdef HAVE___EXP10
114+
#define HAVE_EXP10
113115
#define exp10 __exp10
114116
#endif
115117
#ifdef HAVE_REMAINDER
118+
#define HAVE_DREM
116119
#define drem remainder
117120
#endif
118121

119122
// We replace significand with our own, since there's not a rename-replacement
120123
#ifdef HAVE_FREXP
121-
#define HAVE_CUSTOM_SIGNIFICAND
122124
static double __jq_significand(double x) {
123125
int z;
124126
return 2*frexp(x, &z);
125127
}
128+
#define HAVE_SIGNIFICAND
126129
#define significand __jq_significand
127130
#elif defined(HAVE_SCALBN) && defined(HAVE_ILOGB)
128-
#define HAVE_CUSTOM_SIGNIFICAND
129131
static double __jq_significand(double x) {
130132
return scalbn(x, -ilogb(x));
131133
}
134+
#define HAVE_SIGNIFICAND
132135
#define significand __jq_significand
133136
#endif
134137

@@ -1876,7 +1879,10 @@ static const char jq_builtins[] =
18761879
#undef LIBM_DD
18771880

18781881
#ifdef __APPLE__
1879-
#undef HAVE_CUSTOM_SIGNIFICAND
1882+
#undef HAVE_GAMMA
1883+
#undef HAVE_EXP10
1884+
#undef HAVE_DREM
1885+
#undef HAVE_SIGNIFICAND
18801886
#endif
18811887

18821888
static block gen_builtin_list(block builtins) {

src/libm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ LIBM_DD(erfc)
174174
#else
175175
LIBM_DD_NO(erfc)
176176
#endif
177-
#if (defined(HAVE_EXP10) && !defined(WIN32)) || (defined(__APPLE__) && defined(HAVE___EXP10))
177+
#if defined(HAVE_EXP10) && !defined(WIN32)
178178
LIBM_DD(exp10)
179179
#else
180180
LIBM_DD_NO(exp10)
@@ -274,7 +274,7 @@ LIBM_DDD(scalbln)
274274
#else
275275
LIBM_DDD_NO(scalbln)
276276
#endif
277-
#if defined(HAVE_CUSTOM_SIGNIFICAND) || (defined(HAVE_SIGNIFICAND) && !defined(WIN32))
277+
#if defined(HAVE_SIGNIFICAND) && !defined(WIN32)
278278
LIBM_DD(significand)
279279
#else
280280
LIBM_DD_NO(significand)

0 commit comments

Comments
 (0)