-
Notifications
You must be signed in to change notification settings - Fork 9.8k
include gettimeofday.h to installed headers #2038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
|
Can |
Line 844 in dba7f45
|
No,
|
I did not test it deeply, but is seems this could get rid of gettimeofday: diff --git a/src/ccutil/ocrclass.h b/src/ccutil/ocrclass.h
index 77272c4b..8d1a9cb8 100644
--- a/src/ccutil/ocrclass.h
+++ b/src/ccutil/ocrclass.h
@@ -26,15 +26,8 @@
#ifndef CCUTIL_OCRCLASS_H_
#define CCUTIL_OCRCLASS_H_
-
-#ifndef __GNUC__
-#ifdef _WIN32
-#include "gettimeofday.h"
-#endif
-#else
-#include <sys/time.h>
-#endif
#include <ctime>
+#include <chrono>
#include "host.h"
/*Maximum lengths of various strings*/
@@ -130,7 +123,8 @@ class ETEXT_DESC { // output header
PROGRESS_FUNC progress_callback; /// called whenever progress increases
PROGRESS_FUNC2 progress_callback2;/// monitor-aware progress callback
void* cancel_this; /// this or other data for cancel
- struct timeval end_time; /// Time to stop. Expected to be set only
+ std::chrono::steady_clock::time_point end_time;
+ /// Time to stop. Expected to be set only
/// by call to set_deadline_msecs().
EANYCODE_CHAR text[1]; /// character data
@@ -144,29 +138,25 @@ class ETEXT_DESC { // output header
progress_callback(nullptr),
progress_callback2(&default_progress_func),
cancel_this(nullptr) {
- end_time.tv_sec = 0;
- end_time.tv_usec = 0;
+ end_time = std::chrono::time_point<std::chrono::steady_clock,
+ std::chrono::milliseconds>();
}
// Sets the end time to be deadline_msecs milliseconds from now.
void set_deadline_msecs(int32_t deadline_msecs) {
- gettimeofday(&end_time, nullptr);
- int32_t deadline_secs = deadline_msecs / 1000;
- end_time.tv_sec += deadline_secs;
- end_time.tv_usec += (deadline_msecs - deadline_secs * 1000) * 1000;
- if (end_time.tv_usec > 1000000) {
- end_time.tv_usec -= 1000000;
- ++end_time.tv_sec;
+ if (deadline_msecs > 0) {
+ end_time = std::chrono::steady_clock::now() +
+ std::chrono::milliseconds(deadline_msecs);
}
}
// Returns false if we've not passed the end_time, or have not set a deadline.
bool deadline_exceeded() const {
- if (end_time.tv_sec == 0 && end_time.tv_usec == 0) return false;
- struct timeval now;
- gettimeofday(&now, nullptr);
- return (now.tv_sec > end_time.tv_sec || (now.tv_sec == end_time.tv_sec &&
- now.tv_usec > end_time.tv_usec));
+ if (end_time.time_since_epoch() ==
+ std::chrono::steady_clock::duration::zero())
+ return false;
+ auto now = std::chrono::steady_clock::now();
+ return (now > end_time);
}
private: |
quick observation: tessedit.h only declares |
Pull request #2045 addresses this issue by eliminating |
gettimeofday.h in not part of installed headers (neither via cmake or autotools), but it is included in installed header ocrclass.h.
So using
ocrclass.h
on windows will cause error about missing header file.The text was updated successfully, but these errors were encountered: