comparison src/build-msvctools/compat/mingwcompat_gcc.c @ 3061:f8299bb6c872

Initial support for native MSVC compilation. * add MSVC support files: compiler wrappers and support libraries * adapt libiconv to work with MSVC * adapt gettext to work with MSVC
author Michael Goffioul <michael.goffioul@gmail.com>
date Mon, 17 Jun 2013 22:43:11 -0400
parents
children
comparison
equal deleted inserted replaced
3060:cbdf4575016d 3061:f8299bb6c872
1 #ifdef __MINGW64__
2 #error "this file is not ported to MinGW-64 yet"
3 #endif
4
5 /*
6 * Code mainly copied from libgcc2.c.
7 */
8
9 typedef float SFtype __attribute__ ((mode (SF)));
10 typedef float DFtype __attribute__ ((mode (DF)));
11 typedef float XFtype __attribute__ ((mode (XF)));
12 typedef float TFtype __attribute__ ((mode (TF)));
13
14 #define W_TYPE_SIZE 32
15 #define UDWtype unsigned long long
16 #define UWtype unsigned long
17 #define Wtype_MAXp1_F 0x1p32f
18
19 #define __fixunsdfDI __fixunsdfdi
20 #define __fixunsxfDI __fixunsxfdi
21
22 UDWtype
23 __fixunsdfDI (DFtype a)
24 {
25 /* Get high part of result. The division here will just moves the radix
26 point and will not cause any rounding. Then the conversion to integral
27 type chops result as desired. */
28 const UWtype hi = a / Wtype_MAXp1_F;
29
30 /* Get low part of result. Convert `hi' to floating type and scale it back,
31 then subtract this from the number being converted. This leaves the low
32 part. Convert that to integral type. */
33 const UWtype lo = a - (DFtype) hi * Wtype_MAXp1_F;
34
35 /* Assemble result from the two parts. */
36 return ((UDWtype) hi << W_TYPE_SIZE) | lo;
37 }
38
39 UDWtype
40 __fixunsxfDI (XFtype a)
41 {
42 if (a < 0)
43 return 0;
44
45 /* Compute high word of result, as a flonum. */
46 const XFtype b = (a / Wtype_MAXp1_F);
47 /* Convert that to fixed (but not to DWtype!),
48 and shift it into the high word. */
49 UDWtype v = (UWtype) b;
50 v <<= W_TYPE_SIZE;
51 /* Remove high part from the XFtype, leaving the low part as flonum. */
52 a -= (XFtype)v;
53 /* Convert that to fixed (but not to DWtype!) and add it in.
54 Sometimes A comes out negative. This is significant, since
55 A has more bits than a long int does. */
56 if (a < 0)
57 v -= (UWtype) (- a);
58 else
59 v += (UWtype) a;
60 return v;
61 }
62
63 #define POWIF_IMPL(NAME, TYPE) \
64 TYPE \
65 NAME (TYPE x, int m) \
66 { \
67 unsigned int n = m < 0 ? -m : m; \
68 TYPE y = n % 2 ? x : 1; \
69 while (n >>= 1) \
70 { \
71 x = x * x; \
72 if (n % 2) \
73 y = y * x; \
74 } \
75 return m < 0 ? 1/y : y; \
76 }
77
78 POWIF_IMPL(__powisf2, SFtype)
79 POWIF_IMPL(__powidf2, DFtype)
80 POWIF_IMPL(__powixf2, XFtype)
81
82 long double __strtold (const char *nptr, char **endptr)
83 {
84 return strtod (nptr, endptr);
85 }