2611 Commits
Author SHA1 Message Date
andrey 86a1084ec1 feat: enforce no-RTTI type name registration with static_assert 2026-08-23 08:20:51 +03:00
andrey 8fc2be8dd9 fix: complete PIP_HAS_* flag matrix and restore ESP32/FreeRTOS support
- CMake: disable thread/socket-dependent modules (http_client, mqtt_client,
  client_server) and fftw when the required feature flags are off;
  client_server/cloud no longer tied to the crypt option
- host utils gated on filesystem and the modules they need
- Pico keeps the minimal set; generic FreeRTOS (ESP32) keeps filesystem,
  sockets and serial as in master, module set limited to crypt/compress/io_utils
- PICAN, PIBroadcast, PIPackedTCP vanish without socket+threads
- PISerial: restore PISERIAL_NO_PINS (auto-enabled on PIP_EMBEDDED)
- PIFile: FREERTOS uses fopen/stat (no fopen64 in ESP-IDF newlib)
- drop invalid PICout buffer guards, guard PIObject::deleteLater,
  remove (void)destroying hack, fake PIHIDevice non-Linux stub and the
  redundant PICO_SDK guard in code_model_generator
2026-08-22 19:23:22 +03:00
andrey 17b7d0afbd chore: restore executable bits lost during clang-format pass 2026-08-22 15:53:20 +03:00
andrey f6075307b6 style: run clang-format over all files 2026-08-22 15:52:58 +03:00
andrey 8828aa3f81 fix: build PIP on Pico and arbitrary flag combinations
- guard console subsystem (PIScreen/PIScreenTile/tiles/PITerminal/
  PIKbdListener) by PIP_HAS_THREADS plus a TTY or Windows console
  (new PIP_HAS_TTY platform macro) - termios is not available on
  bare-metal newlib
- guard cloud subsystem (PICloudBase/Client/Server/TCP) by
  PIP_HAS_SOCKET and PIP_HAS_THREADS
- add PIP_BUILD_CONSOLE/PIP_BUILD_CLOUD to the auto-disable flag
  dependencies in CMake
- PIP_CAN (SocketCAN) is Linux-only, exclude other platforms
- on Pico keep sockets/MQTT off by default: pico-sdk lwip provides
  only a partial POSIX socket layer (no netinet/in.h, poll.h)
- PITranslator: inline no-op definitions when PIP_HAS_FILESYSTEM is
  off so the _tr literal links
- PIIODevice: guard read_func/write_func EVENT_HANDLERs (no-threads)
- piwaitevent_p.cpp: drop unused sys/ioctl.h include (missing on
  arm-none-eabi, broke Pico builds)
2026-08-22 15:49:05 +03:00
andrey 32066e3a8c fix: make PIP buildable for no-threads and no-filesystem flag combinations
Found while verifying -DPIP_HAS_THREADS=OFF / -DPIP_HAS_FILESYSTEM=OFF
smoke builds (pre-existing gaps of the branch):

- piinit.cpp: full implementation now requires PIP_HAS_THREADS as well
  (the PIInit class is declared in piinit.h only with threads; without
  threads PIInit is absent altogether, stub/absent branches unchanged)
- PIWaitEvent: drop the PIP_HAS_THREADS guard - it is a plain
  pipe/select/WaitForMultipleObjects wrapper with no thread usage
  (master had no guard), restores unistd.h include for PICAN etc.
- PIEthernet: guard server_thread_ member, server_func(), threaded
  listen/stop parts and writeThreaded() calls by PIP_HAS_THREADS
- PIPeer: guard class/impl by PIP_HAS_THREADS (uses PIThread/PITimer/
  PIDiagnostics), openDevice() /etc/pip.conf read by PIP_HAS_FILESYSTEM
- PIBinaryLog::restart(): guard threaded-read restart by PIP_HAS_THREADS
- PIIODevice::configure(config_file,...), PIConnection::configureFromConfig,
  PIConfig include resolution: guard path-based bodies by PIP_HAS_FILESYSTEM
- PISerial::availableDevicesInfo(): guard /dev and /proc/tty scan by
  PIP_HAS_FILESYSTEM
