aboutsummaryrefslogtreecommitdiff
path: root/src/xz/mytime.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2023-10-22xz/Windows: Allow clock_gettime with POSIX threads.Lasse Collin1-3/+6
If winpthreads are used for threading, it's OK to use clock_gettime() from winpthreads too.
2023-10-22xz/Windows: Ensure that clock_gettime() isn't used with MinGW-w64.Lasse Collin1-2/+7
This commit alone doesn't change anything in the real-world: - configure.ac currently checks for clock_gettime() only when using pthreads. - CMakeLists.txt doesn't check for clock_gettime() on Windows. So clock_gettime() wasn't used with MinGW-w64 before either. clock_gettime() provides monotonic time and it's better than gettimeofday() in this sense. But clock_gettime() is defined in winpthreads, and liblzma or xz needs nothing else from winpthreads. By avoiding clock_gettime(), we avoid the dependency on libwinpthread-1.dll or the need to link against the static version. As a bonus, GetTickCount64() and MinGW-w64's gettimeofday() can be faster than clock_gettime(CLOCK_MONOTONIC, &tv). The resolution is more than good enough for the progress indicator in xz.
2023-10-22xz/Windows: Use GetTickCount64() with MinGW-w64 if using Vista threads.Lasse Collin1-3/+11
2023-09-22MSVC: xz: Use GetTickCount64() to implement mytime_now().Lasse Collin1-2/+9
It's available since Windows Vista.
2023-02-07xz: Improve the comment about start_time in mytime.c.Lasse Collin1-5/+10
start_time is relative to an arbitary point in time, it's not time of day, so using it for anything else than time differences wouldn't make sense.
2023-02-04xz: Add a comment clarifying the use of start_time in mytime.c.Jia Tan1-0/+5
2023-01-27xz: Use clock_gettime() even if CLOCK_MONOTONIC isn't available.Lasse Collin1-3/+8
mythread.h and thus liblzma already does it.
2023-01-27xz: Add SIGTSTP handler for progress indicator time keeping.Lasse Collin1-1/+55
This way, if xz is stopped the elapsed time and estimated time remaining won't get confused by the amount of time spent in the stopped state. This raises SIGSTOP. It's not clear to me if this is the correct way. POSIX and glibc docs say that SIGTSTP shouldn't stop the process if it is orphaned but this commit doesn't attempt to handle that. Search for SIGTSTP in section 2.4.3: https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html
2022-12-30xz: Includes <time.h> and <sys/time.h> conditionally in mytime.c.Jia Tan1-1/+3
Previously, mytime.c depended on mythread.h for <time.h> to be included.
2022-12-30Build: No longer require HAVE_DECL_CLOCK_MONOTONIC to always be set.Jia Tan1-3/+2
Previously, if threading was enabled HAVE_DECL_CLOCK_MONOTONIC would always be set to 0 or 1. However, this macro was needed in xz so if xz was not built with threading and HAVE_DECL_CLOCK_MONOTONIC was not defined but HAVE_CLOCK_GETTIME was, it caused a warning during build. Now, HAVE_DECL_CLOCK_MONOTONIC has been renamed to HAVE_CLOCK_MONOTONIC and will only be set if it is 1.
2020-01-26xz: Set the --flush-timeout deadline when the first input byte arrives.Lasse Collin1-1/+0
xz --flush-timeout=2000, old version: 1. xz is started. The next flush will happen after two seconds. 2. No input for one second. 3. A burst of a few kilobytes of input. 4. No input for one second. 5. Two seconds have passed and flushing starts. The first second counted towards the flush-timeout even though there was no pending data. This can cause flushing to occur more often than needed. xz --flush-timeout=2000, after this commit: 1. xz is started. 2. No input for one second. 3. A burst of a few kilobytes of input. The next flush will happen after two seconds counted from the time when the first bytes of the burst were read. 4. No input for one second. 5. No input for another second. 6. Two seconds have passed and flushing starts.
2020-01-26xz: Move flush_needed from mytime.h to file_pair struct in file_io.h.Lasse Collin1-3/+0
2019-06-23xz: Fix some of the warnings from -Wsign-conversion.Lasse Collin1-2/+2
2013-07-04xz: Move some of the timing code into mytime.[hc].Lasse Collin1-0/+89
This switches units from microseconds to milliseconds. New clock_gettime(CLOCK_MONOTONIC) will be used if available. There is still a fallback to gettimeofday().