diff --git a/src/OSspecific/POSIX/Make/files b/src/OSspecific/POSIX/Make/files index 44ba1ec1bf..ce684dc46b 100644 --- a/src/OSspecific/POSIX/Make/files +++ b/src/OSspecific/POSIX/Make/files @@ -20,7 +20,7 @@ POSIX.C */ fileMonitor.C -#ifdef SunOS64 +#ifdef __sun__ dummyPrintStack.C #else printStack.C diff --git a/src/OSspecific/POSIX/POSIX.C b/src/OSspecific/POSIX/POSIX.C index 57ffb64476..1f67434bff 100644 --- a/src/OSspecific/POSIX/POSIX.C +++ b/src/OSspecific/POSIX/POSIX.C @@ -28,7 +28,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifdef solarisGcc +#if defined(__sun__) && defined(__GNUC__) + // Not certain if this is still required #define _SYS_VNODE_H #endif @@ -59,7 +60,7 @@ Description #include #include -#ifdef darwin +#ifdef __APPLE__ #include #else @@ -1660,7 +1661,7 @@ void* Foam::dlOpen(const fileName& libName, const bool check) } void* handle = ::dlopen(libName.c_str(), RTLD_LAZY|RTLD_GLOBAL); - #ifdef darwin + #ifdef __APPLE__ // Re-try "libXX.so" as "libXX.dylib" if (!handle && libName.hasExt("so")) { @@ -1753,7 +1754,7 @@ bool Foam::dlSymFound(void* handle, const std::string& symbol) } -#ifndef darwin +#ifndef __APPLE__ static int collectLibsCallback ( struct dl_phdr_info *info, @@ -1772,7 +1773,7 @@ static int collectLibsCallback Foam::fileNameList Foam::dlLoaded() { DynamicList libs; - #ifdef darwin + #ifdef __APPLE__ for (uint32_t i=0; i < _dyld_image_count(); ++i) { libs.append(_dyld_get_image_name(i)); diff --git a/src/OSspecific/POSIX/fileStat.C b/src/OSspecific/POSIX/fileStat.C index df5c8ae95f..43ae90348c 100644 --- a/src/OSspecific/POSIX/fileStat.C +++ b/src/OSspecific/POSIX/fileStat.C @@ -30,7 +30,7 @@ License #include "timer.H" #include -#ifndef darwin +#ifndef __APPLE__ #include #endif @@ -115,7 +115,7 @@ double Foam::fileStat::dmodTime() const ( isValid_ ? - #ifdef darwin + #ifdef __APPLE__ (status_.st_mtime + 1e-9*status_.st_mtimespec.tv_nsec) #else (status_.st_mtime + 1e-9*status_.st_mtim.tv_nsec) diff --git a/src/OSspecific/POSIX/printStack.C b/src/OSspecific/POSIX/printStack.C index 2a34f7b0d0..5015123ae3 100644 --- a/src/OSspecific/POSIX/printStack.C +++ b/src/OSspecific/POSIX/printStack.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016 OpenFOAM Foundation @@ -89,7 +89,7 @@ string pOpen(const string& cmd, label line=0) inline word addressToWord(const uintptr_t addr) { OStringStream os; - #ifdef darwin + #ifdef __APPLE__ os << "0x" << hex << uint64_t(addr); #else os << "0x" << hex << addr; @@ -121,7 +121,7 @@ void printSourceFileAndLine // Darwin addr2line implementation. // On other systems (Linux), only use relative addresses for libraries. - #ifndef darwin + #ifndef __APPLE__ if (filename.hasExt("so")) #endif { diff --git a/src/OSspecific/POSIX/signals/feexceptErsatz.H b/src/OSspecific/POSIX/signals/feexceptErsatz.H index 1b866242f2..ee6548b773 100644 --- a/src/OSspecific/POSIX/signals/feexceptErsatz.H +++ b/src/OSspecific/POSIX/signals/feexceptErsatz.H @@ -20,8 +20,8 @@ #ifndef feexceptErsatz_H #define feexceptErsatz_H -#ifdef darwin +#ifdef __APPLE__ #include // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -68,7 +68,7 @@ inline int fedisableexcept(unsigned int excepts) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#endif // darwin +#endif // __APPLE__ #endif // ************************************************************************* // diff --git a/src/OSspecific/POSIX/signals/sigFpe.C b/src/OSspecific/POSIX/signals/sigFpe.C index f192d18eda..25ae021198 100644 --- a/src/OSspecific/POSIX/signals/sigFpe.C +++ b/src/OSspecific/POSIX/signals/sigFpe.C @@ -43,7 +43,7 @@ License #include #endif -#ifdef darwin +#ifdef __APPLE__ #include "feexceptErsatz.H" #endif @@ -121,7 +121,7 @@ void* Foam::sigFpe::mallocNan(size_t size) void Foam::sigFpe::sigHandler(int) { - #if (defined(__linux__) && defined(__GNUC__)) || defined(darwin) + #if (defined(__linux__) && defined(__GNUC__)) || defined(__APPLE__) resetHandler("SIGFPE", SIGFPE); @@ -129,7 +129,7 @@ void Foam::sigFpe::sigHandler(int) error::printStack(Perr); ::raise(SIGFPE); // Throw signal (to old handler) - #endif // (__linux__ && __GNUC__) || darwin + #endif // (__linux__ && __GNUC__) || __APPLE__ } @@ -188,7 +188,7 @@ void Foam::sigFpe::set(bool verbose) { if (!sigActive_ && requested()) { - #if (defined(__linux__) && defined(__GNUC__)) || defined(darwin) + #if (defined(__linux__) && defined(__GNUC__)) || defined(__APPLE__) feenableexcept ( @@ -244,7 +244,7 @@ void Foam::sigFpe::set(bool verbose) void Foam::sigFpe::unset(bool verbose) { - #if (defined(__linux__) && defined(__GNUC__)) || defined(darwin) + #if (defined(__linux__) && defined(__GNUC__)) || defined(__APPLE__) if (sigActive_) { if (verbose) diff --git a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.C b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.C index d7cdc25a8c..4dc26c3a77 100644 --- a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.C +++ b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016 OpenFOAM Foundation @@ -319,7 +319,7 @@ Foam::fileName Foam::dynamicCode::codeRelPath() const Foam::fileName Foam::dynamicCode::libRelPath() const { - #ifdef darwin + #ifdef __APPLE__ return codeRelPath()/libSubDir_/"lib" + codeName_ + ".dylib"; #else return codeRelPath()/libSubDir_/"lib" + codeName_ + ".so"; diff --git a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.H b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.H index 65e3671543..78b687e5bb 100644 --- a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.H +++ b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011 OpenFOAM Foundation @@ -223,7 +223,7 @@ public: // Corresponds to codeRoot()/libSubDir()/lib\.so fileName libPath() const { - #ifdef darwin + #ifdef __APPLE__ return codeRoot_/libSubDir_/"lib" + codeName_ + ".dylib"; #else return codeRoot_/libSubDir_/"lib" + codeName_ + ".so"; diff --git a/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H b/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H index 2f7ed678bb..4501dda96a 100644 --- a/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H +++ b/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H @@ -109,6 +109,18 @@ inline Scalar func(const Scalar s) \ std::cerr<< "No '" << #func << "' function\n"; \ return 0; \ } +#elif defined(__MINGW32__) + // Mingw: with '_' prefix + #define besselFunc(func) \ + inline Scalar func(const Scalar s) \ + { \ + return _##func(s); \ + } + #define besselFunc2(func) \ + inline Scalar func(const int n, const Scalar s) \ + { \ + return _##func(n, s); \ + } #else #define besselFunc(func) \ inline Scalar func(const Scalar s) \ @@ -122,6 +134,7 @@ inline Scalar func(const Scalar s) \ } #endif + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H b/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H index c1030a4ef5..a8721b1d79 100644 --- a/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H +++ b/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H @@ -109,8 +109,8 @@ inline Scalar func(const Scalar s) \ std::cerr<< "No '" << #func << "' function\n"; \ return 0; \ } -#elif defined(darwin) - // No float version for darwin - use a cast. +#elif defined(__APPLE__) + // Darwin: no float version (use a cast) #define besselFunc(func) \ inline Scalar func(const Scalar s) \ { \ @@ -121,7 +121,18 @@ inline Scalar func(const Scalar s) \ { \ return Scalar(::func(n, double(s))); \ } - +#elif defined(__MINGW32__) + // Mingw: with '_' prefix, no float version (use a cast) + #define besselFunc(func) \ + inline Scalar func(const Scalar s) \ + { \ + return _##func(s); \ + } + #define besselFunc2(func) \ + inline Scalar func(const int n, const Scalar s) \ + { \ + return Scalar(_##func(n, double(s))); \ + } #else // With 'f' (float) appended to the name #define besselFunc(func) \ diff --git a/src/OpenFOAM/primitives/ints/int64/int64.H b/src/OpenFOAM/primitives/ints/int64/int64.H index 4027f86328..b0e075b634 100644 --- a/src/OpenFOAM/primitives/ints/int64/int64.H +++ b/src/OpenFOAM/primitives/ints/int64/int64.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2014-2016 OpenFOAM Foundation @@ -46,7 +46,6 @@ SourceFiles #include "pTraits.H" #include "direction.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -120,9 +119,10 @@ inline bool read(const std::string& str, int64_t& val) Istream& operator>>(Istream& is, int64_t& val); Ostream& operator<<(Ostream& os, const int64_t val); -// On Darwin: long is not unambiguously (int32_t | int64_t) +// On Darwin and Windows (mingw): +// long is not unambiguously (int32_t | int64_t) // - explicitly resolve for input and output -#ifdef darwin +#if defined(__APPLE__) || defined(_WIN32) Istream& operator>>(Istream& is, long& val); Ostream& operator<<(Ostream& os, const long val); #endif diff --git a/src/OpenFOAM/primitives/ints/int64/int64IO.C b/src/OpenFOAM/primitives/ints/int64/int64IO.C index 47e7a97ab6..add4abb455 100644 --- a/src/OpenFOAM/primitives/ints/int64/int64IO.C +++ b/src/OpenFOAM/primitives/ints/int64/int64IO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2014-2016 OpenFOAM Foundation @@ -125,7 +125,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const int64_t val) } -#ifdef darwin +#if defined(__APPLE__) || defined(_WIN32) Foam::Istream& Foam::operator>>(Istream& is, long& val) { return operator>>(is, reinterpret_cast(val)); diff --git a/src/OpenFOAM/primitives/ints/uint64/uint64.H b/src/OpenFOAM/primitives/ints/uint64/uint64.H index 694e9f1158..7b2da34766 100644 --- a/src/OpenFOAM/primitives/ints/uint64/uint64.H +++ b/src/OpenFOAM/primitives/ints/uint64/uint64.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2014-2016 OpenFOAM Foundation @@ -119,9 +119,10 @@ inline bool read(const std::string& str, uint64_t& val) Istream& operator>>(Istream& is, uint64_t& val); Ostream& operator<<(Ostream& os, const uint64_t val); -// On Darwin: unsigned long is not unambiguously (uint32_t | uint64_t) +// On Darwin: +// unsigned long is not unambiguously (uint32_t | uint64_t) // - explicitly resolve for output -#ifdef darwin +#ifdef __APPLE__ Ostream& operator<<(Ostream& os, const unsigned long val); #endif diff --git a/src/OpenFOAM/primitives/ints/uint64/uint64IO.C b/src/OpenFOAM/primitives/ints/uint64/uint64IO.C index e6e8369025..38b4e0c9db 100644 --- a/src/OpenFOAM/primitives/ints/uint64/uint64IO.C +++ b/src/OpenFOAM/primitives/ints/uint64/uint64IO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2014-2016 OpenFOAM Foundation @@ -124,7 +124,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const uint64_t val) } -#ifdef darwin +#ifdef __APPLE__ Foam::Ostream& Foam::operator<<(Ostream& os, const unsigned long val) { os << uint64_t(val); diff --git a/wmake/rules/General/general b/wmake/rules/General/general index ec52419e9d..4eb70d6c45 100644 --- a/wmake/rules/General/general +++ b/wmake/rules/General/general @@ -7,7 +7,7 @@ RANLIB = ranlib CPP = cpp LD = ld -GFLAGS = -D$(WM_VERSION) -D$(WM_ARCH) -DWM_ARCH_OPTION=$(WM_ARCH_OPTION) \ +GFLAGS = -D$(WM_VERSION) -DWM_ARCH_OPTION=$(WM_ARCH_OPTION) \ -DWM_$(WM_PRECISION_OPTION) -DWM_LABEL_SIZE=$(WM_LABEL_SIZE) GINC = GLIBS = -lm diff --git a/wmake/rules/darwin64Clang/general b/wmake/rules/darwin64Clang/general index 37bf4f300e..1409ef1e6e 100644 --- a/wmake/rules/darwin64Clang/general +++ b/wmake/rules/darwin64Clang/general @@ -1,4 +1,4 @@ -CPP = cpp -traditional-cpp $(GFLAGS) -Ddarwin +CPP = cpp -traditional-cpp $(GFLAGS) PROJECT_LIBS = -l$(WM_PROJECT) -ldl @@ -11,7 +11,4 @@ include $(DEFAULT_RULES)/c++ # Shared library extension (with '.' separator) EXT_SO = .dylib -# Define general os-type -GFLAGS += -Ddarwin - # -----------------------------------------------------------------------------