All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: linux-ext4@vger.kernel.org
Subject: [e2fsprogs PATCH] lib/support: don't assume qsort_r() is always available on Linux
Date: Mon, 30 Jan 2023 21:58:29 +0000	[thread overview]
Message-ID: <20230130215829.863455-1-ebiggers@kernel.org> (raw)

From: Eric Biggers <ebiggers@google.com>

Since commit 4e5f24ae4267 ("Use an autoconf test to detect for a BSD- or
GNU-style qsort_r function"), e2fsck fails to build for Android because
lib/support/sort_r.h assumes that qsort_r() is always available on
"Linux", but in fact it's not supported by Android's libc.

Rename _SORT_R_LINUX to _SORT_R_GNU to clarify that it's really the
glibc convention for qsort_r(), not the "Linux" convention per se, and
make sort_r.h stop setting it automatically when __linux__ is defined.

Note: this change does *not* prevent glibc's qsort_r() from being used
when e2fsprogs is built using the autotools-based build system, as
'configure' checks for qsort_r() too.  This change just affects the
fallback behavior for when qsort_r() was not already detected.

Fixes: 4e5f24ae4267 ("Use an autoconf test to detect for a BSD- or GNU-style qsort_r function")
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 lib/support/sort_r.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/support/sort_r.h b/lib/support/sort_r.h
index ebf78378..8473ca83 100644
--- a/lib/support/sort_r.h
+++ b/lib/support/sort_r.h
@@ -25,12 +25,12 @@ void sort_r(void *base, size_t nel, size_t width,
 #define _SORT_R_INLINE inline
 
 #if (defined HAVE_GNU_QSORT_R)
-#  define _SORT_R_LINUX
+#  define _SORT_R_GNU
 #elif (defined HAVE_BSD_QSORT_R)
 #  define _SORT_R_BSD
 #elif (defined __gnu_hurd__ || defined __GNU__ || \
-       defined __linux__ || defined __MINGW32__ || defined __GLIBC__)
-#  define _SORT_R_LINUX
+       defined __MINGW32__ || defined __GLIBC__)
+#  define _SORT_R_GNU
 #elif (defined __APPLE__ || defined __MACH__ || defined __DARWIN__ || \
      defined __FreeBSD__ || defined __DragonFly__)
 #  define _SORT_R_BSD
@@ -264,7 +264,7 @@ static _SORT_R_INLINE void sort_r_simple(void *base, size_t nel, size_t w,
 
   #endif
 
-  #if defined _SORT_R_LINUX
+  #if defined _SORT_R_GNU
 
     typedef int(* __compar_d_fn_t)(const void *, const void *, void *);
     extern void qsort_r(void *base, size_t nel, size_t width,
@@ -280,7 +280,7 @@ static _SORT_R_INLINE void sort_r_simple(void *base, size_t nel, size_t w,
                                                   const void *_b, void *_arg),
                                     void *arg)
   {
-    #if defined _SORT_R_LINUX
+    #if defined _SORT_R_GNU
 
       #if defined __GLIBC__ && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 8))
 
@@ -319,7 +319,7 @@ static _SORT_R_INLINE void sort_r_simple(void *base, size_t nel, size_t w,
 
 #undef _SORT_R_INLINE
 #undef _SORT_R_WINDOWS
-#undef _SORT_R_LINUX
+#undef _SORT_R_GNU
 #undef _SORT_R_BSD
 
 #endif /* SORT_R_H_ */

base-commit: b0101535a35c07975227128875204fab07e72996
-- 
2.39.1.456.gfc5497dd1b-goog


             reply	other threads:[~2023-01-30 21:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-30 21:58 Eric Biggers [this message]
2023-02-01  5:54 ` [e2fsprogs PATCH] lib/support: don't assume qsort_r() is always available on Linux Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230130215829.863455-1-ebiggers@kernel.org \
    --to=ebiggers@kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.