ReactOS  0.4.15-dev-1397-g19779b3
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 
16 /* FUNCTIONS *****************************************************************/
17 
18 #ifdef _PREFAST_
19 #pragma warning(disable:__WARNING_WRONG_KIND)
20 #endif
21 
23 _Success_(return)
26  _Kernel_releases_resource_(EngFloatState))
27 ENGAPI
28 BOOL
30 EngRestoreFloatingPointState(
31  _In_reads_(_Inexpressible_(statesize)) PVOID pBuffer)
32 {
34 
36  if (!NT_SUCCESS(Status))
37  {
38  return FALSE;
39  }
40 
41  return TRUE;
42 }
43 
45 _Success_(((pBuffer != NULL && cjBufferSize != 0) && return == 1) ||
46  ((pBuffer == NULL || cjBufferSize == 0) && return > 0))
47 _When_(pBuffer != NULL && cjBufferSize != 0 && return == 1, _Kernel_float_saved_
50 ENGAPI
51 ULONG
53 EngSaveFloatingPointState(
55  _Out_writes_bytes_opt_(cjBufferSize) PVOID pBuffer,
56  _Inout_ ULONG cjBufferSize)
57 {
58  KFLOATING_SAVE TempBuffer;
60 
61  if ((pBuffer == NULL) || (cjBufferSize == 0))
62  {
63  /* Check for floating point support. */
64  Status = KeSaveFloatingPointState(&TempBuffer);
65  if (Status != STATUS_SUCCESS)
66  {
67  return(0);
68  }
69 
70  KeRestoreFloatingPointState(&TempBuffer);
71  return(sizeof(KFLOATING_SAVE));
72  }
73 
74  if (cjBufferSize < sizeof(KFLOATING_SAVE))
75  {
76  return(0);
77  }
78 
80  if (!NT_SUCCESS(Status))
81  {
82  return FALSE;
83  }
84 
85  return TRUE;
86 }
87 
return
Definition: dirsup.c:529
#define TRUE
Definition: types.h:120
#define ENGAPI
Definition: winddi.h:48
LONG NTSTATUS
Definition: precomp.h:26
#define _Kernel_acquires_resource_(kind)
Definition: driverspecs.h:229
#define _Check_return_
Definition: no_sal2.h:60
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define _On_failure_(a)
Definition: no_sal2.h:88
PVOID pBuffer
#define _Kernel_float_restored_
Definition: driverspecs.h:222
#define KeRestoreFloatingPointState(x)
Definition: kmixer.h:33
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define _Inout_
Definition: no_sal2.h:162
#define _Post_satisfies_(e)
Definition: no_sal2.h:66
#define _Kernel_float_saved_
Definition: driverspecs.h:223
#define KeSaveFloatingPointState(x)
Definition: kmixer.h:32
#define _Post_valid_
Definition: no_sal2.h:522
_Check_return_ _Success_(return)
Definition: float.c:23
#define _Kernel_releases_resource_(kind)
Definition: driverspecs.h:226
#define _At_(t, a)
Definition: no_sal2.h:40
#define NULL
Definition: types.h:112
#define _When_(c, a)
Definition: no_sal2.h:38
#define _Out_writes_bytes_opt_(s)
Definition: no_sal2.h:228
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
#define _In_reads_(s)
Definition: no_sal2.h:168
#define _Kernel_requires_resource_not_held_(kind)
Definition: driverspecs.h:228
#define _Kernel_requires_resource_held_(kind)
Definition: driverspecs.h:227
#define APIENTRY
Definition: api.h:79