Cygwin: access: Fix X_OK behaviour for backup operators and admins
[newlib-cygwin.git] / newlib / libm / machine / riscv / riscv_math.h
blob31220ba0e98a77dbabed9ac69d48b5ce9af7364f
1 /*
2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright (c) 2020 Kito Cheng
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * 3. Neither the name of the copyright holder nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
33 * OF THE POSSIBILITY OF SUCH DAMAGE.
36 #ifndef __RISCV_MATH_H
37 #define __RISCV_MATH_H
41 #if defined(__riscv_flen) || defined(__riscv_zfinx)
43 #if (__riscv_flen >= 64) || defined(__riscv_zdinx)
44 #define __RISCV_HARD_FLOAT 64
45 #else
46 #define __RISCV_HARD_FLOAT 32
47 #endif
49 #define FCLASS_NEG_INF (1 << 0)
50 #define FCLASS_NEG_NORMAL (1 << 1)
51 #define FCLASS_NEG_SUBNORMAL (1 << 2)
52 #define FCLASS_NEG_ZERO (1 << 3)
53 #define FCLASS_POS_ZERO (1 << 4)
54 #define FCLASS_POS_SUBNORMAL (1 << 5)
55 #define FCLASS_POS_NORMAL (1 << 6)
56 #define FCLASS_POS_INF (1 << 7)
57 #define FCLASS_SNAN (1 << 8)
58 #define FCLASS_QNAN (1 << 9)
61 #define FCLASS_INF (FCLASS_NEG_INF | FCLASS_POS_INF)
62 #define FCLASS_ZERO (FCLASS_NEG_ZERO | FCLASS_POS_ZERO)
63 #define FCLASS_NORMAL (FCLASS_NEG_NORMAL | FCLASS_POS_NORMAL)
64 #define FCLASS_SUBNORMAL (FCLASS_NEG_SUBNORMAL | FCLASS_POS_SUBNORMAL)
65 #define FCLASS_NAN (FCLASS_SNAN | FCLASS_QNAN)
67 #if (__riscv_flen >= 64) || defined(__riscv_zdinx)
68 static inline long _fclass_d(double x){
69 long fclass;
70 __asm __volatile ("fclass.d\t%0, %1" : "=r" (fclass) : "f" (x));
71 return fclass;
73 #endif
75 #if (__riscv_flen >= 32) || defined(__riscv_zfinx)
76 static inline long _fclass_f(float x){
77 long fclass;
78 __asm __volatile ("fclass.s\t%0, %1" : "=r" (fclass) : "f" (x));
79 return fclass;
81 #endif
83 #endif /* __riscv_flen */
86 #endif /* __RISCV_MATH_H */