Move 'round()' / 'trunc()' etc so that they won't conflict with any versions already...
authorJohn Emmas <johne53@tiscali.co.uk>
Fri, 19 Aug 2016 11:56:34 +0000 (12:56 +0100)
committerJohn Emmas <johne53@tiscali.co.uk>
Fri, 19 Aug 2016 13:11:01 +0000 (14:11 +0100)
libs/pbd/msvc/msvc_pbd.cc
libs/pbd/pbd/msvc_pbd.h
msvc_extra_headers/ardourext/misc.h.input

index 68596e3463ab4c8b20fbb24e9e9cf263def2bc35..20065fff260215bce241f56f691311303a7720a0 100644 (file)
@@ -223,121 +223,121 @@ ssize_t ret;
        return (ret);
 }
 
        return (ret);
 }
 
+#if defined(_MSC_VER) && (_MSC_VER < 1800)
 //***************************************************************
 //
 //***************************************************************
 //
-//     roundf()
+//     expm1()
 //
 //
-// Emulates roundf() using floorf().
+// Emulates C99 expm1() using exp().
 //
 //     Returns:
 //
 //
 //     Returns:
 //
-//    On Success: The largest integer that is less than or
-//                equal to 'x'.
-//    On Failure: None
+//    On Success: (('e' raised to the power of 'x') - 1)
+//                (e.g. expm1(1) == 1.7182818).
+//    On Failure: None, except that calling exp(x) should generate
+//                an appropriate error for us (such as INF etc).
 //
 //
-LIBPBD_API float PBD_APICALLTYPE
-roundf(float x)
+LIBPBD_API double PBD_APICALLTYPE
+expm1(double x)
 {
 {
-       return (floorf(x));
+       return (exp(x) - (double)1.0);
 }
 
 //***************************************************************
 //
 }
 
 //***************************************************************
 //
-//     round()
+//     log1p()
 //
 //
-// Emulates round() using floor().
+// Emulates C99 log1p() using log().
 //
 //     Returns:
 //
 //
 //     Returns:
 //
-//    On Success: The largest integer that is less than or
-//                equal to 'x'.
-//    On Failure: None
+//    On Success: The natural logarithm of (1 + x)
+//                (e.g. log1p(1) == 0.69314718).
+//    On Failure: None, except that calling log(x) should generate
+//                an appropriate error for us (such as ERANGE etc).
 //
 LIBPBD_API double PBD_APICALLTYPE
 //
 LIBPBD_API double PBD_APICALLTYPE
-round(double x)
+log1p(double x)
 {
 {
-       return (floor(x));
+       return (log(x + (double)1.0));
 }
 
 //***************************************************************
 //
 }
 
 //***************************************************************
 //
-//     trunc()
+//     roundf()
 //
 //
-// Emulates trunc() using floor() and ceil().
+// Emulates roundf() using floorf().
 //
 //     Returns:
 //
 //
 //     Returns:
 //
-//    On Success: The largest integer whose magnitude is less
-//                than or equal to 'x' (regardless of sign).
+//    On Success: The largest integer that is less than or
+//                equal to 'x'.
 //    On Failure: None
 //
 //    On Failure: None
 //
-LIBPBD_API double PBD_APICALLTYPE
-trunc(double x)
+LIBPBD_API float PBD_APICALLTYPE
+roundf(float x)
 {
 {
-       if (x < 0)
-               return (ceil(x));
-
-       return (floor(x));
+       return (floorf(x));
 }
 
 }
 
-#if defined(_MSC_VER) && (_MSC_VER < 1800)
 //***************************************************************
 //
 //***************************************************************
 //
-//     expm1()
+//     round()
 //
 //
-// Emulates C99 expm1() using exp().
+// Emulates round() using floor().
 //
 //     Returns:
 //
 //
 //     Returns:
 //
-//    On Success: (('e' raised to the power of 'x') - 1)
-//                (e.g. expm1(1) == 1.7182818).
-//    On Failure: None, except that calling exp(x) should generate
-//                an appropriate error for us (such as INF etc).
+//    On Success: The largest integer that is less than or
+//                equal to 'x'.
+//    On Failure: None
 //
 LIBPBD_API double PBD_APICALLTYPE
 //
 LIBPBD_API double PBD_APICALLTYPE
-expm1(double x)
+round(double x)
 {
 {
-       return (exp(x) - (double)1.0);
+       return (floor(x));
 }
 }
+#endif
 
 
+#if defined(_MSC_VER) && (_MSC_VER < 1900)
 //***************************************************************
 //
 //***************************************************************
 //
-//     log1p()
+//     log2()
 //
 //
-// Emulates C99 log1p() using log().
+// Emulates C99 log2() using log().
 //
 //     Returns:
 //
 //
 //     Returns:
 //
-//    On Success: The natural logarithm of (1 + x)
-//                (e.g. log1p(1) == 0.69314718).
+//    On Success: The binary (base-2) logarithm of 'x'
+//                (e.g. log2(1024) == 10).
 //    On Failure: None, except that calling log(x) should generate
 //                an appropriate error for us (such as ERANGE etc).
 //
 LIBPBD_API double PBD_APICALLTYPE
 //    On Failure: None, except that calling log(x) should generate
 //                an appropriate error for us (such as ERANGE etc).
 //
 LIBPBD_API double PBD_APICALLTYPE
