From 71e0bb92d13af4f8aabb79689a3a7edb81b6680a Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 21 Apr 2003 12:26:08 +0000 Subject: [PATCH] * numeric.c (flo_is_finite_p): use finite() if available. * win32/win32.h (isinf, isnan): define as macro. [ruby-win32:00533] * bcc32/Makefile.sub, win32/Makefile.sub: no longer use missing/isinf.c, missing/isnan.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 ++++++++++ bcc32/Makefile.sub | 5 ++--- numeric.c | 7 ++++++- win32/Makefile.sub | 8 ++++---- win32/win32.h | 30 ++++++++++-------------------- 5 files changed, 32 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index 785f92f5a2..b3b8ed562d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Mon Apr 21 21:25:59 2003 Nobuyoshi Nakada + + * numeric.c (flo_is_finite_p): use finite() if available. + + * win32/win32.h (isinf, isnan): define as macro. + [ruby-win32:00533] + + * bcc32/Makefile.sub, win32/Makefile.sub: no longer use + missing/isinf.c, missing/isnan.c. + Mon Apr 21 18:36:28 2003 Nobuyoshi Nakada * bignum.c (rb_cstr_to_inum): unnecessarily long buffer was used diff --git a/bcc32/Makefile.sub b/bcc32/Makefile.sub index ca63aa8fc6..05fbd59df1 100644 --- a/bcc32/Makefile.sub +++ b/bcc32/Makefile.sub @@ -102,7 +102,7 @@ RFLAGS = $(iconinc) EXTLIBS = !endif LIBS = cw32.lib import32.lib ws2_32.lib $(EXTLIBS) -MISSING = acosh.obj crypt.obj win32.obj isinf.obj +MISSING = acosh.obj crypt.obj win32.obj !ifndef STACK STACK = 0x2000000 @@ -270,6 +270,7 @@ config.h: \#define SIZEOF_DOUBLE 8 \#define HAVE_DECL_SYS_NERR 1 +\#define HAVE_ISINF 1 \#define HAVE_ISNAN 1 \#define HAVE_MEMMOVE 1 \#define HAVE_MKDIR 1 @@ -518,8 +519,6 @@ crypt.obj: crypt.c win32.h dup2.obj: dup2.c win32.h finite.obj: finite.c win32.h flock.obj: flock.c win32.h -isinf.obj: isinf.c win32.h -isnan.obj: isnan.c win32.h memcmp.obj: memcmp.c win32.h memmove.obj: memmove.c win32.h mkdir.obj: mkdir.c win32.h diff --git a/numeric.c b/numeric.c index e77c09faaf..8a76b8f1a1 100644 --- a/numeric.c +++ b/numeric.c @@ -758,9 +758,14 @@ flo_is_finite_p(num) { double value = RFLOAT(num)->value; +#if HAVE_FINITE + if (!finite(value)) + return Qfalse; +#else if (isinf(value) || isnan(value)) return Qfalse; - +#endif + return Qtrue; } diff --git a/win32/Makefile.sub b/win32/Makefile.sub index c358e3b93d..b38087f979 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -93,7 +93,7 @@ RFLAGS = -r EXTLIBS = !endif LIBS = oldnames.lib user32.lib advapi32.lib wsock32.lib $(EXTLIBS) -MISSING = acosh.obj crypt.obj win32.obj isinf.obj isnan.obj +MISSING = acosh.obj crypt.obj win32.obj ARFLAGS = -machine:$(MACHINE) -out: CC = $(CC) -nologo @@ -245,6 +245,8 @@ config.h: #define HAVE_STRTOUL 1 #define HAVE_FLOCK 1 #define HAVE_VSNPRINTF 1 +#define HAVE_ISINF 1 +#define HAVE_ISNAN 1 #define HAVE_FINITE 1 #define HAVE_FMOD 1 #define HAVE_FREXP 1 @@ -328,7 +330,7 @@ s,@AR@,$(AR),;t t s,@ARFLAGS@,$(ARFLAGS),;t t s,@LN_S@,$(LN_S),;t t s,@SET_MAKE@,$(SET_MAKE),;t t -s,@LIBOBJS@, acosh.obj crypt.obj win32.obj isinf.obj isnan.obj,;t t +s,@LIBOBJS@, acosh.obj crypt.obj win32.obj,;t t s,@ALLOCA@,$(ALLOCA),;t t s,@DEFAULT_KCODE@,$(DEFAULT_KCODE),;t t s,@EXEEXT@,.exe,;t t @@ -516,8 +518,6 @@ crypt.obj: {$(srcdir)}missing/crypt.c dup2.obj: {$(srcdir)}missing/dup2.c finite.obj: {$(srcdir)}missing/finite.c flock.obj: {$(srcdir)}missing/flock.c -isinf.obj: {$(srcdir)}missing/isinf.c -isnan.obj: {$(srcdir)}missing/isnan.c memcmp.obj: {$(srcdir)}missing/memcmp.c memmove.obj: {$(srcdir)}missing/memmove.c mkdir.obj: {$(srcdir)}missing/mkdir.c diff --git a/win32/win32.h b/win32/win32.h index b378fb23cd..48d2f1beaf 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -175,40 +175,30 @@ extern int do_aspawn(int, char *, char **); extern int kill(int, int); extern pid_t rb_w32_getpid(void); -#ifdef __BORLANDC__ #include +#if !defined __MINGW32__ || defined __NO_ISOCEXT #ifndef isnan -#define isnan _isnan +#define isnan(x) _isnan(x) +#endif +#ifndef isinf +#define isinf(x) (!_finite(x) && !_isnan(x)) +#endif +#ifndef finite +#define finite(x) _finite(x) +#endif #endif -#ifdef S_ISDIR +#ifdef __BORLANDC__ #undef S_ISDIR -#endif - -#ifdef S_ISFIFO #undef S_ISFIFO -#endif - -#ifdef S_ISBLK #undef S_ISBLK -#endif - -#ifdef S_ISCHR #undef S_ISCHR -#endif - -#ifdef S_ISREG #undef S_ISREG -#endif - #define S_ISDIR(m) (((unsigned short)(m) & S_IFMT) == S_IFDIR) #define S_ISFIFO(m) (((unsigned short)(m) & S_IFMT) == S_IFIFO) #define S_ISBLK(m) (((unsigned short)(m) & S_IFMT) == S_IFBLK) #define S_ISCHR(m) (((unsigned short)(m) & S_IFMT) == S_IFCHR) #define S_ISREG(m) (((unsigned short)(m) & S_IFMT) == S_IFREG) -#elif !defined __MINGW32__ || defined __NO_ISOCEXT -extern int isinf(double); -extern int isnan(double); #endif #if !defined S_IRUSR && !defined __MINGW32__