Blame SOURCES/0156-Introduce-GLIBC_PREREQ_GE-and-GLIBC_PREREQ_LT-macros.patch

242c1e
From 21bbf3a53b8be9b3fe90bcdb66c7ded35bc3e344 Mon Sep 17 00:00:00 2001
242c1e
From: "Dmitry V. Levin" <ldv@altlinux.org>
242c1e
Date: Sat, 12 Sep 2020 08:00:00 +0000
242c1e
Subject: [PATCH 156/162] Introduce GLIBC_PREREQ_GE and GLIBC_PREREQ_LT macros
242c1e
242c1e
* gcc_compat.h (GLIBC_PREREQ_GE, GLIBC_PREREQ_LT): New macros.
242c1e
* tests/ipc_msg.c: Use GLIBC_PREREQ_LT instead of manual checking
242c1e
for __GLIBC__ and __GLIBC_MINOR__.
242c1e
* tests/readahead.c: Likewise.
242c1e
---
242c1e
 gcc_compat.h      | 15 +++++++++++++++
242c1e
 tests/ipc_msg.c   |  9 +++------
242c1e
 tests/readahead.c | 16 ++++++----------
242c1e
 3 files changed, 24 insertions(+), 16 deletions(-)
242c1e
242c1e
diff --git a/gcc_compat.h b/gcc_compat.h
242c1e
index 0525b5e..4c23ebc 100644
242c1e
--- a/gcc_compat.h
242c1e
+++ b/gcc_compat.h
242c1e
@@ -23,6 +23,21 @@
242c1e
 #  define CLANG_PREREQ(maj, min)	0
242c1e
 # endif
242c1e
 
242c1e
+# ifdef __GLIBC__
242c1e
+#  ifdef __GLIBC_MINOR__
242c1e
+#   define GLIBC_PREREQ_GE(maj, min)	\
242c1e
+	((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))
242c1e
+#   define GLIBC_PREREQ_LT(maj, min)	\
242c1e
+	((__GLIBC__ << 16) + __GLIBC_MINOR__ < ((maj) << 16) + (min))
242c1e
+#  else /* !__GLIBC_MINOR__ */
242c1e
+#   define GLIBC_PREREQ_GE(maj, min)	0
242c1e
+#   define GLIBC_PREREQ_LT(maj, min)	1
242c1e
+#  endif
242c1e
+# else /* !__GLIBC__ */
242c1e
+#  define GLIBC_PREREQ_GE(maj, min)	0
242c1e
+#  define GLIBC_PREREQ_LT(maj, min)	0
242c1e
+# endif
242c1e
+
242c1e
 # if !(GNUC_PREREQ(2, 0) || CLANG_PREREQ(1, 0))
242c1e
 #  define __attribute__(x)	/* empty */
242c1e
 # endif
242c1e
diff --git a/tests/ipc_msg.c b/tests/ipc_msg.c
242c1e
index 63bdd77..dd0f303 100644
242c1e
--- a/tests/ipc_msg.c
242c1e
+++ b/tests/ipc_msg.c
242c1e
@@ -26,12 +26,9 @@
242c1e
  * which led to segmentation fault.
242c1e
  */
242c1e
 #undef TEST_MSGCTL_BOGUS_ADDR
242c1e
-#if defined __GLIBC__ && (defined POWERPC64 || defined POWERPC64LE)
242c1e
-# if !(defined __GLIBC_MINOR__) \
242c1e
-   || ((__GLIBC__ << 16) + __GLIBC_MINOR__ < (2 << 16) + 23)
242c1e
-#  define TEST_MSGCTL_BOGUS_ADDR 0
242c1e
-# endif
242c1e
-#endif /* __GLIBC__ && (POWERPC64 || POWERPC64LE) */
242c1e
+#if GLIBC_PREREQ_LT(2, 23) && (defined POWERPC64 || defined POWERPC64LE)
242c1e
+# define TEST_MSGCTL_BOGUS_ADDR 0
242c1e
+#endif
242c1e
 
242c1e
 #ifndef TEST_MSGCTL_BOGUS_ADDR
242c1e
 # define TEST_MSGCTL_BOGUS_ADDR 1
242c1e
diff --git a/tests/readahead.c b/tests/readahead.c
242c1e
index 86d09b0..6f4b81e 100644
242c1e
--- a/tests/readahead.c
242c1e
+++ b/tests/readahead.c
242c1e
@@ -11,24 +11,20 @@
242c1e
 
242c1e
 #ifdef HAVE_READAHEAD
242c1e
 /* Check for glibc readahead argument passing bugs. */
