8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libbc / inc / include / floatingpoint.h
blob251bb3003f2f00963b87cd58d56eb9fc612ed1e2
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
22 #pragma ident "%Z%%M% %I% %E% SMI"
25 * Copyright (c) 1988 by Sun Microsystems, Inc.
29 * IEEE floating-point definitions for constants, types, variables, and
30 * functions implemented in libc.a for: IEEE floating-point arithmetic base
31 * conversion; IEEE floating-point arithmetic modes; IEEE floating-point
32 * arithmetic exception handling; certain functions defined in 4.3 BSD and
33 * System V.
36 #ifndef _floatingpoint_h
37 #define _floatingpoint_h
39 #include <sys/ieeefp.h>
41 /* Sun TYPES for IEEE floating point. */
43 typedef float single;
44 typedef unsigned long extended[3]; /* MC68881/i80387 double-extended type. */
45 #ifdef __STDC__
46 typedef long double quadruple; /* Quadruple-precision type. */
47 #else
48 typedef struct {
49 unsigned long u[4];
50 } quadruple; /* Quadruple-precision type. */
51 #endif
53 #define N_IEEE_EXCEPTION 5 /* Number of floating-point exceptions. */
55 typedef unsigned fp_exception_field_type;
57 * A field containing fp_exceptions OR'ed together.
60 typedef int sigfpe_code_type; /* Type of SIGFPE code. */
62 typedef void (*sigfpe_handler_type) ();
63 /* Pointer to exception handler function. */
65 #define SIGFPE_DEFAULT (void (*)())0 /* default exception handling */
66 #define SIGFPE_IGNORE (void (*)())1 /* ignore this exception or code */
67 #define SIGFPE_ABORT (void (*)())2 /* force abort on exception */
69 /* Sun VARIABLES for IEEE floating point. */
71 extern enum fp_direction_type fp_direction;
73 * Current rounding direction. Updated by ieee_flags.
76 extern enum fp_precision_type fp_precision;
78 * Current rounding precision. Updated by ieee_flags.
81 extern fp_exception_field_type fp_accrued_exceptions;
83 * Sticky accumulated exceptions, updated by ieee_flags. In hardware
84 * implementations this variable is not automatically updated as the hardware
85 * changes and should therefore not be relied on directly.
88 /* Sun definitions for base conversion. */
90 #define DECIMAL_STRING_LENGTH 512
91 /* Size of buffer in decimal_record. */
93 typedef char decimal_string[DECIMAL_STRING_LENGTH];
94 /* Decimal significand. */
96 typedef struct {
97 enum fp_class_type fpclass;
98 int sign;
99 int exponent;
100 decimal_string ds; /* Significand - each char contains an ascii
101 * digit, except the string-terminating ascii
102 * null. */
103 int more; /* On conversion from decimal to binary, != 0
104 * indicates more non-zero digits following
105 * ds. */
106 int ndigits;/* On fixed_form conversion from binary to
107 * decimal, contains number of digits
108 * required for ds. */
110 decimal_record;
112 enum decimal_form {
113 fixed_form, /* Fortran F format: ndigits specifies number
114 * of digits after point; if negative,
115 * specifies rounding to occur to left of
116 * point. */
117 floating_form /* Fortran E format: ndigits specifies number
118 * of significant digits. */
121 typedef struct {
122 enum fp_direction_type rd;
123 /* Rounding direction. */
124 enum decimal_form df; /* Format for binary to decimal conversion. */
125 int ndigits;/* Number of digits for conversion. */
127 decimal_mode;
129 enum decimal_string_form { /* Valid decimal number string formats. */
130 invalid_form, /* Not a valid decimal string format. */
131 whitespace_form, /* All white space - valid in Fortran! */
132 fixed_int_form, /* <digs> */
133 fixed_intdot_form, /* <digs>. */
134 fixed_dotfrac_form, /* .<digs> */
135 fixed_intdotfrac_form, /* <digs>.<frac> */
136 floating_int_form, /* <digs><exp> */
137 floating_intdot_form, /* <digs>.<exp> */
138 floating_dotfrac_form, /* .<digs><exp> */
139 floating_intdotfrac_form, /* <digs>.<digs><exp> */
140 inf_form, /* inf */
141 infinity_form, /* infinity */
142 nan_form, /* nan */
143 nanstring_form /* nan(string) */
146 /* The following externs are used in the implementation of sprintf. */
148 extern void double_to_decimal();
149 extern void quadruple_to_decimal();
150 extern char *econvert();
151 extern char *fconvert();
152 extern char *gconvert();
153 extern char *qeconvert();
154 extern char *qfconvert();
155 extern char *qgconvert();
158 The following are used for other parts of base conversion.
161 extern sigfpe_handler_type ieee_handlers[N_IEEE_EXCEPTION];
163 * Array of pointers to functions to handle SIGFPE's corresponding to IEEE
164 * fp_exceptions. sigfpe_default means do not generate SIGFPE. An invalid
165 * address such as sigfpe_abort will cause abort on that SIGFPE. Updated by
166 * ieee_handler.
169 extern sigfpe_handler_type sigfpe();
171 extern void single_to_decimal();
172 extern void extended_to_decimal();
174 extern void decimal_to_single();
175 extern void decimal_to_double();
176 extern void decimal_to_extended();
177 extern void decimal_to_quadruple();
179 extern char *seconvert();
180 extern char *sfconvert();
181 extern char *sgconvert();
183 extern void string_to_decimal();
184 extern void file_to_decimal();
185 extern void func_to_decimal();
187 /* Definitions from 4.3 BSD math.h 4.6 9/11/85 */
189 extern double atof();
191 /* Definitions from System V */
193 extern int errno;
195 extern double strtod();
197 #endif /* !_floatingpoint_h */