| 1 |
.\" Copyright 2016, Eugene Syromyatnikov <[email protected]> |
| 2 |
.\" Copyright, the authors of the Linux man-pages project |
| 3 |
.\" |
| 4 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 5 |
.\" |
| 6 |
.TH PR_SET_FP_MODE 2const 2026-02-08 "Linux man-pages 6.18" |
| 7 |
.SH NAME |
| 8 |
PR_SET_FP_MODE |
| 9 |
\- |
| 10 |
set the floating point mode of the calling process |
| 11 |
.SH LIBRARY |
| 12 |
Standard C library |
| 13 |
.RI ( libc ,\~ \-lc ) |
| 14 |
.SH SYNOPSIS |
| 15 |
.nf |
| 16 |
.BR "#include <linux/prctl.h>" " /* Definition of " PR_* " constants */" |
| 17 |
.B #include <sys/prctl.h> |
| 18 |
.P |
| 19 |
.BI "int prctl(PR_SET_FP_MODE, unsigned long " mode ); |
| 20 |
.fi |
| 21 |
.SH DESCRIPTION |
| 22 |
On the MIPS architecture, |
| 23 |
user-space code can be built using an ABI which permits |
| 24 |
linking with code that has more restrictive floating-point (FP) requirements. |
| 25 |
For example, |
| 26 |
user-space code may be built to target the O32 FPXX ABI |
| 27 |
and linked with code built for either one of the more restrictive |
| 28 |
FP32 or FP64 ABIs. |
| 29 |
When more restrictive code is linked in, |
| 30 |
the overall requirement for the process is to use the more |
| 31 |
restrictive floating-point mode. |
| 32 |
.P |
| 33 |
Because the kernel has no means of knowing in advance |
| 34 |
which mode the process should be executed in, |
| 35 |
and because these restrictions can |
| 36 |
change over the lifetime of the process, the |
| 37 |
.B PR_SET_FP_MODE |
| 38 |
operation is provided to allow control of the floating-point mode |
| 39 |
from user space. |
| 40 |
.P |
| 41 |
.\" https://dmz-portal.mips.com/wiki/MIPS_O32_ABI_-_FR0_and_FR1_Interlinking |
| 42 |
The |
| 43 |
.I mode |
| 44 |
argument is a bit mask describing the floating-point mode used: |
| 45 |
.TP |
| 46 |
.B PR_FP_MODE_FR |
| 47 |
When this bit is |
| 48 |
.I unset |
| 49 |
(so called |
| 50 |
.BR FR=0 " or " FR0 |
| 51 |
mode), the 32 floating-point registers are 32 bits wide, |
| 52 |
and 64-bit registers are represented as a pair of registers |
| 53 |
(even- and odd- numbered, |
| 54 |
with the even-numbered register containing the lower 32 bits, |
| 55 |
and the odd-numbered register containing the higher 32 bits). |
| 56 |
.IP |
| 57 |
When this bit is |
| 58 |
.I set |
| 59 |
(on supported hardware), |
| 60 |
the 32 floating-point registers are 64 bits wide (so called |
| 61 |
.BR FR=1 " or " FR1 |
| 62 |
mode). |
| 63 |
Note that modern MIPS implementations (MIPS R6 and newer) support |
| 64 |
.B FR=1 |
| 65 |
mode only. |
| 66 |
.IP |
| 67 |
Applications that use the O32 FP32 ABI can operate only when this bit is |
| 68 |
.I unset |
| 69 |
.RB ( FR=0 ; |
| 70 |
or they can be used with FRE enabled, see below). |
| 71 |
Applications that use the O32 FP64 ABI |
| 72 |
(and the O32 FP64A ABI, |
| 73 |
which exists to provide the ability |
| 74 |
to operate with existing FP32 code; |
| 75 |
see below) |
| 76 |
can operate only when this bit is |
| 77 |
.I set |
| 78 |
.RB ( FR=1 ). |
| 79 |
Applications that use the O32 FPXX ABI can operate with either |
| 80 |
.B FR=0 |
| 81 |
or |
| 82 |
.BR FR=1 . |
| 83 |
.TP |
| 84 |
.B PR_FP_MODE_FRE |
| 85 |
Enable emulation of 32-bit floating-point mode. |
| 86 |
When this mode is enabled, |
| 87 |
it emulates 32-bit floating-point operations |
| 88 |
by raising a reserved-instruction exception |
| 89 |
on every instruction that uses 32-bit formats and |
| 90 |
the kernel then handles the instruction in software. |
| 91 |
(The problem lies in the discrepancy of handling odd-numbered registers |
| 92 |
which are the high 32 bits of 64-bit registers with even numbers in |
| 93 |
.B FR=0 |
| 94 |
mode and the lower 32-bit parts of odd-numbered 64-bit registers in |
| 95 |
.B FR=1 |
| 96 |
mode.) |
| 97 |
Enabling this bit is necessary when code with the O32 FP32 ABI should operate |
| 98 |
with code with compatible the O32 FPXX or O32 FP64A ABIs (which require |
| 99 |
.B FR=1 |
| 100 |
FPU mode) or when it is executed on newer hardware (MIPS R6 onwards) |
| 101 |
which lacks |
| 102 |
.B FR=0 |
| 103 |
mode support when a binary with the FP32 ABI is used. |
| 104 |
.IP |
| 105 |
Note that this mode makes sense only when the FPU is in 64-bit mode |
| 106 |
.RB ( FR=1 ). |
| 107 |
.IP |
| 108 |
Note that the use of emulation inherently has a significant performance hit |
| 109 |
and should be avoided if possible. |
| 110 |
.P |
| 111 |
In the N32/N64 ABI, 64-bit floating-point mode is always used, |
| 112 |
so FPU emulation is not required and the FPU always operates in |
| 113 |
.B FR=1 |
| 114 |
mode. |
| 115 |
.P |
| 116 |
This operation is mainly intended for use by the dynamic linker |
| 117 |
.RB ( ld.so (8)). |
| 118 |
.SH RETURN VALUE |
| 119 |
On success, |
| 120 |
0 is returned. |
| 121 |
On error, \-1 is returned, and |
| 122 |
.I errno |
| 123 |
is set to indicate the error. |
| 124 |
.SH ERRORS |
| 125 |
.TP |
| 126 |
.B EOPNOTSUPP |
| 127 |
.I mode |
| 128 |
has an invalid or unsupported value. |
| 129 |
.SH STANDARDS |
| 130 |
Linux. |
| 131 |
MIPS only. |
| 132 |
.SH HISTORY |
| 133 |
Linux 4.0 (MIPS). |
| 134 |
.\" commit 9791554b45a2acc28247f66a5fd5bbc212a6b8c8 |
| 135 |
.SH SEE ALSO |
| 136 |
.BR prctl (2), |
| 137 |
.BR PR_GET_FP_MODE (2const) |