home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_03_05
/
3n05054b
< prev
next >
Wrap
Text File
|
1992-03-10
|
2KB
|
62 lines
Listing 2
/*****************************************************/
/* fpumsg.c */
/* -- Module to implement PeekMessage() with a check */
/* of the FPU's status word. */
/*****************************************************/
#include <windows.h>
#include "fpumsg.h"
BOOL
FPeekMessageLpfn(LPMSG lpmsg, HWND hwnd,
WORD wMsgFilterMin, WORD wMsgFilterMax,
WORD wRemoveMsg, LPFN_NOTIFY lpfnNotify)
/*****************************************************/
/* -- PeekMessage() wrapper. */
/* -- Get a message from the queue. */
/* -- Check the FPU's status first, and if we have */
/* racked up exceptions, call lpfnNotify. */
/* -- Makes sure all exceptions are masked after the */
/* call to PeekMessage(), so win87em won't UAE us */
/* if we do generate an exception. */
/* -- lpmsg : Store message here. */
/* -- hwnd : Get message for this window, */
/* NULL for all windows. */
/* -- wMsgFilterMin : Least message. */
/* -- wMsgFilterMax : Greatest message. */
/* -- wRemoveMsg : PeekMessage() flags. */
/* -- lpfnNotify : Callback in case of FPU */
/* exception. */
/*****************************************************/
{
BOOL fGotMessage;
WORD wStatus, wControl;
/* Get the status of the FPU. */
_asm fstsw wStatus;
_asm wait;
/* Get rid of any exceptions. */
_asm fclex;
/* Did an exception occured? */
if (wStatus & 0x003f)
Notify(wStatus, lpfnNotify);
/* Get a message. */
fGotMessage = PeekMessage(lpmsg, hwnd,
wMsgFilterMin, wMsgFilterMax, wRemoveMsg);
/* Mask all exceptions to prevent win87em from */
/* blowing us away. */
_asm fstcw wControl;
_asm wait;
wControl |= 0x003f;
_asm fldcw wControl
return fGotMessage;
}