242c1e
-# ifdef __GLIBC__
242c1e
 /*
242c1e
  * glibc < 2.8 had an incorrect order of higher and lower parts of offset,
242c1e
  * see https://sourceware.org/bugzilla/show_bug.cgi?id=5208
242c1e
  */
242c1e
-#  if !(defined __GLIBC_MINOR__ && \
242c1e
-	(__GLIBC__ << 16) + __GLIBC_MINOR__ >= (2 << 16) + 8)
242c1e
-#   undef HAVE_READAHEAD
242c1e
-#  endif /* glibc < 2.8 */
242c1e
+# if GLIBC_PREREQ_LT(2, 8)
242c1e
+#  undef HAVE_READAHEAD
242c1e
+# endif /* glibc < 2.8 */
242c1e
 /*
242c1e
  * glibc < 2.25 had an incorrect implementation on mips n64,
242c1e
  * see https://sourceware.org/bugzilla/show_bug.cgi?id=21026
242c1e
  */
242c1e
-#  if defined LINUX_MIPSN64 && !(defined __GLIBC_MINOR__ && \
242c1e
-	(__GLIBC__ << 16) + __GLIBC_MINOR__ >= (2 << 16) + 25)
242c1e
-#   undef HAVE_READAHEAD
242c1e
-#  endif /* LINUX_MIPSN64 && glibc < 2.25 */
242c1e
-# endif /* __GLIBC__ */
242c1e
+# if GLIBC_PREREQ_LT(2, 25) && defined LINUX_MIPSN64
242c1e
+#  undef HAVE_READAHEAD
242c1e
+# endif /* LINUX_MIPSN64 && glibc < 2.25 */
242c1e
 #endif /* HAVE_READAHEAD */
242c1e
 
242c1e
 #ifdef HAVE_READAHEAD
242c1e
diff --git a/tests-m32/ipc_msg.c b/tests-m32/ipc_msg.c
242c1e
index 63bdd77..dd0f303 100644
242c1e
--- a/tests-m32/ipc_msg.c
242c1e
+++ b/tests-m32/ipc_msg.c
242c1e
@@ -26,12 +26,9 @@
242c1e
  * which led to segmentation fault.
242c1e
  */
242c1e
 #undef TEST_MSGCTL_BOGUS_ADDR
242c1e
-#if defined __GLIBC__ && (defined POWERPC64 || defined POWERPC64LE)
242c1e
-# if !(defined __GLIBC_MINOR__) \
242c1e
-   || ((__GLIBC__ << 16) + __GLIBC_MINOR__ < (2 << 16) + 23)
242c1e
-#  define TEST_MSGCTL_BOGUS_ADDR 0
242c1e
-# endif
242c1e
-#endif /* __GLIBC__ && (POWERPC64 || POWERPC64LE) */
242c1e
+#if GLIBC_PREREQ_LT(2, 23) && (defined POWERPC64 || defined POWERPC64LE)
242c1e
+# define TEST_MSGCTL_BOGUS_ADDR 0
242c1e
+#endif
242c1e
 
242c1e
 #ifndef TEST_MSGCTL_BOGUS_ADDR
242c1e
 # define TEST_MSGCTL_BOGUS_ADDR 1
242c1e
diff --git a/tests-m32/readahead.c b/tests-m32/readahead.c
242c1e
index 86d09b0..6f4b81e 100644
242c1e
--- a/tests-m32/readahead.c
242c1e
+++ b/tests-m32/readahead.c
242c1e
@@ -11,24 +11,20 @@
242c1e
 
242c1e
 #ifdef HAVE_READAHEAD
242c1e
 /* Check for glibc readahead argument passing bugs. */
242c1e
-# ifdef __GLIBC__
242c1e
 /*
242c1e
  * glibc < 2.8 had an incorrect order of higher and lower parts of offset,
242c1e
  * see https://sourceware.org/bugzilla/show_bug.cgi?id=5208
242c1e
  */
242c1e
-#  if !(defined __GLIBC_MINOR__ && \
242c1e
-	(__GLIBC__ << 16) + __GLIBC_MINOR__ >= (2 << 16) + 8)
242c1e
-#   undef HAVE_READAHEAD
242c1e
-#  endif /* glibc < 2.8 */
242c1e
+# if GLIBC_PREREQ_LT(2, 8)
242c1e
+#  undef HAVE_READAHEAD
242c1e
+# endif /* glibc < 2.8 */
242c1e
 /*
242c1e
  * glibc < 2.25 had an incorrect implementation on mips n64,
242c1e
  * see https://sourceware.org/bugzilla/show_bug.cgi?id=21026
242c1e
  */
