<pre style='margin:0'>
Christopher Nielsen (mascguy) pushed a commit to branch master
in repository macports-legacy-support.
</pre>
<p><a href="https://github.com/macports/macports-legacy-support/commit/55fd6e3f580f62c2528120fb904238127227e64d">https://github.com/macports/macports-legacy-support/commit/55fd6e3f580f62c2528120fb904238127227e64d</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 55fd6e3f580f62c2528120fb904238127227e64d
</span>Author: Fred Wright <fw@fwright.net>
AuthorDate: Sun Dec 1 16:42:32 2024 -0800
<span style='display:block; white-space:pre;color:#404040;'> Support scandir-compatibility alternatives.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> See the expanded comment in dirent.h.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> TESTED:
</span><span style='display:block; white-space:pre;color:#404040;'> Tests (including relevant update) pass on all platforms.
</span>---
include/dirent.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 49 insertions(+), 6 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/include/dirent.h b/include/dirent.h
</span><span style='display:block; white-space:pre;color:#808080;'>index 5f06891..21e9b0b 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/include/dirent.h
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/include/dirent.h
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -47,16 +47,16 @@ __MP__END_DECLS
</span> #endif /* __MPLS_SDK_SUPPORT_FDOPENDIR__ */
/* new signature for scandir and alphasort (optionally) */
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#if __MPLS_SDK_SUPPORT_NEW_SCANDIR__ \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- && defined(_MACPORTS_LEGACY_COMPATIBLE_SCANDIR) \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- && _MACPORTS_LEGACY_COMPATIBLE_SCANDIR
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if __MPLS_SDK_SUPPORT_NEW_SCANDIR__
</span>
/*
* Here we provide compatibility wrappers so that scandir and alphasort
* references based on the new function signatures can be used with the
* old versions of the functions. To avoid breaking code expecting the
<span style='display:block; white-space:pre;background:#ffe0e0;'>- * normal behavior, these wrappers are only introduced conditionally,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * based on _MACPORTS_LEGACY_COMPATIBLE_SCANDIR being nonzero.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * normal behavior, the wrapper macros are only introduced conditionally,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * based on _MACPORTS_LEGACY_COMPATIBLE_SCANDIR being nonzero. The wrapper
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * *functions* are defined unconditionally, since, by themselves, they don't
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * introduce a conflict.
</span> *
* The wrapper functions are defined as inlines, and then macros are
* defined to make them replace the normal functions. Since the sole
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -71,6 +71,24 @@ __MP__END_DECLS
</span> * directed as appropriate. In the function pointer case, any local
* callable instance is private to the compilation unit, and need only
* handle the INODE64 case in effect there.
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * It's possible that some clients will have issues with the wrapper macros,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * since they're defined as simple macros which could match other uses of
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * the same identifiers (e.g. stucture elements). This could be avoided by
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * using function macros, but those wouldn't work in contexts where taking
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * pointers to them is required. Instead, we provide the following for
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * alternative approaches:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * 1) The wrapper *functions* are defined for all SDK versions, so that they
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * may be used without version tests. With newer SDKs, they are simple
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * transparent wrappers with no casts.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * 2) The macro _MACPORTS_LEGACY_OLD_SCANDIR is provided as the condition
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * where the compatibility issue exists, to allow conditional workarounds
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * without the need for (direct) awareness of SDK versions. This macro
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * is defined for all SDK versions, but only nonzero when the signature
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * issue exists.
</span> */
__MP__BEGIN_DECLS
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -97,11 +115,36 @@ __mpls_scandir(const char *dirname, struct dirent ***namelist,
</span>
__MP__END_DECLS
<span style='display:block; white-space:pre;background:#e0ffe0;'>+/* Define the wrapper macros if requested */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if defined(_MACPORTS_LEGACY_COMPATIBLE_SCANDIR) \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ && _MACPORTS_LEGACY_COMPATIBLE_SCANDIR
</span> #define alphasort __mpls_alphasort
#define scandir __mpls_scandir
<span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#else /* !__MPLS_SDK_SUPPORT_NEW_SCANDIR__ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* Dummy wrapper functions without unnecessary casts */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+static inline int
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+__mpls_alphasort(const struct dirent **d1, const struct dirent **d2)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return alphasort(d1, d2);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#endif /* __MPLS_SDK_SUPPORT_NEW_SCANDIR__ && ... */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+static inline int
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+__mpls_scandir(const char *dirname, struct dirent ***namelist,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int (*select)(const struct dirent *),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int (*compar)(const struct dirent **, const struct dirent **))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return scandir(dirname, namelist, select, compar);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* !__MPLS_SDK_SUPPORT_NEW_SCANDIR__ */
</span>
#endif /* __DARWIN_C_LEVEL >= 200809L */
<span style='display:block; white-space:pre;background:#e0ffe0;'>+/* Provide a testable condition for the scandir signature issue. */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define _MACPORTS_LEGACY_OLD_SCANDIR __MPLS_SDK_SUPPORT_NEW_SCANDIR__
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> #endif /* _MACPORTS_DIRENT_H_ */
</pre><pre style='margin:0'>
</pre>