- PIHIDevice impl: requires filesystem (sysfs scan) in addition to threads
- PIPluginLoader::pluginsDirectories/findLibrary: guard PIFile/PIDir use
  by PIP_HAS_FILESYSTEM (fallback: empty list / path as-is)
2026-08-22 14:33:34 +03:00
andrey 5fd63cc7dc clean: remove dead feature-flag code
- pifile.cpp: drop '|| !defined(PIP_HAS_FILESYSTEM)' from the
  _fopen_call_ condition and the redundant inner
  '#ifdef PIP_HAS_FILESYSTEM' - the whole file is already inside
  PIP_HAS_FILESYSTEM
- remove PISERIAL_NO_PINS (piplatform.h, piserial.cpp): the whole
  piserial.cpp is inside PIP_HAS_SERIAL which is forced OFF for
  Pico/FREERTOS, so the macro could never be active where it mattered;
  keep the Windows/POSIX branches as-is
2026-08-22 14:08:41 +03:00
andrey b97f7feeb3 fix: guard PIConfig path-based API by PIP_HAS_FILESYSTEM
Declarations of PIConfig(PIString, DeviceMode), PIConfig(PIString,
PIStringList) and open(PIString, DeviceMode) now match their
filesystem-guarded definitions in piconfig.cpp (link error otherwise);
the path constructor definition is guarded as well since it calls the
guarded open(). String/device based overloads stay unguarded.
2026-08-22 14:07:12 +03:00
andrey 54de1da27b refactor: merge embedded CMake blocks, link unix libs by feature flags, guard grabber/pipeline headers
- merge the PICO_BOARD and PIP_FREERTOS blocks (90% duplicate) into one
  embedded block; Pico+PICO_FREERTOS now adds -DPIP_FREERTOS so
  pithread.cpp takes the FreeRTOS path instead of POSIX pthreads;
  restore set(ICU OFF)/set(LOCAL ON) for FreeRTOS/embedded targets
- auto-disable dependent flags when PIP_HAS_THREADS=OFF:
  PIP_HAS_PROCESS, PIP_HAS_SERIAL (PIProcess derives from PIThread,
  PISerial/PIIODevice use PIThread) and INTROSPECTION (walks threads)
- LIBS_MAIN: link dl only with PIP_HAS_DYNLIB, pthread/util/rt only with
  PIP_HAS_THREADS (rt was never linked on APPLE), socket on QNX_HOST only
  with PIP_HAS_SOCKET; WIN32 list untouched - arm-none-eabi has no
  libdl/libpthread/librt so Pico firmware links again
- collapse repeated 'NOT DEFINED PICO_SDK_PATH' utils checks into
  _PIP_HOST_TOOLS variable
- FindPIP.cmake: check PIP_FREERTOS instead of the never-set
  PIP_EMBEDDED CMake variable (as in master)
- drop unused set(PIP_MICRO ON) from esp-pip
- wrap PIGrabberBase/PIPipelineThread in #ifdef PIP_HAS_THREADS like
  pithread.h so 'pip.h' compiles in no-threads builds
2026-08-22 14:06:05 +03:00
andrey e0133e23ec fix: remove Android feature-flag overrides and protect code from arbitrary flag combos
- drop the ANDROID_PLATFORM block forcing PROCESS/DYNLIB/FFT off:
  Android has /proc and dlopen and these features worked there in master
- __sighandler__: wrap PIProcess::currentPID() by PIP_HAS_PROCESS (0
  fallback), the dumpApplicationToFile() call itself is already guarded
  by PIP_INTROSPECTION && PIP_HAS_FILESYSTEM
- PISystemMonitor: guard /proc-related members (proc_dir/file/filem) and
  code paths (startOnProcess, run() non-Windows part, gatherThread /proc
  reader) by PIP_HAS_PROCESS/PIP_HAS_FILESYSTEM so the file compiles for
  any flag combination, e.g. -DPIP_HAS_PROCESS=OFF -DPIP_HAS_FILESYSTEM=OFF
