diff options
author | John Emmas <johne53@tiscali.co.uk> | 2014-11-24 12:56:07 +0000 |
---|---|---|
committer | John Emmas <johne53@tiscali.co.uk> | 2014-11-24 12:56:07 +0000 |
commit | c7ddedc5b86ead3d74ffe2061ff850bf02c46edc (patch) | |
tree | c303ffdb90845b0d21c47a6cb5d21c39ebf2be9a | |
parent | 018f559aaddafd231a89b1a013a0ef1f5f768f63 (diff) |
Simulate 'trunc()' which isn't available in MSVC
(needed by 'gtk2_ardour/editor.cc')
-rw-r--r-- | libs/pbd/msvc/msvc_pbd.cc | 21 | ||||
-rw-r--r-- | libs/pbd/pbd/msvc_pbd.h | 1 |
2 files changed, 22 insertions, 0 deletions
diff --git a/libs/pbd/msvc/msvc_pbd.cc b/libs/pbd/msvc/msvc_pbd.cc index 5b9c9d449a..ddef968569 100644 --- a/libs/pbd/msvc/msvc_pbd.cc +++ b/libs/pbd/msvc/msvc_pbd.cc @@ -241,6 +241,27 @@ round(double x) return (floor(x)); } +//*************************************************************** +// +// trunc() +// +// Emulates trunc() using floor() and ceil(). +// +// Returns: +// +// 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 +trunc(double x) +{ + if (x < 0) + return (ceil(x)); + + return (floor(x)); +} + namespace PBD { //*************************************************************** diff --git a/libs/pbd/pbd/msvc_pbd.h b/libs/pbd/pbd/msvc_pbd.h index a623ca2eb2..bee9b8b4a4 100644 --- a/libs/pbd/pbd/msvc_pbd.h +++ b/libs/pbd/pbd/msvc_pbd.h @@ -231,6 +231,7 @@ LIBPBD_API ssize_t PBD_APICALLTYPE pread(int handle, void *buf, size_t nbytes, 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 double PBD_APICALLTYPE round(double x); +LIBPBD_API double PBD_APICALLTYPE trunc(double x); namespace PBD { |