[Issue 5323] New: std.math: struct FloatingPointControl, duplicate code and assumes X86
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Dec 5 08:02:56 PST 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5323
Summary: std.math: struct FloatingPointControl, duplicate code
and assumes X86
Product: D
Version: D2
Platform: Other
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: ibuclaw at ubuntu.com
--- Comment #0 from Iain Buclaw <ibuclaw at ubuntu.com> 2010-12-05 08:01:19 PST ---
Excerpt from struct FloatingPointControl:
/** IEEE hardware exceptions.
* By default, all exceptions are masked (disabled).
*/
enum : uint
{
inexactException = 0x20,
underflowException = 0x10,
overflowException = 0x08,
divByZeroException = 0x04,
invalidException = 0x01,
/// Severe = The overflow, division by zero, and invalid exceptions.
severeExceptions = overflowException | divByZeroException
| invalidException,
allExceptions = severeExceptions | underflowException
| inexactException,
};
A little further up the file in struct IeeeFlags:
// The x87 FPU status register is 16 bits.
// The Pentium SSE2 status register is 32 bits.
uint flags;
version (X86_Any) {
// Applies to both x87 status word (16 bits) and SSE2 status word(32 bits).
enum : int {
INEXACT_MASK = 0x20,
UNDERFLOW_MASK = 0x10,
OVERFLOW_MASK = 0x08,
DIVBYZERO_MASK = 0x04,
INVALID_MASK = 0x01
}
// Don't bother about denormals, they are not supported on most CPUs.
// DENORMAL_MASK = 0x02;
} else version (PPC) {
Both implement the same thing, but have (rather confusingly) different names
and one only implements for X86 whereas the other (at least tries) to implement
PPC and SPARC too.
IMO, as both structs take their values from <fpu_control.h> for GlibC
(<machine/ieeeflags.h> for FreeBSD?? <float.h> for Windows???), these enums
(and possibly the Get/Set/Clear CW functions too) should be consolidated into
one place elsewhere. For example, std.internal.math.fpbits, or possibly
DRuntime...
Regards
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list