summaryrefslogtreecommitdiffstats
path: root/private/crt32/h/fltintrn.h
blob: 5f6cc4d19eef7082054361c5cd2f3be5b24f079b (plain) (blame)
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/***
*fltintrn.h - contains declarations of internal floating point types,
*	      routines and variables
*
*	Copyright (c) 1985-1993, Microsoft Corporation. All rights reserved.
*
*Purpose:
*	Declares floating point types, routines and variables used
*	internally by the C run-time.
*	[Internal]
*
*Revision History:
*	10-20-88  JCR	Changed 'DOUBLE' to 'double' for 386
*	08-15-89  GJF	Fixed copyright, indents
*	10-30-89  GJF	Fixed copyright (again)
*	03-02-90  GJF	Added #ifndef _INC_STRUCT stuff. Also, cleaned up
*			the formatting a bit.
*	03-05-90  GJF	Fixed up the arg types in protoypes. Also, added
*			#include <cruntime.h>
*	03-22-90  GJF	Made _fltin(), _fltin2(), _fltout() and _fltout2()
*			_CALLTYPE2 (for now) and added a prototype for
*			_fptostr().
*	08-01-90  SBM	Moved _cftoe() and _cftof() here from internal.h
*			and _cfltcvt_tab from input.c and output.c,
*			added typedefs for _cfltcvt_tab entries,
*			renamed module from <struct.h> to <fltintrn.h> and
*			adjusted #ifndef stuff to #ifndef _INC_FLTINTRN
*	08-29-90  SBM	Changed type of _cfltcvt_tab[] to agree with
*			definition in cmiscdat.c
*       04-26-91  SRW   Removed level 3 warnings
*	08-26-91  JCR	Changed MIPS to _MIPS_, ANSI naming
*	08-06-92  GJF	Function calling type and variable type macros. Revised
*			use of target processor macros.
*	11-09-92  GJF	Fixed preprocessing conditionals for MIPS.
*       01-09-93  SRW   Remove usage of MIPS and ALPHA to conform to ANSI
*			Use _MIPS_ and _ALPHA_ instead.
*	01-21-93  GJF	Removed support for C6-386's _cdecl.
*	03-31-93  CFW	Added #pragma warning to suppress "long double" warnings.
*
****/

#ifndef _INC_FLTINTRN

#ifdef __cplusplus
extern "C" {
#endif

#include <cruntime.h>

/*
 * Conditional macro definition for function calling type and variable type
 * qualifiers.
 */
#if   ( (_MSC_VER >= 800) && (_M_IX86 >= 300) )

/*
 * Definitions for MS C8-32 (386/486) compiler
 */
#define _CRTAPI1 __cdecl
#define _CRTAPI2 __cdecl

#else

/*
 * Other compilers (e.g., MIPS)
 */
#define _CRTAPI1
#define _CRTAPI2
#define _CRTVAR1

#endif

// C4069: "long double != double"
#pragma warning(disable:4069)	// disable C4069 warning
// #pragma warning(default:4069)	// use this to reenable, if desired

/*
 * structs used to fool the compiler into not generating floating point
 * instructions when copying and pushing [long] double values
 */

#ifndef DOUBLE

typedef struct {
	double x;
} DOUBLE;

#endif

#ifndef LONGDOUBLE

typedef struct {
#if   defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC)
	/*
	 * No long double type for MIPS, ALPHA, or PPC
	 */
	double x;
#else
	/*
	 * Assume there is a long double type
	 */
	long double x;
#endif
} LONGDOUBLE;

#endif

/*
 * typedef for _fltout
 */

typedef struct _strflt
{
	int sign;	      /* zero if positive otherwise negative */
	int decpt;	      /* exponent of floating point number */
	int flag;	      /* zero if okay otherwise IEEE overflow */
	char *mantissa;       /* pointer to mantissa in string form */
}
	*STRFLT;


/*
 * typedef for _fltin
 */

typedef struct _flt
{
	int flags;
	int nbytes;	     /* number of characters read */
	long lval;
	double dval;	     /* the returned floating point number */
}
	*FLT;


/* floating point conversion routines, keep in sync with mrt32\include\convert.h */

char *_cftoe(double *, char *, int, int);
char *_cftof(double *, char *, int);
void _CRTAPI1 _fptostr(char *, int, STRFLT);

#ifdef	MTHREAD

STRFLT	_CRTAPI2 _fltout2( double, STRFLT, char * );
FLT	_CRTAPI2 _fltin2( FLT , const char *, int, int, int );

#else

STRFLT	_CRTAPI2 _fltout( double );
FLT	_CRTAPI2 _fltin( const char *, int, int, int );

#endif


/*
 * table of pointers to floating point helper routines
 *
 * We can't specify the prototypes for the entries of the table accurately,
 * since different functions in the table have different arglists.
 * So we declare the functions to take and return void (which is the
 * correct prototype for _fptrap(), which is what the entries are all
 * initialized to if no floating point is loaded) and cast appropriately
 * on every usage.
 */

typedef void (* PFV)(void);
extern PFV _cfltcvt_tab[6];

typedef void (* PF0)(DOUBLE*, char*, int, int, int);
#define _cfltcvt(a,b,c,d,e) (*((PF0)_cfltcvt_tab[0]))(a,b,c,d,e)

typedef void (* PF1)(char*);
#define _cropzeros(a)	    (*((PF1)_cfltcvt_tab[1]))(a)

typedef void (* PF2)(int, char*, char*);
#define _fassign(a,b,c)     (*((PF2)_cfltcvt_tab[2]))(a,b,c)

typedef void (* PF3)(char*);
#define _forcdecpt(a)	    (*((PF3)_cfltcvt_tab[3]))(a)

typedef int (* PF4)(DOUBLE*);
#define _positive(a)	    (*((PF4)_cfltcvt_tab[4]))(a)

typedef void (* PF5)(LONGDOUBLE*, char*, int, int, int);
#define _cldcvt(a,b,c,d,e)  (*((PF5)_cfltcvt_tab[5]))(a,b,c,d,e)

#ifdef __cplusplus
}
#endif

#define _INC_FLTINTRN
#endif	/* _INC_FLTINTRN */