File: ctrl87.h

package info (click to toggle)
gnuplot 3.5beta6.347-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 5,032 kB
  • ctags: 4,235
  • sloc: ansic: 42,086; makefile: 561; asm: 539; sh: 386; objc: 379; csh: 297; pascal: 194; perl: 138; lisp: 88
file content (148 lines) | stat: -rw-r--r-- 5,304 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/* $Id: ctrl87.h,v 1.2 1998/03/22 22:31:27 drd Exp $ */

/* GNUPLOT - ctrl87.h */

/*[
 * Copyright 1986 - 1993, 1998   Thomas Williams, Colin Kelley
 *
 * Permission to use, copy, and distribute this software and its
 * documentation for any purpose with or without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.
 *
 * Permission to modify the software is granted, but not the right to
 * distribute the complete modified source code.  Modifications are to
 * be distributed as patches to the released version.  Permission to
 * distribute binaries produced by compiling modified sources is granted,
 * provided you
 *   1. distribute the corresponding source modifications from the
 *    released version in the form of a patch file along with the binaries,
 *   2. add special version identification to distinguish your version
 *    in addition to the base release version number,
 *   3. provide your name and address as the primary contact for the
 *    support of your modified version, and
 *   4. retain our contact information in regard to use of the base
 *    software.
 * Permission to distribute the released version of the source code along
 * with corresponding source modifications in the form of a patch file is
 * granted with same provisions 2 through 4 for binary distributions.
 *
 * This software is provided "as is" without express or implied warranty
 * to the extent permitted by applicable law.
]*/


#ifndef __CONTROL87_H__


#define __CONTROL87_H__


#ifdef __CONTROL87_C__
#define EXTERN
#else
#define EXTERN extern
#endif


/* 8087/80287 Status Word format   */

#define SW_INVALID      0x0001  /* Invalid operation            */
#define SW_DENORMAL     0x0002  /* Denormalized operand         */
#define SW_ZERODIVIDE   0x0004  /* Zero divide                  */
#define SW_OVERFLOW     0x0008  /* Overflow                     */
#define SW_UNDERFLOW    0x0010  /* Underflow                    */
#define SW_INEXACT      0x0020  /* Precision (Inexact result)   */

/* 8087/80287 Control Word format */

#define MCW_EM              0x003f  /* interrupt Exception Masks*/
#define     EM_INVALID      0x0001  /*   invalid                */
#define     EM_DENORMAL     0x0002  /*   denormal               */
#define     EM_ZERODIVIDE   0x0004  /*   zero divide            */
#define     EM_OVERFLOW     0x0008  /*   overflow               */
#define     EM_UNDERFLOW    0x0010  /*   underflow              */
#define     EM_INEXACT      0x0020  /*   inexact (precision)    */

#define MCW_IC              0x1000  /* Infinity Control */
#define     IC_AFFINE       0x1000  /*   affine         */
#define     IC_PROJECTIVE   0x0000  /*   projective     */

#define MCW_RC          0x0c00  /* Rounding Control     */
#define     RC_CHOP     0x0c00  /*   chop               */
#define     RC_UP       0x0800  /*   up                 */
#define     RC_DOWN     0x0400  /*   down               */
#define     RC_NEAR     0x0000  /*   near               */

#define MCW_PC          0x0300  /* Precision Control    */
#define     PC_24       0x0000  /*    24 bits           */
#define     PC_53       0x0200  /*    53 bits           */
#define     PC_64       0x0300  /*    64 bits           */

/**************************************************************************/
/*************************   Type declarations   **************************/
/**************************************************************************/

/**************************************************************************/
/************************   Function declarations   ***********************/
/**************************************************************************/

/*
   _control87 changes floating-point control word.

   Declaration:
   ------------
     unsigned short _control87(unsigned short newcw, unsigned short mask);

   Remarks:
   --------
  _control87 retrieves or changes the floating-point control word.

  The floating-point control word is an unsigned short that specifies the
  following modes in the 80x87 FPU:
   o  allowed exceptions
   o  infinity mode
   o  rounding mode
   o  precision mode

  Changing these modes allows you to mask or unmask floating-point exceptions.

  _control87 matches the bits in mask to the bits in newcw.

  If any mask bit = 1, the corresponding bit in newcw contains the new value
  for the same bit in the floating-point control word.

  If mask = 0000, _control87 returns the floating-point control word without
  altering it.

   Examples:
   ---------
  Switching to projective infinity mode:
     _control87(IC_PROJECTIVE, MCW_IC);

  Disabling all exceptions:
     _control87(MCW_EM, MCW_EM);

   Return Value:
   -------------
  The bits in the value returned reflect the new floating-point control word.
*/
EXTERN unsigned short _control87(unsigned short newcw, unsigned short mask);


/**************************************************************************/
/**************************   Global variables   **************************/
/**************************************************************************/



#ifdef __CONTROL87_C__
#else
#endif


#undef EXTERN


#endif