1
2 #include "precomp.h"
3 #include "winesup.h"
4
5 #ifdef _LIBCNT_
6
7 static struct lconv _LIBCNT_lconv =
8 {
9 ".", // char* decimal_point;
10 ",", // char* thousands_sep;
11 " ", // char* grouping;
12 "$", // char* int_curr_symbol;
13 "$", // char* currency_symbol;
14 ".", // char* mon_decimal_point;
15 "?", // char* mon_thousands_sep;
16 "/", // char* mon_grouping;
17 "+", // char* positive_sign;
18 "-", // char* negative_sign;
19 4, // char int_frac_digits;
20 4, // char frac_digits;
21 4, // char p_cs_precedes;
22 1, // char p_sep_by_space;
23 0, // char n_cs_precedes;
24 1, // char n_sep_by_space;
25 1, // char p_sign_posn;
26 1, // char n_sign_posn;
27 };
28
29 threadlocinfo _LIBCNT_locinfo =
30 {
31 2, // LONG refcount;
32 0, // CP_ACP, // unsigned int lc_codepage;
33 0, // unsigned int lc_collate_cp;
34 {0}, // unsigned long lc_handle[6];
35 {{0}}, // LC_ID lc_id[6];
36
37 // struct {
38 // char *locale;
39 // wchar_t *wlocale;
40 // int *refcount;
41 // int *wrefcount;
42 // } lc_category[6];
43 {{0}},
44
45 0, // int lc_clike;
46 2, // int mb_cur_max;
47 0, // int *lconv_intl_refcount;
48 0, // int *lconv_num_refcount;
49 0, // int *lconv_mon_refcount;
50 &_LIBCNT_lconv, // struct MSVCRT_lconv *lconv;
51 0, // int *ctype1_refcount;
52 0, // unsigned short *ctype1;
53 0, // const unsigned short *pctype;
54 0, // unsigned char *pclmap;
55 0, // unsigned char *pcumap;
56 0, // struct __lc_time_data *lc_time_curr;
57 };
58
59 #define get_locinfo() (&_LIBCNT_locinfo)
60
61 #endif
62
63 #define _SET_NUMBER_(type) *va_arg((*ap), type*) = negative ? -cur : cur
64
65 void
66 __declspec(noinline)
_internal_handle_float(int negative,int exp,int suppress,ULONGLONG d,int l_or_L_prefix,va_list * ap)67 _internal_handle_float(
68 int negative,
69 int exp,
70 int suppress,
71 ULONGLONG d,
72 int l_or_L_prefix,
73 va_list *ap)
74 {
75 long double cur = 1, expcnt = 10;
76 unsigned fpcontrol;
77 BOOL negexp;
78 #ifdef _M_ARM
79 DbgBreakPoint();
80 fpcontrol = _controlfp(0, 0);
81 #else
82 fpcontrol = _control87(0, 0);
83 _control87(_EM_DENORMAL|_EM_INVALID|_EM_ZERODIVIDE
84 |_EM_OVERFLOW|_EM_UNDERFLOW|_EM_INEXACT, 0xffffffff);
85 #endif
86 negexp = (exp < 0);
87 if(negexp)
88 exp = -exp;
89 /* update 'cur' with this exponent. */
90 while(exp) {
91 if(exp & 1)
92 cur *= expcnt;
93 exp /= 2;
94 expcnt = expcnt*expcnt;
95 }
96 cur = (negexp ? d/cur : d*cur);
97
98 #ifdef _M_ARM
99 DbgBreakPoint();
100 _controlfp(fpcontrol, 0xffffffff);
101 #else
102 _control87(fpcontrol, 0xffffffff);
103 #endif
104
105 if (!suppress) {
106 if (l_or_L_prefix) _SET_NUMBER_(double);
107 else _SET_NUMBER_(float);
108 }
109 }
110