Files
pip/libs/main/core/piwaitevent_p.h
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

68 lines
1.5 KiB
C++

/*
PIP - Platform Independent Primitives
Private PIP wait object
Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PIWAITEVENT_P_H
#define PIWAITEVENT_P_H
#include "pibase.h"
// clang-format off
#ifdef WINDOWS
# include <stdarg.h>
# include <windef.h>
# include <winbase.h>
#else
# include <sys/select.h>
# include <unistd.h>
#endif
// clang-format on
class PIP_EXPORT PIWaitEvent {
public:
~PIWaitEvent();
enum CheckRole { // UNIX only
CheckRead,
CheckWrite,
CheckExeption
};
void create();
void destroy();
bool wait(int fd = -1, CheckRole role = CheckRead);
bool sleep(int us); // return if sleep done
void interrupt();
bool isCreate() const;
void * getEvent() const; // WINDOWS only
private:
#ifdef WINDOWS
void * event = nullptr;
#else
int pipe_fd[2] = {-1, -1};
fd_set fds[3];
enum {
ReadEnd = 0,
WriteEnd = 1
};
#endif
};
#endif // PIWAITEVENT_P_H