[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
Base Operating System and Extensions Technical Reference, Volume 1

fp_sh_info, fp_sh_trap_info, or fp_sh_set_stat Subroutine

Purpose

From within a floating-point signal handler, determines any floating-point exception that caused the trap in the process and changes the state of the Floating-Point Status and Control register (FPSCR) in the user process.

Library

Standard C Library (libc.a)

Syntax

#include <fpxcp.h>
#include <fptrap.h>
#include <signal.h>
void fp_sh_info(scp, fcp, struct_size)
struct sigcontext *scp;
struct fp_sh_info *fcp;
size_t struct_size;
void fp_sh_trap_info(scp, fcp)
struct sigcontext *scp;
struct fp_ctx *fcp;
void fp_sh_set_stat(scp, fpscr)
struct sigcontext *scp;
fpstat_t fpscr;

Description

These subroutines are for use within a user-written signal handler. They return information about the process that was running at the time the signal occurred, and they update the Floating-Point Status and Control register for the process.

Note: The fp_sh_trap_info subroutine is maintained for compatibility only. It has been replaced by the fp_sh_info subroutine, which should be used for development.

These subroutines operate only on the state of the user process that was running at the time the signal was delivered. They read and write the sigcontext structure. They do not change the state of the signal handler process itself.

The state of the signal handler process can be modified by the fp_any_enable, fp_is_enabled, fp_enable_all, fp_enable, fp_disable_all, or fp_disable subroutine.

fp_sh_info

The fp_sh_info subroutine returns information about the process that caused the trap by means of a floating-point context (fp_sh_info) structure. This structure contains the following information:

typedef struct fp_sh_info {
fpstat_t       fpscr;
fpflag_t       trap;
short          trap_mode;
char           flags;
char           extra;
} fp_sh_info_t;

The fields are:

fpscr The Floating-Point Status and Control register (FPSCR) in the user process at the time the interrupt occurred.
trap A mask indicating the trap or traps that caused the signal handler to be entered. This mask is the logical OR operator of the enabled floating-point exceptions that occurred to cause the trap. This mask can have up to two exceptions; if there are two, the INEXACT signal must be one of them. If the mask is 0, the SIGFPE signal was raised not by a floating-point operation, but by the kill or raise subroutine or the kill command.
trap_mode The trap mode in effect in the process at the time the signal handler was entered. The values returned in the fp_sh_info.trap_mode file use the following argument definitions:
FP_TRAP_OFF
Trapping off
FP_TRAP_SYNC
Precise trapping on
FP_TRAP_IMP_REC
Recoverable imprecise trapping on
FP_TRAP_IMP
Non-recoverable imprecise trapping on
flags This field is interpreted as an array of bits and should be accessed with masks. The following mask is defined:
FP_IAR_STAT
If the value of the bit at this mask is 1, the exception was precise and the IAR points to the instruction that caused the exception. If the value bit at this mask is 0, the exception was imprecise.

fp_sh_trap_info

The fp_sh_trap_info subroutine is maintained for compatibility only. The fp_sh_trap_info subroutine returns information about the process that caused the trap by means of a floating-point context (fp_ctx) structure. This structure contains the following information:

fpstat_t fpscr;
fpflag_t trap;

The fields are:

fpscr The Floating-Point Status and Control register (FPSCR) in the user process at the time the interrupt occurred.
trap A mask indicating the trap or traps that caused the signal handler to be entered. This mask is the logical OR operator of the enabled floating-point exceptions that occurred to cause the trap. This mask can have up to two exceptions; if there are two, the INEXACT signal must be one of them. If the mask is 0, the SIGFPE signal was raised not by a floating-point operation, but by the kill or raise subroutine or the kill command.

fp_sh_set_stat

The fp_sh_set_stat subroutine updates the Floating-Point Status and Control register (FPSCR) in the user process with the value in the fpscr field.

The signal handler must either clear the exception bit that caused the trap to occur or disable the trap to prevent a recurrence. If the instruction generated more than one exception, and the signal handler clears only one of these exceptions, a signal is raised for the remaining exception when the next floating-point instruction is executed in the user process.

Parameters

fcp Specifies a floating-point context structure.
scp Specifies a sigcontext structure for the interrupt.
struct_size Specifies the size of the fp_sh_info structure.
fpscr Specifies which Floating-Point Status and Control register to update.

Related Information

The fp_any_enable, fp_disable_all, fp_disable, fp_enable_all, fp_enable, or fp_is_enabled subroutine, fp_clr_flag, fp_read_flag, fp_set_flag, or fp_swap_flag subroutine, fp_trap subroutine.

Floating-Point Exceptions Overview in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]