2012-04-13 16:27:14 +00:00
|
|
|
/*
|
2004-03-11 21:38:58 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* PURPOSE: Engine floating point functions
|
2015-11-10 17:41:55 +00:00
|
|
|
* FILE: win32ss/gdi/eng/float.c
|
2012-04-13 16:27:14 +00:00
|
|
|
* PROGRAMER: David Welch
|
2004-03-11 21:38:58 +00:00
|
|
|
*/
|
2005-06-29 07:09:25 +00:00
|
|
|
|
2007-05-14 03:55:28 +00:00
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
2010-04-26 13:58:46 +00:00
|
|
|
#include <win32k.h>
|
2004-03-11 21:38:58 +00:00
|
|
|
|
2005-06-29 07:09:25 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
2007-05-14 03:55:28 +00:00
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
2015-03-10 00:12:41 +00:00
|
|
|
#ifdef _PREFAST_
|
|
|
|
#pragma warning(disable:__WARNING_WRONG_KIND)
|
|
|
|
#endif
|
|
|
|
|
2015-03-10 00:11:29 +00:00
|
|
|
_Check_return_
|
|
|
|
_Success_(return)
|
|
|
|
_Kernel_float_restored_
|
|
|
|
_At_(*pBuffer, _Kernel_requires_resource_held_(EngFloatState)
|
|
|
|
_Kernel_releases_resource_(EngFloatState))
|
|
|
|
ENGAPI
|
2004-03-11 21:38:58 +00:00
|
|
|
BOOL
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2012-04-13 16:27:14 +00:00
|
|
|
EngRestoreFloatingPointState(
|
2015-03-10 00:11:29 +00:00
|
|
|
_In_reads_(_Inexpressible_(statesize)) PVOID pBuffer)
|
2004-03-11 21:38:58 +00:00
|
|
|
{
|
2012-04-13 16:27:14 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
|
2015-03-10 00:11:29 +00:00
|
|
|
Status = KeRestoreFloatingPointState((PKFLOATING_SAVE)pBuffer);
|
2012-04-13 16:27:14 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
2004-03-11 21:38:58 +00:00
|
|
|
{
|
2012-04-13 16:27:14 +00:00
|
|
|
return FALSE;
|
2004-03-11 21:38:58 +00:00
|
|
|
}
|
2012-04-13 16:27:14 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2004-03-11 21:38:58 +00:00
|
|
|
}
|
|
|
|
|
2015-03-10 00:11:29 +00:00
|
|
|
_Check_return_
|
|
|
|
_Success_(((pBuffer != NULL && cjBufferSize != 0) && return == 1) ||
|
|
|
|
((pBuffer == NULL || cjBufferSize == 0) && return > 0))
|
|
|
|
_When_(pBuffer != NULL && cjBufferSize != 0 && return == 1, _Kernel_float_saved_
|
|
|
|
_At_(*pBuffer, _Post_valid_ _Kernel_acquires_resource_(EngFloatState)))
|
|
|
|
_On_failure_(_Post_satisfies_(return == 0))
|
|
|
|
ENGAPI
|
2004-04-09 20:03:21 +00:00
|
|
|
ULONG
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2012-04-13 16:27:14 +00:00
|
|
|
EngSaveFloatingPointState(
|
2015-03-10 00:11:29 +00:00
|
|
|
_At_(*pBuffer, _Kernel_requires_resource_not_held_(EngFloatState))
|
|
|
|
_Out_writes_bytes_opt_(cjBufferSize) PVOID pBuffer,
|
|
|
|
_Inout_ ULONG cjBufferSize)
|
2004-03-11 21:38:58 +00:00
|
|
|
{
|
2012-04-13 16:27:14 +00:00
|
|
|
KFLOATING_SAVE TempBuffer;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
2015-03-10 00:11:29 +00:00
|
|
|
if ((pBuffer == NULL) || (cjBufferSize == 0))
|
2005-05-08 02:11:54 +00:00
|
|
|
{
|
2012-04-13 16:27:14 +00:00
|
|
|
/* Check for floating point support. */
|
|
|
|
Status = KeSaveFloatingPointState(&TempBuffer);
|
|
|
|
if (Status != STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
KeRestoreFloatingPointState(&TempBuffer);
|
|
|
|
return(sizeof(KFLOATING_SAVE));
|
2004-03-11 21:38:58 +00:00
|
|
|
}
|
2012-04-13 16:27:14 +00:00
|
|
|
|
2015-03-10 00:11:29 +00:00
|
|
|
if (cjBufferSize < sizeof(KFLOATING_SAVE))
|
2004-03-11 21:38:58 +00:00
|
|
|
{
|
2012-04-13 16:27:14 +00:00
|
|
|
return(0);
|
2004-03-11 21:38:58 +00:00
|
|
|
}
|
2012-04-13 16:27:14 +00:00
|
|
|
|
2015-03-10 00:11:29 +00:00
|
|
|
Status = KeSaveFloatingPointState((PKFLOATING_SAVE)pBuffer);
|
2012-04-13 16:27:14 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
2004-03-11 21:38:58 +00:00
|
|
|
{
|
2012-04-13 16:27:14 +00:00
|
|
|
return FALSE;
|
2004-03-11 21:38:58 +00:00
|
|
|
}
|
2012-04-13 16:27:14 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2004-03-11 21:38:58 +00:00
|
|
|
}
|
2012-04-13 16:27:14 +00:00
|
|
|
|