242c1e
-#  if defined LINUX_MIPSN64 && !(defined __GLIBC_MINOR__ && \
242c1e
-	(__GLIBC__ << 16) + __GLIBC_MINOR__ >= (2 << 16) + 25)
242c1e
-#   undef HAVE_READAHEAD
242c1e
-#  endif /* LINUX_MIPSN64 && glibc < 2.25 */
242c1e
-# endif /* __GLIBC__ */
242c1e
+# if GLIBC_PREREQ_LT(2, 25) && defined LINUX_MIPSN64
242c1e
+#  undef HAVE_READAHEAD
242c1e
+# endif /* LINUX_MIPSN64 && glibc < 2.25 */
242c1e
 #endif /* HAVE_READAHEAD */
242c1e
 
242c1e
 #ifdef HAVE_READAHEAD
242c1e
diff --git a/tests-mx32/ipc_msg.c b/tests-mx32/ipc_msg.c
242c1e
index 63bdd77..dd0f303 100644
242c1e
--- a/tests-mx32/ipc_msg.c
242c1e
+++ b/tests-mx32/ipc_msg.c
242c1e
@@ -26,12 +26,9 @@
242c1e
  * which led to segmentation fault.
242c1e
  */
242c1e
 #undef TEST_MSGCTL_BOGUS_ADDR
242c1e
-#if defined __GLIBC__ && (defined POWERPC64 || defined POWERPC64LE)
242c1e
-# if !(defined __GLIBC_MINOR__) \
242c1e
-   || ((__GLIBC__ << 16) + __GLIBC_MINOR__ < (2 << 16) + 23)
242c1e
-#  define TEST_MSGCTL_BOGUS_ADDR 0
242c1e
-# endif
242c1e
-#endif /* __GLIBC__ && (POWERPC64 || POWERPC64LE) */
242c1e
+#if GLIBC_PREREQ_LT(2, 23) && (defined POWERPC64 || defined POWERPC64LE)
242c1e
+# define TEST_MSGCTL_BOGUS_ADDR 0
242c1e
+#endif
242c1e
 
242c1e
 #ifndef TEST_MSGCTL_BOGUS_ADDR
242c1e
 # define TEST_MSGCTL_BOGUS_ADDR 1
242c1e
diff --git a/tests-mx32/readahead.c b/tests-mx32/readahead.c
242c1e
index 86d09b0..6f4b81e 100644
242c1e
--- a/tests-mx32/readahead.c
242c1e
+++ b/tests-mx32/readahead.c
242c1e
@@ -11,24 +11,20 @@
242c1e
 
242c1e
 #ifdef HAVE_READAHEAD
242c1e
 /* Check for glibc readahead argument passing bugs. */
242c1e
-# ifdef __GLIBC__
242c1e
 /*
242c1e
  * glibc < 2.8 had an incorrect order of higher and lower parts of offset,
242c1e
  * see https://sourceware.org/bugzilla/show_bug.cgi?id=5208
242c1e
  */
242c1e
-#  if !(defined __GLIBC_MINOR__ && \
242c1e
-	(__GLIBC__ << 16) + __GLIBC_MINOR__ >= (2 << 16) + 8)
242c1e
-#   undef HAVE_READAHEAD
242c1e
-#  endif /* glibc < 2.8 */
242c1e
+# if GLIBC_PREREQ_LT(2, 8)
242c1e
+#  undef HAVE_READAHEAD
242c1e
+# endif /* glibc < 2.8 */
242c1e
 /*
242c1e
  * glibc < 2.25 had an incorrect implementation on mips n64,
242c1e
  * see https://sourceware.org/bugzilla/show_bug.cgi?id=21026
242c1e
  */
242c1e
-#  if defined LINUX_MIPSN64 && !(defined __GLIBC_MINOR__ && \
242c1e
-	(__GLIBC__ << 16) + __GLIBC_MINOR__ >= (2 << 16) + 25)
242c1e
-#   undef HAVE_READAHEAD
242c1e
-#  endif /* LINUX_MIPSN64 && glibc < 2.25 */
242c1e
-# endif /* __GLIBC__ */
242c1e
+# if GLIBC_PREREQ_LT(2, 25) && defined LINUX_MIPSN64
242c1e
+#  undef HAVE_READAHEAD
242c1e
+# endif /* LINUX_MIPSN64 && glibc < 2.25 */
242c1e
 #endif /* HAVE_READAHEAD */
242c1e
 
242c1e
 #ifdef HAVE_READAHEAD
242c1e
-- 
242c1e
2.1.4
242c1e