[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Base Operating System and Extensions Technical Reference, Volume 1

fp_trap Subroutine

Purpose

Queries or changes the mode of the user process to allow floating-point exceptions to generate traps.

Library

Standard C Library (libc.a)

Syntax

#include <fptrap.h>

int fp_trap(flag)
int flag;

Description

The fp_trap subroutine queries and changes the mode of the user process to allow or disallow floating-point exception trapping. Floating-point traps can only be generated when a process is executing in a traps-enabled mode.

The default state is to execute in pipelined mode and not to generate floating-point traps.

Note: The fp_trap routines only change the execution state of the process. To generate floating-point traps, you must also enable traps. Use the fp_enable and fp_enable_all subroutines to enable traps.

Before calling the fp_trap(FP_TRAP_SYNC) routine, previous floating-point operations can set to True certain exception bits in the Floating-Point Status and Control register (FPSCR). Enabling these exceptions and calling the fp_trap(FP_TRAP_SYNC) routine does not cause an immediate trap to occur. That is, the operation of these traps is edge-sensitive, not level-sensitive.

The fp_trap subroutine does not clear the exception history. You can query this history by using any of the following subroutines:

Parameters

flag Specifies a query of or change in the mode of the user process:
FP_TRAP_OFF
Puts the user process into trapping-off mode and returns the previous mode of the process, either FP_TRAP_SYNC, FP_TRAP_IMP, FP_TRAP_IMP_REC, or FP_TRAP_OFF.
FP_TRAP_QUERY
Returns the current mode of the user process.
FP_TRAP_SYNC
Puts the user process into precise trapping mode and returns the previous mode of the process.
FP_TRAP_IMP
Puts the user process into non-recoverable imprecise trapping mode and returns the previous mode.
FP_TRAP_IMP_REC
Puts the user process into recoverable imprecise trapping mode and returns the previous mode.
FP_TRAP_FASTMODE
Puts the user process into the fastest trapping mode available on the hardware platform.
Note: Some hardware models do not support all modes. If an unsupported mode is requested, the fp_trap subroutine returns FP_TRAP_UNIMPL.

Return Values

If called with the FP_TRAP_OFF, FP_TRAP_IMP, FP_TRAP_IMP_REC, or FP_TRAP_SYNC flag, the fp_trap subroutine returns a value indicating which flag was in the previous mode of the process if the hardware supports the requested mode. If the hardware does not support the requested mode, the fp_trap subroutine returns FP_TRAP_UNIMPL.

If called with the FP_TRAP_QUERY flag, the fp_trap subroutine returns a value indicating the current mode of the process, either the FP_TRAP_OFF, FP_TRAP_IMP, FP_TRAP_IMP_REC, or FP_TRAP_SYNC flag.

If called with FP_TRAP_FASTMODE, the fp_trap subroutine sets the fastest mode available and returns the mode selected.

Error Codes

If the fp_trap subroutine is called with an invalid parameter, the subroutine returns FP_TRAP_ERROR.

If the requested mode is not supported on the hardware platform, the subroutine returns FP_TRAP_UNIMPL.


[ Previous | Next | Contents | Glossary | Home | Search ]