_fpreset
Remonter à float.h - Index
Header File
float.h
Category
Math Routines
Prototype
void _fpreset(void);
Description
Reinitializes floating-point math package.
_fpreset reinitializes the floating-point math package. This function is usually used in conjunction with system or the exec... or spawn... functions. It is also used to recover from floating-point errors before calling longjmp.
Remarque : If an 80x87 coprocessor is used in a program a child process (executed by the system, or by an exec... or spawn... function) might alter the parent process' floating-point state.
- If you use an 80x87 take the following precautions:
- Do not call system or an exec... or spawn... function while a floating-point expression is being evaluated.
Call _fpreset to reset the floating-point state after using system exec... or spawn... if there is any chance that the child process performed a floating-point operation with the 80x87.
Return Value
None.
Example
#include <process.h>
#include <float.h>
#include <stdio.h>
int safe_fpu_exec(wchar_t* program)
{
/* Spawn another process with NOWAIT flag */
int pid = _wspawnl(P_NOWAIT, program, NULL);
int exitCode;
/* Check for error */
if (pid == -1)
return -1;
/* Wait for the application to finish */
cwait(&exitCode, pid, 0);
/* Reset the FPU state since the child process might have altered it */
_fpreset();
return exitCode;
}
Portability
| POSIX | Win32 | ANSI C | ANSI C++ |
|---|---|---|---|
|
+ |