These changes are MSVC specific and shouldn't affect the other builds.
(incidentally, libpbd already offers a function called 'fast_log2()'. Not sure if that could have been used instead...)
return (floor(x));
}
+//***************************************************************
+//
+// log2()
+//
+// Emulates C99 log2() using log().
+//
+// 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).
+//
+LIBPBD_API double PBD_APICALLTYPE
+log2(double x)
+{
+ return (log(x) / log((double)2.0));
+}
+
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);
namespace PBD {
#define rint(value) round(value)
#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);
#endif
#endif /* __ardour_msvc_extensions_h__ */