BSD Porting fixes, conditional compilation and use of gettimeofday()
This commit is contained in:
parent
b5dfc41759
commit
5f0073b9e0
|
@ -46,6 +46,7 @@ using namespace std;
|
||||||
#if !(defined(__MACH__) && defined(__APPLE__))
|
#if !(defined(__MACH__) && defined(__APPLE__))
|
||||||
#include <sys/sysinfo.h>
|
#include <sys/sysinfo.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <sys/wait.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// number of added entitis to check memory after
|
// number of added entitis to check memory after
|
||||||
|
|
|
@ -47,7 +47,10 @@
|
||||||
# include <Shlobj.h>
|
# include <Shlobj.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(FC_OS_BSD)
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "Document.h"
|
#include "Document.h"
|
||||||
|
@ -2091,7 +2094,18 @@ std::string Application::FindHomePath(const char* sCall)
|
||||||
// path. In the worst case we simply get q wrong path and FreeCAD is not
|
// path. In the worst case we simply get q wrong path and FreeCAD is not
|
||||||
// able to load its modules.
|
// able to load its modules.
|
||||||
char resolved[PATH_MAX];
|
char resolved[PATH_MAX];
|
||||||
|
#if defined(FC_OS_BSD)
|
||||||
|
int mib[4];
|
||||||
|
mib[0] = CTL_KERN;
|
||||||
|
mib[1] = KERN_PROC;
|
||||||
|
mib[2] = KERN_PROC_PATHNAME;
|
||||||
|
mib[3] = -1;
|
||||||
|
size_t cb = sizeof(resolved);
|
||||||
|
sysctl(mib, 4, resolved, &cb, NULL, 0);
|
||||||
|
int nchars = strlen(resolved);
|
||||||
|
#else
|
||||||
int nchars = readlink("/proc/self/exe", resolved, PATH_MAX);
|
int nchars = readlink("/proc/self/exe", resolved, PATH_MAX);
|
||||||
|
#endif
|
||||||
if (nchars < 0 || nchars >= PATH_MAX)
|
if (nchars < 0 || nchars >= PATH_MAX)
|
||||||
throw Base::Exception("Cannot determine the absolute path of the executable");
|
throw Base::Exception("Cannot determine the absolute path of the executable");
|
||||||
resolved[nchars] = '\0'; // enfore null termination
|
resolved[nchars] = '\0'; // enfore null termination
|
||||||
|
|
|
@ -57,10 +57,13 @@ TimeInfo::~TimeInfo()
|
||||||
|
|
||||||
void TimeInfo::setCurrent(void)
|
void TimeInfo::setCurrent(void)
|
||||||
{
|
{
|
||||||
#if defined (_MSC_VER)
|
#if defined (FC_OS_WIN32)
|
||||||
_ftime( &timebuffer );
|
_ftime( &timebuffer );
|
||||||
#elif defined(__GNUC__)
|
#else
|
||||||
ftime( &timebuffer );
|
struct timeval t;
|
||||||
|
gettimeofday(&t, NULL);
|
||||||
|
timebuffer.time = t.tv_sec;
|
||||||
|
timebuffer.millitm = t.tv_usec / 1000;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,13 +28,25 @@
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#if defined(FC_OS_WIN32)
|
||||||
#include <sys/timeb.h>
|
#include <sys/timeb.h>
|
||||||
|
#else
|
||||||
|
#include <sys/time.h>
|
||||||
|
#endif
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
# include <stdint.h>
|
# include <stdint.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(FC_OS_WIN32)
|
||||||
|
struct timeb
|
||||||
|
{
|
||||||
|
int64_t time;
|
||||||
|
unsigned short millitm;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Base
|
namespace Base
|
||||||
{
|
{
|
||||||
/// BaseClass class and root of the type system
|
/// BaseClass class and root of the type system
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
# undef _PreComp_
|
# undef _PreComp_
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FC_OS_LINUX
|
#ifdef FC_OS_LINUX || defined(FC_OS_BSD)
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#elif defined(FC_OS_LINUX)
|
#elif defined(FC_OS_LINUX) || defined(FC_OS_BSD)
|
||||||
# ifndef GNU_SOURCE
|
# ifndef GNU_SOURCE
|
||||||
# define GNU_SOURCE
|
# define GNU_SOURCE
|
||||||
# endif
|
# endif
|
||||||
|
@ -111,7 +111,7 @@ extern "C"
|
||||||
argv[0] = (char*)malloc(MAX_PATH);
|
argv[0] = (char*)malloc(MAX_PATH);
|
||||||
strncpy(argv[0],szFileName,MAX_PATH);
|
strncpy(argv[0],szFileName,MAX_PATH);
|
||||||
argv[0][MAX_PATH-1] = '\0'; // ensure null termination
|
argv[0][MAX_PATH-1] = '\0'; // ensure null termination
|
||||||
#elif defined(FC_OS_LINUX)
|
#elif defined(FC_OS_LINUX) || defined(FC_OS_BSD)
|
||||||
putenv("LANG=C");
|
putenv("LANG=C");
|
||||||
putenv("LC_ALL=C");
|
putenv("LC_ALL=C");
|
||||||
// get whole path of the library
|
// get whole path of the library
|
||||||
|
|
|
@ -20,7 +20,9 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#if defined(FC_OS_WIN32)
|
||||||
#include <sys/timeb.h>
|
#include <sys/timeb.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <Base/Exception.h>
|
#include <Base/Exception.h>
|
||||||
#include <Base/Interpreter.h>
|
#include <Base/Interpreter.h>
|
||||||
|
|
|
@ -22,7 +22,7 @@ using namespace Wm4;
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
// support for GetTime
|
// support for GetTime
|
||||||
#ifdef __APPLE__
|
#if !defined(WIN32)
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
static timeval gs_kInitial;
|
static timeval gs_kInitial;
|
||||||
static bool gs_bInitializedTime = false;
|
static bool gs_bInitializedTime = false;
|
||||||
|
@ -103,7 +103,7 @@ void System::EndianCopy (int iSize, int iQuantity, const void* pvSrc,
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
double System::GetTime ()
|
double System::GetTime ()
|
||||||
{
|
{
|
||||||
#ifdef __APPLE__
|
#if !defined(WIN32)
|
||||||
if (!gs_bInitializedTime)
|
if (!gs_bInitializedTime)
|
||||||
{
|
{
|
||||||
gs_bInitializedTime = true;
|
gs_bInitializedTime = true;
|
||||||
|
|
|
@ -21,7 +21,9 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#if defined(FC_OS_WIN32)
|
||||||
#include <sys/timeb.h>
|
#include <sys/timeb.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <Base/Exception.h>
|
#include <Base/Exception.h>
|
||||||
#include <Base/Interpreter.h>
|
#include <Base/Interpreter.h>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user