mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
COMP: some low-level darwin-related patches
- a partial selection from https://github.com/mrklein/openfoam-os-x with adjustments. The primary purpose is to reduce header-level incompatibilities and to provide a common set of make rules to allow easier patching (or re-integration).
This commit is contained in:
@ -103,6 +103,11 @@ case Linux:
|
||||
endsw
|
||||
breaksw
|
||||
|
||||
case Darwin: # Presumably x86_64
|
||||
if (! $?WM_ARCH_OPTION ) setenv WM_ARCH_OPTION 64 # Default to 64-bit
|
||||
setenv WM_ARCH darwin64
|
||||
breaksw
|
||||
|
||||
case SunOS:
|
||||
setenv WM_ARCH SunOS64
|
||||
setenv WM_MPLIB FJMPI
|
||||
|
||||
@ -97,6 +97,11 @@ Linux)
|
||||
esac
|
||||
;;
|
||||
|
||||
Darwin) # Presumably x86_64
|
||||
: ${WM_ARCH_OPTION:=64}; export WM_ARCH_OPTION # Default to 64-bit
|
||||
WM_ARCH=darwin64
|
||||
;;
|
||||
|
||||
SunOS)
|
||||
WM_ARCH=SunOS64
|
||||
WM_MPLIB=FJMPI
|
||||
|
||||
@ -1547,6 +1547,15 @@ void* Foam::dlOpen(const fileName& lib, const bool check)
|
||||
}
|
||||
void* handle = ::dlopen(lib.c_str(), RTLD_LAZY|RTLD_GLOBAL);
|
||||
|
||||
#ifdef darwin
|
||||
// Re-try "libXX.so" as "libXX.dylib"
|
||||
if (!handle && lib.hasExt("so"))
|
||||
{
|
||||
const fileName dylib(lib.lessExt().ext("dylib"));
|
||||
handle = ::dlopen(dylib.c_str(), RTLD_LAZY|RTLD_GLOBAL);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!handle && check)
|
||||
{
|
||||
WarningInFunction
|
||||
@ -1631,6 +1640,7 @@ bool Foam::dlSymFound(void* handle, const std::string& symbol)
|
||||
}
|
||||
|
||||
|
||||
#ifndef darwin
|
||||
static int collectLibsCallback
|
||||
(
|
||||
struct dl_phdr_info *info,
|
||||
@ -1643,12 +1653,21 @@ static int collectLibsCallback
|
||||
ptr->append(info->dlpi_name);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Foam::fileNameList Foam::dlLoaded()
|
||||
{
|
||||
DynamicList<fileName> libs;
|
||||
#ifdef darwin
|
||||
for (uint32_t i=0; i < _dyld_image_count(); ++i)
|
||||
{
|
||||
libs.append(_dyld_get_image_name(i));
|
||||
}
|
||||
#else
|
||||
dl_iterate_phdr(collectLibsCallback, &libs);
|
||||
#endif
|
||||
|
||||
if (POSIX::debug)
|
||||
{
|
||||
std::cout
|
||||
|
||||
@ -37,6 +37,9 @@ SourceFiles
|
||||
#define clockValue_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifdef darwin
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -40,7 +40,9 @@ SourceFiles
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef __GNUC__
|
||||
#ifdef darwin
|
||||
#include <machine/endian.h>
|
||||
#elif defined __GNUC__
|
||||
#include <endian.h>
|
||||
#elif defined __mips
|
||||
#include <standards.h>
|
||||
|
||||
@ -87,7 +87,11 @@ string pOpen(const string& cmd, label line=0)
|
||||
inline word addressToWord(const uintptr_t addr)
|
||||
{
|
||||
OStringStream os;
|
||||
#ifdef darwin
|
||||
os << "0x" << hex << uint64_t(addr);
|
||||
#else
|
||||
os << "0x" << hex << addr;
|
||||
#endif
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
@ -315,7 +315,11 @@ Foam::fileName Foam::dynamicCode::codeRelPath() const
|
||||
|
||||
Foam::fileName Foam::dynamicCode::libRelPath() const
|
||||
{
|
||||
#ifdef darwin
|
||||
return codeRelPath()/libSubDir_/"lib" + codeName_ + ".dylib";
|
||||
#else
|
||||
return codeRelPath()/libSubDir_/"lib" + codeName_ + ".so";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
// Forward declarations
|
||||
class dynamicCodeContext;
|
||||
class ISstream;
|
||||
class OSstream;
|
||||
@ -92,11 +92,11 @@ private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
dynamicCode(const dynamicCode&);
|
||||
//- No copy construct
|
||||
dynamicCode(const dynamicCode&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const dynamicCode&);
|
||||
//- No copy assignment
|
||||
void operator=(const dynamicCode&) = delete;
|
||||
|
||||
|
||||
protected:
|
||||
@ -221,7 +221,11 @@ public:
|
||||
// Corresponds to codeRoot()/libSubDir()/lib\<codeName\>.so
|
||||
fileName libPath() const
|
||||
{
|
||||
#ifdef darwin
|
||||
return codeRoot_/libSubDir_/"lib" + codeName_ + ".dylib";
|
||||
#else
|
||||
return codeRoot_/libSubDir_/"lib" + codeName_ + ".so";
|
||||
#endif
|
||||
}
|
||||
|
||||
//- Path for specified code name relative to \$FOAM_CASE
|
||||
|
||||
@ -166,11 +166,10 @@ transFunc(erfc)
|
||||
transFunc(lgamma)
|
||||
transFunc(tgamma)
|
||||
|
||||
transFunc(j0)
|
||||
transFunc(j1)
|
||||
|
||||
transFunc(y0)
|
||||
transFunc(y1)
|
||||
besselFunc(j0)
|
||||
besselFunc(j1)
|
||||
besselFunc(y0)
|
||||
besselFunc(y1)
|
||||
|
||||
|
||||
inline Scalar& setComponent(Scalar& s, const direction)
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
@ -100,6 +100,15 @@ inline Scalar func(const Scalar s) \
|
||||
return ::func(s); \
|
||||
}
|
||||
|
||||
|
||||
// Double-precision bessel functions
|
||||
#define besselFunc(func) \
|
||||
inline Scalar func(const Scalar s) \
|
||||
{ \
|
||||
return ::func(s); \
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
@ -115,6 +124,7 @@ inline Scalar func(const Scalar s) \
|
||||
#undef ScalarROOTVSMALL
|
||||
#undef ScalarRead
|
||||
#undef transFunc
|
||||
#undef besselFunc
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -83,6 +83,41 @@ inline Scalar atan2(const Scalar y, const Scalar x)
|
||||
return ::atan2f(y, x);
|
||||
}
|
||||
|
||||
// Single-precision transcendental functions (with 'f' appended to the name)
|
||||
#define transFunc(func) \
|
||||
inline Scalar func(const Scalar s) \
|
||||
{ \
|
||||
return ::func##f(s); \
|
||||
}
|
||||
|
||||
|
||||
#ifdef darwin
|
||||
// Single-precision bessel functions. (No float version for darwin).
|
||||
#define besselFunc(func) \
|
||||
inline Scalar func(const Scalar s) \
|
||||
{ \
|
||||
return ::func(s); \
|
||||
}
|
||||
|
||||
inline Scalar jn(const int n, const Scalar s)
|
||||
{
|
||||
return Scalar(::jn(n, double(s)));
|
||||
}
|
||||
|
||||
inline Scalar yn(const int n, const Scalar s)
|
||||
{
|
||||
return Scalar(::yn(n, double(s)));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// Single-precision bessel functions (with 'f' appended to the name)
|
||||
#define besselFunc(func) \
|
||||
inline Scalar func(const Scalar s) \
|
||||
{ \
|
||||
return ::func##f(s); \
|
||||
}
|
||||
|
||||
inline Scalar jn(const int n, const Scalar s)
|
||||
{
|
||||
return ::jnf(n, s);
|
||||
@ -93,12 +128,8 @@ inline Scalar yn(const int n, const Scalar s)
|
||||
return ::ynf(n, s);
|
||||
}
|
||||
|
||||
// Single-precision transcendental functions (with 'f' appended to the name)
|
||||
#define transFunc(func) \
|
||||
inline Scalar func(const Scalar s) \
|
||||
{ \
|
||||
return ::func##f(s); \
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -115,6 +146,7 @@ inline Scalar func(const Scalar s) \
|
||||
#undef ScalarROOTVSMALL
|
||||
#undef ScalarRead
|
||||
#undef transFunc
|
||||
#undef besselFunc
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
16
wmake/rules/darwin64Clang/c
Normal file
16
wmake/rules/darwin64Clang/c
Normal file
@ -0,0 +1,16 @@
|
||||
SUFFIXES += .c
|
||||
|
||||
cc = clang -m64 -Ddarwin
|
||||
|
||||
cWARN = -Wall
|
||||
|
||||
include $(DEFAULT_RULES)/c$(WM_COMPILE_OPTION)
|
||||
|
||||
cFLAGS = $(GFLAGS) $(cWARN) $(cOPT) $(cDBUG) $(LIB_HEADER_DIRS) -fPIC
|
||||
|
||||
ctoo = $(WM_SCHEDULER) $(cc) $(cFLAGS) -c $< -o $@
|
||||
|
||||
LINK_LIBS = $(cDBUG)
|
||||
|
||||
LINKLIBSO = $(cc) -Wl,-dylib,-undefined,dynamic_lookup
|
||||
LINKEXE = $(cc) -Wl,-execute,-undefined,dynamic_lookup
|
||||
17
wmake/rules/darwin64Clang/c++
Normal file
17
wmake/rules/darwin64Clang/c++
Normal file
@ -0,0 +1,17 @@
|
||||
include $(GENERAL_RULES)/Clang/c++
|
||||
|
||||
CC = clang++ -std=c++11 -m64 -Ddarwin
|
||||
|
||||
include $(DEFAULT_RULES)/c++$(WM_COMPILE_OPTION)
|
||||
|
||||
c++FLAGS = $(GFLAGS) $(c++WARN) $(c++OPT) $(c++DBUG) $(ptFLAGS) $(LIB_HEADER_DIRS) -fPIC
|
||||
|
||||
Ctoo = $(WM_SCHEDULER) $(CC) $(c++FLAGS) -c $< -o $@
|
||||
cxxtoo = $(Ctoo)
|
||||
cctoo = $(Ctoo)
|
||||
cpptoo = $(Ctoo)
|
||||
|
||||
LINK_LIBS = $(c++DBUG)
|
||||
|
||||
LINKLIBSO = $(CC) $(c++FLAGS) -Wl,-dylib,-undefined,dynamic_lookup
|
||||
LINKEXE = $(CC) $(c++FLAGS) -Wl,-execute,-undefined,dynamic_lookup
|
||||
2
wmake/rules/darwin64Clang/c++Debug
Normal file
2
wmake/rules/darwin64Clang/c++Debug
Normal file
@ -0,0 +1,2 @@
|
||||
c++DBUG = -g -DFULLDEBUG
|
||||
c++OPT = -O0
|
||||
2
wmake/rules/darwin64Clang/c++Opt
Normal file
2
wmake/rules/darwin64Clang/c++Opt
Normal file
@ -0,0 +1,2 @@
|
||||
c++DBUG =
|
||||
c++OPT = -O3
|
||||
2
wmake/rules/darwin64Clang/c++Prof
Normal file
2
wmake/rules/darwin64Clang/c++Prof
Normal file
@ -0,0 +1,2 @@
|
||||
c++DBUG = -pg
|
||||
c++OPT = -O2
|
||||
2
wmake/rules/darwin64Clang/cDebug
Normal file
2
wmake/rules/darwin64Clang/cDebug
Normal file
@ -0,0 +1,2 @@
|
||||
cDBUG = -g -DFULLDEBUG
|
||||
cOPT = -O0
|
||||
2
wmake/rules/darwin64Clang/cOpt
Normal file
2
wmake/rules/darwin64Clang/cOpt
Normal file
@ -0,0 +1,2 @@
|
||||
cDBUG =
|
||||
cOPT = -O3
|
||||
2
wmake/rules/darwin64Clang/cProf
Normal file
2
wmake/rules/darwin64Clang/cProf
Normal file
@ -0,0 +1,2 @@
|
||||
cDBUG = -pg
|
||||
cOPT = -O2
|
||||
9
wmake/rules/darwin64Clang/general
Normal file
9
wmake/rules/darwin64Clang/general
Normal file
@ -0,0 +1,9 @@
|
||||
CPP = cpp -traditional-cpp $(GFLAGS) -Ddarwin
|
||||
|
||||
PROJECT_LIBS = -l$(WM_PROJECT) -ldl
|
||||
|
||||
include $(GENERAL_RULES)/standard
|
||||
include $(GENERAL_RULES)/Clang/openmp
|
||||
|
||||
include $(DEFAULT_RULES)/c
|
||||
include $(DEFAULT_RULES)/c++
|
||||
16
wmake/rules/darwin64Gcc/c
Normal file
16
wmake/rules/darwin64Gcc/c
Normal file
@ -0,0 +1,16 @@
|
||||
SUFFIXES += .c
|
||||
|
||||
cc = gcc -m64 -Ddarwin
|
||||
|
||||
cWARN = -Wall
|
||||
|
||||
include $(DEFAULT_RULES)/c$(WM_COMPILE_OPTION)
|
||||
|
||||
cFLAGS = $(GFLAGS) $(cWARN) $(cOPT) $(cDBUG) $(LIB_HEADER_DIRS) -fPIC
|
||||
|
||||
ctoo = $(WM_SCHEDULER) $(cc) $(cFLAGS) -c $< -o $@
|
||||
|
||||
LINK_LIBS = $(cDBUG)
|
||||
|
||||
LINKLIBSO = $(cc) -Wl,-dylib,-undefined,dynamic_lookup
|
||||
LINKEXE = $(cc) -Wl,-execute,-undefined,dynamic_lookup
|
||||
17
wmake/rules/darwin64Gcc/c++
Normal file
17
wmake/rules/darwin64Gcc/c++
Normal file
@ -0,0 +1,17 @@
|
||||
include $(GENERAL_RULES)/Gcc/c++
|
||||
|
||||
CC = g++ -std=c++11 -m64 -Ddarwin
|
||||
|
||||
include $(DEFAULT_RULES)/c++$(WM_COMPILE_OPTION)
|
||||
|
||||
c++FLAGS = $(GFLAGS) $(c++WARN) $(c++OPT) $(c++DBUG) $(ptFLAGS) $(LIB_HEADER_DIRS) -fPIC
|
||||
|
||||
Ctoo = $(WM_SCHEDULER) $(CC) $(c++FLAGS) -c $< -o $@
|
||||
cxxtoo = $(Ctoo)
|
||||
cctoo = $(Ctoo)
|
||||
cpptoo = $(Ctoo)
|
||||
|
||||
LINK_LIBS = $(c++DBUG)
|
||||
|
||||
LINKLIBSO = $(CC) $(c++FLAGS) -Wl,-dylib,-undefined,dynamic_lookup
|
||||
LINKEXE = $(CC) $(c++FLAGS) -Wl,-execute,-undefined,dynamic_lookup
|
||||
2
wmake/rules/darwin64Gcc/c++Debug
Normal file
2
wmake/rules/darwin64Gcc/c++Debug
Normal file
@ -0,0 +1,2 @@
|
||||
c++DBUG = -ggdb3 -DFULLDEBUG
|
||||
c++OPT = -O0 -fdefault-inline
|
||||
4
wmake/rules/darwin64Gcc/c++Opt
Normal file
4
wmake/rules/darwin64Gcc/c++Opt
Normal file
@ -0,0 +1,4 @@
|
||||
c++DBUG =
|
||||
c++OPT = -O3
|
||||
|
||||
ROUNDING_MATH = -frounding-math
|
||||
2
wmake/rules/darwin64Gcc/c++Prof
Normal file
2
wmake/rules/darwin64Gcc/c++Prof
Normal file
@ -0,0 +1,2 @@
|
||||
c++DBUG = -pg
|
||||
c++OPT = -O2
|
||||
2
wmake/rules/darwin64Gcc/cDebug
Normal file
2
wmake/rules/darwin64Gcc/cDebug
Normal file
@ -0,0 +1,2 @@
|
||||
cDBUG = -ggdb -DFULLDEBUG
|
||||
cOPT = -O1 -fdefault-inline -finline-functions
|
||||
2
wmake/rules/darwin64Gcc/cOpt
Normal file
2
wmake/rules/darwin64Gcc/cOpt
Normal file
@ -0,0 +1,2 @@
|
||||
cDBUG =
|
||||
cOPT = -O3
|
||||
2
wmake/rules/darwin64Gcc/cProf
Normal file
2
wmake/rules/darwin64Gcc/cProf
Normal file
@ -0,0 +1,2 @@
|
||||
cDBUG = -pg
|
||||
cOPT = -O2
|
||||
9
wmake/rules/darwin64Gcc/general
Normal file
9
wmake/rules/darwin64Gcc/general
Normal file
@ -0,0 +1,9 @@
|
||||
CPP = cpp -traditional-cpp $(GFLAGS) -Ddarwin
|
||||
|
||||
PROJECT_LIBS = -l$(WM_PROJECT) -ldl
|
||||
|
||||
include $(GENERAL_RULES)/standard
|
||||
include $(GENERAL_RULES)/Gcc/openmp
|
||||
|
||||
include $(DEFAULT_RULES)/c
|
||||
include $(DEFAULT_RULES)/c++
|
||||
@ -110,7 +110,9 @@ make="make"
|
||||
nCores=0
|
||||
allCores()
|
||||
{
|
||||
nCores=$(egrep -c "^processor" /proc/cpuinfo 2>/dev/null) || nCores=1
|
||||
nCores=$(egrep -c "^processor" /proc/cpuinfo 2>/dev/null) || \
|
||||
nCores=$(getconf _NPROCESSORS_ONLN 2>/dev/null) || \
|
||||
nCores=1
|
||||
: ${nCores:=1}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user