ReactOS  0.4.13-dev-249-gcba1a2f
floatobj.h
Go to the documentation of this file.
1 #pragma once
2 
3 C_ASSERT(sizeof(FIX) == sizeof(LONG));
4 #define FIX2LONG(x) (((x) + 8) >> 4)
5 #define LONG2FIX(x) ((x) << 4)
6 
7 #if defined(_M_IX86)
8 
10 BOOL
11 _FLOATOBJ_Equal(FLOATOBJ *pf1, FLOATOBJ *pf2)
12 {
13  EFLOAT_S *pef1 = (EFLOAT_S*)pf1;
14  EFLOAT_S *pef2 = (EFLOAT_S*)pf2;
15  return (pef1->lMant == pef2->lMant && pef1->lExp == pef2->lExp);
16 }
17 #define FLOATOBJ_Equal _FLOATOBJ_Equal
18 
20 LONG
21 _FLOATOBJ_GetLong(FLOATOBJ *pf)
22 {
23  EFLOAT_S *pef = (EFLOAT_S*)pf;
24  return pef->lMant >> (32 - pef->lExp);
25 }
26 #define FLOATOBJ_GetLong _FLOATOBJ_GetLong
27 
39 BOOL
42 {
43  EFLOAT_S *pef = (EFLOAT_S*)pf;
44  LONG lShift = 32 - pef->lExp;
45  if (lShift < 0)
46  {
47  return FALSE;
48  }
49  *pl = pef->lMant >> lShift;
50  return TRUE;
51 }
52 
54 LONG
56 {
57  EFLOAT_S *pef = (EFLOAT_S*)pf;
58  LONG Shift = (28 - pef->lExp);
59  return (Shift >= 0 ? pef->lMant >> Shift : pef->lMant << -Shift);
60 }
61 
63 BOOL
65 {
66  EFLOAT_S *pef = (EFLOAT_S*)pf;
67  ULONG ulShift = pef->lExp;
68  if (ulShift < 32)
69  return ((pef->lMant << ulShift) == 0);
70  else
71  return (ulShift == 32);
72 }
73 
75 BOOL
77 {
78  EFLOAT_S *pef = (EFLOAT_S*)pf;
79  return (pef->lMant == 0 && pef->lExp == 0);
80 }
81 
83 BOOL
85 {
86  EFLOAT_S *pef = (EFLOAT_S*)pf;
87  return (pef->lMant == 0x40000000 && pef->lExp == 2);
88 }
89 
90 extern const FLOATOBJ gef0;
91 extern const FLOATOBJ gef1;
92 extern const FLOATOBJ gef16;
93 
94 #define FLOATOBJ_0 {0x00000000, 0x00000000}
95 #define FLOATOBJ_1 {0x40000000, 0x00000002}
96 #define FLOATOBJ_16 {0x40000000, 0x00000006}
97 #define FLOATOBJ_1_16 {0x40000000, 0xfffffffe}
98 
99 #define FLOATOBJ_Set0(fo) do { (fo)->ul1 = 0; (fo)->ul2 = 0; } while (0)
100 #define FLOATOBJ_Set1(fo) do { (fo)->ul1 = 0x40000000; (fo)->ul2 = 2; } while (0)
101 
102 #else
103 
104 #define FLOATOBJ_bConvertToLong(pf, pl) (*pl = (LONG)*pf, TRUE)
105 #define FLOATOBJ_IsLong(pf) ((FLOAT)((LONG)*(pf)) == *(pf))
106 #define FLOATOBJ_Equal0(pf) (*(pf) == 0.)
107 #define FLOATOBJ_Equal1(pf) (*(pf) == 1.)
108 #define FLOATOBJ_GetFix(pf) ((LONG)(*(pf) * 16.))
109 
110 #define FLOATOBJ_0 0.
111 #define FLOATOBJ_1 1.
112 #define FLOATOBJ_16 16.
113 #define FLOATOBJ_1_16 (1./16.)
114 
115 static const FLOATOBJ gef0 = 0.;
116 static const FLOATOBJ gef1 = 1.;
117 static const FLOATOBJ gef16 = 16.;
118 
119 #define FLOATOBJ_Set0(fo) *(fo) = 0;
120 #define FLOATOBJ_Set1(fo) *(fo) = 1;
121 
122 #endif
#define TRUE
Definition: types.h:120
#define FLOATOBJ_Equal0(pf)
Definition: floatobj.h:106
#define FASTCALL
Definition: nt_native.h:50
#define FLOATOBJ_IsLong(pf)
Definition: floatobj.h:105
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
static const FLOATOBJ gef1
Definition: floatobj.h:116
#define FORCEINLINE
Definition: ntbasedef.h:221
#define FLOATOBJ_GetFix(pf)
Definition: floatobj.h:108
#define FLOATOBJ_bConvertToLong(pf, pl)
Definition: floatobj.h:104
FLOAT FLOATOBJ
Definition: winddi.h:677
static const FLOATOBJ gef0
Definition: floatobj.h:115
LONG FIX
Definition: winddi.h:126
static const FLOATOBJ gef16
Definition: floatobj.h:117
LONG lExp
Definition: ntgdityp.h:387
_In_ ULONG Shift
Definition: rtlfuncs.h:2683
LONG lMant
Definition: ntgdityp.h:386
unsigned int ULONG
Definition: retypes.h:1
#define FLOATOBJ_Equal1(pf)
Definition: floatobj.h:107
C_ASSERT(sizeof(FIX)==sizeof(LONG))
signed int * PLONG
Definition: retypes.h:5