Date: Sun, 21 Dec 2003 13:47:16 -0800 (PST) From: "Steven G. Kargl" <kargl@troutmask.apl.washington.edu> To: freebsd-standards@freebsd.org Subject: fenv.h implementation questions Message-ID: <200312212147.hBLLlGrr028043@troutmask.apl.washington.edu>
next in thread | raw e-mail | index | archive | help
Is the following a sufficient implementation of fenv.h? _fenv_t and _fexcept_t would be defined in machine/fenv.h, which I haven't implemented, yet. I'm assuming that these may be architecture specific (e.g., endianness). SuSv3 states that the exception and rounding mode macros are to be defined *if and only if* the implementation supports them. It also states that the function prototypes that I've include need to be specified. However, why would we need to specify, say, fegetround(), if the implementation doesn't support control of the rounding mode? Finally, how the heck do we implement the #pragma at the end? #ifndef _FENV_H_ #define _FENV_H_ #include <sys/cdefs.h> #include <machine/fenv.h> typedef fenv_t _fenv_t; typedef fexcept_t _fexcept_t; #ifdef _EXCEPTIONS #define FE_DIVBYZERO 0x00000001 /* Divide by zero */ #define FE_INEXACT 0x00000002 /* Inexact flag raised */ #define FE_INVALID 0x00000004 /* Invalid operation */ #define FE_OVERFLOW 0x00000008 /* Overflow */ #define FE_UNDERFLOW 0x00000010 /* Underflow */ #define FE_ALL_EXCEPT 0x0000001F /* Bitwise-or of above flags */ #endif /* _EXCEPTIONS */ #ifdef _ROUNDING_MODES #define FE_DOWNWARD 0x00000020 /* Round downward */ #define FE_TONEAREST 0x00000040 /* Round to nearest */ #define FE_TOWARDZERO 0x00000080 /* Round towards zero */ #define FE_UPWARD 0x00000100 /* Round upwards */ #endif /* _ROUNDING_MODES */ #define FE_DFL_ENV (fenv_t const *) #if !defined(_FENV_INLINED_) __BEGIN_DECLS extern int feclearexcept(int); extern int fegetenv(fenv_t *); extern int fegetexceptflag(fexcept_t *, int); extern int fegetround(void); extern int feholdexcept(fenv_t *); extern int feraiseexcept(int); extern int fesetenv(const fenv_t *); extern int fesetexceptflag(const fexcept_t *, int); extern int fesetround(int); extern int fetestexcept(int); extern int feupdateenv(fenv_t *); __END_DECLS #endif /* !_FENV_INLINED_ */ #if 0 /* XXX Need to implement the FENV_ACCESS pragma */ #endif #endif /* _FENV_H_ */ -- Steve http://troutmask.apl.washington.edu/~kargl/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200312212147.hBLLlGrr028043>