-log1p(double x)
+log2(double x)
 {
 {
-       return (log(x + (double)1.0));
+       return (log(x) / log((double)2.0));
 }
 }
-#endif
 
 
-#if defined(_MSC_VER) && (_MSC_VER < 1900)
 //***************************************************************
 //
 //***************************************************************
 //
-//     log2()
+//     trunc()
 //
 //
-// Emulates C99 log2() using log().
+// Emulates trunc() using floor() and ceil().
 //
 //     Returns:
 //
 //
 //     Returns:
 //
-//    On Success: The binary (base-2) logarithm of 'x'
-//                (e.g. log2(1024) == 10).
-//    On Failure: None, except that calling log(x) should generate
-//                an appropriate error for us (such as ERANGE etc).
+//    On Success: The largest integer whose magnitude is less
+//                than or equal to 'x' (regardless of sign).
+//    On Failure: None
 //
 LIBPBD_API double PBD_APICALLTYPE
 //
 LIBPBD_API double PBD_APICALLTYPE
-log2(double x)
+trunc(double x)
 {
 {
-       return (log(x) / log((double)2.0));
+       if (x < 0)
+               return (ceil(x));
+
+       return (floor(x));
 }
 #endif
 
 }
 #endif
 
index 1a017fcb8ae61e74d160e9f153f50c9d4c3bc268..9a3c10266223cb092afcecd43d87bc6f7c461dd8 100644 (file)
@@ -230,17 +230,17 @@ LIBPBD_API int                            __cdecl         gettimeofday(struct timeval *__restrict tv, __
 LIBPBD_API ssize_t                     PBD_APICALLTYPE pread(int handle, void *buf, size_t nbytes, off_t offset);
 LIBPBD_API ssize_t                     PBD_APICALLTYPE pwrite(int handle, const void *buf, size_t nbytes, off_t offset);
 LIBPBD_API int                         PBD_APICALLTYPE poll(struct pollfd *fds, nfds_t nfds, int timeout);
 LIBPBD_API ssize_t                     PBD_APICALLTYPE pread(int handle, void *buf, size_t nbytes, off_t offset);
 LIBPBD_API ssize_t                     PBD_APICALLTYPE pwrite(int handle, const void *buf, size_t nbytes, off_t offset);
 LIBPBD_API int                         PBD_APICALLTYPE poll(struct pollfd *fds, nfds_t nfds, int timeout);
-LIBPBD_API float                       PBD_APICALLTYPE roundf(float x);
-LIBPBD_API double                      PBD_APICALLTYPE round(double x);
-LIBPBD_API double                      PBD_APICALLTYPE trunc(double x);
 
 #if defined(_MSC_VER) && (_MSC_VER < 1800)
 LIBPBD_API double                      PBD_APICALLTYPE expm1(double x);
 LIBPBD_API double                      PBD_APICALLTYPE log1p(double x);
 
 #if defined(_MSC_VER) && (_MSC_VER < 1800)
 LIBPBD_API double                      PBD_APICALLTYPE expm1(double x);
 LIBPBD_API double                      PBD_APICALLTYPE log1p(double x);
+LIBPBD_API double                      PBD_APICALLTYPE round(double x);
+LIBPBD_API float                       PBD_APICALLTYPE roundf(float x);
 #endif
 
 #if defined(_MSC_VER) && (_MSC_VER < 1900)
 LIBPBD_API double                      PBD_APICALLTYPE log2 (double x);
 #endif
 
 #if defined(_MSC_VER) && (_MSC_VER < 1900)
 LIBPBD_API double                      PBD_APICALLTYPE log2 (double x);
+LIBPBD_API double                      PBD_APICALLTYPE trunc(double x);
 #endif
 
 namespace PBD {
 #endif
 
 namespace PBD {
index 6b6533b510eca0fe36df2bfcf07076a579964d36..47cff5629571385e602affe07a5c33b94f381bca 100644 (file)
@@ -252,17 +252,17 @@ inline int64_t abs(int64_t val) throw()
 #endif
 
 #if !defined(LIBPBD_API) || defined(PBD_IS_IN_WIN_STATIC_LIB)
 #endif
 
 #if !defined(LIBPBD_API) || defined(PBD_IS_IN_WIN_STATIC_LIB)
-extern  double round(double x);
-extern  float roundf(float x);
-
 // Emulate some C99 math functions which MSVC itself didn't
 // implement until later in life.
 #if defined(_MSC_VER) && (_MSC_VER < 1800)
 extern  double expm1(double x);
 extern  double log1p(double x);
 // Emulate some C99 math functions which MSVC itself didn't
 // implement until later in life.
 #if defined(_MSC_VER) && (_MSC_VER < 1800)
 extern  double expm1(double x);
 extern  double log1p(double x);
+extern  double round(double x);
+extern  float roundf(float x);
 #endif
 #if defined(_MSC_VER) && (_MSC_VER < 1900)
 extern  double log2 (double x);
 #endif
 #if defined(_MSC_VER) && (_MSC_VER < 1900)
 extern  double log2 (double x);
+extern  double trunc(double x);
 #endif
 #endif
 
 #endif
 #endif