From f13f5e70c1b84cd748cd9e12d55251d78449e1b6 Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Mon, 17 Jul 2023 21:37:54 +0100 Subject: [PATCH] More macOS stat fixes --- doc/NEWS.md | 1 + doc/TODO.md | 1 - src/include/pv-internal.h | 10 ++++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/NEWS.md b/doc/NEWS.md index 49181ff..0b103aa 100644 --- a/doc/NEWS.md +++ b/doc/NEWS.md @@ -7,6 +7,7 @@ UNRELEASED * feature: the "`--watchfd`" option will now show relative filenames, if they are under the current directory (pull request [#66](https://github.com/a-j-wood/pv/pull/66) supplied by [ikasty](https://github.com/ikasty)) * fix: correction to `pv_in_foreground()` to behave as its comment block says it should, when not on a terminal - corrects [GH#19 "No output in Arch Linux initcpio after 1.6.6"](https://github.com/a-j-wood/pv/issues/19), [GH#31 "No output written from inside zsh <() construct"](https://github.com/a-j-wood/pv/issues/31), [GH#55 "pv Stopped Working in the Background"](https://github.com/a-j-wood/pv/issues/55) (pull request [#64](https://github.com/a-j-wood/pv/pull/64) supplied by [Michael Weiß](https://github.com/quitschbo)) * fix: workaround for OS X 11 behaviour in configure script regarding stat64 at compile time (pull request [#57](https://github.com/a-j-wood/pv/pull/57) supplied by [Dave Beckett](https://github.com/dajobe)) + * fix: workaround for macOS equivalence of stat to stat64 - patches from [Filippo Valsorda](https://github.com/FiloSottile) and [Demitri Muna](https://github.com/demitri), correcting [GH#33 "Fix compilation problems due to `stat64()` on Apple Silicon"](https://github.com/a-j-wood/pv/issues/33) * fix: add burst rate limit to transfer, so rate limits are not broken by bursty traffic (pull request [#62](https://github.com/a-j-wood/pv/pull/62) supplied by [Volodymyr Bychkovyak](https://github.com/vbychkoviak)) * fix: corrected "`--force`" option so it will still output progress when not in the same process group as the owner of the terminal - corrects [GH#23 "No output with "`-f`" when run in background after 1.6.6"](https://github.com/a-j-wood/pv/issues/23) and helps to correct [GH#31 "No output written from inside zsh <() construct"](https://github.com/a-j-wood/pv/issues/31) * fix: corrected elapsed time display to show as D:HH:MM:SS after 1 day, like the ETA does - corrects [GH#16 "Show days in same format in ETA as in elapsed time"](https://github.com/a-j-wood/pv/issues/16) diff --git a/doc/TODO.md b/doc/TODO.md index a407e0b..d2b1f3c 100644 --- a/doc/TODO.md +++ b/doc/TODO.md @@ -7,7 +7,6 @@ Bugs * ([GH#13](https://github.com/a-j-wood/pv/issues/13)) Use `clock_gettime()` in ETA calculation to cope with machine suspend/resume (Mateju Miroslav) * ([GH#20](https://github.com/a-j-wood/pv/issues/20)) Terminal state is not restored correctly in all cases (VA) * ([GH#24](https://github.com/a-j-wood/pv/issues/24)) Race condition with multiple "`pv -c`" leaves terminal state inconsistent (Lars Ellenberg, Viktor Ashirov) - * ([GH#33](https://github.com/a-j-wood/pv/issues/33)) Fix compilation problems due to `stat64()` on Apple Silicon (Filippo Valsorda - Jan 2021) * ([GH#34](https://github.com/a-j-wood/pv/issues/34)) Continue timer even if input or output is blocking (Martin Probst - Jun 2017) Feature requests diff --git a/src/include/pv-internal.h b/src/include/pv-internal.h index 04d9d58..87af94a 100644 --- a/src/include/pv-internal.h +++ b/src/include/pv-internal.h @@ -18,6 +18,16 @@ #include #include +/* + * Since macOS 10.6, stat64 variants are equivalent to plain stat, and the + * suffixed versions have been removed in macOS 11. See stat(2). + */ +#if defined(__APPLE__) || defined(APPLE) +#define stat64 stat +#define fstat64 fstat +#define lstat64 lstat +#endif + #ifdef __cplusplus extern "C" { #endif