2026-08-22 14:00:17 +03:00
andrey 35d3136ffc fix: use PIP_HAS_RTTI in state machine formatHash and make no-RTTI builds work
- pistatemachine_base.h checked non-existent macros __GXX_RTTI__/__RTTI__,
  so on GCC/Clang desktop builds formatHash() always returned 0 and the
  guard signature check in testGuard() never fired (UB on incompatible
  signatures). Now the real PIP_HAS_RTTI (pibase_macros.h) is used.
- no-RTTI fallback: each Function<Args...> instantiation takes a unique
  hash from a process-wide counter (a per-instantiation counter would
  give every signature the same hash on first call).
- __pip_typename__ primary template: replace hard static_assert with a
  generic fallback; containers/stream operators instantiate it for
  arbitrary T in no-RTTI builds (Pico/arm-none-eabi has no RTTI), so the
  assert made any no-RTTI build impossible. Explicit
  __PIP_TYPENAME_DECLARE specializations still take precedence.
2026-08-22 13:56:27 +03:00
andrey b82ad8e6cd fix: remove non-inline __PIInit_Initializer__ definitions from piinit.h (ODR violation)
The stub member definitions lived in the header and were picked up by
every TU including piinit.h, causing multiple-definition link errors in
embedded (PIP_EMBEDDED) builds. Definitions now live only in piinit.cpp;
the stub implementation is compiled in the '#else' branch guarded by
PIP_HAS_THREADS (no-PIInit builds are unchanged).
2026-08-22 13:46:35 +03:00
andrey 858d205fd3 fix: guard PIObject dump diagnostics by PIP_INTROSPECTION and drop PIP_FORCE_NO_PIINTROSPECTION
- invert friend block in piobject.h (friends needed when introspection
  is enabled) and remove dead friend PIObjectManager
- guard PIObject::dump()/dumpApplication()/dumpApplicationToFile()
  declarations and definitions by PIP_INTROSPECTION
  (dumpApplicationToFile additionally requires PIP_HAS_FILESYSTEM)
- guard dumpApplicationToFile() call in __sighandler__ by
  PIP_INTROSPECTION && PIP_HAS_FILESYSTEM
- replace '#if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)'
  with plain '#ifdef PIP_INTROSPECTION' everywhere, remove PIP_FORCE_NO_PIINTROSPECTION
- fix broken PIINTROSPECTION_CONTAINER_ALLOC(T, (as - ...)) in
  pideque.h/pivector.h ('as' no longer exists, use new_rsize)
