From 3721ec2e3dd24fe560fde319430932673779c7b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=8B=D1=87=D0=BA=D0=BE=D0=B2=20=D0=90=D0=BD=D0=B4?= =?UTF-8?q?=D1=80=D0=B5=D0=B9?= Date: Tue, 5 Feb 2019 00:53:14 +0000 Subject: [PATCH] add initial FreeRTOS support git-svn-id: svn://db.shs.com.ru/pip@685 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5 --- CMakeLists.txt | 4 +++- src_main/core/piinit.cpp | 4 ---- src_main/system/pisystemtests.cpp | 10 ++++++++-- src_main/thread/pithread.cpp | 4 ++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c1418853..1405d103 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -190,7 +190,7 @@ endif() # Check if RT timers exists set(CMAKE_REQUIRED_INCLUDES time.h) set(CMAKE_REQUIRED_LIBRARIES ) -if((NOT DEFINED ENV{QNX_HOST}) AND (NOT APPLE) AND (NOT WIN32) AND (NOT DEFINED ANDROID_PLATFORM)) +if((NOT DEFINED ENV{QNX_HOST}) AND (NOT APPLE) AND (NOT WIN32) AND (NOT DEFINED ANDROID_PLATFORM) AND (NOT PIP_FREERTOS)) list(APPEND LIBS_MAIN rt) set(CMAKE_REQUIRED_LIBRARIES rt) endif() @@ -276,6 +276,7 @@ if ((NOT DEFINED LIBPROJECT) AND (DEFINED ANDROID_PLATFORM)) #message("${ANDROID_SYSTEM_LIBRARY_PATH}/usr/include") #message("${ANDROID_NDK}/sysroot/usr/include") endif() +if(NOT PIP_FREERTOS) if(WIN32) if(${C_COMPILER} STREQUAL "cl.exe") else() @@ -291,6 +292,7 @@ else() endif() endif() endif() +endif() set(PIP_LIBS) if(PIP_FREERTOS) set(PIP_LIBS ${LIBS_MAIN}) diff --git a/src_main/core/piinit.cpp b/src_main/core/piinit.cpp index 51c4223d..0209ad4f 100644 --- a/src_main/core/piinit.cpp +++ b/src_main/core/piinit.cpp @@ -218,14 +218,11 @@ PIInit::PIInit() { #endif #ifdef MAC_OS host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &__pi_mac_clock); -#endif #endif char cbuff[1024]; memset(cbuff, 0, 1024); -#ifndef FREERTOS if (gethostname(cbuff, 1023) == 0) sinfo->hostname = cbuff; -#endif #ifdef WINDOWS SYSTEM_INFO sysinfo; GetSystemInfo(&sysinfo); @@ -258,7 +255,6 @@ PIInit::PIInit() { if (l) sinfo->user = l; } -# ifndef FREERTOS struct utsname uns; if (uname(&uns) == 0) { sinfo->OS_version = uns.release; diff --git a/src_main/system/pisystemtests.cpp b/src_main/system/pisystemtests.cpp index bfde06df..d7e44018 100755 --- a/src_main/system/pisystemtests.cpp +++ b/src_main/system/pisystemtests.cpp @@ -17,8 +17,12 @@ along with this program. If not, see . */ + #include "pisystemtests.h" -#include "piconfig.h" + +#ifndef PIP_FREERTOS +# include "piconfig.h" +#endif namespace PISystemTests { @@ -32,7 +36,7 @@ namespace PISystemTests { PISystemTests::PISystemTestReader::PISystemTestReader() { -#ifndef WINDOWS +#if !defined(WINDOWS) && !defined(FREERTOS) PIConfig conf(PIStringAscii("/etc/pip.conf"), PIIODevice::ReadOnly); //conf.setReopenEnabled(false); time_resolution_ns = conf.getValue(PIStringAscii("time_resolution_ns"), 1); @@ -40,3 +44,5 @@ PISystemTests::PISystemTestReader::PISystemTestReader() { usleep_offset_us = conf.getValue(PIStringAscii("usleep_offset_us"), 60); #endif } + + diff --git a/src_main/thread/pithread.cpp b/src_main/thread/pithread.cpp index 855784f6..37454e5a 100755 --- a/src_main/thread/pithread.cpp +++ b/src_main/thread/pithread.cpp @@ -389,7 +389,7 @@ bool PIThread::waitForStart(int timeout_msecs) { void PIThread::__thread_func__(void * t) { #ifndef WINDOWS -# ifndef ANDROID +# if !defined(ANDROID) && !defined(FREERTOS) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, 0); pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0); # endif @@ -466,7 +466,7 @@ void PIThread::__thread_func__(void * t) { void PIThread::__thread_func_once__(void * t) { #ifndef WINDOWS -# ifndef ANDROID +# if !defined(ANDROID) && !defined(FREERTOS) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, 0); pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0); # endif