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()
{
return (log(x) / log((double)2.0));
}
+#endif
namespace PBD {
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 {
#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__ */