]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - soft-fp/op-common.h
Add narrowing multiply functions.
[thirdparty/glibc.git] / soft-fp / op-common.h
index 4526afd1b6ffc3cedeb698e6b57ef1566782fc1b..d6f32aef331938517d662af77b485e9d7ac0576d 100644 (file)
     }                                                                  \
   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.  */