From 077ac9887bd473d77f3c06d5b936e7f971040000 Mon Sep 17 00:00:00 2001 From: Andrey Bychkov Date: Tue, 11 Aug 2026 19:51:42 +0300 Subject: [PATCH] refactor: rename PIP_NO_\* to PIP_HAS_\* with inverted logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All feature flags now use positive naming (enabled by default): - PIP_HAS_FILESYSTEM, PIP_HAS_THREADS, PIP_HAS_SOCKET - PIP_HAS_PROCESS, PIP_HAS_DYNLIB, PIP_HAS_FFT, PIP_HAS_SERIAL Preprocessor guards inverted: - #ifndef PIP_NO_X → #ifdef PIP_HAS_X - #ifdef PIP_NO_X → #ifndef PIP_HAS_X CMake options default ON instead of OFF. Platform blocks set flags OFF to disable features. 85 files transformed via Python script + 2 manual fixes. --- CMakeLists.txt | 104 +++++++++--------- libs/console/piterminal.cpp | 4 +- libs/io_utils/pibroadcast.cpp | 4 +- libs/io_utils/piethutilbase.cpp | 4 +- libs/io_utils/pipackedtcp.cpp | 4 +- libs/io_utils/pistreampacker.cpp | 4 +- libs/main/application/pilog.cpp | 8 +- libs/main/application/pilog.h | 8 +- libs/main/application/pisingleapplication.cpp | 4 +- libs/main/application/pisingleapplication.h | 4 +- libs/main/application/pisystemmonitor.cpp | 28 ++--- libs/main/application/pisystemmonitor.h | 12 +- libs/main/application/pitranslator.cpp | 4 +- libs/main/code/picodeparser.cpp | 4 +- libs/main/console/pikbdlistener.cpp | 4 +- libs/main/console/pikbdlistener.h | 4 +- libs/main/core/picout.cpp | 4 +- libs/main/core/piinit.h | 6 +- libs/main/core/piobject.cpp | 28 ++--- libs/main/core/piobject.h | 30 ++--- libs/main/core/piwaitevent_p.cpp | 4 +- libs/main/core/piwaitevent_p.h | 4 +- libs/main/io_devices/pibinarylog.cpp | 8 +- libs/main/io_devices/pibinarylog.h | 4 +- libs/main/io_devices/pican.cpp | 2 +- libs/main/io_devices/piconfig.cpp | 16 +-- libs/main/io_devices/pidir.cpp | 4 +- libs/main/io_devices/pidir.h | 8 +- libs/main/io_devices/piethernet.cpp | 4 +- libs/main/io_devices/piethernet.h | 4 +- libs/main/io_devices/pifile.cpp | 8 +- libs/main/io_devices/pifile.h | 8 +- libs/main/io_devices/pigpio.cpp | 4 +- libs/main/io_devices/pigpio.h | 4 +- libs/main/io_devices/piiodevice.cpp | 40 +++---- libs/main/io_devices/piiodevice.h | 8 +- libs/main/io_devices/pipeer.cpp | 4 +- libs/main/io_devices/pipeer.h | 4 +- libs/main/io_devices/piserial.cpp | 4 +- libs/main/io_devices/pispi.cpp | 4 +- libs/main/io_utils/pibasetransfer.cpp | 28 ++--- libs/main/io_utils/pibasetransfer.h | 4 +- libs/main/io_utils/pibroadcast.h | 4 +- libs/main/io_utils/piconnection.cpp | 4 +- libs/main/io_utils/piconnection.h | 20 ++-- libs/main/io_utils/pidiagnostics.cpp | 4 +- libs/main/io_utils/pidiagnostics.h | 4 +- libs/main/io_utils/piethutilbase.h | 4 +- libs/main/io_utils/pifiletransfer.cpp | 4 +- libs/main/io_utils/pifiletransfer.h | 4 +- libs/main/io_utils/pipackedtcp.h | 4 +- libs/main/io_utils/pistreampacker.h | 4 +- libs/main/math/pifft.cpp | 4 +- libs/main/math/pifft.h | 4 +- .../serialization/pivaluetree_conversions.cpp | 14 +-- .../pistatemachine_transition.cpp | 8 +- .../state_machine/pistatemachine_transition.h | 2 +- libs/main/system/pihidevice.cpp | 4 +- libs/main/system/pihidevice.h | 4 +- libs/main/system/pilibrary.cpp | 4 +- libs/main/system/pilibrary.h | 4 +- libs/main/system/piplugin.cpp | 4 +- libs/main/system/piplugin.h | 4 +- libs/main/system/piprocess.cpp | 4 +- libs/main/system/piprocess.h | 4 +- libs/main/system/pisysteminfo.cpp | 6 +- libs/main/system/pisystemtests.cpp | 8 +- libs/main/thread/piconditionvar.cpp | 4 +- libs/main/thread/piconditionvar.h | 8 +- libs/main/thread/pimutex.cpp | 4 +- libs/main/thread/pimutex.h | 8 +- libs/main/thread/pireadwritelock.cpp | 4 +- libs/main/thread/pisemaphore.cpp | 4 +- libs/main/thread/pithread.cpp | 12 +- libs/main/thread/pithread.h | 6 +- libs/main/thread/pithreadnotifier.cpp | 4 +- libs/main/thread/pithreadnotifier.h | 4 +- libs/main/thread/pithreadpoolloop.cpp | 4 +- libs/main/thread/pithreadpoolworker.cpp | 4 +- libs/main/thread/pithreadpoolworker.h | 4 +- libs/main/thread/pitimer.cpp | 4 +- libs/main/thread/pitimer.h | 4 +- libs/main/types/pinetworkaddress.cpp | 8 +- libs/main/types/pitime.cpp | 2 +- libs/main/types/pivarianttypes.cpp | 14 +-- 85 files changed, 344 insertions(+), 342 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 21ae4f27..8a09a2fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,13 +73,13 @@ option(INTROSPECTION "Build with introspection" OFF) option(TESTS "Build tests" OFF) option(TESTS_RUN "Run tests before install step" OFF) option(COVERAGE "Build project with coverage info" OFF) -option(PIP_NO_FILESYSTEM "Disable filesystem support" OFF) -option(PIP_NO_THREADS "Disable threading support" OFF) -option(PIP_NO_SOCKET "Disable socket/network support" OFF) -option(PIP_NO_PROCESS "Disable process management" OFF) -option(PIP_NO_DYNLIB "Disable dynamic library loading" OFF) -option(PIP_NO_FFT "Disable FFT support" OFF) -option(PIP_NO_SERIAL "Disable serial port support" OFF) +option(PIP_HAS_FILESYSTEM "Enable filesystem support" ON) +option(PIP_HAS_THREADS "Enable threading support" ON) +option(PIP_HAS_SOCKET "Enable socket/network support" ON) +option(PIP_HAS_PROCESS "Enable process management" ON) +option(PIP_HAS_DYNLIB "Enable dynamic library loading" ON) +option(PIP_HAS_FFT "Enable FFT support" ON) +option(PIP_HAS_SERIAL "Enable serial port support" ON) option(PIP_FFTW_F "Support fftw module for float" ON) option(PIP_FFTW_L "Support fftw module for long double" ON) option(PIP_FFTW_Q "Support fftw module for quad double" OFF) @@ -228,71 +228,71 @@ foreach(F ${PIP_FOLDERS}) endif() endforeach(F) -if (TESTS) - set(PIP_ROOT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") - if (TESTS_RUN) - enable_testing() - endif() - add_subdirectory(tests) -endif() - if(DEFINED PICO_BOARD) add_definitions(-DPICO_SDK) add_definitions(-DPIP_EMBEDDED) - set(PIP_NO_FILESYSTEM ON CACHE BOOL "" FORCE) + set(PIP_HAS_FILESYSTEM OFF CACHE BOOL "" FORCE) if(NOT DEFINED PICO_FREERTOS) - set(PIP_NO_THREADS ON CACHE BOOL "" FORCE) + set(PIP_HAS_THREADS OFF CACHE BOOL "" FORCE) endif() if(NOT DEFINED PICO_LWIP) - set(PIP_NO_SOCKET ON CACHE BOOL "" FORCE) + set(PIP_HAS_SOCKET OFF CACHE BOOL "" FORCE) set(PIP_BUILD_MQTT_CLIENT OFF CACHE BOOL "" FORCE) endif() - set(PIP_NO_PROCESS ON CACHE BOOL "" FORCE) - set(PIP_NO_DYNLIB ON CACHE BOOL "" FORCE) - set(PIP_NO_FFT ON CACHE BOOL "" FORCE) - set(PIP_NO_SERIAL ON CACHE BOOL "" FORCE) + set(PIP_HAS_PROCESS OFF CACHE BOOL "" FORCE) + set(PIP_HAS_DYNLIB OFF CACHE BOOL "" FORCE) + set(PIP_HAS_FFT OFF CACHE BOOL "" FORCE) + set(PIP_HAS_SERIAL OFF CACHE BOOL "" FORCE) message(STATUS "Building PIP for Pi Pico SDK ${PICO_SDK_VERSION_STRING}") endif() if(PIP_FREERTOS) add_definitions(-DPIP_FREERTOS) add_definitions(-DPIP_EMBEDDED) - set(PIP_NO_FILESYSTEM ON CACHE BOOL "" FORCE) + set(PIP_HAS_FILESYSTEM OFF CACHE BOOL "" FORCE) if(NOT DEFINED LWIP) - set(PIP_NO_SOCKET ON CACHE BOOL "" FORCE) + set(PIP_HAS_SOCKET OFF CACHE BOOL "" FORCE) endif() - set(PIP_NO_PROCESS ON CACHE BOOL "" FORCE) - set(PIP_NO_DYNLIB ON CACHE BOOL "" FORCE) - set(PIP_NO_FFT ON CACHE BOOL "" FORCE) - set(PIP_NO_SERIAL ON CACHE BOOL "" FORCE) + set(PIP_HAS_PROCESS OFF CACHE BOOL "" FORCE) + set(PIP_HAS_DYNLIB OFF CACHE BOOL "" FORCE) + set(PIP_HAS_FFT OFF CACHE BOOL "" FORCE) + set(PIP_HAS_SERIAL OFF CACHE BOOL "" FORCE) endif() if(DEFINED ANDROID_PLATFORM) - set(PIP_NO_PROCESS ON CACHE BOOL "" FORCE) - set(PIP_NO_DYNLIB ON CACHE BOOL "" FORCE) - set(PIP_NO_FFT ON CACHE BOOL "" FORCE) + set(PIP_HAS_PROCESS OFF CACHE BOOL "" FORCE) + set(PIP_HAS_DYNLIB OFF CACHE BOOL "" FORCE) + set(PIP_HAS_FFT OFF CACHE BOOL "" FORCE) endif() -if(PIP_NO_FILESYSTEM) - add_definitions(-DPIP_NO_FILESYSTEM) +if(PIP_HAS_FILESYSTEM) + add_definitions(-DPIP_HAS_FILESYSTEM) endif() -if(PIP_NO_THREADS) - add_definitions(-DPIP_NO_THREADS) +if(PIP_HAS_THREADS) + add_definitions(-DPIP_HAS_THREADS) endif() -if(PIP_NO_SOCKET) - add_definitions(-DPIP_NO_SOCKET) +if(PIP_HAS_SOCKET) + add_definitions(-DPIP_HAS_SOCKET) endif() -if(PIP_NO_PROCESS) - add_definitions(-DPIP_NO_PROCESS) +if(PIP_HAS_PROCESS) + add_definitions(-DPIP_HAS_PROCESS) endif() -if(PIP_NO_DYNLIB) - add_definitions(-DPIP_NO_DYNLIB) +if(PIP_HAS_DYNLIB) + add_definitions(-DPIP_HAS_DYNLIB) endif() -if(PIP_NO_FFT) - add_definitions(-DPIP_NO_FFT) +if(PIP_HAS_FFT) + add_definitions(-DPIP_HAS_FFT) endif() -if(PIP_NO_SERIAL) - add_definitions(-DPIP_NO_SERIAL) +if(PIP_HAS_SERIAL) + add_definitions(-DPIP_HAS_SERIAL) +endif() + +if (TESTS) + set(PIP_ROOT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") + if (TESTS_RUN) + enable_testing() + endif() + add_subdirectory(tests) endif() # Check Bessel functions @@ -885,13 +885,13 @@ message(" ICU strings : ${PIP_ICU}") message(" Introspection: ${PIP_INTROSPECTION}") message(" Coverage : ${PIP_COVERAGE}") message(" Feature flags:") -message(" PIP_NO_FILESYSTEM: ${PIP_NO_FILESYSTEM}") -message(" PIP_NO_THREADS : ${PIP_NO_THREADS}") -message(" PIP_NO_SOCKET : ${PIP_NO_SOCKET}") -message(" PIP_NO_PROCESS : ${PIP_NO_PROCESS}") -message(" PIP_NO_DYNLIB : ${PIP_NO_DYNLIB}") -message(" PIP_NO_FFT : ${PIP_NO_FFT}") -message(" PIP_NO_SERIAL : ${PIP_NO_SERIAL}") +message(" PIP_HAS_FILESYSTEM: ${PIP_HAS_FILESYSTEM}") +message(" PIP_HAS_THREADS : ${PIP_HAS_THREADS}") +message(" PIP_HAS_SOCKET : ${PIP_HAS_SOCKET}") +message(" PIP_HAS_PROCESS : ${PIP_HAS_PROCESS}") +message(" PIP_HAS_DYNLIB : ${PIP_HAS_DYNLIB}") +message(" PIP_HAS_FFT : ${PIP_HAS_FFT}") +message(" PIP_HAS_SERIAL : ${PIP_HAS_SERIAL}") if(INTROSPECTION) message(STATUS " Warning: Introspection reduces the performance!") endif() diff --git a/libs/console/piterminal.cpp b/libs/console/piterminal.cpp index 85fbfafb..f7c51bf8 100644 --- a/libs/console/piterminal.cpp +++ b/libs/console/piterminal.cpp @@ -23,7 +23,7 @@ #include "pisharedmemory.h" #if !defined(PICO_SDK) -#ifndef PIP_NO_PROCESS +#ifdef PIP_HAS_PROCESS # ifdef WINDOWS # include # include @@ -979,6 +979,6 @@ bool PITerminal::resize(int cols, int rows) { return ret; } -#endif // PIP_NO_PROCESS +#endif // PIP_HAS_PROCESS #endif // !PICO_SDK diff --git a/libs/io_utils/pibroadcast.cpp b/libs/io_utils/pibroadcast.cpp index 78dd04a6..2ea80bba 100644 --- a/libs/io_utils/pibroadcast.cpp +++ b/libs/io_utils/pibroadcast.cpp @@ -21,7 +21,7 @@ #include "piliterals_time.h" -#ifndef PIP_NO_SOCKET +#ifdef PIP_HAS_SOCKET /** \class PIBroadcast * \brief Broadcast for all interfaces, including loopback @@ -271,4 +271,4 @@ void PIBroadcast::run() { if (ac) addressesChanged(); } -#endif // PIP_NO_SOCKET +#endif // PIP_HAS_SOCKET diff --git a/libs/io_utils/piethutilbase.cpp b/libs/io_utils/piethutilbase.cpp index 891fbfbc..50cfd04b 100644 --- a/libs/io_utils/piethutilbase.cpp +++ b/libs/io_utils/piethutilbase.cpp @@ -19,7 +19,7 @@ #include "piethutilbase.h" -#ifndef PIP_NO_SOCKET +#ifdef PIP_HAS_SOCKET #include "pitranslator.h" #ifdef PIP_CRYPT @@ -132,4 +132,4 @@ size_t PIEthUtilBase::cryptSizeAddition() { #endif } -#endif // PIP_NO_SOCKET +#endif // PIP_HAS_SOCKET diff --git a/libs/io_utils/pipackedtcp.cpp b/libs/io_utils/pipackedtcp.cpp index 91e916f3..b1e399ad 100644 --- a/libs/io_utils/pipackedtcp.cpp +++ b/libs/io_utils/pipackedtcp.cpp @@ -22,7 +22,7 @@ #include "piethernet.h" #include "piliterals.h" -#ifndef PIP_NO_SOCKET +#ifdef PIP_HAS_SOCKET /** \class PIPackedTCP pipackedtcp.h @@ -200,4 +200,4 @@ bool PIPackedTCP::closeDevice() { return eth->close(); } -#endif // PIP_NO_SOCKET +#endif // PIP_HAS_SOCKET diff --git a/libs/io_utils/pistreampacker.cpp b/libs/io_utils/pistreampacker.cpp index 367b5216..a5f17f14 100644 --- a/libs/io_utils/pistreampacker.cpp +++ b/libs/io_utils/pistreampacker.cpp @@ -26,7 +26,7 @@ #include "piiodevice.h" #include "pitranslator.h" -#ifndef PIP_NO_SOCKET +#ifdef PIP_HAS_SOCKET #ifdef __GNUC__ # pragma GCC diagnostic pop #endif @@ -178,4 +178,4 @@ uint PIStreamPacker::sizeCryptedSize() { return sizeof(int) + (crypt_size ? cryptSizeAddition() : 0); } -#endif // PIP_NO_SOCKET +#endif // PIP_HAS_SOCKET diff --git a/libs/main/application/pilog.cpp b/libs/main/application/pilog.cpp index a1560ebd..b7e55da2 100644 --- a/libs/main/application/pilog.cpp +++ b/libs/main/application/pilog.cpp @@ -24,8 +24,8 @@ #include "piliterals_time.h" #include "pitime.h" -#ifndef PIP_NO_THREADS -# ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_THREADS +# ifdef PIP_HAS_FILESYSTEM //! \class PILog pilog.h //! \details @@ -248,5 +248,5 @@ void PILog::run() { } } -# endif // PIP_NO_FILESYSTEM -#endif // PIP_NO_THREADS +# endif // PIP_HAS_FILESYSTEM +#endif // PIP_HAS_THREADS diff --git a/libs/main/application/pilog.h b/libs/main/application/pilog.h index 99cf83e7..59673e21 100644 --- a/libs/main/application/pilog.h +++ b/libs/main/application/pilog.h @@ -29,8 +29,8 @@ #include "piiostream.h" #include "pithread.h" -#ifndef PIP_NO_THREADS -# ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_THREADS +# ifdef PIP_HAS_FILESYSTEM //! \~\ingroup Application //! \~\brief @@ -187,7 +187,7 @@ private: int part_number = -1, cout_id = -1; }; -# endif // PIP_NO_FILESYSTEM -#endif // PIP_NO_THREADS +# endif // PIP_HAS_FILESYSTEM +#endif // PIP_HAS_THREADS #endif // PIlog_H diff --git a/libs/main/application/pisingleapplication.cpp b/libs/main/application/pisingleapplication.cpp index 164f6c9e..f13eb133 100644 --- a/libs/main/application/pisingleapplication.cpp +++ b/libs/main/application/pisingleapplication.cpp @@ -24,7 +24,7 @@ #include "pisharedmemory.h" #include "pitime.h" -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS //! \class PISingleApplication pisingleapplication.h //! \~\details @@ -154,4 +154,4 @@ void PISingleApplication::waitFirst() const { piMSleep(50); } -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS diff --git a/libs/main/application/pisingleapplication.h b/libs/main/application/pisingleapplication.h index 6380fc6f..616c9d42 100644 --- a/libs/main/application/pisingleapplication.h +++ b/libs/main/application/pisingleapplication.h @@ -29,7 +29,7 @@ class PISharedMemory; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS //! \~\ingroup Application //! \~\brief @@ -94,5 +94,5 @@ private: int sacnt; }; -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS #endif // PISINGLEAPPLICATION_H diff --git a/libs/main/application/pisystemmonitor.cpp b/libs/main/application/pisystemmonitor.cpp index 71293d3a..c5364ef2 100644 --- a/libs/main/application/pisystemmonitor.cpp +++ b/libs/main/application/pisystemmonitor.cpp @@ -40,7 +40,7 @@ struct kqueue_id_t; # include "esp_heap_caps.h" #endif -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS void PISystemMonitor::ProcessStats::makeStrings() { physical_memsize_readable.setReadableSize(physical_memsize); @@ -51,7 +51,7 @@ void PISystemMonitor::ProcessStats::makeStrings() { } -# ifndef PIP_NO_PROCESS +# ifdef PIP_HAS_PROCESS PRIVATE_DEFINITION_START(PISystemMonitor) # ifndef WINDOWS # ifdef MAC_OS @@ -70,13 +70,13 @@ PRIVATE_DEFINITION_START(PISystemMonitor) PITimeMeasurer tm; # endif PRIVATE_DEFINITION_END(PISystemMonitor) -# endif // PIP_NO_PROCESS +# endif // PIP_HAS_PROCESS PISystemMonitor::PISystemMonitor(): PIThread() { pID_ = cycle = 0; cpu_count = PISystemInfo::instance()->processorsCount; -# ifndef PIP_NO_PROCESS +# ifdef PIP_HAS_PROCESS # ifndef WINDOWS # ifdef QNX page_size = 4096; @@ -87,7 +87,7 @@ PISystemMonitor::PISystemMonitor(): PIThread() { PRIVATE->hProc = 0; PRIVATE->mem_cnt.cb = sizeof(PRIVATE->mem_cnt); # endif -# endif // PIP_NO_PROCESS +# endif // PIP_HAS_PROCESS setName("system_monitor"_a); } @@ -97,7 +97,7 @@ PISystemMonitor::~PISystemMonitor() { } -# ifndef PIP_NO_PROCESS +# ifdef PIP_HAS_PROCESS bool PISystemMonitor::startOnProcess(int pID, PISystemTime interval) { stop(); pID_ = pID; @@ -123,16 +123,16 @@ bool PISystemMonitor::startOnProcess(int pID, PISystemTime interval) { # endif return start(interval); } -# endif // PIP_NO_PROCESS +# endif // PIP_HAS_PROCESS bool PISystemMonitor::startOnSelf(PISystemTime interval) { -# ifndef PIP_NO_PROCESS +# ifdef PIP_HAS_PROCESS bool ret = startOnProcess(PIProcess::currentPID(), interval); cycle = -1; # else bool ret = start(interval); -# endif // PIP_NO_PROCESS +# endif // PIP_HAS_PROCESS return ret; } @@ -181,7 +181,7 @@ void PISystemMonitor::run() { tbid.clear(); ProcessStats tstat; tstat.ID = pID_; -# ifndef PIP_NO_THREADS +# ifdef PIP_HAS_THREADS __PIThreadCollection * pitc = __PIThreadCollection::instance(); pitc->lock(); PIVector tv = pitc->threads(); @@ -319,7 +319,7 @@ void PISystemMonitor::run() { PRIVATE->tm.reset(); # endif // WINDOWS # endif // FREERTOS -# endif // PIP_NO_THREADS +# endif // PIP_HAS_THREADS tstat.cpu_load_system = piClampf(tstat.cpu_load_system, 0.f, 100.f); tstat.cpu_load_user = piClampf(tstat.cpu_load_user, 0.f, 100.f); @@ -352,7 +352,7 @@ void PISystemMonitor::gatherThread(llong id) { PISystemMonitor::ThreadStats ts; if (id == 0) return; ts.id = id; -# ifdef PIP_NO_PROCESS +# ifndef PIP_HAS_PROCESS ts.name = tbid.value(id, ""); # else ts.name = tbid.value(id, ""); @@ -395,7 +395,7 @@ void PISystemMonitor::gatherThread(llong id) { ts.kernel_time = FILETIME2PISystemTime(times[2]); ts.user_time = FILETIME2PISystemTime(times[3]); # endif -# endif // PIP_NO_PROCESS +# endif // PIP_HAS_PROCESS cur_tm[id] = ts; } @@ -462,4 +462,4 @@ void PISystemMonitor::Pool::remove(PISystemMonitor * sm) { sysmons.remove(sm->pID()); } -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS diff --git a/libs/main/application/pisystemmonitor.h b/libs/main/application/pisystemmonitor.h index 506071e5..1e17c86e 100644 --- a/libs/main/application/pisystemmonitor.h +++ b/libs/main/application/pisystemmonitor.h @@ -28,7 +28,7 @@ #include "pifile.h" #include "pithread.h" -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS //! \~\ingroup Application //! \~\brief @@ -206,12 +206,12 @@ public: PIString name; }; -# ifndef PIP_NO_PROCESS +# ifdef PIP_HAS_PROCESS //! \~english Starts monitoring the process with PID "pID" using the given update interval. //! \~russian Запускает мониторинг процесса с PID "pID" с указанным интервалом обновления. bool startOnProcess(int pID, PISystemTime interval = PISystemTime::fromSeconds(1.)); -# endif // PIP_NO_PROCESS +# endif // PIP_HAS_PROCESS //! \~english Starts monitoring the current application process. //! \~russian Запускает мониторинг текущего процесса приложения. @@ -272,9 +272,9 @@ private: PIMap tbid; mutable PIMutex stat_mutex; int pID_, page_size, cpu_count, cycle; -# ifndef PIP_NO_PROCESS +# ifdef PIP_HAS_PROCESS PRIVATE_DECLARATION(PIP_EXPORT) -# endif // PIP_NO_PROCESS +# endif // PIP_HAS_PROCESS class PIP_EXPORT Pool { friend class PISystemMonitor; @@ -338,5 +338,5 @@ BINARY_STREAM_READ(PISystemMonitor::ThreadStats) { return s; } -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS #endif // PISYSTEMMONITOR_H diff --git a/libs/main/application/pitranslator.cpp b/libs/main/application/pitranslator.cpp index e30afd45..f9c58df0 100644 --- a/libs/main/application/pitranslator.cpp +++ b/libs/main/application/pitranslator.cpp @@ -25,7 +25,7 @@ #include "pitranslator_p.h" #include "pivaluetree_conversions.h" -#ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM //! \class PITranslator pitranslator.h //! \details @@ -116,4 +116,4 @@ PITranslator * PITranslator::instance() { return &ret; } -#endif // PIP_NO_FILESYSTEM +#endif // PIP_HAS_FILESYSTEM diff --git a/libs/main/code/picodeparser.cpp b/libs/main/code/picodeparser.cpp index 75cf0734..aa7492b8 100644 --- a/libs/main/code/picodeparser.cpp +++ b/libs/main/code/picodeparser.cpp @@ -153,7 +153,7 @@ bool PICodeParser::isEnum(const PIString & name) { } -#ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM bool PICodeParser::parseFileInternal(const PIString & file, bool follow_includes) { if (proc_files[file]) return true; with_includes = follow_includes; @@ -179,7 +179,7 @@ bool PICodeParser::parseFileInternal(const PIString & file, bool follow_includes piCout << "parsing" << f.path() << "done"; return ret; } -#endif // PIP_NO_FILESYSTEM +#endif // PIP_HAS_FILESYSTEM void PICodeParser::clear() { diff --git a/libs/main/console/pikbdlistener.cpp b/libs/main/console/pikbdlistener.cpp index 0ae2c0cc..7ebefe6b 100644 --- a/libs/main/console/pikbdlistener.cpp +++ b/libs/main/console/pikbdlistener.cpp @@ -18,7 +18,7 @@ */ #include "pikbdlistener.h" -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS # include "piincludes_p.h" # include "piliterals.h" @@ -590,4 +590,4 @@ void PIKbdListener::setActive(bool yes) { } } -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS diff --git a/libs/main/console/pikbdlistener.h b/libs/main/console/pikbdlistener.h index 2e99841e..42987a61 100644 --- a/libs/main/console/pikbdlistener.h +++ b/libs/main/console/pikbdlistener.h @@ -27,7 +27,7 @@ #include "pibase.h" -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS # include "pithread.h" # include "pitime.h" @@ -381,5 +381,5 @@ REGISTER_PIVARIANTSIMPLE(PIKbdListener::KeyEvent) REGISTER_PIVARIANTSIMPLE(PIKbdListener::MouseEvent) REGISTER_PIVARIANTSIMPLE(PIKbdListener::WheelEvent) -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS #endif // PIKBDLISTENER_H diff --git a/libs/main/core/picout.cpp b/libs/main/core/picout.cpp index 89f57bab..11e9ab63 100644 --- a/libs/main/core/picout.cpp +++ b/libs/main/core/picout.cpp @@ -709,7 +709,7 @@ void PICout::applyFormat(PICoutFormat f) { } -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS PIString PICout::getBuffer() { PIMutexLocker ml(PICout::__mutex__()); PIString ret = PICout::__string__(); @@ -729,7 +729,7 @@ void PICout::clearBuffer() { PIMutexLocker ml(PICout::__mutex__()); PICout::__string__().clear(); } -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS bool PICout::setOutputDevice(PICout::OutputDevice d, bool on) { diff --git a/libs/main/core/piinit.h b/libs/main/core/piinit.h index 1272b1f5..06fdc0d4 100644 --- a/libs/main/core/piinit.h +++ b/libs/main/core/piinit.h @@ -32,11 +32,11 @@ #include "pibase.h" // PIInit stub: enabled for embedded or when core features are missing -#if defined(PIP_EMBEDDED) || (defined(PIP_NO_THREADS) && defined(PIP_NO_FILESYSTEM)) +#if defined(PIP_EMBEDDED) || (!defined(PIP_HAS_THREADS) && !defined(PIP_HAS_FILESYSTEM)) # define _PIP_INIT_STUB_ #endif -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS # include "piincludes.h" @@ -127,5 +127,5 @@ private: }; -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS #endif // PIINIT_H diff --git a/libs/main/core/piobject.cpp b/libs/main/core/piobject.cpp index 3c4f08dd..1ef2d0c7 100644 --- a/libs/main/core/piobject.cpp +++ b/libs/main/core/piobject.cpp @@ -22,7 +22,7 @@ #include "piconditionvar.h" #include "pithread.h" #include "pitime.h" -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS # include "pifile.h" # include "piiostream.h" # include "pisysteminfo.h" @@ -176,11 +176,11 @@ PIObject::PIObject(const PIString & name): _signature_(__PIOBJECT_SIGNATURE__), in_event_cnt = 0; setName(name); setDebug(true); -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS mutexObjects().lock(); #endif objects() << this; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS mutexObjects().unlock(); #endif // piCout << "new" << this; @@ -190,11 +190,11 @@ PIObject::PIObject(const PIString & name): _signature_(__PIOBJECT_SIGNATURE__), PIObject::~PIObject() { in_event_cnt = 0; // piCout << "delete" << this; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS mutexObjects().lock(); #endif objects().removeAll(this); -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS mutexObjects().unlock(); #endif deleted(this); @@ -472,7 +472,7 @@ void PIObject::piDisconnect(PIObject * src, const PIString & sig) { src->connections.remove(i); i--; if (dest) { -#if !defined(ANDROID) && !defined(MAC_OS) && !defined(PIP_NO_THREADS) +#if !defined(ANDROID) && !defined(MAC_OS) && defined(PIP_HAS_THREADS) PIMutexLocker _mld(dest->mutex_connect, src != dest); #endif dest->updateConnectors(); @@ -490,7 +490,7 @@ void PIObject::piDisconnectAll() { // piCout << "disconnect"<< src << o; if (!o || (o == this)) continue; if (!o->isPIObject()) continue; -#if !defined(ANDROID) && !defined(MAC_OS) && !defined(PIP_NO_THREADS) +#if !defined(ANDROID) && !defined(MAC_OS) && defined(PIP_HAS_THREADS) PIMutexLocker _mld(o->mutex_connect, this != o); #endif PIVector & oc(o->connections); @@ -555,7 +555,7 @@ PIMap & PIObject::__meta_data() { } -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS void PIObject::callQueuedEvents() { mutex_queue.lock(); PIVector<__QueuedEvent> qe = events_queue; @@ -569,7 +569,7 @@ void PIObject::callQueuedEvents() { if (e.dest_o->thread_safe_) e.dest_o->mutex_.unlock(); } } -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS //! \details @@ -580,11 +580,11 @@ void PIObject::callQueuedEvents() { //! При первом вызове стартует фоновый поток для удаления объектов. //! Каждый объект из очереди удаляется только когда выйдет из всех //! событий и обработок. -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS void PIObject::deleteLater() { Deleter::instance()->post(this); } -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS bool PIObject::findSuitableMethodV(const PIString & method, int args, int & ret_args, PIObject::__MetaFunc & ret) { @@ -744,7 +744,7 @@ void PIObject::dump(const PIString & line_prefix) const { } -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS void dumpApplication(bool with_objects) { PIMutexLocker _ml(PIObject::mutexObjects()); // printf("dump application ...\n"); @@ -847,7 +847,7 @@ bool PIObject::Connection::disconnect() const { return ret; } -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS PRIVATE_DEFINITION_START(PIObject::Deleter) PIThread thread; PIConditionVariable cond_var; @@ -911,4 +911,4 @@ void PIObject::Deleter::deleteObject(PIObject * o) { } // piCout << "[Deleter] delete" << (uintptr_t)o << "done"; } -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS diff --git a/libs/main/core/piobject.h b/libs/main/core/piobject.h index d85218ca..164d06d8 100644 --- a/libs/main/core/piobject.h +++ b/libs/main/core/piobject.h @@ -461,7 +461,7 @@ public: i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender)); } else { bool ts = sender->thread_safe_; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS if (ts) i.dest_o->mutex_.lock(); #endif i.dest_o->eventBegin(); @@ -471,7 +471,7 @@ public: sender->eventEnd(); if (i.dest_o->isPIObject()) { i.dest_o->emitter_ = 0; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS if (ts) i.dest_o->mutex_.unlock(); #endif i.dest_o->eventEnd(); @@ -498,7 +498,7 @@ public: i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender, vl)); } else { bool ts = sender->thread_safe_; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS if (ts) i.dest_o->mutex_.lock(); #endif i.dest_o->eventBegin(); @@ -511,7 +511,7 @@ public: sender->eventEnd(); if (i.dest_o->isPIObject()) { i.dest_o->emitter_ = 0; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS if (ts) i.dest_o->mutex_.unlock(); #endif i.dest_o->eventEnd(); @@ -538,7 +538,7 @@ public: i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender, vl)); } else { bool ts = sender->thread_safe_; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS if (ts) i.dest_o->mutex_.lock(); #endif i.dest_o->eventBegin(); @@ -552,7 +552,7 @@ public: sender->eventEnd(); if (i.dest_o->isPIObject()) { i.dest_o->emitter_ = 0; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS if (ts) i.dest_o->mutex_.unlock(); #endif i.dest_o->eventEnd(); @@ -580,7 +580,7 @@ public: i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender, vl)); } else { bool ts = sender->thread_safe_; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS if (ts) i.dest_o->mutex_.lock(); #endif i.dest_o->eventBegin(); @@ -595,7 +595,7 @@ public: sender->eventEnd(); if (i.dest_o->isPIObject()) { i.dest_o->emitter_ = 0; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS if (ts) i.dest_o->mutex_.unlock(); #endif i.dest_o->eventEnd(); @@ -629,7 +629,7 @@ public: i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender, vl)); } else { bool ts = sender->thread_safe_; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS if (ts) i.dest_o->mutex_.lock(); #endif i.dest_o->eventBegin(); @@ -645,7 +645,7 @@ public: sender->eventEnd(); if (i.dest_o->isPIObject()) { i.dest_o->emitter_ = 0; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS if (ts) i.dest_o->mutex_.unlock(); #endif i.dest_o->eventEnd(); @@ -658,7 +658,7 @@ public: //! \~english Returns the first live object with name "name", or \c nullptr. //! \~russian Возвращает первый живой объект с именем "name", либо \c nullptr. -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS static PIObject * findByName(const PIString & name) { PIMutexLocker _ml(mutexObjects()); for (auto * i: PIObject::objects()) { @@ -675,7 +675,7 @@ public: //! \~english Returns whether this object belongs to class "T" or one of its registered descendants. //! \~russian Возвращает, принадлежит ли этот объект классу "T" или одному из его зарегистрированных потомков. -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS template bool isTypeOf() const { if (!isPIObject()) return false; @@ -820,7 +820,7 @@ private: PIVector values; }; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS class Deleter { public: Deleter(); @@ -859,7 +859,7 @@ private: PIObject * emitter_; std::atomic_int in_event_cnt; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS PIMutex mutex_, mutex_connect, mutex_queue; bool thread_safe_, proc_event_queue; #else @@ -868,7 +868,7 @@ private: #endif }; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS //! \~english Dumps application-level %PIObject diagnostics. //! \~russian Выводит диагностическую информацию уровня приложения для %PIObject. diff --git a/libs/main/core/piwaitevent_p.cpp b/libs/main/core/piwaitevent_p.cpp index 9558f366..e23afdc1 100644 --- a/libs/main/core/piwaitevent_p.cpp +++ b/libs/main/core/piwaitevent_p.cpp @@ -18,7 +18,7 @@ */ #include "piwaitevent_p.h" -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS # ifdef WINDOWS // # ifdef _WIN32_WINNT // # undef _WIN32_WINNT @@ -154,4 +154,4 @@ void * PIWaitEvent::getEvent() const { # endif } -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS diff --git a/libs/main/core/piwaitevent_p.h b/libs/main/core/piwaitevent_p.h index cfdc877b..caa81705 100644 --- a/libs/main/core/piwaitevent_p.h +++ b/libs/main/core/piwaitevent_p.h @@ -20,7 +20,7 @@ #ifndef PIWAITEVENT_P_H #define PIWAITEVENT_P_H -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS # include "pibase.h" // clang-format off @@ -67,5 +67,5 @@ private: }; -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS #endif // PIWAITEVENT_P_H diff --git a/libs/main/io_devices/pibinarylog.cpp b/libs/main/io_devices/pibinarylog.cpp index 0aff20b2..8b45919e 100644 --- a/libs/main/io_devices/pibinarylog.cpp +++ b/libs/main/io_devices/pibinarylog.cpp @@ -24,7 +24,7 @@ #include "piliterals_time.h" #include "pipropertystorage.h" -#ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM # include "pitime.h" # include "pitranslator.h" @@ -60,11 +60,11 @@ static const uchar binlog_sig[] = {'B', 'I', 'N', 'L', 'O', 'G'}; REGISTER_DEVICE(PIBinaryLog) PIBinaryLog::PIBinaryLog() { -# ifdef PIP_NO_THREADS +# ifndef PIP_HAS_THREADS setThreadedReadBufferSize(512); # else setThreadedReadBufferSize(64_KiB); -# endif // PIP_NO_THREADS +# endif // PIP_HAS_THREADS is_started = is_indexed = is_pause = false; create_index_on_fly = false; current_index = -1; @@ -1011,4 +1011,4 @@ void PIBinaryLog::CompleteIndex::makeIndexPos() { index_pos[index[i].pos] = i; } -#endif // PIP_NO_FILESYSTEM +#endif // PIP_HAS_FILESYSTEM diff --git a/libs/main/io_devices/pibinarylog.h b/libs/main/io_devices/pibinarylog.h index dd6f8dfa..07dfe1a2 100644 --- a/libs/main/io_devices/pibinarylog.h +++ b/libs/main/io_devices/pibinarylog.h @@ -29,7 +29,7 @@ #include "pichunkstream.h" #include "pifile.h" -#ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM //! \~english Class for writing and reading binary data to/from log files, with support for playback in different modes. //! \~russian Класс для записи и чтения бинарных данных в/из файлов логов с поддержкой воспроизведения в различных режимах. @@ -993,5 +993,5 @@ inline PICout operator<<(PICout s, const PIBinaryLog::BinLogInfo & bi) { return s; } -#endif // PIP_NO_FILESYSTEM +#endif // PIP_HAS_FILESYSTEM #endif // PIBINARYLOG_H diff --git a/libs/main/io_devices/pican.cpp b/libs/main/io_devices/pican.cpp index c43484da..92d345f7 100644 --- a/libs/main/io_devices/pican.cpp +++ b/libs/main/io_devices/pican.cpp @@ -20,7 +20,7 @@ #include "pipropertystorage.h" #include "piwaitevent_p.h" -#if !defined(WINDOWS) && !defined(MAC_OS) && !defined(PIP_NO_SOCKET) +#if !defined(WINDOWS) && !defined(MAC_OS) && defined(PIP_HAS_SOCKET) # define PIP_CAN #endif #ifdef PIP_CAN diff --git a/libs/main/io_devices/piconfig.cpp b/libs/main/io_devices/piconfig.cpp index 5eb0de2c..e1495381 100644 --- a/libs/main/io_devices/piconfig.cpp +++ b/libs/main/io_devices/piconfig.cpp @@ -288,7 +288,7 @@ PIConfig::PIConfig(PIIODevice * device, PIIODevice::DeviceMode mode) { } -#ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM PIConfig::PIConfig(const PIString & path, PIStringList dirs) { _init(); internal = true; @@ -312,7 +312,7 @@ PIConfig::PIConfig(const PIString & path, PIStringList dirs) { _setupDev(); parse(); } -#endif // PIP_NO_FILESYSTEM +#endif // PIP_HAS_FILESYSTEM PIConfig::~PIConfig() { @@ -321,7 +321,7 @@ PIConfig::~PIConfig() { } -#ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM bool PIConfig::open(const PIString & path, PIIODevice::DeviceMode mode) { _destroy(); incdirs << PIFile::fileInfo(path).dir(); @@ -332,7 +332,7 @@ bool PIConfig::open(const PIString & path, PIIODevice::DeviceMode mode) { parse(); return dev->isOpened(); } -#endif // PIP_NO_FILESYSTEM +#endif // PIP_HAS_FILESYSTEM bool PIConfig::open(PIString * string, PIIODevice::DeviceMode mode) { @@ -351,7 +351,7 @@ bool PIConfig::open(PIIODevice * device, PIIODevice::DeviceMode mode) { dev = device; if (dev) { dev->open(mode); -#ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM if (dev->isTypeOf()) incdirs << PIFile::fileInfo(((PIFile *)dev)->path()).dir(); #endif } @@ -389,7 +389,7 @@ void PIConfig::_setupDev() { void PIConfig::_clearDev() { if (!dev) return; -#ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM if (PIString(dev->className()) == "PIFile") { ((PIFile *)dev)->clear(); return; @@ -405,7 +405,7 @@ void PIConfig::_clearDev() { void PIConfig::_flushDev() { if (!dev) return; -#ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM if (PIString(dev->className()) == "PIFile") { ((PIFile *)dev)->flush(); } @@ -421,7 +421,7 @@ bool PIConfig::_isEndDev() { void PIConfig::_seekToBeginDev() { if (!dev) return; -#ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM if (PIString(dev->className()) == "PIFile") { ((PIFile *)dev)->seekToBegin(); return; diff --git a/libs/main/io_devices/pidir.cpp b/libs/main/io_devices/pidir.cpp index 00d16a9b..85eb595b 100644 --- a/libs/main/io_devices/pidir.cpp +++ b/libs/main/io_devices/pidir.cpp @@ -16,7 +16,7 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ -#ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM #include "pidir.h" #include "piincludes_p.h" @@ -612,4 +612,4 @@ void PIDir::CurrentDirOverrider::save(const PIFile::FileInfo & info) { else PIDir::setCurrent(PIDir::current().path() + PIDir::separator + p); } -#endif // PIP_NO_FILESYSTEM +#endif // PIP_HAS_FILESYSTEM diff --git a/libs/main/io_devices/pidir.h b/libs/main/io_devices/pidir.h index 77c1b0d6..60e889f3 100644 --- a/libs/main/io_devices/pidir.h +++ b/libs/main/io_devices/pidir.h @@ -30,7 +30,7 @@ #include "piregularexpression.h" -#ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM //! \~\ingroup IO //! \~\brief //! \~english Local directory. @@ -218,10 +218,10 @@ private: PIString path_, scan_; }; -#endif // PIP_NO_FILESYSTEM +#endif // PIP_HAS_FILESYSTEM -#ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM inline bool operator<(const PIFile::FileInfo & v0, const PIFile::FileInfo & v1) { return (v0.path < v1.path); } @@ -245,7 +245,7 @@ inline PICout operator<<(PICout s, const PIDir & v) { s.restoreControls(); return s; } -#endif // PIP_NO_FILESYSTEM +#endif // PIP_HAS_FILESYSTEM #endif // PIDIR_H diff --git a/libs/main/io_devices/piethernet.cpp b/libs/main/io_devices/piethernet.cpp index 42877ff6..4642f987 100644 --- a/libs/main/io_devices/piethernet.cpp +++ b/libs/main/io_devices/piethernet.cpp @@ -18,7 +18,7 @@ */ #include "piethernet.h" -#ifndef PIP_NO_SOCKET +#ifdef PIP_HAS_SOCKET # include "piconfig.h" # include "piconstchars.h" @@ -1505,4 +1505,4 @@ bool PIEthernet::ethIsWriteable(int sock) { # endif } -#endif // PIP_NO_SOCKET +#endif // PIP_HAS_SOCKET diff --git a/libs/main/io_devices/piethernet.h b/libs/main/io_devices/piethernet.h index 569d58cc..ad55a0d7 100644 --- a/libs/main/io_devices/piethernet.h +++ b/libs/main/io_devices/piethernet.h @@ -29,7 +29,7 @@ #include "piiodevice.h" #include "pinetworkaddress.h" -#ifndef PIP_NO_SOCKET +#ifdef PIP_HAS_SOCKET # ifdef ANDROID struct @@ -706,5 +706,5 @@ inline bool operator!=(const PIEthernet::Interface & v0, const PIEthernet::Inter return (v0.name != v1.name || v0.address != v1.address || v0.netmask != v1.netmask); } -#endif // PIP_NO_SOCKET +#endif // PIP_HAS_SOCKET #endif // PIETHERNET_H diff --git a/libs/main/io_devices/pifile.cpp b/libs/main/io_devices/pifile.cpp index b42a7e8a..682eb4e4 100644 --- a/libs/main/io_devices/pifile.cpp +++ b/libs/main/io_devices/pifile.cpp @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM # include "pifile.h" # include "pidir.h" @@ -46,7 +46,7 @@ # include # endif # define S_IFHDN 0x40 -# if defined(QNX) || defined(ANDROID) || defined(PIP_NO_FILESYSTEM) +# if defined(QNX) || defined(ANDROID) || !defined(PIP_HAS_FILESYSTEM) # define _fopen_call_ fopen # define _fseek_call_ fseek # define _ftell_call_ ftell @@ -538,7 +538,7 @@ PIFile::FileInfo PIFile::fileInfo(const PIString & path) { ret.time_modification = PIDateTime::fromSystemTime(PISystemTime(fs.MTIME.tv_sec, fs.MTIME.tv_nsec)); # endif # endif -# ifndef PIP_NO_FILESYSTEM +# ifdef PIP_HAS_FILESYSTEM ret.perm_user = FileInfo::Permissions((mode & S_IRUSR) == S_IRUSR, (mode & S_IWUSR) == S_IWUSR, (mode & S_IXUSR) == S_IXUSR); ret.perm_group = FileInfo::Permissions((mode & S_IRGRP) == S_IRGRP, (mode & S_IWGRP) == S_IWGRP, (mode & S_IXGRP) == S_IXGRP); ret.perm_other = FileInfo::Permissions((mode & S_IROTH) == S_IROTH, (mode & S_IWOTH) == S_IWOTH, (mode & S_IXOTH) == S_IXOTH); @@ -636,4 +636,4 @@ int PIFile::writeAll(const PIString & path, const PIByteArray & data) { f.clear(); return f.write(data.data(), data.size_s()); } -#endif // PIP_NO_FILESYSTEM +#endif // PIP_HAS_FILESYSTEM diff --git a/libs/main/io_devices/pifile.h b/libs/main/io_devices/pifile.h index 7cf6aaae..61048068 100644 --- a/libs/main/io_devices/pifile.h +++ b/libs/main/io_devices/pifile.h @@ -31,7 +31,7 @@ #include "pipropertystorage.h" -#ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM //! \~\ingroup IO //! \~\brief //! \~english Local file. @@ -362,10 +362,10 @@ private: llong _size = -1; PIString prec_str; }; -#endif // PIP_NO_FILESYSTEM +#endif // PIP_HAS_FILESYSTEM -#ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM //! \relatesalso PICout //! \~english Output operator to \a PICout. //! \~russian Оператор вывода в \a PICout. @@ -398,6 +398,6 @@ BINARY_STREAM_READ(PIFile::FileInfo) { v.perm_group.raw >> v.perm_other.raw; return s; } -#endif // PIP_NO_FILESYSTEM +#endif // PIP_HAS_FILESYSTEM #endif // PIFILE_H diff --git a/libs/main/io_devices/pigpio.cpp b/libs/main/io_devices/pigpio.cpp index 0683a376..da1c6170 100644 --- a/libs/main/io_devices/pigpio.cpp +++ b/libs/main/io_devices/pigpio.cpp @@ -30,7 +30,7 @@ #endif #include "piliterals.h" -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS //! \class PIGPIO pigpio.h //! \~english \section PIGPIO_sec0 Synopsis @@ -309,4 +309,4 @@ void PIGPIO::clearWatch() { // # pragma GCC diagnostic pop # endif -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS diff --git a/libs/main/io_devices/pigpio.h b/libs/main/io_devices/pigpio.h index 0bdd98ca..3fba9129 100644 --- a/libs/main/io_devices/pigpio.h +++ b/libs/main/io_devices/pigpio.h @@ -28,7 +28,7 @@ #include "pithread.h" -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS //! \~\ingroup IO //! \~\brief @@ -144,6 +144,6 @@ private: PIMutex mutex; }; -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS #endif // PIGPIO_H diff --git a/libs/main/io_devices/piiodevice.cpp b/libs/main/io_devices/piiodevice.cpp index ea71ced0..bc0c0b57 100644 --- a/libs/main/io_devices/piiodevice.cpp +++ b/libs/main/io_devices/piiodevice.cpp @@ -117,7 +117,7 @@ //! -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS PIMutex PIIODevice::nfp_mutex; #endif PIMap PIIODevice::nfp_cache; @@ -198,7 +198,7 @@ void PIIODevice::setThreadedReadBufferSize(int new_size) { } -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS bool PIIODevice::isThreadedRead() const { return read_thread.isRunning(); } @@ -252,7 +252,7 @@ bool PIIODevice::waitThreadedReadFinished(PISystemTime timeout) { bool PIIODevice::isThreadedWrite() const { -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS return write_thread.isRunning(); #else return false; @@ -261,14 +261,14 @@ bool PIIODevice::isThreadedWrite() const { void PIIODevice::startThreadedWrite() { -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS if (!write_thread.isRunning()) write_thread.startOnce(); #endif } void PIIODevice::stopThreadedWrite() { -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS if (!write_thread.isRunning()) return; write_thread.stop(); #endif @@ -276,14 +276,14 @@ void PIIODevice::stopThreadedWrite() { void PIIODevice::terminateThreadedWrite() { -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS write_thread.terminate(); #endif } bool PIIODevice::waitThreadedWriteFinished(PISystemTime timeout) { -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS return write_thread.waitForFinish(timeout); #else (void)timeout; @@ -293,7 +293,7 @@ bool PIIODevice::waitThreadedWriteFinished(PISystemTime timeout) { void PIIODevice::clearThreadedWriteQueue() { -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS write_thread.lock(); write_queue.clear(); write_thread.unlock(); @@ -302,7 +302,7 @@ void PIIODevice::clearThreadedWriteQueue() { void PIIODevice::start() { -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS startThreadedRead(); #endif startThreadedWrite(); @@ -310,7 +310,7 @@ void PIIODevice::start() { void PIIODevice::stop() { -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS stopThreadedRead(); #endif stopThreadedWrite(); @@ -319,7 +319,7 @@ void PIIODevice::stop() { void PIIODevice::stopAndWait(PISystemTime timeout) { stop(); -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS waitThreadedReadFinished(timeout); #endif waitThreadedWriteFinished(timeout); @@ -357,7 +357,7 @@ void PIIODevice::_init() { setOptions(0); setReopenEnabled(true); setReopenTimeout(1_s); -#ifdef PIP_NO_THREADS +#ifndef PIP_HAS_THREADS threaded_read_buffer_size = 512; #else threaded_read_buffer_size = 4_KiB; @@ -368,11 +368,11 @@ void PIIODevice::_init() { if (!isOpened()) open(); }); read_thread.setSlot([this](void *) { read_func(); }); -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS } -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS void PIIODevice::write_func() { while (!write_thread.isStopping()) { while (!write_queue.isEmpty()) { @@ -412,7 +412,7 @@ void PIIODevice::read_func() { threadedRead(buffer_tr.data(), readed_); threadedReadEvent(buffer_tr.data(), readed_); } -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS PIIODevice * PIIODevice::newDeviceByPrefix(const char * prefix) { @@ -443,7 +443,7 @@ PIByteArray PIIODevice::readForTime(PISystemTime timeout) { } -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS ullong PIIODevice::writeThreaded(const PIByteArray & data) { write_thread.lock(); write_queue.enqueue(PIPair(data, tri)); @@ -663,17 +663,17 @@ PIIODevice * PIIODevice::createFromVariant(const PIVariantTypes::IODevice & d) { PIString PIIODevice::normalizeFullPath(const PIString & full_path) { -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS nfp_mutex.lock(); #endif PIString ret = nfp_cache.value(full_path); if (!ret.isEmpty()) { -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS nfp_mutex.unlock(); #endif return ret; } -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS nfp_mutex.unlock(); #endif PIIODevice * d = createFromFullPath(full_path); @@ -685,7 +685,7 @@ PIString PIIODevice::normalizeFullPath(const PIString & full_path) { void PIIODevice::cacheFullPath(const PIString & full_path, const PIIODevice * d) { -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS PIMutexLocker nfp_ml(nfp_mutex); #endif nfp_cache[full_path] = d->constructFullPath(); diff --git a/libs/main/io_devices/piiodevice.h b/libs/main/io_devices/piiodevice.h index 2cee7ff4..a339016b 100644 --- a/libs/main/io_devices/piiodevice.h +++ b/libs/main/io_devices/piiodevice.h @@ -242,7 +242,7 @@ public: //! \~russian Возвращает пользовательские данные, передаваемые в callback потокового чтения. void * threadedReadData() const { return ret_data_; } -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS //! \~english Returns whether threaded read is running. //! \~russian Возвращает, запущено ли потоковое чтение. bool isThreadedRead() const; @@ -273,7 +273,7 @@ public: //! \~english Waits until threaded read finishes or "timeout" expires. //! \~russian Ожидает завершения потокового чтения, но не дольше "timeout". bool waitThreadedReadFinished(PISystemTime timeout = {}); -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS //! \~english Returns delay between unsuccessful threaded read attempts in milliseconds. @@ -362,7 +362,7 @@ public: PIByteArray readForTime(PISystemTime timeout); -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS //! \~english Queues "data" for threaded write and returns task ID. //! \~russian Помещает "data" в очередь потоковой записи и возвращает ID задания. ullong writeThreaded(const void * data, ssize_t max_size) { return writeThreaded(PIByteArray(data, uint(max_size))); } @@ -615,7 +615,7 @@ private: bool reopen_enabled = true, destroying = false; static PIMap nfp_cache; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS PIThread read_thread, write_thread; PIQueue> write_queue; static PIMutex nfp_mutex; diff --git a/libs/main/io_devices/pipeer.cpp b/libs/main/io_devices/pipeer.cpp index 54035592..8fed4f83 100644 --- a/libs/main/io_devices/pipeer.cpp +++ b/libs/main/io_devices/pipeer.cpp @@ -24,7 +24,7 @@ #include "piliterals_time.h" #include "pipropertystorage.h" -#ifndef PIP_NO_SOCKET +#ifdef PIP_HAS_SOCKET # include "pitime.h" # define _PIPEER_MSG_SIZE 4000 @@ -1179,4 +1179,4 @@ bool PIPeer::hasPeer(const PIString & name) { return false; } -#endif // PIP_NO_SOCKET +#endif // PIP_HAS_SOCKET diff --git a/libs/main/io_devices/pipeer.h b/libs/main/io_devices/pipeer.h index 591ef381..46161dd9 100644 --- a/libs/main/io_devices/pipeer.h +++ b/libs/main/io_devices/pipeer.h @@ -38,7 +38,7 @@ //! \~russian //! Класс обнаруживает пиры, маршрутизирует пакеты по имени пира и может предоставлять поток trusted-peer через унаследованные \a read() и //! \a write(). -#ifndef PIP_NO_SOCKET +#ifdef PIP_HAS_SOCKET class PIP_EXPORT PIPeer: public PIIODevice { PIIODEVICE(PIPeer, "peer"); @@ -437,6 +437,6 @@ BINARY_STREAM_READ(PIPeer::PeerInfo) { s >> v.name >> v.addresses >> v.dist >> v.neighbours >> v.cnt >> v.time; return s; } -#endif // PIP_NO_SOCKET +#endif // PIP_HAS_SOCKET #endif // PIPEER_H diff --git a/libs/main/io_devices/piserial.cpp b/libs/main/io_devices/piserial.cpp index 3891f111..a2c3d507 100644 --- a/libs/main/io_devices/piserial.cpp +++ b/libs/main/io_devices/piserial.cpp @@ -19,7 +19,7 @@ #include "piserial.h" -#ifndef PIP_NO_SERIAL +#ifdef PIP_HAS_SERIAL # include "piconfig.h" # include "pidir.h" @@ -1326,4 +1326,4 @@ void PISerial::threadedReadBufferSizeChanged() { # endif } -#endif // PIP_NO_SERIAL +#endif // PIP_HAS_SERIAL diff --git a/libs/main/io_devices/pispi.cpp b/libs/main/io_devices/pispi.cpp index 30c5c54c..47f7f76b 100644 --- a/libs/main/io_devices/pispi.cpp +++ b/libs/main/io_devices/pispi.cpp @@ -43,11 +43,11 @@ REGISTER_DEVICE(PISPI) PISPI::PISPI(const PIString & path, uint speed, PIIODevice::DeviceMode mode): PIIODevice(path, mode) { -#ifdef PIP_NO_THREADS +#ifndef PIP_HAS_THREADS setThreadedReadBufferSize(512); #else setThreadedReadBufferSize(1024); -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS setPath(path); setSpeed(speed); setBits(8); diff --git a/libs/main/io_utils/pibasetransfer.cpp b/libs/main/io_utils/pibasetransfer.cpp index 40a00827..2f4fdd73 100644 --- a/libs/main/io_utils/pibasetransfer.cpp +++ b/libs/main/io_utils/pibasetransfer.cpp @@ -29,7 +29,7 @@ const uint PIBaseTransfer::signature = 0x54424950; PIBaseTransfer::PIBaseTransfer() : crc(standardCRC_16()) -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS , diag(false) #endif { @@ -44,7 +44,7 @@ PIBaseTransfer::PIBaseTransfer() send_queue = 0; send_up = 0; timeout_ = 10.; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS diag.setDisconnectTimeout(PISystemTime::fromSeconds(timeout_ / 10.)); diag.setName("PIBaseTransfer"); diag.start(20_Hz); @@ -60,7 +60,7 @@ PIBaseTransfer::PIBaseTransfer() PIBaseTransfer::~PIBaseTransfer() { -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS diag.stopAndWait(); #endif break_ = true; @@ -94,7 +94,7 @@ void PIBaseTransfer::setPause(bool pause_) { void PIBaseTransfer::setTimeout(double sec) { timeout_ = sec; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS diag.setDisconnectTimeout(PISystemTime::fromSeconds(sec)); #endif } @@ -103,7 +103,7 @@ void PIBaseTransfer::setTimeout(double sec) { void PIBaseTransfer::received(PIByteArray data) { packet_header_size = sizeof(PacketHeader) + customHeader().size(); if (data.size() < sizeof(PacketHeader)) { -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS diag.received(data.size(), false); #endif return; @@ -113,12 +113,12 @@ void PIBaseTransfer::received(PIByteArray data) { PacketType pt = (PacketType)h.type; if (!h.check_sig()) { piCoutObj << "invalid packet signature"_tr("PIBaseTransfer"); -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS diag.received(data.size(), false); #endif return; } else -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS diag.received(data.size(), true); #endif // piCoutObj << "receive" << h.session_id << h.type << h.id; @@ -195,7 +195,9 @@ void PIBaseTransfer::received(PIByteArray data) { replies.resize(sr.packets + 1); replies.fill(pt_Unknown); pm_string.resize(replies.size(), '-'); +#ifdef PIP_HAS_THREADS diag.reset(); +#endif is_receiving = true; break_ = false; mutex_send.lock(); @@ -277,7 +279,7 @@ void PIBaseTransfer::received(PIByteArray data) { return; } break; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS #endif case pt_Pause: mutex_header.lock(); @@ -309,7 +311,7 @@ bool PIBaseTransfer::send_process() { mutex_session.lock(); packet_header_size = sizeof(PacketHeader) + customHeader().size(); break_ = false; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS diag.reset(); #endif sendStarted(); @@ -359,7 +361,7 @@ bool PIBaseTransfer::send_process() { } stm.reset(); ba = build_packet(i); -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS diag.sended(ba.size_s()); #endif sendRequest(ba); @@ -414,7 +416,7 @@ bool PIBaseTransfer::send_process() { continue; } ba = build_packet(chk - 1); -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS diag.sended(ba.size_s()); #endif sendRequest(ba); @@ -521,7 +523,7 @@ void PIBaseTransfer::sendReply(PacketType reply) { header.type = reply; PIByteArray ba; ba << header; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS if (is_sending || is_receiving) diag.sended(ba.size_s()); #endif sendRequest(ba); @@ -542,7 +544,7 @@ bool PIBaseTransfer::getStartRequest() { state_string = "send request"; PITimeMeasurer tm; while (tm.elapsed_s() < timeout_) { -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS diag.sended(ba.size_s()); #endif sendRequest(ba); diff --git a/libs/main/io_utils/pibasetransfer.h b/libs/main/io_utils/pibasetransfer.h index 190aed14..b8f9d0b5 100644 --- a/libs/main/io_utils/pibasetransfer.h +++ b/libs/main/io_utils/pibasetransfer.h @@ -161,7 +161,7 @@ public: //! \~russian Возвращает число байтов, уже обработанных в текущей сессии. llong bytesCur() const { return bytes_cur; } -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS //! \~english Get diagnostics object //! \~russian Получить объект диагностики //! \~\return @@ -348,7 +348,7 @@ private: CRC_16 crc; int send_queue; int send_up; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS PIDiagnostics diag; #endif PIMutex mutex_session; diff --git a/libs/main/io_utils/pibroadcast.h b/libs/main/io_utils/pibroadcast.h index 7af0921e..60a8cc6c 100644 --- a/libs/main/io_utils/pibroadcast.h +++ b/libs/main/io_utils/pibroadcast.h @@ -34,7 +34,7 @@ //! \~\brief //! \~english Multi-channel sender and receiver over multicast, broadcast and loopback endpoints. //! \~russian Многоканальный отправитель и приемник через multicast-, broadcast- и loopback-конечные точки. -#ifndef PIP_NO_SOCKET +#ifdef PIP_HAS_SOCKET class PIP_IO_UTILS_EXPORT PIBroadcast : public PIThread , public PIEthUtilBase { @@ -183,6 +183,6 @@ private: int lo_pcnt; bool _started, _send_only, _reinit; }; -#endif // PIP_NO_SOCKET +#endif // PIP_HAS_SOCKET #endif // PIBROADCAST_H diff --git a/libs/main/io_utils/piconnection.cpp b/libs/main/io_utils/piconnection.cpp index 7470583d..1e9cc7f7 100644 --- a/libs/main/io_utils/piconnection.cpp +++ b/libs/main/io_utils/piconnection.cpp @@ -24,7 +24,7 @@ #include "piliterals_time.h" #include "pitime.h" -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS # include "pitranslator.h" /** \class PIConnection @@ -1312,4 +1312,4 @@ __DevicePoolContainer__::__DevicePoolContainer__() { __device_pool__ = new PIConnection::DevicePool(); } -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS diff --git a/libs/main/io_utils/piconnection.h b/libs/main/io_utils/piconnection.h index fa83f2cc..8bad2ff8 100644 --- a/libs/main/io_utils/piconnection.h +++ b/libs/main/io_utils/piconnection.h @@ -379,7 +379,7 @@ public: bool isEmpty() const { return device_modes.isEmpty(); } -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS //! \~english Returns diagnostics object for device or filter "full_path_name". //! \~russian Возвращает объект диагностики для устройства или фильтра "full_path_name". PIDiagnostics * diagnostic(const PIString & full_path_name) const; @@ -417,7 +417,7 @@ public: //! \~russian Возвращает, работает ли общий пул устройств в режиме имитации. static bool isFakeMode(); -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS class PIP_EXPORT DevicePool: public PIThread { PIOBJECT_SUBCLASS(DevicePool, PIThread); friend void __DevicePool_threadReadDP(void * ddp); @@ -459,7 +459,7 @@ public: PIMap devices; bool fake; }; -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS //! \events @@ -475,7 +475,7 @@ public: //! \~russian Генерируется, когда фильтр "from" выдает пакет. EVENT2(packetReceivedEvent, const PIString &, from, const PIByteArray &, data); -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS //! \fn void qualityChanged(const PIIODevice * device, PIDiagnostics::Quality new_quality, PIDiagnostics::Quality old_quality) //! \~english Emitted when diagnostics quality of "device" changes. //! \~russian Генерируется при изменении качества диагностики устройства "device". @@ -502,7 +502,7 @@ private: void rawReceived(PIIODevice * dev, const PIString & from, const PIByteArray & data); void unboundExtractor(PIPacketExtractor * pe); EVENT_HANDLER2(void, packetExtractorReceived, const uchar *, data, int, size); -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS EVENT_HANDLER2(void, diagQualityChanged, PIDiagnostics::Quality, new_quality, PIDiagnostics::Quality, old_quality); #endif @@ -517,7 +517,7 @@ private: PIVector devices; }; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS class PIP_EXPORT Sender: public PITimer { PIOBJECT_SUBCLASS(Sender, PIObject); @@ -533,21 +533,21 @@ private: #endif PIMap extractors; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS PIMap senders; #endif PIMap device_names; PIMap device_modes; PIMap> bounded_extractors; PIMap> channels_; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS PIMap diags_; #endif static PIVector _connections; }; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS void __DevicePool_threadReadDP(void * ddp); extern PIP_EXPORT PIConnection::DevicePool * __device_pool__; @@ -559,7 +559,7 @@ public: }; static __DevicePoolContainer__ __device_pool_container__; -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS #endif // PICONNECTION_H diff --git a/libs/main/io_utils/pidiagnostics.cpp b/libs/main/io_utils/pidiagnostics.cpp index 5f64cb45..fddfb197 100644 --- a/libs/main/io_utils/pidiagnostics.cpp +++ b/libs/main/io_utils/pidiagnostics.cpp @@ -19,7 +19,7 @@ #include "pidiagnostics.h" -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS # include "piliterals_time.h" # include "pitranslator.h" @@ -253,4 +253,4 @@ void PIDiagnostics::changeDisconnectTimeout(PISystemTime disct) { mutex_state.unlock(); } -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS diff --git a/libs/main/io_utils/pidiagnostics.h b/libs/main/io_utils/pidiagnostics.h index 56ae202a..c5aec198 100644 --- a/libs/main/io_utils/pidiagnostics.h +++ b/libs/main/io_utils/pidiagnostics.h @@ -29,7 +29,7 @@ #include "pitimer.h" -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS //! \~\ingroup IO-Utils //! \brief //! \~english Connection diagnostics for packet frequency, throughput and receive quality @@ -236,6 +236,6 @@ inline bool operator!=(const PIDiagnostics::Entry & f, const PIDiagnostics::Entr inline bool operator<(const PIDiagnostics::Entry & f, const PIDiagnostics::Entry & s) { return f.bytes_ok < s.bytes_ok; } -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS #endif // PIDIAGNOSTICS_H diff --git a/libs/main/io_utils/piethutilbase.h b/libs/main/io_utils/piethutilbase.h index d8b572d2..983a24b2 100644 --- a/libs/main/io_utils/piethutilbase.h +++ b/libs/main/io_utils/piethutilbase.h @@ -24,7 +24,7 @@ #ifndef PIETHUTILBASE_H #define PIETHUTILBASE_H -#ifndef PIP_NO_SOCKET +#ifdef PIP_HAS_SOCKET #include "pibytearray.h" #include "pip_io_utils_export.h" @@ -97,5 +97,5 @@ private: bool _crypt; }; -#endif // PIP_NO_SOCKET +#endif // PIP_HAS_SOCKET #endif // PIETHUTILBASE_H diff --git a/libs/main/io_utils/pifiletransfer.cpp b/libs/main/io_utils/pifiletransfer.cpp index d6d0a6fa..4eb8b630 100644 --- a/libs/main/io_utils/pifiletransfer.cpp +++ b/libs/main/io_utils/pifiletransfer.cpp @@ -19,7 +19,7 @@ #include "pifiletransfer.h" -#ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM const char PIFileTransfer::sign[] = {'P', 'F', 'T'}; PIFileTransfer::PIFileTransfer() { @@ -341,4 +341,4 @@ void PIFileTransfer::send_finished(bool ok) { } } -#endif // PIP_NO_FILESYSTEM +#endif // PIP_HAS_FILESYSTEM diff --git a/libs/main/io_utils/pifiletransfer.h b/libs/main/io_utils/pifiletransfer.h index 2b45a119..8191b39d 100644 --- a/libs/main/io_utils/pifiletransfer.h +++ b/libs/main/io_utils/pifiletransfer.h @@ -31,7 +31,7 @@ #include "pibasetransfer.h" #include "pidir.h" -#ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM # define __PIFILETRANSFER_VERSION 2 @@ -263,6 +263,6 @@ inline PICout operator<<(PICout s, const PIFileTransfer::PFTFileInfo & v) { s.restoreControls(); return s; } -#endif // PIP_NO_FILESYSTEM +#endif // PIP_HAS_FILESYSTEM #endif // PIFILETRANSFER_H diff --git a/libs/main/io_utils/pipackedtcp.h b/libs/main/io_utils/pipackedtcp.h index 17244ed6..94b8c3de 100644 --- a/libs/main/io_utils/pipackedtcp.h +++ b/libs/main/io_utils/pipackedtcp.h @@ -24,7 +24,7 @@ #ifndef pipackedtcp_H #define pipackedtcp_H -#ifndef PIP_NO_SOCKET +#ifdef PIP_HAS_SOCKET #include "piiodevice.h" #include "pinetworkaddress.h" @@ -123,6 +123,6 @@ private: REGISTER_DEVICE(PIPackedTCP) -#endif // PIP_NO_SOCKET +#endif // PIP_HAS_SOCKET #endif diff --git a/libs/main/io_utils/pistreampacker.h b/libs/main/io_utils/pistreampacker.h index befab248..ba0e52ab 100644 --- a/libs/main/io_utils/pistreampacker.h +++ b/libs/main/io_utils/pistreampacker.h @@ -24,7 +24,7 @@ #ifndef PISTREAMPACKER_H #define PISTREAMPACKER_H -#ifndef PIP_NO_SOCKET +#ifdef PIP_HAS_SOCKET #include "piethutilbase.h" #include "piobject.h" @@ -201,5 +201,5 @@ private: mutable PIMutex prog_s_mutex, prog_r_mutex; }; -#endif // PIP_NO_SOCKET +#endif // PIP_HAS_SOCKET #endif // PISTREAMPACKER_H diff --git a/libs/main/math/pifft.cpp b/libs/main/math/pifft.cpp index 8c372dcb..bc4a8049 100644 --- a/libs/main/math/pifft.cpp +++ b/libs/main/math/pifft.cpp @@ -19,7 +19,7 @@ #include "pifft.h" -#ifndef PIP_NO_FFT +#ifdef PIP_HAS_FFT PIFFT_double::PIFFT_double() {} @@ -1961,4 +1961,4 @@ void PIFFT_float::ftbase_ffttwcalc(PIVector * a, int aoffset, int n1, int } } -#endif // PIP_NO_FFT +#endif // PIP_HAS_FFT diff --git a/libs/main/math/pifft.h b/libs/main/math/pifft.h index 6067a545..1709753b 100644 --- a/libs/main/math/pifft.h +++ b/libs/main/math/pifft.h @@ -59,7 +59,7 @@ #include "pimathcomplex.h" -#ifndef PIP_NO_FFT +#ifdef PIP_HAS_FFT # include "pip_fftw_export.h" @@ -384,6 +384,6 @@ typedef PIFFTW PIFFTWld; # endif -#endif // PIP_NO_FFT +#endif // PIP_HAS_FFT #endif // PIFFT_H diff --git a/libs/main/serialization/pivaluetree_conversions.cpp b/libs/main/serialization/pivaluetree_conversions.cpp index 18066934..5607bbd2 100644 --- a/libs/main/serialization/pivaluetree_conversions.cpp +++ b/libs/main/serialization/pivaluetree_conversions.cpp @@ -43,7 +43,7 @@ PIString mask(const PIString & str) { } PIString overrideFile(PIString path) { -#ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM if (path.isEmpty()) return {}; PIFile::FileInfo fi(path); auto ext = fi.extension(); @@ -142,7 +142,7 @@ PIValueTree PIValueTreeConversions::fromText(PIIODevice * device) { PIMap substitutions; if (!device) return ret; PIString base_path; -#ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM if (device->isTypeOf()) base_path = PIFile::FileInfo(device->path()).dir().replaceAll('\\', '/'); #endif PIIOTextStream ts(device); @@ -217,7 +217,7 @@ PIValueTree PIValueTreeConversions::fromText(PIIODevice * device) { line.cutLeft(1).trim(); if (path.front() == "include") { PIString include = line.trimmed(); -#ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM if (!PIFile::FileInfo(include).isAbsolute()) { include = base_path + "/" + include.replaceAll('\\', '/'); include.replaceAll("//", '/'); @@ -353,7 +353,7 @@ PIValueTree PIValueTreeConversions::fromText(const PIString & str) { PIValueTree PIValueTreeConversions::fromJSONFile(const PIString & path) { -#ifdef PIP_NO_FILESYSTEM +#ifndef PIP_HAS_FILESYSTEM return PIValueTree(); #else auto ret = PIValueTreeConversions::fromJSON(PIJSON::fromJSON(PIString::fromUTF8(PIFile::readAll(path)))); @@ -368,7 +368,7 @@ PIValueTree PIValueTreeConversions::fromJSONFile(const PIString & path) { PIValueTree PIValueTreeConversions::fromTextFile(const PIString & path) { -#ifdef PIP_NO_FILESYSTEM +#ifndef PIP_HAS_FILESYSTEM return PIValueTree(); #else PIFile f(path, PIIODevice::ReadOnly); @@ -385,7 +385,7 @@ PIValueTree PIValueTreeConversions::fromTextFile(const PIString & path) { bool PIValueTreeConversions::toJSONFile(const PIString & path, const PIValueTree & root, Options options) { -#ifdef PIP_NO_FILESYSTEM +#ifndef PIP_HAS_FILESYSTEM return false; #else auto d = toJSON(root, options).toJSON(PIJSON::Tree).toUTF8(); @@ -396,7 +396,7 @@ bool PIValueTreeConversions::toJSONFile(const PIString & path, const PIValueTree bool PIValueTreeConversions::toTextFile(const PIString & path, const PIValueTree & root, Options options) { -#ifdef PIP_NO_FILESYSTEM +#ifndef PIP_HAS_FILESYSTEM return false; #else auto d = toText(root, options).toUTF8(); diff --git a/libs/main/state_machine/pistatemachine_transition.cpp b/libs/main/state_machine/pistatemachine_transition.cpp index 2fe4c797..ba88ef4b 100644 --- a/libs/main/state_machine/pistatemachine_transition.cpp +++ b/libs/main/state_machine/pistatemachine_transition.cpp @@ -99,7 +99,7 @@ void PITransitionBase::trigger() { PITransitionTimeout::PITransitionTimeout(PIStateBase * source, PIStateBase * target, PISystemTime timeout) : PITransitionBase(source, target, 0) { -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS timer.setInterval(timeout); timer.setSlot([this] { trigger(); @@ -110,21 +110,21 @@ PITransitionTimeout::PITransitionTimeout(PIStateBase * source, PIStateBase * tar PITransitionTimeout::~PITransitionTimeout() { -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS timer.stopAndWait(); #endif } void PITransitionTimeout::enabled() { -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS timer.start(); #endif } void PITransitionTimeout::disabled() { -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS timer.stop(); #endif } diff --git a/libs/main/state_machine/pistatemachine_transition.h b/libs/main/state_machine/pistatemachine_transition.h index e0f6ea5e..a905a526 100644 --- a/libs/main/state_machine/pistatemachine_transition.h +++ b/libs/main/state_machine/pistatemachine_transition.h @@ -142,7 +142,7 @@ private: void enabled() override; void disabled() override; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS PITimer timer; #endif }; diff --git a/libs/main/system/pihidevice.cpp b/libs/main/system/pihidevice.cpp index b006b25b..e3f8117c 100644 --- a/libs/main/system/pihidevice.cpp +++ b/libs/main/system/pihidevice.cpp @@ -3,7 +3,7 @@ #include "piliterals_string.h" #include "piliterals_time.h" -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS # ifndef WINDOWS # include "pidir.h" # include "pifile.h" @@ -674,4 +674,4 @@ PIHIDeviceInfo PIHIDevice::findDevice(const PIString & name) { return PIHIDeviceInfo(); } -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS diff --git a/libs/main/system/pihidevice.h b/libs/main/system/pihidevice.h index 899b9300..8640115a 100644 --- a/libs/main/system/pihidevice.h +++ b/libs/main/system/pihidevice.h @@ -169,7 +169,7 @@ PIP_EXPORT PICout operator<<(PICout s, const PIHIDeviceInfo & v); //! \~english Provides access to HID (Human Interface Device) devices such as game controllers, joysticks, and other input devices. //! \~russian Предоставляет доступ к HID (Human Interface Device) устройствам, таким как геймконтроллеры, джойстики и другие устройства //! ввода. -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS class PIP_EXPORT PIHIDevice: public PIThread { PIOBJECT_SUBCLASS(PIHIDevice, PIThread) @@ -271,7 +271,7 @@ private: PIMap prev_buttons, cur_buttons; float dead_zone = 0.f; }; -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS #endif diff --git a/libs/main/system/pilibrary.cpp b/libs/main/system/pilibrary.cpp index 47769cc2..d5b225da 100644 --- a/libs/main/system/pilibrary.cpp +++ b/libs/main/system/pilibrary.cpp @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#ifndef PIP_NO_DYNLIB +#ifdef PIP_HAS_DYNLIB # include "pilibrary.h" @@ -233,4 +233,4 @@ void PILibrary::getLastError() { # endif } -#endif // PIP_NO_DYNLIB +#endif // PIP_HAS_DYNLIB diff --git a/libs/main/system/pilibrary.h b/libs/main/system/pilibrary.h index c1375d5c..2f8807d2 100644 --- a/libs/main/system/pilibrary.h +++ b/libs/main/system/pilibrary.h @@ -26,7 +26,7 @@ #ifndef PILIBRARY_H #define PILIBRARY_H -#ifndef PIP_NO_DYNLIB +#ifdef PIP_HAS_DYNLIB # include "pistring.h" @@ -82,5 +82,5 @@ private: PIString libpath, liberror; }; -#endif // PIP_NO_DYNLIB +#endif // PIP_HAS_DYNLIB #endif // PILIBRARY_H diff --git a/libs/main/system/piplugin.cpp b/libs/main/system/piplugin.cpp index 93e9b453..8e3dd8a0 100644 --- a/libs/main/system/piplugin.cpp +++ b/libs/main/system/piplugin.cpp @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#ifndef PIP_NO_DYNLIB +#ifdef PIP_HAS_DYNLIB # include "piplugin.h" @@ -493,4 +493,4 @@ PIString PIPluginLoader::libExtension() { } -#endif // PIP_NO_DYNLIB +#endif // PIP_HAS_DYNLIB diff --git a/libs/main/system/piplugin.h b/libs/main/system/piplugin.h index fb730367..eac36920 100644 --- a/libs/main/system/piplugin.h +++ b/libs/main/system/piplugin.h @@ -28,7 +28,7 @@ #ifndef PIPLUGIN_H #define PIPLUGIN_H -#ifndef PIP_NO_DYNLIB +#ifdef PIP_HAS_DYNLIB # include "pilibrary.h" # include "pistringlist.h" @@ -298,5 +298,5 @@ private: }; -#endif // PIP_NO_DYNLIB +#endif // PIP_HAS_DYNLIB #endif // PIPLUGIN_H diff --git a/libs/main/system/piprocess.cpp b/libs/main/system/piprocess.cpp index ee31ed69..97f64057 100644 --- a/libs/main/system/piprocess.cpp +++ b/libs/main/system/piprocess.cpp @@ -18,7 +18,7 @@ */ #include "pitime.h" -#ifndef PIP_NO_PROCESS +#ifdef PIP_HAS_PROCESS # include "piincludes_p.h" # include "piliterals_bytes.h" @@ -516,4 +516,4 @@ PIString PIProcess::getEnvironmentVariable(const PIString & variable) { return PIString(); } -#endif // PIP_NO_PROCESS +#endif // PIP_HAS_PROCESS diff --git a/libs/main/system/piprocess.h b/libs/main/system/piprocess.h index e6e523fd..ae837566 100644 --- a/libs/main/system/piprocess.h +++ b/libs/main/system/piprocess.h @@ -26,7 +26,7 @@ #ifndef PIPROCESS_H #define PIPROCESS_H -#ifndef PIP_NO_PROCESS +#ifdef PIP_HAS_PROCESS # include "pithread.h" @@ -258,5 +258,5 @@ private: std::atomic_bool exec_finished; }; -#endif // PIP_NO_PROCESS +#endif // PIP_HAS_PROCESS #endif // PIPROCESS_H diff --git a/libs/main/system/pisysteminfo.cpp b/libs/main/system/pisysteminfo.cpp index e202c508..c3f020f8 100644 --- a/libs/main/system/pisysteminfo.cpp +++ b/libs/main/system/pisysteminfo.cpp @@ -207,7 +207,7 @@ PIVector PISystemInfo::mountInfo(bool ignore_cache) { PIString confDir() { return #ifdef WINDOWS -# ifndef PIP_NO_FILESYSTEM +# ifdef PIP_HAS_FILESYSTEM PIDir::home().path() + "/AppData/Local" # else "" @@ -215,7 +215,7 @@ PIString confDir() { #elif defined(ANDROID) "" #else -# ifndef PIP_NO_FILESYSTEM +# ifdef PIP_HAS_FILESYSTEM PIDir::home().path() + "/.config" # else "" @@ -242,7 +242,7 @@ PIString PISystemInfo::machineKey() { PISystemInfo * si = instance(); PIByteArray salt; PIString conf = confDir() + "/.pip_machine_salt"; -#ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM if (PIFile::isExists(conf)) salt = PIFile::readAll(conf); if (salt.size_s() != SALT_SIZE) { salt = generateSalt(); diff --git a/libs/main/system/pisystemtests.cpp b/libs/main/system/pisystemtests.cpp index 9bcc2d44..e0554069 100644 --- a/libs/main/system/pisystemtests.cpp +++ b/libs/main/system/pisystemtests.cpp @@ -19,9 +19,9 @@ #include "pisystemtests.h" -#ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM # include "piconfig.h" -#endif // !PIP_NO_FILESYSTEM +#endif // PIP_HAS_FILESYSTEM namespace PISystemTests { @@ -35,10 +35,10 @@ PISystemTestReader pisystestreader; PISystemTests::PISystemTestReader::PISystemTestReader() { -#if !defined(WINDOWS) && !defined(PIP_NO_FILESYSTEM) +#if !defined(WINDOWS) && defined(PIP_HAS_FILESYSTEM) PIConfig conf(PIStringAscii("/etc/pip.conf"), PIIODevice::ReadOnly); time_resolution_ns = conf.getValue(PIStringAscii("time_resolution_ns"), 1).toLong(); time_elapsed_ns = conf.getValue(PIStringAscii("time_elapsed_ns"), 0).toLong(); usleep_offset_us = conf.getValue(PIStringAscii("usleep_offset_us"), 60).toLong(); -#endif // !WINDOWS && !PIP_NO_FILESYSTEM +#endif // !WINDOWS && PIP_HAS_FILESYSTEM } diff --git a/libs/main/thread/piconditionvar.cpp b/libs/main/thread/piconditionvar.cpp index 19d184fd..4a1fa9fb 100644 --- a/libs/main/thread/piconditionvar.cpp +++ b/libs/main/thread/piconditionvar.cpp @@ -23,7 +23,7 @@ # define _WIN32_WINNT 0x0600 #endif -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS #include "piconditionvar.h" #include "piincludes_p.h" #ifdef WINDOWS @@ -178,4 +178,4 @@ void PIConditionVariable::notifyAll() { pthread_cond_broadcast(&PRIVATE->nativeHandle); #endif } -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS diff --git a/libs/main/thread/piconditionvar.h b/libs/main/thread/piconditionvar.h index c5a96a5c..1ada84fe 100644 --- a/libs/main/thread/piconditionvar.h +++ b/libs/main/thread/piconditionvar.h @@ -29,7 +29,7 @@ #include "pisystemtime.h" -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS //! \~\ingroup Thread //! \~\brief //! \~english Condition variable used together with external %PIMutex. @@ -175,9 +175,9 @@ private: PRIVATE_DECLARATION(PIP_EXPORT) }; -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS -#ifdef PIP_NO_THREADS +#ifndef PIP_HAS_THREADS class PIConditionVariable { public: void wait(PIMutex &) {} @@ -187,6 +187,6 @@ public: void notifyOne() {} void notifyAll() {} }; -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS #endif // PICONDITIONVAR_H diff --git a/libs/main/thread/pimutex.cpp b/libs/main/thread/pimutex.cpp index 78a8dc15..37774d90 100644 --- a/libs/main/thread/pimutex.cpp +++ b/libs/main/thread/pimutex.cpp @@ -107,7 +107,7 @@ //! \} -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS #include "pimutex.h" #include "piincludes_p.h" @@ -229,4 +229,4 @@ void PIMutex::destroy() { pthread_mutex_destroy(&(PRIVATE->mutex)); #endif } -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS diff --git a/libs/main/thread/pimutex.h b/libs/main/thread/pimutex.h index 998bd1db..c88acc3c 100644 --- a/libs/main/thread/pimutex.h +++ b/libs/main/thread/pimutex.h @@ -28,7 +28,7 @@ #include "piinit.h" -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS //! \~\ingroup Thread //! \~\brief //! \~english Mutex for mutual exclusion between threads. @@ -94,9 +94,9 @@ private: bool cond; }; -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS -#ifdef PIP_NO_THREADS +#ifndef PIP_HAS_THREADS //! \~\ingroup Thread //! \~\brief //! \~english Dummy mutex for builds without threading support. @@ -117,6 +117,6 @@ class PIMutexLocker { public: PIMutexLocker(PIMutex &, bool = true) {} }; -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS #endif // PIMUTEX_H diff --git a/libs/main/thread/pireadwritelock.cpp b/libs/main/thread/pireadwritelock.cpp index 8525590a..b0fa67c2 100644 --- a/libs/main/thread/pireadwritelock.cpp +++ b/libs/main/thread/pireadwritelock.cpp @@ -151,7 +151,7 @@ #include "pireadwritelock.h" -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS PIReadWriteLock::PIReadWriteLock() {} @@ -235,4 +235,4 @@ void PIReadWriteLock::unlockRead() { var.notifyAll(); } -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS diff --git a/libs/main/thread/pisemaphore.cpp b/libs/main/thread/pisemaphore.cpp index 2d73ca66..4d0a90f2 100644 --- a/libs/main/thread/pisemaphore.cpp +++ b/libs/main/thread/pisemaphore.cpp @@ -98,7 +98,7 @@ #include "pisemaphore.h" -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS PISemaphore::PISemaphore(int initial) { @@ -153,4 +153,4 @@ int PISemaphore::available() const { return count; } -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS diff --git a/libs/main/thread/pithread.cpp b/libs/main/thread/pithread.cpp index 3c5c39eb..253c9dec 100644 --- a/libs/main/thread/pithread.cpp +++ b/libs/main/thread/pithread.cpp @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS # include "pithread.h" # include "piincludes_p.h" @@ -450,7 +450,7 @@ __THREAD_FUNC_RET__ thread_function_once(void * t) { //! \return \c false если таймаут истёк -# ifndef PIP_NO_THREADS +# ifdef PIP_HAS_THREADS __PIThreadCollection * __PIThreadCollection::instance() { return __PIThreadCollection_Initializer__::__instance__; @@ -516,7 +516,7 @@ __PIThreadCollection_Initializer__::~__PIThreadCollection_Initializer__() { } } -# endif // PIP_NO_THREADS +# endif // PIP_HAS_THREADS PRIVATE_DEFINITION_START(PIThread) @@ -1003,7 +1003,7 @@ void PIThread::runOnce(PIObject * object, const char * handler, const PIString & delete t; return; } -# ifndef PIP_NO_THREADS +# ifdef PIP_HAS_THREADS __PIThreadCollection::instance()->startedAuto(t); CONNECT0(void, t, stopped, __PIThreadCollection::instance(), stoppedAuto); # endif @@ -1037,7 +1037,7 @@ void PIThread::runOnce(std::function func, const PIString & name) { PIThread * t = new PIThread(); t->setName(name); t->setSlot(std::move(func)); -# ifndef PIP_NO_THREADS +# ifdef PIP_HAS_THREADS __PIThreadCollection::instance()->startedAuto(t); CONNECT0(void, t, stopped, __PIThreadCollection::instance(), stoppedAuto); # endif @@ -1079,4 +1079,4 @@ bool PIThread::_waitForFinish(PISystemTime max_tm) { # endif return false; } -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS diff --git a/libs/main/thread/pithread.h b/libs/main/thread/pithread.h index 68cfc361..9f1ddd60 100644 --- a/libs/main/thread/pithread.h +++ b/libs/main/thread/pithread.h @@ -43,7 +43,7 @@ class PIThread; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS class PIIntrospectionThreads; class PIP_EXPORT __PIThreadCollection: public PIObject { @@ -97,7 +97,7 @@ typedef std::function ThreadFunc; //! проход без повторяющегося цикла обработки очереди. class PIP_EXPORT PIThread: public PIObject { PIOBJECT_SUBCLASS(PIThread, PIObject); -# ifndef PIP_NO_THREADS +# ifdef PIP_HAS_THREADS friend class PIIntrospectionThreads; # endif @@ -338,5 +338,5 @@ private: void setThreadName(); }; -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS #endif // PITHREAD_H diff --git a/libs/main/thread/pithreadnotifier.cpp b/libs/main/thread/pithreadnotifier.cpp index f02c2669..b851d796 100644 --- a/libs/main/thread/pithreadnotifier.cpp +++ b/libs/main/thread/pithreadnotifier.cpp @@ -19,7 +19,7 @@ #include "pithreadnotifier.h" -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS //! \addtogroup Thread //! \{ @@ -145,4 +145,4 @@ void PIThreadNotifier::notify() { m.unlock(); } -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS diff --git a/libs/main/thread/pithreadnotifier.h b/libs/main/thread/pithreadnotifier.h index 16642923..c53ba54a 100644 --- a/libs/main/thread/pithreadnotifier.h +++ b/libs/main/thread/pithreadnotifier.h @@ -27,7 +27,7 @@ #include "piconditionvar.h" -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS //! \~\ingroup Thread //! \~\brief @@ -64,6 +64,6 @@ private: PIMutex m; PIConditionVariable v; }; -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS #endif // PITHREADNOTIFIER_H diff --git a/libs/main/thread/pithreadpoolloop.cpp b/libs/main/thread/pithreadpoolloop.cpp index 5eae72ce..a76f8b1b 100644 --- a/libs/main/thread/pithreadpoolloop.cpp +++ b/libs/main/thread/pithreadpoolloop.cpp @@ -23,7 +23,7 @@ #include "pisysteminfo.h" #include "pithread.h" -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS //! \addtogroup Thread @@ -169,4 +169,4 @@ void PIThreadPoolLoop::exec(int index_start, int index_count, std::functionnotifier.notify(); } -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS diff --git a/libs/main/thread/pithreadpoolworker.h b/libs/main/thread/pithreadpoolworker.h index 45c80fc4..fe75e6f6 100644 --- a/libs/main/thread/pithreadpoolworker.h +++ b/libs/main/thread/pithreadpoolworker.h @@ -33,7 +33,7 @@ //! \~\brief //! \~english Fixed-size pool of worker threads for generic-purpose tasks. //! \~russian Фиксированный пул рабочих потоков для задач общего назначения. -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS class PIP_EXPORT PIThreadPoolWorker: public PIObject { PIOBJECT(PIThreadPoolWorker) @@ -173,7 +173,7 @@ private: PISet contexts; std::atomic_int64_t next_task_id = {0}; }; -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS #endif // PITHREADPOOLWORKER_H diff --git a/libs/main/thread/pitimer.cpp b/libs/main/thread/pitimer.cpp index 5630230c..96340e43 100644 --- a/libs/main/thread/pitimer.cpp +++ b/libs/main/thread/pitimer.cpp @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS #include "pitimer.h" #include "piconditionvar.h" @@ -316,4 +316,4 @@ void PITimer::stop() { thread->stop(); event.notifyAll(); } -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS diff --git a/libs/main/thread/pitimer.h b/libs/main/thread/pitimer.h index 43ffad16..554c05d6 100644 --- a/libs/main/thread/pitimer.h +++ b/libs/main/thread/pitimer.h @@ -44,7 +44,7 @@ class PIThread; -#ifndef PIP_NO_THREADS +#ifdef PIP_HAS_THREADS //! \~\ingroup Thread //! \~\brief //! \~english Periodic timer that emits ticks from an internal worker thread. @@ -247,5 +247,5 @@ protected: PIConditionVariable event; }; -#endif // PIP_NO_THREADS +#endif // PIP_HAS_THREADS #endif // PITIMER_H diff --git a/libs/main/types/pinetworkaddress.cpp b/libs/main/types/pinetworkaddress.cpp index fdbc5a52..3b02db4e 100644 --- a/libs/main/types/pinetworkaddress.cpp +++ b/libs/main/types/pinetworkaddress.cpp @@ -20,7 +20,7 @@ #include "pinetworkaddress.h" // clang-format off -#ifndef PIP_NO_SOCKET +#ifdef PIP_HAS_SOCKET #ifdef QNX # include #else @@ -34,7 +34,7 @@ # endif # endif #endif -#endif // PIP_NO_SOCKET +#endif // PIP_HAS_SOCKET // clang-format on @@ -147,7 +147,7 @@ PINetworkAddress PINetworkAddress::resolve(const PIString & host_port) { PINetworkAddress PINetworkAddress::resolve(const PIString & host, ushort port) { -#ifndef PIP_NO_SOCKET +#ifdef PIP_HAS_SOCKET PINetworkAddress ret(0, port); hostent * he = gethostbyname(host.dataAscii()); if (!he) return ret; @@ -170,7 +170,7 @@ void PINetworkAddress::splitIPPort(const PIString & ipp, PIString * _ip, int * _ void PINetworkAddress::initIP(const PIString & _ip) { -#ifndef PIP_NO_SOCKET +#ifdef PIP_HAS_SOCKET ip_ = inet_addr(_ip.dataAscii()); #else (void)_ip; diff --git a/libs/main/types/pitime.cpp b/libs/main/types/pitime.cpp index cbe09b76..310c234c 100644 --- a/libs/main/types/pitime.cpp +++ b/libs/main/types/pitime.cpp @@ -56,7 +56,7 @@ void piUSleep(int usecs) { #elif defined(PICO_SDK) sleep_us(usecs); #else -# ifndef PIP_NO_THREADS +# ifdef PIP_HAS_THREADS usecs -= PISystemTests::usleep_offset_us; # endif if (usecs > 0) usleep(usecs); diff --git a/libs/main/types/pivarianttypes.cpp b/libs/main/types/pivarianttypes.cpp index 7c5696e1..a69ddb94 100644 --- a/libs/main/types/pivarianttypes.cpp +++ b/libs/main/types/pivarianttypes.cpp @@ -21,9 +21,9 @@ #include "colors_p.h" #include "pipropertystorage.h" -#ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM # include "piiodevice.h" -#endif // PIP_NO_FILESYSTEM +#endif // PIP_HAS_FILESYSTEM int PIVariantTypes::Enum::selectedValue() const { @@ -84,11 +84,11 @@ PIStringList PIVariantTypes::Enum::names() const { PIVariantTypes::IODevice::IODevice() { -#ifndef PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM mode = PIIODevice::ReadWrite; #else - mode = 0; // TODO: PIIODevice for PIP_NO_FILESYSTEM -#endif // PIP_NO_FILESYSTEM + mode = 0; // TODO: PIIODevice for PIP_HAS_FILESYSTEM +#endif // PIP_HAS_FILESYSTEM options = 0; } @@ -121,12 +121,12 @@ PIString PIVariantTypes::IODevice::toPICout() const { } if (rwc == 1) s += "o"; s += ", flags="; -#ifndef PIP_NO_FILESYSTEM // TODO: PIIODevice for PIP_NO_FILESYSTEM +#ifdef PIP_HAS_FILESYSTEM // TODO: PIIODevice for !PIP_HAS_FILESYSTEM if (options != 0) { if (((PIIODevice::DeviceOptions)options)[PIIODevice::BlockingRead]) s += " br"; if (((PIIODevice::DeviceOptions)options)[PIIODevice::BlockingWrite]) s += " bw"; } -#endif // PIP_NO_FILESYSTEM +#endif // PIP_HAS_FILESYSTEM PIPropertyStorage ps = get(); for (const auto & p: ps) { s += ", " + p.name + "=\"" + p.value.toString() + "\"";