From b496a71d2e90175439bde3cc1fbb5bd7437e86ab Mon Sep 17 00:00:00 2001 From: John Emmas Date: Sat, 30 Jan 2021 13:55:25 +0000 Subject: [PATCH] Some preliminary changes needed to support building with VS2019 (these get me about as far as 'libardour' ) --- libs/ardour/ardour/types.h | 2 +- libs/ardour/x86_functions_fma.cc | 4 ++++ libs/pbd/msvc/msvc_pbd.cc | 4 ++-- libs/pbd/pbd/msvc_pbd.h | 18 ++++++++++------- .../ardourext/float_cast.h.input | 2 +- msvc_extra_headers/ardourext/misc.h.input | 20 +++++++++++-------- 6 files changed, 31 insertions(+), 19 deletions(-) diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h index b28f181f94..dbb28cf0eb 100644 --- a/libs/ardour/ardour/types.h +++ b/libs/ardour/ardour/types.h @@ -58,7 +58,7 @@ using Temporal::max_samplepos; using Temporal::max_samplecnt; -#if __GNUC__ < 3 +#if defined (__GNUC__) && (__GNUC__ < 3) typedef int intptr_t; #endif diff --git a/libs/ardour/x86_functions_fma.cc b/libs/ardour/x86_functions_fma.cc index 6e446b834b..79fe32323d 100644 --- a/libs/ardour/x86_functions_fma.cc +++ b/libs/ardour/x86_functions_fma.cc @@ -17,6 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifdef FPU_AVX_FMA_SUPPORT + #include "ardour/mix.h" #include @@ -135,3 +137,5 @@ x86_fma_mix_buffers_with_gain( } } while (0); } + +#endif // FPU_AVX_FMA_SUPPORT diff --git a/libs/pbd/msvc/msvc_pbd.cc b/libs/pbd/msvc/msvc_pbd.cc index 855c873dd5..4d276eb85c 100644 --- a/libs/pbd/msvc/msvc_pbd.cc +++ b/libs/pbd/msvc/msvc_pbd.cc @@ -753,7 +753,7 @@ bool bValidPath = false; #if (_WIN32_WINNT >= 0x0500) if (0 == strRootFileSystemType.compare("NTFS")) { - if (TestForMinimumSpecOS()) // Hard links were only available from Win2K onwards + if (TestForMinimumSpecOS(NULL)) // Hard links were only available from Win2K onwards if (0 == CreateHardLinkA(link_filepath, existing_filepath, NULL)) { // Note that the above API call cannot create a link to a directory, so // should we also be checking that the supplied path was actually a file? @@ -882,7 +882,7 @@ bool bValidPath = false; std::transform(strRootFileSystemType.begin(), strRootFileSystemType.end(), strRootFileSystemType.begin(), ::toupper); #if (_WIN32_WINNT >= 0x0500) if (0 == strRootFileSystemType.compare("NTFS")) - if (TestForMinimumSpecOS()) // Hard links were only available from Win2K onwards + if (TestForMinimumSpecOS(NULL)) // Hard links were only available from Win2K onwards if (0 == DeleteFileA(link_filepath)) ret = GetLastError(); else diff --git a/libs/pbd/pbd/msvc_pbd.h b/libs/pbd/pbd/msvc_pbd.h index cbb2320fd7..0dc19671b1 100644 --- a/libs/pbd/pbd/msvc_pbd.h +++ b/libs/pbd/pbd/msvc_pbd.h @@ -217,18 +217,22 @@ LIBPBD_API double PBD_APICALLTYPE trunc(double x); namespace PBD { -LIBPBD_API bool PBD_APICALLTYPE TestForMinimumSpecOS(char *revision="currently ignored"); -LIBPBD_API char* PBD_APICALLTYPE realpath (const char *original_path, char resolved_path[_MAX_PATH+1]); -LIBPBD_API int PBD_APICALLTYPE mkstemp (char *template_name); -LIBPBD_API int PBD_APICALLTYPE ntfs_link (const char *existing_filepath, const char *link_filepath); -LIBPBD_API int PBD_APICALLTYPE ntfs_unlink (const char *link_filepath); - // These are used to replicate 'dirent.h' functionality LIBPBD_API DIR* PBD_APICALLTYPE opendir (const char *szPath); LIBPBD_API struct dirent* PBD_APICALLTYPE readdir (DIR *pDir); LIBPBD_API int PBD_APICALLTYPE closedir (DIR *pDir); -} // namespace PBD +#if defined(_MSC_VER) && (_MSC_VER < 1900) +LIBPBD_API char* PBD_APICALLTYPE realpath (const char *original_path, char resolved_path[_MAX_PATH+1]); +LIBPBD_API int PBD_APICALLTYPE mkstemp (char *template_name); + +// JE - 30-01-2021 (AFAICT these ones aren't needed any more) +LIBPBD_API bool PBD_APICALLTYPE TestForMinimumSpecOS(char *revision="currently ignored"); +LIBPBD_API int PBD_APICALLTYPE ntfs_link (const char *existing_filepath, const char *link_filepath); +LIBPBD_API int PBD_APICALLTYPE ntfs_unlink (const char *link_filepath); +#endif + +} // namespace PBD */ #ifdef __cplusplus } /* extern "C" */ diff --git a/msvc_extra_headers/ardourext/float_cast.h.input b/msvc_extra_headers/ardourext/float_cast.h.input index 73eb2c38f6..5ade2bfd21 100644 --- a/msvc_extra_headers/ardourext/float_cast.h.input +++ b/msvc_extra_headers/ardourext/float_cast.h.input @@ -36,7 +36,7 @@ */ #ifndef __FLOAT_CAST_H__ // Added by JE - 30-11-2009 #define __FLOAT_CAST_H__ -#if (defined (WIN32) || defined (_WIN32)) +#if defined (WIN32) || defined (_WIN32) #include diff --git a/msvc_extra_headers/ardourext/misc.h.input b/msvc_extra_headers/ardourext/misc.h.input index 032252a72d..7471ccd649 100644 --- a/msvc_extra_headers/ardourext/misc.h.input +++ b/msvc_extra_headers/ardourext/misc.h.input @@ -47,12 +47,6 @@ #include #include -// 'std::isnan()' is not available in MSVC. Assume '_isnan(double)' -#define isnan(val) _isnan((double)val) - -// 'std::isinf()' is not available in MSVC. Assume '!_finite(double)' -#define isinf(val) !_finite((double)val) - // 'INFINITY' is not defined in MSVC. Assume 'HUGE_VAL' #ifndef INFINITY #define INFINITY HUGE_VAL @@ -69,6 +63,8 @@ #define X_OK 1 // Miscellaneous #defines +// JE - (these ones believed to be no longer needed from VS2015 onward) +#if defined(_MSC_VER) && (_MSC_VER < 1900) #define __attribute__(x) #define llabs _abs64 #define atoll _atoi64 @@ -76,9 +72,10 @@ #define getcwd _getcwd #define getpid _getpid #define snprintf _snprintf -#define random rand #define link ntfs_link #define unlink ntfs_unlink +#endif +#define random rand #define strcasecmp stricmp #define strncasecmp strnicmp #define strtok_r( _s, _sep, _lasts ) \ @@ -217,10 +214,17 @@ inline int64_t abs(int64_t val) throw() #endif #endif -// fmin() and fmax() +// fmin() and fmax() etc. #if defined(_MSC_VER) && (_MSC_VER < 1900) #define fmin(a, b) __min((double)a, (double)b) #define fmax(a, b) __max((double)a, (double)b) + +// 'std::isnan()' is not available in early versions of MSVC. Assume '_isnan(double)' +#define isnan(val) _isnan((double)val) + +// 'std::isinf()' is not available in early versions of MSVC. Assume '!_finite(double)' +#define isinf(val) !_finite((double)val) + #endif // approximate POSIX pipe()