]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - soft-fp/op-common.h
soft-fp: Properly check _FP_W_TYPE_SIZE [BZ #24066]
[thirdparty/glibc.git] / soft-fp / op-common.h
index f52194ecd1c7909836b26ad7869057340ff9ca06..a6406798fc490018a6789a8f6efbd0e72785d7fe 100644 (file)
@@ -1,5 +1,5 @@
 /* Software floating-point emulation. Common operations.
-   Copyright (C) 1997-2017 Free Software Foundation, Inc.
+   Copyright (C) 1997-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Richard Henderson (rth@cygnus.com),
                  Jakub Jelinek (jj@ultra.linux.cz),
     }                                                                  \
   while (0)
 
+/* Truncate from a wider floating-point format to a narrower one.
+   Input and output are cooked.  */
+#define FP_TRUNC_COOKED(dfs, sfs, dwc, swc, D, S)                      \
+  do                                                                   \
+    {                                                                  \
+      _FP_STATIC_ASSERT (_FP_FRACBITS_##sfs >= _FP_FRACBITS_##dfs,     \
+                        "destination mantissa wider than source");     \
+      if (S##_c == FP_CLS_NAN)                                         \
+       _FP_FRAC_SRL_##swc (S, (_FP_WFRACBITS_##sfs                     \
+                               - _FP_WFRACBITS_##dfs));                \
+      else                                                             \
+       _FP_FRAC_SRS_##swc (S, (_FP_WFRACBITS_##sfs                     \
+                               - _FP_WFRACBITS_##dfs),                 \
+                           _FP_WFRACBITS_##sfs);                       \
+      _FP_FRAC_COPY_##dwc##_##swc (D, S);                              \
+      D##_e = S##_e;                                                   \
+      D##_c = S##_c;                                                   \
+      D##_s = S##_s;                                                   \
+    }                                                                  \
+  while (0)
+
 /* Helper primitives.  */
 
 /* Count leading zeros in a word.  */