My first commit.
[dragonfly.git] / sys / i386 / gnu / fpemul / exception.h
1 /*
2  *  exception.h
3  *
4  *
5  * Copyright (C) 1992,1993,1994
6  *                       W. Metzenthen, 22 Parker St, Ormond, Vic 3163,
7  *                       Australia.  E-mail   billm@vaxc.cc.monash.edu.au
8  * All rights reserved.
9  *
10  * This copyright notice covers the redistribution and use of the
11  * FPU emulator developed by W. Metzenthen. It covers only its use
12  * in the 386BSD, FreeBSD and NetBSD operating systems. Any other
13  * use is not permitted under this copyright.
14  *
15  * Redistribution and use in source and binary forms, with or without
16  * modification, are permitted provided that the following conditions
17  * are met:
18  * 1. Redistributions of source code must retain the above copyright
19  *    notice, this list of conditions and the following disclaimer.
20  * 2. Redistributions in binary form must include information specifying
21  *    that source code for the emulator is freely available and include
22  *    either:
23  *      a) an offer to provide the source code for a nominal distribution
24  *         fee, or
25  *      b) list at least two alternative methods whereby the source
26  *         can be obtained, e.g. a publically accessible bulletin board
27  *         and an anonymous ftp site from which the software can be
28  *         downloaded.
29  * 3. All advertising materials specifically mentioning features or use of
30  *    this emulator must acknowledge that it was developed by W. Metzenthen.
31  * 4. The name of W. Metzenthen may not be used to endorse or promote
32  *    products derived from this software without specific prior written
33  *    permission.
34  *
35  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
36  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
37  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
38  * W. METZENTHEN BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
39  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
40  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
41  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
42  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
43  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
44  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45  *
46  *
47  * The purpose of this copyright, based upon the Berkeley copyright, is to
48  * ensure that the covered software remains freely available to everyone.
49  *
50  * The software (with necessary differences) is also available, but under
51  * the terms of the GNU copyleft, for the Linux operating system and for
52  * the djgpp ms-dos extender.
53  *
54  * W. Metzenthen   June 1994.
55  *
56  *
57  * $FreeBSD: src/sys/gnu/i386/fpemul/exception.h,v 1.9 1999/08/28 00:42:49 peter Exp $
58  * $DragonFly: src/sys/i386/gnu/fpemul/Attic/exception.h,v 1.3 2003/08/07 21:17:20 dillon Exp $
59  *
60  *
61  */
62
63 #ifndef _EXCEPTION_H_
64 #define _EXCEPTION_H_
65
66
67 #ifdef LOCORE
68 #define Const_(x)       $/**/x
69 #else
70 #define Const_(x)       x
71 #endif
72
73 #ifndef SW_C1
74 #include "fpu_emu.h"
75 #endif                          /* SW_C1 */
76
77 #define FPU_BUSY        Const_(0x8000)  /* FPU busy bit (8087 compatibility) */
78 #define EX_ErrorSummary Const_(0x0080)  /* Error summary status */
79 /* Special exceptions: */
80 #define EX_INTERNAL     Const_(0x8000)  /* Internal error in wm-FPU-emu */
81 #define EX_StackOver    Const_(0x0041|SW_C1)    /* stack overflow */
82 #define EX_StackUnder   Const_(0x0041)  /* stack underflow */
83 /* Exception flags: */
84 #define EX_Precision    Const_(0x0020)  /* loss of precision */
85 #define EX_Underflow    Const_(0x0010)  /* underflow */
86 #define EX_Overflow     Const_(0x0008)  /* overflow */
87 #define EX_ZeroDiv      Const_(0x0004)  /* divide by zero */
88 #define EX_Denormal     Const_(0x0002)  /* denormalized operand */
89 #define EX_Invalid      Const_(0x0001)  /* invalid operation */
90
91
92 #ifndef LOCORE
93
94 #ifdef DEBUG
95 #define EXCEPTION(x)                                                        \
96         do {                                                                \
97                 printf("exception in %s at line %d\n", __FILE__, __LINE__); \
98                 exception(x);                                               \
99         } while (0)
100 #else
101 #define EXCEPTION(x)    exception(x)
102 #endif
103
104 #endif                          /* LOCORE */
105
106 #endif                          /* _EXCEPTION_H_ */