Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions include/nds3/definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,23 @@
#include <vector>
#include <map>

#ifdef _WIN32
#include <pthread.h>

#include <windows.h>
// https://github.com/esa/pykep/issues/47
#define CLOCK_REALTIME 0
static int clock_gettime(int, struct timespec *spec) //C-file part
{
__int64 wintime; GetSystemTimeAsFileTime((FILETIME*)&wintime);
wintime -= 116444736000000000i64; //1jan1601 to 1jan1970
spec->tv_sec = wintime / 10000000i64; //seconds
spec->tv_nsec = wintime % 10000000i64 * 100; //nano-seconds
return 0;
}

#endif

namespace nds
{

Expand Down Expand Up @@ -300,19 +317,19 @@ typedef std::list<std::string> enumerationStrings_t;
#define NDS_DEFINE_DRIVER(driverName, className)\
extern "C" \
{ \
void* allocateDevice(nds::Factory& factory, const std::string& device, const nds::namedParameters_t& parameters) \
NDS3_API void* allocateDevice(nds::Factory& factory, const std::string& device, const nds::namedParameters_t& parameters) \
{ \
return new className(factory, device, parameters); \
} \
void deallocateDevice(void* device) \
NDS3_API void deallocateDevice(void* device) \
{ \
delete (className*)device; \
} \
const char* getDeviceName() \
NDS3_API const char* getDeviceName() \
{ \
return #driverName; \
} \
nds::RegisterDevice<className> registerDevice##driverName(#driverName); \
NDS3_API nds::RegisterDevice<className> registerDevice##driverName(#driverName); \
} // extern "C"

// Generic helper definitions for shared library support
Expand Down
5 changes: 5 additions & 0 deletions include/nds3/impl/logStreamGetterImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@

#include <ostream>
#include <array>

#ifdef _WIN32
#include <pthread.h>
#endif

#include "nds3/definitions.h"

namespace nds
Expand Down
5 changes: 3 additions & 2 deletions src/ndsFactoryImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
*/

#include <cstdlib>
#include <link.h>
#include <elf.h>
#include <dlfcn.h>
#include <errno.h>
#include <sstream>
Expand Down Expand Up @@ -494,6 +492,9 @@ NdsFactoryImpl::fileNames_t NdsFactoryImpl::separateFoldersList(const char* fold
return folders;
}

#ifndef RTLD_NODELETE
#define RTLD_NODELETE 0
#endif

DynamicModule::DynamicModule(const std::string& libraryName):
m_moduleHandle(dlopen(libraryName.c_str(), RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE))
Expand Down
28 changes: 14 additions & 14 deletions src/pvBaseIn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,26 @@ void PVBaseIn::replicateFrom(const std::string &sourceInputPVName)
std::static_pointer_cast<PVBaseInImpl>(m_pImplementation)->replicateFrom(sourceInputPVName);
}

template void PVBaseIn::read<std::int32_t>(timespec*, std::int32_t*) const;
template void PVBaseIn::push<std::int32_t>(const timespec&, const std::int32_t&);
template void NDS3_API PVBaseIn::read<std::int32_t>(timespec*, std::int32_t*) const;
template void NDS3_API PVBaseIn::push<std::int32_t>(const timespec&, const std::int32_t&);

template void PVBaseIn::read<double>(timespec*, double*) const;
template void PVBaseIn::push<double>(const timespec&, const double&);
template void NDS3_API PVBaseIn::read<double>(timespec*, double*) const;
template void NDS3_API PVBaseIn::push<double>(const timespec&, const double&);

template void PVBaseIn::read<std::vector<std::int8_t> >(timespec*, std::vector<std::int8_t>*) const;
template void PVBaseIn::push<std::vector<std::int8_t> >(const timespec&, const std::vector<std::int8_t>&);
template void NDS3_API PVBaseIn::read<std::vector<std::int8_t> >(timespec*, std::vector<std::int8_t>*) const;
template void NDS3_API PVBaseIn::push<std::vector<std::int8_t> >(const timespec&, const std::vector<std::int8_t>&);

template void PVBaseIn::read<std::vector<std::uint8_t> >(timespec*, std::vector<std::uint8_t>*) const;
template void PVBaseIn::push<std::vector<std::uint8_t> >(const timespec&, const std::vector<std::uint8_t>&);
template void NDS3_API PVBaseIn::read<std::vector<std::uint8_t> >(timespec*, std::vector<std::uint8_t>*) const;
template void NDS3_API PVBaseIn::push<std::vector<std::uint8_t> >(const timespec&, const std::vector<std::uint8_t>&);

template void PVBaseIn::read<std::vector<std::int32_t> >(timespec*, std::vector<std::int32_t>*) const;
template void PVBaseIn::push<std::vector<std::int32_t> >(const timespec&, const std::vector<std::int32_t>&);
template void NDS3_API PVBaseIn::read<std::vector<std::int32_t> >(timespec*, std::vector<std::int32_t>*) const;
template void NDS3_API PVBaseIn::push<std::vector<std::int32_t> >(const timespec&, const std::vector<std::int32_t>&);

template void PVBaseIn::read<std::vector<double> >(timespec*, std::vector<double>*) const;
template void PVBaseIn::push<std::vector<double> >(const timespec&, const std::vector<double>&);
template void NDS3_API PVBaseIn::read<std::vector<double> >(timespec*, std::vector<double>*) const;
template void NDS3_API PVBaseIn::push<std::vector<double> >(const timespec&, const std::vector<double>&);

template void PVBaseIn::read<std::string >(timespec*, std::string*) const;
template void PVBaseIn::push<std::string >(const timespec&, const std::string&);
template void NDS3_API PVBaseIn::read<std::string >(timespec*, std::string*) const;
template void NDS3_API PVBaseIn::push<std::string >(const timespec&, const std::string&);

}

14 changes: 13 additions & 1 deletion src/threadStd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

#include <thread>

#ifdef _WIN32
#include <pthread.h>
#endif

#include "nds3/impl/threadStd.h"

namespace nds
Expand All @@ -17,7 +21,15 @@ namespace nds
ThreadStd::ThreadStd(FactoryBaseImpl* pFactory, const std::string &name, threadFunction_t function):
ThreadBaseImpl(pFactory, name), m_thread(function)
{
pthread_setname_np(m_thread.native_handle(), name.c_str());
#ifdef _WIN32
pthread_t thread;
thread.p = m_thread.native_handle();
thread.x = 0;
pthread_setname_np(thread, name.c_str());
#else
pthread_setname_np(m_thread.native_handle(), name.c_str());
#endif

}

void ThreadStd::join()
Expand Down