#else
UNIMPLEMENTED_FLOAT_EXCEPTIONS_PRIMITIVE ()
#endif
+
+/* The subnormal operand exception is nonstandard but appears on x86. */
+
+DEFINE_PRIMITIVE ("FLOAT-SUBNORMAL-OPERAND-EXCEPTION", Prim_float_subnormal_operand_exception, 0, 0, 0)
+#ifdef FE_DENORMAL
+ FLOAT_EXCEPTIONS_PRIMITIVE (FE_DENORMAL)
+#else
+ UNIMPLEMENTED_FLOAT_EXCEPTIONS_PRIMITIVE ()
+#endif
\f
DEFINE_PRIMITIVE ("FLOAT-EXCEPTIONS", Prim_float_exceptions, 0, 0, 0)
FLOAT_EXCEPTIONS_PRIMITIVE (FE_ALL_EXCEPT)
(flo:exception:underflow float-underflow-exception 0)
(flo:exception:overflow float-overflow-exception 0)
(flo:exception:inexact-result float-inexact-result-exception 0)
+ (flo:exception:subnormal-operand float-subnormal-operand-exception 0)
(flo:test-exceptions test-float-exceptions 1)
(flo:save-exception-flags save-float-exception-flags 1)
(flo:test-exception-flags test-float-exception-flags 2)
(n 'invalid-operation (flo:exception:invalid-operation)
(n 'overflow (flo:exception:overflow)
(n 'underflow (flo:exception:underflow)
- '()))))))
+ (n 'subnormal-operand (flo:exception:subnormal-operand)
+ '())))))))
(define (flo:names->exceptions names)
(define (name->exceptions name)
((invalid-operation) (flo:exception:invalid-operation))
((overflow) (flo:exception:overflow))
((underflow) (flo:exception:underflow))
+ ((subnormal-operand) (flo:exception:subnormal-operand))
(else (error:bad-range-argument names 'flo:names->exceptions))))
(guarantee list-of-unique-symbols? names 'flo:names->exceptions)
(reduce fix:or 0 (map name->exceptions names)))
flo:exception:inexact-result
flo:exception:invalid-operation
flo:exception:overflow
+ flo:exception:subnormal-operand
flo:exception:underflow
flo:exceptions->names
flo:have-environment?
;; (Note that if underflow is trapped, then the machine traps
;; whether or not the result is exact. Go figure.)
(flo:* (no-op .5000001) (flo:shift (no-op 1.) -1022)))))
+
+(if (not (zero? (flo:exception:subnormal-operand)))
+ (begin
+ (define-fpe-descriptor 'SUBNORMAL-OPERAND #t
+ flo:exception:subnormal-operand
+ ;; XXX Should have its own condition type, but this requires OS
+ ;; support for the siginfo code.
+ condition-type:inexact-floating-point-result)
+ (define-fpe-elicitor 'SUBNORMAL-OPERAND 'RAISE
+ (lambda ()
+ (flo:raise-exceptions! (flo:exception:subnormal-operand))))
+ (define-fpe-elicitor 'SUBNORMAL-OPERAND 'USE-A-SUBNORMAL-OPERAND
+ (let ((x (no-op flo:smallest-positive-subnormal)))
+ (lambda ()
+ (flo:+ x flo:smallest-positive-subnormal))))))
\f
(define (for-each-trappable-exception receiver)
(for-each-exception