xref: /freebsd/lib/libc/riscv/gen/fpsetmask.c (revision 559a218c9b257775fb249b67945fe4a05b7a6b9f)
1*7393b267SKristof Provost /*-
2*7393b267SKristof Provost  * Copyright (c) 2020 Axiado
3*7393b267SKristof Provost  * All rights reserved.
4*7393b267SKristof Provost  *
5*7393b267SKristof Provost  * This software was developed by Kristof Provost under
6*7393b267SKristof Provost  * sponsorship from Axiado.
7*7393b267SKristof Provost  *
8*7393b267SKristof Provost  * Redistribution and use in source and binary forms, with or without
9*7393b267SKristof Provost  * modification, are permitted provided that the following conditions
10*7393b267SKristof Provost  * are met:
11*7393b267SKristof Provost  * 1. Redistributions of source code must retain the above copyright
12*7393b267SKristof Provost  *    notice, this list of conditions and the following disclaimer.
13*7393b267SKristof Provost  * 2. Redistributions in binary form must reproduce the above copyright
14*7393b267SKristof Provost  *    notice, this list of conditions and the following disclaimer in the
15*7393b267SKristof Provost  *    documentation and/or other materials provided with the distribution.
16*7393b267SKristof Provost  *
17*7393b267SKristof Provost  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18*7393b267SKristof Provost  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19*7393b267SKristof Provost  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20*7393b267SKristof Provost  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21*7393b267SKristof Provost  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22*7393b267SKristof Provost  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23*7393b267SKristof Provost  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24*7393b267SKristof Provost  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25*7393b267SKristof Provost  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26*7393b267SKristof Provost  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27*7393b267SKristof Provost  * SUCH DAMAGE.
28*7393b267SKristof Provost  */
29*7393b267SKristof Provost 
30*7393b267SKristof Provost #include <sys/types.h>
31*7393b267SKristof Provost #include <ieeefp.h>
32*7393b267SKristof Provost 
33*7393b267SKristof Provost /**
34*7393b267SKristof Provost  * RISC-V doesn't support floating-point exceptions: RISC-V Instruction Set
35*7393b267SKristof Provost  * Manual: Volume I: User-Level ISA, 11.2 Floating-Point Control and Status
36*7393b267SKristof Provost  * Register: "As allowed by the standard, we do not support traps on
37*7393b267SKristof Provost  * floating-point exceptions in the base ISA, but instead require explicit
38*7393b267SKristof Provost  * checks of the flags in software. We considered adding branches controlled
39*7393b267SKristof Provost  * directly by the contents of the floating-point accrued exception flags, but
40*7393b267SKristof Provost  * ultimately chose to omit these instructions to keep the ISA simple."
41*7393b267SKristof Provost  *
42*7393b267SKristof Provost  * We still need this function, because some applications (notably Perl) call
43*7393b267SKristof Provost  * it, but we cannot provide a meaningful implementation.
44*7393b267SKristof Provost  **/
45*7393b267SKristof Provost fp_except_t
fpsetmask(fp_except_t mask)46*7393b267SKristof Provost fpsetmask(fp_except_t mask)
47*7393b267SKristof Provost {
48*7393b267SKristof Provost 
49*7393b267SKristof Provost 	return (0);
50*7393b267SKristof Provost }
51