summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/pbd/msvc/msvc_pbd.cc42
-rw-r--r--libs/pbd/pbd/msvc_pbd.h10
-rw-r--r--msvc_extra_headers/ardourext/misc.h.input12
3 files changed, 60 insertions, 4 deletions
diff --git a/libs/pbd/msvc/msvc_pbd.cc b/libs/pbd/msvc/msvc_pbd.cc
index ab79d8f45d..f49ac5393c 100644
--- a/libs/pbd/msvc/msvc_pbd.cc
+++ b/libs/pbd/msvc/msvc_pbd.cc
@@ -262,6 +262,47 @@ trunc(double x)
return (floor(x));
}
+#if defined(_MSC_VER) && (_MSC_VER < 1800)
+//***************************************************************
+//
+// expm1()
+//
+// Emulates C99 expm1() using exp().
+//
+// 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).
+//
+LIBPBD_API double PBD_APICALLTYPE
+expm1(double x)
+{
+ return (exp(x) - (double)1.0);
+}
+
+//***************************************************************
+//
+// log1p()
+//
+// Emulates C99 log1p() using log().
+//
+// Returns:
+//
+// 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
+log1p(double x)
+{
+ return (log(x + (double)1.0));
+}
+#endif
+
+#if defined(_MSC_VER) && (_MSC_VER < 1900)
//***************************************************************
//
// log2()
@@ -280,6 +321,7 @@ log2(double x)
{
return (log(x) / log((double)2.0));
}
+#endif
namespace PBD {
diff --git a/libs/pbd/pbd/msvc_pbd.h b/libs/pbd/pbd/msvc_pbd.h
index 7529619f1d..5a6b550242 100644
--- a/libs/pbd/pbd/msvc_pbd.h
+++ b/libs/pbd/pbd/msvc_pbd.h
@@ -232,7 +232,15 @@ LIBPBD_API ssize_t PBD_APICALLTYPE pwrite(int handle, const void *buf, size_t
LIBPBD_API int PBD_APICALLTYPE poll(struct pollfd *fds, nfds_t nfds, int timeout);
LIBPBD_API double PBD_APICALLTYPE round(double x);
LIBPBD_API double PBD_APICALLTYPE trunc(double x);
-LIBPBD_API double PBD_APICALLTYPE log2(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);
+#endif
+
+#if defined(_MSC_VER) && (_MSC_VER < 1900)
+LIBPBD_API double PBD_APICALLTYPE log2 (double x);
+#endif
namespace PBD {
diff --git a/msvc_extra_headers/ardourext/misc.h.input b/msvc_extra_headers/ardourext/misc.h.input
index 161ed167f1..11ba638494 100644
--- a/msvc_extra_headers/ardourext/misc.h.input
+++ b/msvc_extra_headers/ardourext/misc.h.input
@@ -254,9 +254,15 @@ inline int64_t abs(int64_t val) throw()
#if !defined(LIBPBD_API) || defined(PBD_IS_IN_WIN_STATIC_LIB)
extern double round(double x);
-// log2().... MSVC doesn't offer the C99 function 'log2()'
-// so let's emulate it.
-extern double log2(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);
+#endif
+#if defined(_MSC_VER) && (_MSC_VER < 1900)
+extern double log2 (double x);
+#endif
#endif
#endif /* __ardour_msvc_extensions_h__ */