16738 viona should allow configurable packet padding
[illumos-gate.git] / usr / src / head / floatingpoint.h
blobb1f49174c2022e20731fe5a072bc6031b7e3fa4f
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
21 /* Copyright (C) 1989 AT&T */
22 /* All Rights Reserved */
25 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
28 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
29 * Use is subject to license terms.
32 #ifndef _FLOATINGPOINT_H
33 #define _FLOATINGPOINT_H
35 #ifdef __STDC__
36 #include <stdio_tag.h>
37 #endif
38 #include <sys/ieeefp.h>
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
45 * <floatingpoint.h> contains definitions for constants, types, variables,
46 * and functions for:
47 * IEEE floating-point arithmetic base conversion;
48 * IEEE floating-point arithmetic modes;
49 * IEEE floating-point arithmetic exception handling.
51 #if defined(__STDC__) && !defined(_FILEDEFED)
52 #define _FILEDEFED
53 typedef __FILE FILE;
54 #endif
56 typedef int sigfpe_code_type; /* Type of SIGFPE code. */
58 typedef void (*sigfpe_handler_type)(); /* Pointer to exception handler */
60 #define SIGFPE_DEFAULT (void (*)())0 /* default exception handling */
61 #define SIGFPE_IGNORE (void (*)())1 /* ignore this exception or code */
62 #define SIGFPE_ABORT (void (*)())2 /* force abort on exception */
64 extern sigfpe_handler_type sigfpe(sigfpe_code_type, sigfpe_handler_type);
67 * Types for IEEE floating point.
69 typedef float single;
71 #ifndef _EXTENDED
72 #define _EXTENDED
73 typedef unsigned extended[3];
74 #endif
76 typedef long double quadruple; /* Quadruple-precision type. */
78 typedef unsigned fp_exception_field_type;
80 * A field containing fp_exceptions OR'ed
81 * together.
84 * Definitions for base conversion.
86 #define DECIMAL_STRING_LENGTH 512 /* Size of buffer in decimal_record. */
88 typedef char decimal_string[DECIMAL_STRING_LENGTH];
89 /* Decimal significand. */
91 typedef struct {
92 enum fp_class_type fpclass;
93 int sign;
94 int exponent;
95 decimal_string ds; /* Significand - each char contains an ascii */
96 /* digit, except the string-terminating */
97 /* ascii null. */
98 int more; /* On conversion from decimal to binary, != 0 */
99 /* indicates more non-zero digits following */
100 /* ds. */
101 int ndigits; /* On fixed_form conversion from binary to */
102 /* decimal, contains number of digits */
103 /* required for ds. */
104 } decimal_record;
106 enum decimal_form {
107 fixed_form, /* Fortran F format: ndigits specifies number */
108 /* of digits after point; if negative, */
109 /* specifies rounding to occur to left of */
110 /* point. */
111 floating_form /* Fortran E format: ndigits specifies number */
112 /* of significant digits. */
115 typedef struct {
116 enum fp_direction_type rd;
117 /* Rounding direction. */
118 enum decimal_form df; /* Format for conversion from binary to */
119 /* decimal. */
120 int ndigits; /* Number of digits for conversion. */
121 } decimal_mode;
123 enum decimal_string_form { /* Valid decimal number string formats. */
124 invalid_form, /* Not a valid decimal string format. */
125 whitespace_form, /* All white space - valid in Fortran! */
126 fixed_int_form, /* <digs> */
127 fixed_intdot_form, /* <digs>. */
128 fixed_dotfrac_form, /* .<digs> */
129 fixed_intdotfrac_form, /* <digs>.<frac> */
130 floating_int_form, /* <digs><exp> */
131 floating_intdot_form, /* <digs>.<exp> */
132 floating_dotfrac_form, /* .<digs><exp> */
133 floating_intdotfrac_form, /* <digs>.<digs><exp> */
134 inf_form, /* inf */
135 infinity_form, /* infinity */
136 nan_form, /* nan */
137 nanstring_form /* nan(string) */
140 extern void single_to_decimal(single *, decimal_mode *, decimal_record *,
141 fp_exception_field_type *);
142 extern void double_to_decimal(double *, decimal_mode *, decimal_record *,
143 fp_exception_field_type *);
144 extern void extended_to_decimal(extended *, decimal_mode *,
145 decimal_record *, fp_exception_field_type *);
146 extern void quadruple_to_decimal(quadruple *, decimal_mode *,
147 decimal_record *, fp_exception_field_type *);
149 extern void decimal_to_single(single *, decimal_mode *, decimal_record *,
150 fp_exception_field_type *);
151 extern void decimal_to_double(double *, decimal_mode *, decimal_record *,
152 fp_exception_field_type *);
153 extern void decimal_to_extended(extended *, decimal_mode *,
154 decimal_record *, fp_exception_field_type *);
155 extern void decimal_to_quadruple(quadruple *, decimal_mode *,
156 decimal_record *, fp_exception_field_type *);
158 extern void string_to_decimal(char **, int, int, decimal_record *,
159 enum decimal_string_form *, char **);
160 extern void func_to_decimal(char **, int, int, decimal_record *,
161 enum decimal_string_form *, char **,
162 int (*)(void), int *, int (*)(int));
163 extern void file_to_decimal(char **, int, int, decimal_record *,
164 enum decimal_string_form *, char **,
165 FILE *, int *);
167 extern char *seconvert(single *, int, int *, int *, char *);
168 extern char *sfconvert(single *, int, int *, int *, char *);
169 extern char *sgconvert(single *, int, int, char *);
170 extern char *econvert(double, int, int *, int *, char *);
171 extern char *fconvert(double, int, int *, int *, char *);
172 extern char *gconvert(double, int, int, char *);
173 extern char *qeconvert(quadruple *, int, int *, int *, char *);
174 extern char *qfconvert(quadruple *, int, int *, int *, char *);
175 extern char *qgconvert(quadruple *, int, int, char *);
177 extern char *ecvt(double, int, int *, int *);
178 extern char *fcvt(double, int, int *, int *);
179 extern char *gcvt(double, int, char *);
181 #if __cplusplus >= 199711L
182 namespace std {
183 #endif
185 * ANSI C Standard says the following entry points should be
186 * prototyped in <stdlib.h>. They are now, but weren't before.
188 extern double atof(const char *);
189 extern double strtod(const char *, char **);
190 #if __cplusplus >= 199711L
193 using std::atof;
194 using std::strtod;
195 #endif /* end of namespace std */
197 #ifdef __cplusplus
199 #endif
201 #endif /* _FLOATINGPOINT_H */