2026-08-22 13:44:58 +03:00
peri4 b1cab18496 version 5.9.0 2026-08-17 20:36:43 +03:00
peri4 b1060fd572 PIEthernet fix: no more close outdated fd on disconnect (error at work with MHD) 2026-08-17 20:26:36 +03:00
andrey 75cfdd2e4c small fix 2026-08-12 18:54:25 +03:00
andrey a94d5d536b remove spaces 2026-08-12 18:23:48 +03:00
andrey aed98059de Merge pull request 'add rpm support for deploy_tool' (#211) from rpm_support into master
Reviewed-on: #211
2026-08-12 17:05:48 +03:00
andrey 7af2b0bb07 remove some ifdefs 2026-08-12 15:12:36 +03:00
andrey e2c0445c1b remove some unused defines 2026-08-12 14:04:49 +03:00
andrey 8bf7738e8a __PIP_TYPENAME_DECLARE 2026-08-11 22:55:59 +03:00
andrey 5f222d6c0c Add PIP_HAS_RTTI 2026-08-11 22:17:16 +03:00
andrey 077ac9887b refactor: rename PIP_NO_\* to PIP_HAS_\* with inverted logic
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.
2026-08-11 19:51:42 +03:00
andrey 9214e805d9 add rpm support for deploy_tool 2026-08-11 19:04:33 +03:00
andrey 1db0dfea43 Merge branch 'master' into pico_sdk 2026-08-11 18:21:50 +03:00
andrey fd578ea927 fix: address review issues from MICRO_PIP migration
- piconditionvar.h: remove phantom wait(lk, timeout) stubs not in real class
- pithread.h: remove duplicate #ifndef PIP_NO_THREADS guard
- piscreendrawer/tile/tiles.cpp: remove duplicate #if !defined(PICO_SDK)
- cmake/FindPIP.cmake: replace PIP_MICRO with PIP_EMBEDDED
2026-08-11 15:26:55 +03:00
andrey 5fe03eaf96 fix ctest 2026-08-11 14:41:25 +03:00
andrey 399ae3a20c fix ctest 2026-08-11 14:40:51 +03:00
andrey 2dfe68cc3d chore: remove docs/ directory 2026-08-11 14:35:45 +03:00
andrey 4d8b743075 refactor: migrate MICRO_PIP to fine-grained feature flags
Replace monolithic MICRO_PIP/PIP_MICRO with granular flags:

Feature flags (CMake options + platform auto-detection):
- PIP_NO_FILESYSTEM, PIP_NO_THREADS, PIP_NO_SOCKET
- PIP_NO_PROCESS, PIP_NO_DYNLIB, PIP_NO_FFT, PIP_NO_SERIAL

Embedded optimization flag:
- PIP_EMBEDDED (auto-set for Pico SDK and FreeRTOS)
  Controls buffer sizes, time stubs, terminal fallback, init stubs

Platform blocks in CMakeLists.txt:
- Pico SDK: auto-disables FS, PROCESS, DYNLIB, FFT, SERIAL;
  conditionally disables THREADS (no FreeRTOS) and SOCKET (no LWIP)
- FreeRTOS: auto-disables FS, PROCESS, DYNLIB, FFT, SERIAL;
  conditionally disables SOCKET (no LWIP)
- Android: auto-disables PROCESS, DYNLIB, FFT

Updated 96 files across libs/, utils/, tests/, and CMakeLists.txt.
Builds verified for Linux (547 tests pass) and Pico SDK (100%).
Removed all MICRO_PIP and PIP_MICRO references (0 remaining).
2026-08-11 14:34:59 +03:00
andrey a81a450c44 Merge pull request 'Bugfixes part 3' (#209) from bugfixes3 into master
Reviewed-on: #209
2026-08-11 11:16:55 +03:00
andrey f2d692725a version 2026-08-11 11:15:57 +03:00
andrey 87c53d45a4 Merge branch 'master' into pico_sdk 2026-08-11 09:56:27 +03:00
andrey c8f6fe7641 Reapply "fix: PISingleApplication TOCTOU — two shm reads replaced with single atomic read"
This reverts commit fc2e49b096.
2026-08-10 21:39:31 +03:00
andrey ace5960e70 fix(piusb): fix 4 bugs in USB read/write/enumeration/close
1. Missing break in readDevice() Bulk case: Bulk read result was
   overwritten by interrupt read, silently corrupting all bulk reads.

2. Wrong variable in writeDevice(): switch checked ep_read instead
   of ep_write; Interrupt case used ep_read.address for writes.

3. Interface mismatch in closeDevice(): always released interface 0
   (intefrace_) instead of the actually claimed interface
   (interface_claimed), leaking non-zero interface claims.

4. Wrong index in interface enumeration: used outer loop variable c
   (configuration index) instead of i (interface index), reading
   wrong interface descriptors or causing OOB access.
2026-08-10 16:26:30 +03:00
andrey 69673ff7c6 fix(curl_thread_pool): clean up clients_in_proc in destroy()
destroy() aborted and deleted clients in the queue but did not
delete clients that were currently being processed (clients_in_proc).
If a thread was terminated while processing a client, that client
object and its CURL handle were leaked.
2026-08-10 16:26:23 +03:00
andrey 9a4384a378 fix(piopencl): release context on command queue creation failure
If clCreateContext succeeded but clCreateCommandQueue failed,
the context handle was returned without being released, leaking
the OpenCL context and all associated GPU resources.
2026-08-10 16:26:18 +03:00
andrey 4d2c268710 fix(piluaprogram): add destructor to close Lua state
luaL_newstate() allocates a Lua state (~2-4 MB with libraries)
in the constructor, but there was no destructor to call lua_close().
Every PILuaProgram instance leaked its entire Lua state.
Add ~PILuaProgram() that calls lua_close(PRIVATE->lua_state).
2026-08-10 16:26:13 +03:00
andrey 9294cd7b7b fix(picrypt): use crypto_box_* constants for public-key decrypt
The decrypt() function for crypto_box (public-key) used
crypto_secretbox_NONCEBYTES and crypto_secretbox_MACBYTES
(secret-key constants) instead of crypto_box_* constants.
These happen to be equal in libsodium but are semantically
different APIs. Fix ensures consistency with the encrypt()
counterpart.
2026-08-10 16:26:08 +03:00
andrey 16adea05af fix(picompress): pass correct source size to uncompress()
piDecompress() appended original size as 8-byte ullong at the end
of compressed data, but passed zba.size() (including the 8 bytes)
to uncompress(). This fed trailing metadata as part of the zlib
stream. Fix: subtract sizeof(ullong) from source length.
2026-08-10 16:26:02 +03:00
andrey aa64eb4c7f fix(pibasetransfer): fix ABBA deadlock — enforce consistent mutex lock ordering
received() acquired mutex_header and mutex_session in different orders
depending on packet type:
  - pt_Data path:  mutex_header → mutex_session
  - pt_Start path: mutex_session → mutex_header

send_process() acquires mutex_session independently. When running
concurrently with received(), the reversed lock ordering creates a
classic ABBA deadlock scenario.

Fix: enforce consistent ordering (mutex_header → mutex_session) in
all code paths. Restructured pt_Start case and buildSession() to
always acquire mutex_header before mutex_session.
2026-08-10 15:48:40 +03:00
andrey c3bdc5464e fix(piconnection): prevent UAF in DevicePool::run() during connection deletion
The background run() thread copies allConnections() then iterates
each connection's diags_ map. If a PIConnection is deleted from
another thread between the copy and the iteration, dereferencing
the pointer is UAF. Add null check and protect diags_ iteration
with __device_pool__ lock.
2026-08-10 15:48:31 +03:00
andrey b180d91b1e fix(pibasetransfer): make shared flags std::atomic<bool> to eliminate data race
Flags break_, is_sending, is_receiving, is_pause are accessed from
both the send thread (send_process) and the read thread (received)
without synchronization. Plain bool reads/writes from multiple threads
is undefined behavior per C++ standard. Convert to std::atomic<bool>
with proper initializers.
2026-08-10 15:48:24 +03:00
andrey 1c9cdbba19 fix(picloudserver): use piMin<ssize_t> to avoid signed/unsigned UB in Client::readDevice
piMini(max_size, buff.size()) implicitly narrows size_t to int,
which is UB for large buffers. Replace with explicit piMin<ssize_t>
matching the correct pattern used in picloudclient.cpp.
2026-08-10 15:48:12 +03:00
andrey f9a846a3e9 Revert "fix(PIFFT_float): correct plan entry size from 4 to 8"
This reverts commit 2bb3884aee.
2026-08-10 14:59:18 +03:00
andrey fc2e49b096 Revert "fix: PISingleApplication TOCTOU — two shm reads replaced with single atomic read"
This reverts commit 1b23a258b8.
2026-08-10 14:59:13 +03:00
andrey 1a153eefbc fix(PISystemInfo): correct guard for df output parsing
The guard ml.size_s() < 2 allowed size==2, but ml[2] was then
accessed — OOB read on truncated or unusual df output lines.
2026-08-06 17:01:30 +03:00
andrey 9e280ef976 fix(PISerial): close fd when probe read fails in availableDevicesInfo
When the non-blocking probe read returned EIO, the loop continued
without closing the file descriptor, leaking one fd per rejected
port on each call.
2026-08-06 17:01:30 +03:00
andrey c8ad8ecaf4 fix(PISPI): close fd on ioctl error paths
Three ioctl calls after successful open() returned false without
closing the file descriptor, leaking one fd per failed open attempt.
2026-08-06 17:01:30 +03:00
andrey 1aa6f1af81 fix(PIByteArray): prevent OOB in fromBase64 with non-multiple-of-4 input
The buffer was sized as floor(sz/4)*3 but the loop ran ceil(sz/4)
times, writing 3 bytes per iteration. For sz%4!=0, this wrote past
the buffer end. Also guarded sz<4 to avoid processing trivially
short or malformed input.
2026-08-06 17:01:30 +03:00