ReactOS 0.4.16-dev-2298-gcac013a
float.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: Engine floating point functions
5 * FILE: win32ss/gdi/eng/float.c
6 * PROGRAMER: David Welch
7 */
8
9/* INCLUDES *****************************************************************/
10
11#include <win32k.h>
12
13#define NDEBUG
14#include <debug.h>
15
17{
21
22/* FUNCTIONS *****************************************************************/
23
24#ifdef _PREFAST_
25#pragma warning(disable:__WARNING_WRONG_KIND)
26#endif
27
29_Success_(return)
32 _Kernel_releases_resource_(EngFloatState))
34BOOL
36EngRestoreFloatingPointState(
37 _In_reads_(_Inexpressible_(statesize)) PVOID pBuffer)
38{
41
42 if (!State->IsFloatingPointSaved)
43 {
44 DPRINT1("The driver has attempted to restore floating point state after already restoring it.\n");
45 DPRINT1("This (probably ICafe AMD) driver has done an incorrect behavior.\n");
46 return FALSE;
47 }
48
49 State->IsFloatingPointSaved = FALSE;
50
52 if (!NT_SUCCESS(Status))
53 {
54 return FALSE;
55 }
56
57 return TRUE;
58}
59
61_Success_(((pBuffer != NULL && cjBufferSize != 0) && return == 1) ||
62 ((pBuffer == NULL || cjBufferSize == 0) && return > 0))
63_When_(pBuffer != NULL && cjBufferSize != 0 && return == 1, _Kernel_float_saved_
69EngSaveFloatingPointState(
72 _Inout_ ULONG cjBufferSize)
73{
76
77 if ((pBuffer == NULL) || (cjBufferSize == 0))
78 {
79 KFLOATING_SAVE TempBuffer;
80
81 /* Check for floating point support. */
82 Status = KeSaveFloatingPointState(&TempBuffer);
84 {
85 return(0);
86 }
87 KeRestoreFloatingPointState(&TempBuffer);
88 return sizeof(WIN32K_FLOATING_SAVE);
89 }
90
91 if (cjBufferSize < sizeof(WIN32K_FLOATING_SAVE))
92 {
93 return(0);
94 }
95
96 /* Per MSDN, "This buffer must be zero-initialized, and must be in nonpaged memory." */
98
99 if (State->IsFloatingPointSaved)
100 {
101 DPRINT1("The driver has attempted to save floating point state after already saving it.\n");
102 DPRINT1("This (probably ICafe AMD) driver has done an incorrect behavior.\n");
103 }
104
105 Status = KeSaveFloatingPointState(&State->FloatState);
106 if (!NT_SUCCESS(Status))
107 {
108 return FALSE;
109 }
110
111 State->IsFloatingPointSaved = TRUE;
112 return TRUE;
113}
114
unsigned char BOOLEAN
Definition: actypes.h:127
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
return
Definition: dirsup.c:529
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define APIENTRY
Definition: api.h:79
#define _Kernel_float_restored_
Definition: driverspecs.h:240
#define _Kernel_requires_resource_held_(kind)
Definition: driverspecs.h:245
#define _Kernel_requires_resource_not_held_(kind)
Definition: driverspecs.h:246
#define _Kernel_releases_resource_(kind)
Definition: driverspecs.h:244
#define _Kernel_acquires_resource_(kind)
Definition: driverspecs.h:247
#define _Kernel_float_saved_
Definition: driverspecs.h:241
unsigned int BOOL
Definition: ntddk_ex.h:94
struct _WIN32K_FLOATING_SAVE * PWIN32K_FLOATING_SAVE
struct _WIN32K_FLOATING_SAVE WIN32K_FLOATING_SAVE
Status
Definition: gdiplustypes.h:25
#define KeSaveFloatingPointState(x)
Definition: kmixer.h:32
#define KeRestoreFloatingPointState(x)
Definition: kmixer.h:33
#define _In_reads_(s)
Definition: no_sal2.h:168
#define _Inout_
Definition: no_sal2.h:162
#define _Success_(c)
Definition: no_sal2.h:84
#define _At_(t, a)
Definition: no_sal2.h:40
#define _Check_return_
Definition: no_sal2.h:60
#define _On_failure_(a)
Definition: no_sal2.h:88
#define _Out_writes_bytes_opt_(s)
Definition: no_sal2.h:228
#define _Post_valid_
Definition: no_sal2.h:522
#define _Post_satisfies_(e)
Definition: no_sal2.h:66
#define _When_(c, a)
Definition: no_sal2.h:38
PVOID pBuffer
#define STATUS_SUCCESS
Definition: shellext.h:65
BOOLEAN IsFloatingPointSaved
Definition: float.c:19
KFLOATING_SAVE FloatState
Definition: float.c:18
uint32_t ULONG
Definition: typedefs.h:59
#define ENGAPI
Definition: winddi.h:48