From: Taylor R Campbell Date: Fri, 6 Aug 2010 01:15:30 +0000 (+0000) Subject: Emulate C99 fenv.h with BSD ieeefp.h if necessary. X-Git-Tag: 20101212-Gtk~120 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=e3c57874125b713f87465c7aa339fcab37009fa7;p=mit-scheme.git Emulate C99 fenv.h with BSD ieeefp.h if necessary. --- diff --git a/src/microcode/configure.ac b/src/microcode/configure.ac index a3e22029e..7f930cfda 100644 --- a/src/microcode/configure.ac +++ b/src/microcode/configure.ac @@ -402,7 +402,8 @@ AC_HEADER_STDC AC_HEADER_STDBOOL AC_HEADER_SYS_WAIT AC_HEADER_TIME -AC_CHECK_HEADERS([bsdtty.h fcntl.h fenv.h limits.h malloc.h sgtty.h stropts.h time.h]) +AC_CHECK_HEADERS([bsdtty.h fcntl.h fenv.h ieeefp.h limits.h malloc.h sgtty.h]) +AC_CHECK_HEADERS([stropts.h time.h]) AC_CHECK_HEADERS([sys/file.h sys/ioctl.h sys/mount.h sys/param.h sys/poll.h]) AC_CHECK_HEADERS([sys/ptyio.h sys/socket.h sys/time.h sys/un.h sys/vfs.h]) AC_CHECK_HEADERS([termio.h termios.h unistd.h utime.h]) @@ -650,7 +651,7 @@ AC_FUNC_WAIT3 AC_CHECK_FUNCS([ctermid]) AC_CHECK_FUNCS([dup2]) AC_CHECK_FUNCS([fcntl fdatasync fegetround fesetround floor fpathconf frexp]) -AC_CHECK_FUNCS([fsync fsync_range ftruncate]) +AC_CHECK_FUNCS([fpgetround fpsetround fsync fsync_range ftruncate]) AC_CHECK_FUNCS([getcwd gethostbyname gethostname getlogin getpagesize getpgrp]) AC_CHECK_FUNCS([getpt gettimeofday getwd grantpt]) AC_CHECK_FUNCS([kill]) diff --git a/src/microcode/sysprim.c b/src/microcode/sysprim.c index 1d1cc592f..7654116bf 100644 --- a/src/microcode/sysprim.c +++ b/src/microcode/sysprim.c @@ -205,6 +205,48 @@ DEFINE_PRIMITIVE ("CC-BLOCK-LINKAGE-INFO", Prim_cc_block_linkage_info, 1, 1, 0) PRIMITIVE_RETURN (cc_block_linkage_info (ARG_REF (1))); } +/* Emulate with BSD's . */ + +#if !defined(HAVE_FENV_H) && defined(HAVE_IEEEFP_H) +# include +#endif + +#if !defined(HAVE_FEGETROUND) && defined(HAVE_FPGETROUND) +# define fegetround fpgetround +# define HAVE_FEGETROUND +#endif + +#if !defined(HAVE_FESETROUND) && defined(HAVE_FPSETROUND) + +static inline int +fesetround (int mode) +{ + /* fpsetround never fails; instead, it returns the old rounding mode, + which has only a one-in-four chance in general of being 0 as the + SET-FLOAT-ROUNDING-MODE primitive wants. */ + (void) fpsetround (mode); + return (0); +} + +# define HAVE_FESETROUND +#endif + +#if !defined(FE_TONEAREST) && defined(FP_RN) +# define FE_TONEAREST FP_RN +#endif + +#if !defined(FE_TOWARDZERO) && defined(FP_RZ) +# define FE_TOWARDZERO FP_RZ +#endif + +#if !defined(FE_DOWNWARD) && defined(FP_RM) +# define FE_DOWNWARD FP_RM +#endif + +#if !defined(FE_UPWARD) && defined(FP_RP) +# define FE_UPWARD FP_RP +#endif + #ifndef __GNUC__ # pragma STDC FENV_ACCESS ON #endif