exp2l: Work around a NetBSD 10.0/i386 bug.
[gnulib.git] / lib / signed-snan.h
blob7e6483a7618e0a91772d0a1a68bca135d74bafd6
1 /* Macros for signalling not-a-number.
2 Copyright (C) 2023-2024 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 #ifndef _SIGNED_SNAN_H
18 #define _SIGNED_SNAN_H
20 #include "signed-nan.h"
21 #include "snan.h"
24 #if HAVE_SNANF
26 /* Returns a signalling 'float' NaN with sign bit == 0 in memory. */
27 _GL_UNUSED static memory_float
28 memory_positive_SNaNf ()
30 return construct_memory_SNaNf (positive_NaNf ());
33 /* Returns a signalling 'float' NaN with sign bit == 1 in memory. */
34 _GL_UNUSED static memory_float
35 memory_negative_SNaNf ()
37 return construct_memory_SNaNf (negative_NaNf ());
40 /* Note: On 32-bit x86 processors, as well as on x86_64 processors with
41 CC="gcc -mfpmath=387", the following functions may return a quiet NaN
42 instead. Use the functions with 'memory_' prefix if you need to avoid this.
43 See <https://lists.gnu.org/archive/html/bug-gnulib/2023-10/msg00060.html>
44 for details. */
46 /* Returns a signalling 'float' NaN with sign bit == 0. */
47 _GL_UNUSED static float
48 positive_SNaNf ()
50 return memory_positive_SNaNf ().value;
53 /* Returns a signalling 'float' NaN with sign bit == 1. */
54 _GL_UNUSED static float
55 negative_SNaNf ()
57 return memory_negative_SNaNf ().value;
60 #endif
63 #if HAVE_SNAND
65 /* Returns a signalling 'double' NaN with sign bit == 0 in memory. */
66 _GL_UNUSED static memory_double
67 memory_positive_SNaNd ()
69 return construct_memory_SNaNd (positive_NaNd ());
72 /* Returns a signalling 'double' NaN with sign bit == 1 in memory. */
73 _GL_UNUSED static memory_double
74 memory_negative_SNaNd ()
76 return construct_memory_SNaNd (negative_NaNd ());
79 /* Note: On 32-bit x86 processors, as well as on x86_64 processors with
80 CC="gcc -mfpmath=387", the following functions may return a quiet NaN
81 instead. Use the functions with 'memory_' prefix if you need to avoid this.
82 See <https://lists.gnu.org/archive/html/bug-gnulib/2023-10/msg00060.html>
83 for details. */
85 /* Returns a signalling 'double' NaN with sign bit == 0. */
86 _GL_UNUSED static double
87 positive_SNaNd ()
89 return memory_positive_SNaNd ().value;
92 /* Returns a signalling 'double' NaN with sign bit == 1. */
93 _GL_UNUSED static double
94 negative_SNaNd ()
96 return memory_negative_SNaNd ().value;
99 #endif
102 #if HAVE_SNANL
104 /* Returns a signalling 'long double' NaN with sign bit == 0 in memory. */
105 _GL_UNUSED static memory_long_double
106 memory_positive_SNaNl ()
108 return construct_memory_SNaNl (positive_NaNl ());
111 /* Returns a signalling 'long double' NaN with sign bit == 1 in memory. */
112 _GL_UNUSED static memory_long_double
113 memory_negative_SNaNl ()
115 return construct_memory_SNaNl (negative_NaNl ());
118 /* Note: On 32-bit x86 processors, as well as on x86_64 processors with
119 CC="gcc -mfpmath=387", if HAVE_SAME_LONG_DOUBLE_AS_DOUBLE is 1, the
120 following functions may return a quiet NaN instead. Use the functions
121 with 'memory_' prefix if you need to avoid this. See
122 <https://lists.gnu.org/archive/html/bug-gnulib/2023-10/msg00060.html>
123 for details. */
125 /* Returns a signalling 'long double' NaN with sign bit == 0. */
126 _GL_UNUSED static long double
127 positive_SNaNl ()
129 return memory_positive_SNaNl ().value;
132 /* Returns a signalling 'long double' NaN with sign bit == 1. */
133 _GL_UNUSED static long double
134 negative_SNaNl ()
136 return memory_negative_SNaNl ().value;
139 #endif
142 #endif /* _SIGNED_SNAN_H */