mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 23:05:04 +01:00
Move 'round()' / 'trunc()' etc so that they won't conflict with any versions already available in MSVC
This commit is contained in:
parent
4ece16f348
commit
8e2d1c7f2a
3 changed files with 63 additions and 63 deletions
|
|
@ -223,63 +223,6 @@ ssize_t ret;
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************
|
|
||||||
//
|
|
||||||
// roundf()
|
|
||||||
//
|
|
||||||
// Emulates roundf() using floorf().
|
|
||||||
//
|
|
||||||
// Returns:
|
|
||||||
//
|
|
||||||
// On Success: The largest integer that is less than or
|
|
||||||
// equal to 'x'.
|
|
||||||
// On Failure: None
|
|
||||||
//
|
|
||||||
LIBPBD_API float PBD_APICALLTYPE
|
|
||||||
roundf(float x)
|
|
||||||
{
|
|
||||||
return (floorf(x));
|
|
||||||
}
|
|
||||||
|
|
||||||
//***************************************************************
|
|
||||||
//
|
|
||||||
// round()
|
|
||||||
//
|
|
||||||
// Emulates round() using floor().
|
|
||||||
//
|
|
||||||
// Returns:
|
|
||||||
//
|
|
||||||
// On Success: The largest integer that is less than or
|
|
||||||
// equal to 'x'.
|
|
||||||
// On Failure: None
|
|
||||||
//
|
|
||||||
LIBPBD_API double PBD_APICALLTYPE
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) && (_MSC_VER < 1800)
|
#if defined(_MSC_VER) && (_MSC_VER < 1800)
|
||||||
//***************************************************************
|
//***************************************************************
|
||||||
//
|
//
|
||||||
|
|
@ -318,6 +261,42 @@ log1p(double x)
|
||||||
{
|
{
|
||||||
return (log(x + (double)1.0));
|
return (log(x + (double)1.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//***************************************************************
|
||||||
|
//
|
||||||
|
// roundf()
|
||||||
|
//
|
||||||
|
// Emulates roundf() using floorf().
|
||||||
|
//
|
||||||
|
// Returns:
|
||||||
|
//
|
||||||
|
// On Success: The largest integer that is less than or
|
||||||
|
// equal to 'x'.
|
||||||
|
// On Failure: None
|
||||||
|
//
|
||||||
|
LIBPBD_API float PBD_APICALLTYPE
|
||||||
|
roundf(float x)
|
||||||
|
{
|
||||||
|
return (floorf(x));
|
||||||
|
}
|
||||||
|
|
||||||
|
//***************************************************************
|
||||||
|
//
|
||||||
|
// round()
|
||||||
|
//
|
||||||
|
// Emulates round() using floor().
|
||||||
|
//
|
||||||
|
// Returns:
|
||||||
|
//
|
||||||
|
// On Success: The largest integer that is less than or
|
||||||
|
// equal to 'x'.
|
||||||
|
// On Failure: None
|
||||||
|
//
|
||||||
|
LIBPBD_API double PBD_APICALLTYPE
|
||||||
|
round(double x)
|
||||||
|
{
|
||||||
|
return (floor(x));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER) && (_MSC_VER < 1900)
|
#if defined(_MSC_VER) && (_MSC_VER < 1900)
|
||||||
|
|
@ -339,6 +318,27 @@ log2(double x)
|
||||||
{
|
{
|
||||||
return (log(x) / log((double)2.0));
|
return (log(x) / log((double)2.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//***************************************************************
|
||||||
|
//
|
||||||
|
// 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));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace PBD {
|
namespace PBD {
|
||||||
|
|
|
||||||
|
|
@ -230,17 +230,17 @@ LIBPBD_API int __cdecl gettimeofday(struct timeval *__restrict tv, __
|
||||||
LIBPBD_API ssize_t PBD_APICALLTYPE pread(int handle, void *buf, size_t nbytes, off_t offset);
|
LIBPBD_API ssize_t PBD_APICALLTYPE pread(int handle, void *buf, size_t nbytes, off_t offset);
|
||||||
LIBPBD_API ssize_t PBD_APICALLTYPE pwrite(int handle, const void *buf, size_t nbytes, off_t offset);
|
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 int PBD_APICALLTYPE poll(struct pollfd *fds, nfds_t nfds, int timeout);
|
||||||
LIBPBD_API float PBD_APICALLTYPE roundf(float x);
|
|
||||||
LIBPBD_API double PBD_APICALLTYPE round(double x);
|
|
||||||
LIBPBD_API double PBD_APICALLTYPE trunc(double x);
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) && (_MSC_VER < 1800)
|
#if defined(_MSC_VER) && (_MSC_VER < 1800)
|
||||||
LIBPBD_API double PBD_APICALLTYPE expm1(double x);
|
LIBPBD_API double PBD_APICALLTYPE expm1(double x);
|
||||||
LIBPBD_API double PBD_APICALLTYPE log1p(double x);
|
LIBPBD_API double PBD_APICALLTYPE log1p(double x);
|
||||||
|
LIBPBD_API double PBD_APICALLTYPE round(double x);
|
||||||
|
LIBPBD_API float PBD_APICALLTYPE roundf(float x);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER) && (_MSC_VER < 1900)
|
#if defined(_MSC_VER) && (_MSC_VER < 1900)
|
||||||
LIBPBD_API double PBD_APICALLTYPE log2 (double x);
|
LIBPBD_API double PBD_APICALLTYPE log2 (double x);
|
||||||
|
LIBPBD_API double PBD_APICALLTYPE trunc(double x);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace PBD {
|
namespace PBD {
|
||||||
|
|
|
||||||
|
|
@ -252,17 +252,17 @@ inline int64_t abs(int64_t val) throw()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(LIBPBD_API) || defined(PBD_IS_IN_WIN_STATIC_LIB)
|
#if !defined(LIBPBD_API) || defined(PBD_IS_IN_WIN_STATIC_LIB)
|
||||||
extern double round(double x);
|
|
||||||
extern float roundf(float x);
|
|
||||||
|
|
||||||
// Emulate some C99 math functions which MSVC itself didn't
|
// Emulate some C99 math functions which MSVC itself didn't
|
||||||
// implement until later in life.
|
// implement until later in life.
|
||||||
#if defined(_MSC_VER) && (_MSC_VER < 1800)
|
#if defined(_MSC_VER) && (_MSC_VER < 1800)
|
||||||
extern double expm1(double x);
|
extern double expm1(double x);
|
||||||
extern double log1p(double x);
|
extern double log1p(double x);
|
||||||
|
extern double round(double x);
|
||||||
|
extern float roundf(float x);
|
||||||
#endif
|
#endif
|
||||||
#if defined(_MSC_VER) && (_MSC_VER < 1900)
|
#if defined(_MSC_VER) && (_MSC_VER < 1900)
|
||||||
extern double log2 (double x);
|
extern double log2 (double x);
|
||||||
|
extern double trunc(double x);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue