X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=msvc_extra_headers%2Fardourext%2Fmisc.h.input;h=a5f4e9e95cecbcfc9fd1d84fb75bab0b3363126f;hb=cc1d33a91de47c6e227dae8551250d4c0938917e;hp=63ce6c562c8cef006eb22c9ce92143c4698dfcae;hpb=302b08c0592a6b7c40dec8c04f52c346e14b17af;p=ardour.git diff --git a/msvc_extra_headers/ardourext/misc.h.input b/msvc_extra_headers/ardourext/misc.h.input index 63ce6c562c..a5f4e9e95c 100644 --- a/msvc_extra_headers/ardourext/misc.h.input +++ b/msvc_extra_headers/ardourext/misc.h.input @@ -49,6 +49,10 @@ #define INFINITY HUGE_VAL #endif +#ifndef NAN +#define NAN _NANCODE +#endif + // File access modes copied from unistd.h #define F_OK 0 #define R_OK 4 @@ -63,6 +67,7 @@ #define getcwd _getcwd #define getpid _getpid #define snprintf _snprintf +#define random rand #define link ntfs_link #define unlink ntfs_unlink #define strcasecmp stricmp @@ -73,11 +78,6 @@ #ifndef PATH_MAX #define PATH_MAX _MAX_PATH #endif -#define DECLARE_DEFAULT_COMPARISONS(Type) \ - extern bool operator > (const Type& lhs, const Type& rhs); \ - extern bool operator < (const Type& lhs, const Type& rhs); \ - extern bool operator != (const Type& lhs, const Type& rhs); \ - extern bool operator == (const Type& lhs, const Type& rhs); // Types missing from Win32 'stat.h' (hopefully Windows // will either act sensibly or ignore most of them). @@ -181,15 +181,6 @@ typedef int register_t; #endif #endif -// round().... Unlike Linux, Windows doesn't seem to support the -// concept of a system-wide (or programmable) rounding direction. -// Fortunately, 'round to nearest' seems to be the default action -// under Linux, so let's copy that until we find out otherwise. -#define rint(value) round(value) -#if !defined(PBD_API) || defined(PBD_IS_IN_WIN_STATIC_LIB) -extern double round(double x); -#endif - // System V compatibility typedef unsigned short ushort; typedef unsigned int uint; @@ -205,8 +196,9 @@ typedef _mode_t mode_t; #endif /* _MODE_T_ */ // int64 abs() +#if (defined(_MSC_VER) && (_MSC_VER < 1500)) #ifdef __cplusplus // Normal 'C' doesn't permit over-ridden functions !! -inline uint64_t abs(int64_t val) +inline int64_t abs(int64_t val) throw() { if (val < 0) return val * (-1); @@ -214,6 +206,7 @@ inline uint64_t abs(int64_t val) return val; } #endif +#endif // fmin() and fmax() #define fmin(a, b) min((double)a, (double)b) @@ -231,8 +224,17 @@ inline uint64_t abs(int64_t val) // #include the main headers for Ardour MSVC #ifdef __cplusplus -#if defined(BUILDING_PBD) || defined(PBD_IS_IN_WIN_STATIC_LIB) +#if defined(LIBPBD_DLL) || defined(PBD_IS_IN_WIN_STATIC_LIB) #include + +#ifdef LIBPBD_DLL +#define DEFAULT_COMPARISONS_DEFINED +#define DECLARE_DEFAULT_COMPARISONS(Type) \ + LIBPBD_API bool operator > (const Type& lhs, const Type& rhs); \ + LIBPBD_API bool operator < (const Type& lhs, const Type& rhs); \ + LIBPBD_API bool operator != (const Type& lhs, const Type& rhs); \ + LIBPBD_API bool operator == (const Type& lhs, const Type& rhs); +#endif #endif #if defined(BUILDING_LIBARDOUR) || defined(LIBARDOUR_IS_IN_WIN_STATIC_LIB) #include @@ -242,4 +244,28 @@ inline uint64_t abs(int64_t val) #endif #endif // __cplusplus +#ifndef DEFAULT_COMPARISONS_DEFINED +#define DEFAULT_COMPARISONS_DEFINED +#define DECLARE_DEFAULT_COMPARISONS(Type) \ + extern bool operator > (const Type& lhs, const Type& rhs); \ + extern bool operator < (const Type& lhs, const Type& rhs); \ + extern bool operator != (const Type& lhs, const Type& rhs); \ + extern bool operator == (const Type& lhs, const Type& rhs); +#endif + +#if !defined(LIBPBD_API) || defined(PBD_IS_IN_WIN_STATIC_LIB) +// 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); +extern double round(double x); +extern float roundf(float x); +#endif +#if defined(_MSC_VER) && (_MSC_VER < 1900) +extern double log2 (double x); +extern double trunc(double x); +#endif +#endif + #endif /* __ardour_msvc_extensions_h__ */