diff --git a/libs/console/piterminal.cpp b/libs/console/piterminal.cpp index fbf1b718..795d9af3 100644 --- a/libs/console/piterminal.cpp +++ b/libs/console/piterminal.cpp @@ -147,7 +147,8 @@ void PITerminal::write(const PIByteArray & d) { if (PRIVATE->fd == 0) return; // ssize_t wrote = 0; // wrote = - ::write(PRIVATE->fd, d.data(), d.size_s()); + auto _r = ::write(PRIVATE->fd, d.data(), d.size_s()); + NO_UNUSED(_r); // piCout << "wrote" << wrote << d; # endif # endif @@ -345,8 +346,8 @@ void PITerminal::getCursor(int & x, int & y) { int sz = 0; PRIVATE->shm->read(&sz, 4); # else - x = PRIVATE->cur_x; - y = PRIVATE->cur_y; + x = PRIVATE->cur_x; + y = PRIVATE->cur_y; # endif } @@ -933,7 +934,7 @@ void PITerminal::destroy() { } if (PRIVATE->pipe != INVALID_HANDLE_VALUE) CloseHandle(PRIVATE->pipe); if (PRIVATE->hConBuf != INVALID_HANDLE_VALUE) CloseHandle(PRIVATE->hConBuf); - // piCout << "destroy" << size_y; + // piCout << "destroy" << size_y; # else # ifdef HAS_FORKPTY if (PRIVATE->pid != 0) kill(PRIVATE->pid, SIGKILL); diff --git a/libs/main/core/piwaitevent_p.cpp b/libs/main/core/piwaitevent_p.cpp index 7526cf53..3dff58bc 100644 --- a/libs/main/core/piwaitevent_p.cpp +++ b/libs/main/core/piwaitevent_p.cpp @@ -129,7 +129,8 @@ void PIWaitEvent::interrupt() { #ifdef WINDOWS SetEvent(event); #else - ::write(pipe_fd[WriteEnd], "", 1); + auto _r = ::write(pipe_fd[WriteEnd], "", 1); + NO_UNUSED(_r); #endif } diff --git a/libs/main/io_devices/pifile.cpp b/libs/main/io_devices/pifile.cpp index 732b4e8d..879f0ef1 100644 --- a/libs/main/io_devices/pifile.cpp +++ b/libs/main/io_devices/pifile.cpp @@ -263,7 +263,8 @@ PIByteArray PIFile::readAll(bool forceRead) { if (s < 0) return a; a.resize(s); seekToBegin(); - fread(a.data(), 1, s, PRIVATE->fd); + auto _r = fread(a.data(), 1, s, PRIVATE->fd); + NO_UNUSED(_r); seek(cp); if (s >= 0) a.resize(s); return a; @@ -517,10 +518,10 @@ PIFile::FileInfo PIFile::fileInfo(const PIString & path) { _stat_struct_ fs; piZeroMemory(fs); _stat_call_(path.data(), &fs); - int mode = fs.st_mode; - ret.size = fs.st_size; - ret.id_user = fs.st_uid; - ret.id_group = fs.st_gid; + int mode = fs.st_mode; + ret.size = fs.st_size; + ret.id_user = fs.st_uid; + ret.id_group = fs.st_gid; # ifdef ANDROID ret.time_access = PIDateTime::fromSystemTime(PISystemTime(fs.st_atime, fs.st_atime_nsec)); ret.time_modification = PIDateTime::fromSystemTime(PISystemTime(fs.st_mtime, fs.st_mtime_nsec)); @@ -541,9 +542,9 @@ PIFile::FileInfo PIFile::fileInfo(const PIString & path) { # endif # endif # ifndef MICRO_PIP - 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); + 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); piZeroMemory(fs); _stat_link_(path.data(), &fs); mode &= ~S_IFLNK; diff --git a/libs/main/io_devices/pisharedmemory.cpp b/libs/main/io_devices/pisharedmemory.cpp index 8c2a4aae..a3e9d654 100644 --- a/libs/main/io_devices/pisharedmemory.cpp +++ b/libs/main/io_devices/pisharedmemory.cpp @@ -136,7 +136,10 @@ bool PISharedMemory::openDevice() { PRIVATE->owner = true; // piCoutObj << "created" << fd; } - if (fd >= 0) ftruncate(fd, dsize); + if (fd >= 0) { + auto _r = ftruncate(fd, dsize); + NO_UNUSED(_r); + } PRIVATE->data = mmap(0, dsize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); ::close(fd); if (PRIVATE->data == MAP_FAILED) { diff --git a/libs/main/thread/pithread.cpp b/libs/main/thread/pithread.cpp index a7445d35..4e03b73a 100644 --- a/libs/main/thread/pithread.cpp +++ b/libs/main/thread/pithread.cpp @@ -833,11 +833,11 @@ bool PIThread::waitForFinish(PISystemTime timeout) { } return true; } - tmf_.reset(); - while (tmf_.elapsed() < timeout) { + PITimeMeasurer tm; + while (tm.elapsed() < timeout) { if (_waitForFinish(PISystemTime::fromMilliseconds(PIP_MIN_MSLEEP))) return true; } - return tmf_.elapsed() < timeout; + return tm.elapsed() < timeout; } @@ -848,10 +848,10 @@ bool PIThread::waitForStart(PISystemTime timeout) { piMinSleep(); return true; } - tms_.reset(); - while (!running_ && tms_.elapsed() < timeout) + PITimeMeasurer tm; + while (!running_ && tm.elapsed() < timeout) piMinSleep(); - return tms_.elapsed() < timeout; + return tm.elapsed() < timeout; } @@ -950,10 +950,10 @@ void PIThread::__thread_func__() { // PICout(PICoutManipulators::DefaultControls) << "thread" << this << "wait" << "..."; PIINTROSPECTION_THREAD_WAIT(this); if (delay_.isNotNull()) { - tmr_.reset(); + PITimeMeasurer tm; double sl(0.); while (1) { - sl = piMind(delay_.toMilliseconds() - tmr_.elapsed_m(), PIP_MIN_MSLEEP); + sl = piMind(delay_.toMilliseconds() - tm.elapsed_m(), PIP_MIN_MSLEEP); if (terminating) break; if (sl <= 0.) break; piMSleep(sl); diff --git a/libs/main/thread/pithread.h b/libs/main/thread/pithread.h index 0e29754e..af97009e 100644 --- a/libs/main/thread/pithread.h +++ b/libs/main/thread/pithread.h @@ -288,7 +288,6 @@ protected: llong tid_ = -1; void * data_ = nullptr; mutable PIMutex thread_mutex; - PITimeMeasurer tmf_, tms_, tmr_; PIThread::Priority priority_ = piNormal; ThreadFunc ret_func = nullptr; PIThreadNotifier state_notifier; diff --git a/libs/main/types/pisystemtime.cpp b/libs/main/types/pisystemtime.cpp index 4cbb1e27..4d218968 100644 --- a/libs/main/types/pisystemtime.cpp +++ b/libs/main/types/pisystemtime.cpp @@ -317,6 +317,14 @@ PISystemTime PITimeMeasurer::elapsed() const { } +PISystemTime PITimeMeasurer::elapsedAndReset() { + auto ct = PISystemTime::current(true); + auto ret = ct - t_st; + t_st = ct; + return ret; +} + + // PISystemTime::Frequency PISystemTime PISystemTime::Frequency::toSystemTime() const { diff --git a/libs/main/types/pisystemtime.h b/libs/main/types/pisystemtime.h index e089b4b5..a68aceec 100644 --- a/libs/main/types/pisystemtime.h +++ b/libs/main/types/pisystemtime.h @@ -501,43 +501,24 @@ public: //! \~russian Возвращает в PISystemTime время, прошедшее с последнего вызова \a reset(), либо создания измерителя. PISystemTime elapsed() const; - double reset_time_n() const { return t_st.toNanoseconds(); } - double reset_time_u() const { return t_st.toMicroseconds(); } - double reset_time_m() const { return t_st.toMilliseconds(); } - double reset_time_s() const { return t_st.toSeconds(); } + //! \~\brief + //! \~english Returns PISystemTime elapsed from last \a reset() execution or from timer measurer creation and call \a reset(). + //! \~russian Возвращает в PISystemTime время, прошедшее с последнего вызова \a reset(), либо создания измерителя, и вызывает \a + //! reset(). + PISystemTime elapsedAndReset(); //! \~\brief //! \~english Returns time mark of last \a reset() execution or timer measurer creation. //! \~russian Возвращает отметку времени последнего вызова \a reset(), либо создания измерителя. - PISystemTime reset_time() { return t_st; } + PISystemTime reset_time() DEPRECATEDM("use PISystemTime::resetTime()") { return t_st; } //! \~\brief - //! \~english Returns nanoseconds representation of current system time. - //! \~russian Возвращает в наносекундах системное время. - static double elapsed_system_n() { return PISystemTime::current(true).toNanoseconds(); } - - //! \~\brief - //! \~english Returns microseconds representation of current system time. - //! \~russian Возвращает в микросекундах системное время. - static double elapsed_system_u() { return PISystemTime::current(true).toMicroseconds(); } - - //! \~\brief - //! \~english Returns milliseconds representation of current system time. - //! \~russian Возвращает в милисекундах системное время. - static double elapsed_system_m() { return PISystemTime::current(true).toMilliseconds(); } - - //! \~\brief - //! \~english Returns seconds representation of current system time. - //! \~russian Возвращает в секундах системное время. - static double elapsed_system_s() { return PISystemTime::current(true).toSeconds(); } - - //! \~\brief - //! \~english Returns time mark of current system time. - //! \~russian Возвращает системное время. - static PISystemTime elapsed_system() { return PISystemTime::current(true); } + //! \~english Returns time mark of last \a reset() execution or timer measurer creation. + //! \~russian Возвращает отметку времени последнего вызова \a reset(), либо создания измерителя. + PISystemTime resetTime() const { return t_st; } private: - PISystemTime t_st, t_cur; + PISystemTime t_st; }; #endif // PITIME_H diff --git a/utils/deploy_tool/main.cpp b/utils/deploy_tool/main.cpp index 72da03aa..1485d3bf 100644 --- a/utils/deploy_tool/main.cpp +++ b/utils/deploy_tool/main.cpp @@ -40,7 +40,7 @@ void setCommands() { cmd_copydir = "cp -rf "; ign_err_suffix = " 2> /dev/null"; # ifdef MAC_OS - qplatforms = "cocoa"; + qplatforms = "cocoa"; # else qplatforms = "xcb,wayland"; # endif @@ -381,7 +381,8 @@ void copyWildcard(const PIString & from, const PIString & to) { PIFile::FileInfo fi(from); system(("robocopy \"" + fi.dir() + "\" \"" + to + "\" \"" + fi.name() + "\" /E /NJH /NJS /NP /NDL /NS /NC /NFL 1> NUL").data()); #else - system((cmd_copy + from + " \"" + to + "/\"" + cmd_suffix).data()); + auto _r = system((cmd_copy + from + " \"" + to + "/\"" + cmd_suffix).data()); + NO_UNUSED(_r); #endif } @@ -797,13 +798,14 @@ int main(int argc, char * argv[]) { if (need_cp) { piCout << "copy" << l; if (!fake) { - system((cmd_copy + "\"" + l + "\" \"" + out_dir + "\"" + cmd_suffix).data()); + auto _r = system((cmd_copy + "\"" + l + "\" \"" + out_dir + "\"" + cmd_suffix).data()); if (strip.isNotEmpty()) { if (!otool.isEmpty()) // Apple - system((strip + " -S \"" + out_dir + fi.name() + "\"").data()); + _r = system((strip + " -S \"" + out_dir + fi.name() + "\"").data()); else - system((strip + " --strip-unneeded \"" + out_dir + fi.name() + "\"").data()); + _r = system((strip + " --strip-unneeded \"" + out_dir + fi.name() + "\"").data()); } + NO_UNUSED(_r); } } } @@ -812,7 +814,10 @@ int main(int argc, char * argv[]) { PIString fd = findLib(f); if (!fd.isEmpty()) { piCout << "copy framework" << f; - if (!fake) system((cmd_copydir + "\"" + fd + "\" \"" + out_dir + "\"" + cmd_suffix).data()); + if (!fake) { + auto _r = system((cmd_copydir + "\"" + fd + "\" \"" + out_dir + "\"" + cmd_suffix).data()); + NO_UNUSED(_r); + } } else miss_frameworks << f; }