In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/c4125715f8ee8caa13f08097fd26b383f0507d4c?hp=a14c24d0aff00806bd26ad296c7dc8ed2aed3f0a>

- Log -----------------------------------------------------------------
commit c4125715f8ee8caa13f08097fd26b383f0507d4c
Author: Jarkko Hietaniemi <[email protected]>
Date:   Thu Sep 4 11:48:30 2014 -0400

    POSIX math: Use rounding macros, instead of the c99_ functions.
    
    This avoids the need for forward declarations.  Also rename
    the functions with UPPERCASE so people are more careful.

M       ext/POSIX/POSIX.xs

commit c40e90c4b1f82a8630976f5302d9a3a427c38977
Author: Jarkko Hietaniemi <[email protected]>
Date:   Thu Sep 4 11:40:33 2014 -0400

    POSIX math: let's not override the real lrint().

M       ext/POSIX/POSIX.xs

commit 1dfc8cb81aab3f4f9954218ee6dbf8bfbd4a14da
Author: Jarkko Hietaniemi <[email protected]>
Date:   Thu Sep 4 11:37:34 2014 -0400

    POSIX math: Cygwin lacks at least nexttoward.

M       ext/POSIX/POSIX.xs

commit 879d23d21f8a241db1f5f1b5816110cd46a65d4d
Author: Jarkko Hietaniemi <[email protected]>
Date:   Thu Sep 4 11:34:45 2014 -0400

    POSIX math: There's no #elifdef, unfortunately.

M       ext/POSIX/POSIX.xs

commit b6250659892d3195c5d3ecd04773e78dc0ccd564
Author: Jarkko Hietaniemi <[email protected]>
Date:   Thu Sep 4 10:33:07 2014 -0400

    Avoid gcc warning.
    
    Cwd.xs:200:50: warning: size argument in 'strlcat' call appears to be size 
of the source; expected the size of the destination [-Wstrlcpy-strlcat-size]
    
    No effective difference since both the source and destination
    are buf[MAXPATHLEN].  They are now.

M       dist/PathTools/Cwd.xs
-----------------------------------------------------------------------

Summary of changes:
 dist/PathTools/Cwd.xs |  2 +-
 ext/POSIX/POSIX.xs    | 38 ++++++++++++++++++++++++--------------
 2 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/dist/PathTools/Cwd.xs b/dist/PathTools/Cwd.xs
index 4ddbdac..1f174bf 100644
--- a/dist/PathTools/Cwd.xs
+++ b/dist/PathTools/Cwd.xs
@@ -197,7 +197,7 @@ bsd_realpath(const char *path, char resolved[MAXPATHLEN])
                                                symlink[slen] = '/';
                                                symlink[slen + 1] = 0;
                                        }
-                                       left_len = my_strlcat(symlink, left, 
sizeof(left));
+                                       left_len = my_strlcat(symlink, left, 
sizeof(symlink));
                                        if (left_len >= sizeof(left)) {
                                                errno = ENAMETOOLONG;
                                                return (NULL);
diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs
index 7cbd03a..334f1c8 100644
--- a/ext/POSIX/POSIX.xs
+++ b/ext/POSIX/POSIX.xs
@@ -420,6 +420,10 @@
 
 #endif
 
+#ifdef __CYGWIN__
+#  undef c99_nexttoward
+#endif
+
 /* The Bessel functions: BSD, SVID, XPG4, and POSIX.  But not C99. */
 #ifdef HAS_J0
 #  if defined(USE_LONG_DOUBLE) && defined(HAS_J0L)
@@ -672,29 +676,35 @@ static int my_fegetround()
 #endif
 }
 
+/* Toward closest integer. */
+#define MY_ROUND_NEAREST(x) ((NV)((IV)((x) >= 0.0 ? (x) + 0.5 : (x) - 0.5)))
+
+/* Toward zero. */
+#define MY_ROUND_TRUNC(x) ((NV)((IV)(x)))
+
 /* Toward minus infinity. */
-#define my_round_down(x) ((NV)((IV)(x >= 0.0 ? x : x - 0.5)))
+#define MY_ROUND_DOWN(x) ((NV)((IV)((x) >= 0.0 ? (x) : (x) - 0.5)))
 
 /* Toward plus infinity. */
-#define my_round_up(x) ((NV)((IV)(x >= 0.0 ? x + 0.5 : x)))
+#define MY_ROUND_UP(x) ((NV)((IV)((x) >= 0.0 ? (x) + 0.5 : (x))))
 
 static NV my_rint(NV x)
 {
 #ifdef FE_TONEAREST
   switch (my_fegetround()) {
   default:
-  case FE_TONEAREST:  return c99_round(x);
-  case FE_TOWARDZERO: return c99_trunc(x);
-  case FE_DOWNWARD:   return my_round_down(x);
-  case FE_UPWARD:     return my_round_up(x);
+  case FE_TONEAREST:  return MY_ROUND_NEAREST(x);
+  case FE_TOWARDZERO: return MY_ROUND_TRUNC(x);
+  case FE_DOWNWARD:   return MY_ROUND_DOWN(x);
+  case FE_UPWARD:     return MY_ROUND_UP(x);
   }
 #elif defined(HAS_FPGETROUND)
   switch (fpgetround()) {
   default:
-  case FP_RN: return c99_round(x);
-  case FP_RZ: return c99_trunc(x);
-  case FP_RM: return my_round_down(x);
-  case FE_RP: return my_round_up(x);
+  case FP_RN: return MY_ROUND_NEAREST(x);
+  case FP_RZ: return MY_ROUND_TRUNC(x);
+  case FP_RM: return MY_ROUND_DOWN(x);
+  case FE_RP: return MY_ROUND_UP(x);
   }
 #else
   return NV_NAN;
@@ -713,7 +723,7 @@ static NV my_rint(NV x)
 
 #ifndef c99_lrint
 #  ifdef FE_TONEAREST
-static IV lrint(NV x)
+static IV my_lrint(NV x)
 {
   return (IV)my_rint(x);
 }
@@ -734,7 +744,7 @@ static IV lrint(NV x)
 #ifndef c99_round
 static NV my_round(NV x)
 {
-  return (NV)((IV)(x >= 0.0 ? x + 0.5 : x - 0.5));
+  return MY_ROUND_NEAREST(x);
 }
 #  define c99_round my_round
 #endif
@@ -768,7 +778,7 @@ static NV my_tgamma(NV x)
 #ifndef c99_trunc
 static NV my_trunc(NV x)
 {
-  return (NV)((IV)(x));
+  return MY_ROUND_TRUNC(x);
 }
 #  define c99_trunc my_trunc
 #endif
@@ -2054,7 +2064,7 @@ fesetround(x)
     CODE:
 #ifdef HAS_FEGETROUND /* canary for fesetround */
        RETVAL = fesetround(x);
-#elif HAS_FPGETROUND /* canary for fpsetround */
+#elif defined(HAS_FPGETROUND) /* canary for fpsetround */
        switch (x) {
         default:
        case FE_TONEAREST:  RETVAL = fpsetround(FP_RN); break;

--
Perl5 Master Repository

Reply via email to