GETFLOATSTATE(2) —
NAME
getfloatstate − return machine and process floating point state
SYNOPSIS
#include <machine/float.h>
int getfloatstate(state, size)
struct floatstate∗state;/∗ structure to hold return information ∗/
int∗size;/∗ Length ∗/
int setfloatstate(mask, state, size)
struct floatstate∗mask,/∗ mask of bits/fields to change ∗/
∗state;/∗ new fields/return state ∗/
int∗size;/∗ Length ∗/
int whichfpa();
DESCRIPTION
Getfloatstate can be used to determine what floating point hardware exists on the machine, as well as what floating point hardware the current (invoking) process is using.
On input, size contains the length of the floatstate structure. On output, size contains the length of the returned structure.
Setfloatstate is used to change the floating point state. A user process may use setfloatstate to release any resources allocated to that process. In addition, the superuser may use setfloatstate to change the effective configuration of the actual hardware. This latter use is most useful when loading the Advanced Floating Point Adapter card. Setfloatstate returns, after processing, the new state in the floatstate structure pointed to by the state argument. In addition, the size of the returned floatstate structure is returned in the integer pointed to by the size argument.
Whichfpa returns a value indicating what floating point hardware the current (invoking) process is using. The returned values are FLOAT_MC881, FLOAT_FPA, FLOAT_AFPA, and FLOAT_EMUL.
The include file <machine/float.h> contains the definition of the floatstate structure, as well as definitions of the bits used to specify the hardware. Currently, the definitions are as follows:
struct floatstate {
int
hardware_state,/∗ What exists on the system ∗/
process_state;/∗ What is allocated to this process ∗/
void
(∗emulator)(),/∗ Address of floating point emulator ∗/
(∗code_generator)();/∗ Address of floating point code generator ∗/
int
fpa_registerset;/∗ (At this time) which fpa register set ∗/
};
#define FLOAT_MC8810x01/∗ Using mc881/mc881 exists ∗/
#define FLOAT_FPA0x02/∗ Using fpa/afpa exists ∗/
#define FLOAT_AFPA0x04/∗ Using afpa/afpa operational∗/
#define FLOAT_EMUL0x08/∗ Using emulator ∗/
#define FLOAT_AFPA_HARDWARE0x10/∗ Afpa hardware exists ∗/
/∗
∗ Control store accesses to afpa enabled.
∗ In this state, the only legal afpa commands are
∗ those to load the microcode.
∗/
#define FLOAT_AFPA_CONTROL_STORE_ENABLE 0x20
NOTES
The following macros, which are defined in <machine/float.h>, are for querying the floating point state information. Each of these takes an integer parameter.
float_has_881 (x)
float_has_fpa (x)
float_has_afpa (x)
float_has_fpa_or_afpa (x)
float_has_emul (x)
RETURN VALUE
If the calls succeed, a value of 0 is returned. If an error occurs, the value −1 is returned, and a more precise error code is placed in the global variable errno.
ERRORS
The possible errors are:
[EFAULT] The state parameter or size parameter specified a bad address.
[EINVAL] The size parameter pointed to a location which contained an unknown value.
SEE ALSO
getfpemulator(2)
"Floating Point Arithmetic" in Volume II, Supplementary Documents
BUGS
Setfloatstate disallows some changes in the floating point state silently, with no changes to errno. The only way to be sure that the new floating point state is what was desired is to interrogate the state returned in the floatstate structure pointed to by the state argument.
Setfloatstate allows the superuser to acquire a specific AFPA register set, even if the floating point state of the system is such that the system would not normally allow use of the floating point hardware. If the process loses the register set (for example, by a debugger looking at the contents of the registers), accesses to the register may be lost.
PRPQs 5799-WZQ/5799-PFF: IBM/4.3 — Dec 1987