diff options
author | John Emmas <johne53@tiscali.co.uk> | 2015-01-10 11:56:24 +0000 |
---|---|---|
committer | John Emmas <johne53@tiscali.co.uk> | 2015-01-10 11:56:24 +0000 |
commit | f59810596648ae107c7858ecc6add4b3b9ff1ac7 (patch) | |
tree | ea72dfb0668c617a34225bab3d01b918827690d7 /libs | |
parent | ca7965d7aa4b56bca74dd4137e03bdb581c738c8 (diff) |
Add support for the C99 function 'log2()' which is newly needed by 'gtk2_ardour/tempo_lines.cc' (but isn't available from MSVC).
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...)
Diffstat (limited to 'libs')
-rw-r--r-- | libs/pbd/msvc/msvc_pbd.cc | 19 | ||||
-rw-r--r-- | libs/pbd/pbd/msvc_pbd.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/libs/pbd/msvc/msvc_pbd.cc b/libs/pbd/msvc/msvc_pbd.cc index ddef968569..ab79d8f45d 100644 --- a/libs/pbd/msvc/msvc_pbd.cc +++ b/libs/pbd/msvc/msvc_pbd.cc @@ -262,6 +262,25 @@ trunc(double x) 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 { //*************************************************************** diff --git a/libs/pbd/pbd/msvc_pbd.h b/libs/pbd/pbd/msvc_pbd.h index bee9b8b4a4..7529619f1d 100644 --- a/libs/pbd/pbd/msvc_pbd.h +++ b/libs/pbd/pbd/msvc_pbd.h @@ -232,6 +232,7 @@ 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); namespace PBD { |