diff --git a/include/nds3/definitions.h b/include/nds3/definitions.h index f7a0f75de..0b55dd3b2 100644 --- a/include/nds3/definitions.h +++ b/include/nds3/definitions.h @@ -27,6 +27,23 @@ #include #include +#ifdef _WIN32 +#include + +#include + // 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 { @@ -300,19 +317,19 @@ typedef std::list 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 registerDevice##driverName(#driverName); \ +NDS3_API nds::RegisterDevice registerDevice##driverName(#driverName); \ } // extern "C" // Generic helper definitions for shared library support diff --git a/include/nds3/impl/logStreamGetterImpl.h b/include/nds3/impl/logStreamGetterImpl.h index b03db0c45..c0230651a 100644 --- a/include/nds3/impl/logStreamGetterImpl.h +++ b/include/nds3/impl/logStreamGetterImpl.h @@ -12,6 +12,11 @@ #include #include + +#ifdef _WIN32 +#include +#endif + #include "nds3/definitions.h" namespace nds diff --git a/src/ndsFactoryImpl.cpp b/src/ndsFactoryImpl.cpp index 8f5c66d9c..e7d7df17f 100644 --- a/src/ndsFactoryImpl.cpp +++ b/src/ndsFactoryImpl.cpp @@ -8,8 +8,6 @@ */ #include -#include -#include #include #include #include @@ -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)) diff --git a/src/pvBaseIn.cpp b/src/pvBaseIn.cpp index bdf1e2c58..2082bd84f 100644 --- a/src/pvBaseIn.cpp +++ b/src/pvBaseIn.cpp @@ -44,26 +44,26 @@ void PVBaseIn::replicateFrom(const std::string &sourceInputPVName) std::static_pointer_cast(m_pImplementation)->replicateFrom(sourceInputPVName); } -template void PVBaseIn::read(timespec*, std::int32_t*) const; -template void PVBaseIn::push(const timespec&, const std::int32_t&); +template void NDS3_API PVBaseIn::read(timespec*, std::int32_t*) const; +template void NDS3_API PVBaseIn::push(const timespec&, const std::int32_t&); -template void PVBaseIn::read(timespec*, double*) const; -template void PVBaseIn::push(const timespec&, const double&); +template void NDS3_API PVBaseIn::read(timespec*, double*) const; +template void NDS3_API PVBaseIn::push(const timespec&, const double&); -template void PVBaseIn::read >(timespec*, std::vector*) const; -template void PVBaseIn::push >(const timespec&, const std::vector&); +template void NDS3_API PVBaseIn::read >(timespec*, std::vector*) const; +template void NDS3_API PVBaseIn::push >(const timespec&, const std::vector&); -template void PVBaseIn::read >(timespec*, std::vector*) const; -template void PVBaseIn::push >(const timespec&, const std::vector&); +template void NDS3_API PVBaseIn::read >(timespec*, std::vector*) const; +template void NDS3_API PVBaseIn::push >(const timespec&, const std::vector&); -template void PVBaseIn::read >(timespec*, std::vector*) const; -template void PVBaseIn::push >(const timespec&, const std::vector&); +template void NDS3_API PVBaseIn::read >(timespec*, std::vector*) const; +template void NDS3_API PVBaseIn::push >(const timespec&, const std::vector&); -template void PVBaseIn::read >(timespec*, std::vector*) const; -template void PVBaseIn::push >(const timespec&, const std::vector&); +template void NDS3_API PVBaseIn::read >(timespec*, std::vector*) const; +template void NDS3_API PVBaseIn::push >(const timespec&, const std::vector&); -template void PVBaseIn::read(timespec*, std::string*) const; -template void PVBaseIn::push(const timespec&, const std::string&); +template void NDS3_API PVBaseIn::read(timespec*, std::string*) const; +template void NDS3_API PVBaseIn::push(const timespec&, const std::string&); } diff --git a/src/threadStd.cpp b/src/threadStd.cpp index 909449007..ca70fb414 100644 --- a/src/threadStd.cpp +++ b/src/threadStd.cpp @@ -9,6 +9,10 @@ #include +#ifdef _WIN32 +#include +#endif + #include "nds3/impl/threadStd.h" namespace nds @@ -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()