Fix compilation problems due to stat64() on Apple Silicon #33

Closed
opened 2022-05-29 18:48:24 +00:00 by a-j-wood · 2 comments
a-j-wood commented 2022-05-29 18:48:24 +00:00 (Migrated from github.com)

Date: Mon, 04 Jan 2021 19:25:25 +0100
From: Filippo Valsorda
Subject: PATCH: make pv compile on Apple Silicon

Since macOS 10.6, stat64 variants are equivalent to plain stat, and the suffixed versions have been removed in macOS 11 (although apparently only running on Apple Silicon). See stat(2).

diff --git a/src/include/pv-internal.h b/src/include/pv-internal.h
index 46d7496..fed25fe 100644
--- a/src/include/pv-internal.h
+++ b/src/include/pv-internal.h
@@ -18,6 +18,14 @@
#include <sys/time.h>
#include <sys/stat.h>

+// Since macOS 10.6, stat64 variants are equivalent to plain stat, and the
+// suffixed versions have been removed in macOS 11. See stat(2).
+#ifdef APPLE
+#define stat64 stat
+#define fstat64 fstat
+#define lstat64 lstat
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif

Date: Mon, 04 Jan 2021 19:25:25 +0100 From: Filippo Valsorda Subject: PATCH: make pv compile on Apple Silicon Since macOS 10.6, stat64 variants are equivalent to plain stat, and the suffixed versions have been removed in macOS 11 (although apparently only running on Apple Silicon). See stat(2). diff --git a/src/include/pv-internal.h b/src/include/pv-internal.h index 46d7496..fed25fe 100644 --- a/src/include/pv-internal.h +++ b/src/include/pv-internal.h @@ -18,6 +18,14 @@ #include <sys/time.h> #include <sys/stat.h> +// Since macOS 10.6, stat64 variants are equivalent to plain stat, and the +// suffixed versions have been removed in macOS 11. See stat(2). +#ifdef __APPLE__ +#define stat64 stat +#define fstat64 fstat +#define lstat64 lstat +#endif + #ifdef __cplusplus extern "C" { #endif
demitri commented 2023-05-07 03:57:53 +00:00 (Migrated from github.com)

That patch worked for me, except to change

#ifdef APPLE

to

#if defined(__APPLE__)
That patch worked for me, except to change ```c #ifdef APPLE ``` to ```c #if defined(__APPLE__) ```
a-j-wood commented 2023-07-17 20:36:56 +00:00 (Migrated from github.com)

Thanks @FiloSottile and @demitri, changes for this will be in the next release after 1.6.20.

Thanks @FiloSottile and @demitri, changes for this will be in the next release after 1.6.20.
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: a-j-wood/pv#33
There is no content yet.