Skip to content

Commit

Permalink
_finitef is unavailable on Windows x86
Browse files Browse the repository at this point in the history
Instead cast it inline to a double on Windows.
  • Loading branch information
kddnewton committed Dec 2, 2024
1 parent ec5c11c commit 4cfe19a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
11 changes: 0 additions & 11 deletions include/prism/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,6 @@
# define PRISM_HAS_FILESYSTEM
#endif

/**
* isinf on Windows is defined as accepting a float, but on POSIX systems it
* accepts a float, a double, or a long double. We want to mirror this behavior
* on windows.
*/
#ifdef _WIN32
# include <float.h>
# undef isinf
# define isinf(x) (sizeof(x) == sizeof(float) ? !_finitef(x) : !_finite(x))
#endif

/**
* If you build prism with a custom allocator, configure it with
* "-D PRISM_XALLOCATOR" to use your own allocator that defines xmalloc,
Expand Down
9 changes: 8 additions & 1 deletion src/prism.c
Original file line number Diff line number Diff line change
Expand Up @@ -4142,7 +4142,14 @@ pm_double_parse(pm_parser_t *parser, const pm_token_t *token) {

// If errno is set, then it should only be ERANGE. At this point we need to
// check if it's infinity (it should be).
if (errno == ERANGE && isinf(value)) {
if (
errno == ERANGE &&
#ifdef _WIN32
isinf((float) value)
#else
isinf(value)
#endif
) {
int warn_width;
const char *ellipsis;

Expand Down

0 comments on commit 4cfe19a

Please sign in to comment.