Debian Codegraph @

m4/nan-mips.m4

raw
1 # nan-mips.m4
2 # serial 1
3 dnl Copyright (C) 2023-2025 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7 dnl This file is offered as-is, without any warranty.
8
9 # Extra meta-info mentioned by lib/snan.h.
10 AC_DEFUN_ONCE([gl_NAN_MIPS],
11 [
12 AC_REQUIRE([AC_CANONICAL_HOST])
13 case "$host_cpu" in
14 mips*)
15 AC_CACHE_CHECK([whether the NaN float encoding is IEEE 754-2008 compliant],
16 [gl_cv_nan2008_f],
17 [AC_RUN_IFELSE(
18 [AC_LANG_PROGRAM([[
19 float volatile zero;
20 /* Assume 'float' has 32 bits, i.e. IEEE single-float. */
21 union { float value; unsigned int word; } qnan;
22 ]],
23 [[qnan.value = zero / zero;
24 return !((qnan.word >> 22) & 1);
25 ]])
26 ],
27 [gl_cv_nan2008_f=yes],
28 [gl_cv_nan2008_f=no],
29 [gl_cv_nan2008_f="guessing no"])
30 ])
31 case "$gl_cv_nan2008_f" in
32 *yes) gl_mips_nan2008_f=1 ;;
33 *) gl_mips_nan2008_f=0 ;;
34 esac
35 AC_DEFINE_UNQUOTED([MIPS_NAN2008_FLOAT], [$gl_mips_nan2008_f],
36 [Define to 1 if the encoding of NaN 'float's is as in IEEE 754-2008 § 6.2.1.])
37
38 AC_CACHE_CHECK([whether the NaN double encoding is IEEE 754-2008 compliant],
39 [gl_cv_nan2008_d],
40 [AC_RUN_IFELSE(
41 [AC_LANG_PROGRAM([[
42 double volatile zero;
43 /* Assume 'double' has 64 bits, i.e. IEEE double-float. */
44 union { double value; unsigned long long word; } qnan;
45 ]],
46 [[qnan.value = zero / zero;
47 return !((qnan.word >> 51) & 1);
48 ]])
49 ],
50 [gl_cv_nan2008_d=yes],
51 [gl_cv_nan2008_d=no],
52 [gl_cv_nan2008_d="guessing no"])
53 ])
54 case "$gl_cv_nan2008_d" in
55 *yes) gl_mips_nan2008_d=1 ;;
56 *) gl_mips_nan2008_d=0 ;;
57 esac
58 AC_DEFINE_UNQUOTED([MIPS_NAN2008_DOUBLE], [$gl_mips_nan2008_d],
59 [Define to 1 if the encoding of NaN 'double's is as in IEEE 754-2008 § 6.2.1.])
60
61 AC_CACHE_CHECK([whether the NaN long double encoding is IEEE 754-2008 compliant],
62 [gl_cv_nan2008_l],
63 [AC_RUN_IFELSE(
64 [AC_LANG_PROGRAM([[
65 #include <float.h>
66 long double volatile zero;
67 #define NWORDS \
68 ((sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
69 union { long double value; unsigned int word[NWORDS]; } qnan;
70 ]],
71 [[qnan.value = zero / zero;
72 #if defined _MIPSEB /* equivalent: __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ */
73 return !((qnan.word[0] >> ((LDBL_MANT_DIG - 2) % 32)) & 1);
74 #else
75 return !((qnan.word[NWORDS - 1] >> ((LDBL_MANT_DIG - 2) % 32)) & 1);
76 #endif
77 ]])
78 ],
79 [gl_cv_nan2008_l=yes],
80 [gl_cv_nan2008_l=no],
81 [gl_cv_nan2008_l="guessing no"])
82 ])
83 case "$gl_cv_nan2008_l" in
84 *yes) gl_mips_nan2008_l=1 ;;
85 *) gl_mips_nan2008_l=0 ;;
86 esac
87 AC_DEFINE_UNQUOTED([MIPS_NAN2008_LONG_DOUBLE], [$gl_mips_nan2008_l],
88 [Define to 1 if the encoding of NaN 'long double's is as in IEEE 754-2008 § 6.2.1.])
89 ;;
90 esac
91 ])