adenilson / rpms / zlib

Forked from rpms/zlib 8 months ago
Clone
3d619b
From 480b65cae6c20a41aa698a6c9d3b260f6f744004 Mon Sep 17 00:00:00 2001
3d619b
From: Ilya Leoshkevich <iii@linux.ibm.com>
3d619b
Date: Thu, 2 Feb 2023 19:41:32 +0100
3d619b
Subject: [PATCH] 0003-PATCH-Fix-clang-s-behavior-on-versions-7.patch
3d619b
3d619b
---
3d619b
 contrib/power/clang_workaround.h | 15 ++++++++++-----
3d619b
 1 file changed, 10 insertions(+), 5 deletions(-)
3d619b
3d619b
diff --git a/contrib/power/clang_workaround.h b/contrib/power/clang_workaround.h
3d619b
index b5e7dae..915f7e5 100644
3d619b
--- a/contrib/power/clang_workaround.h
3d619b
+++ b/contrib/power/clang_workaround.h
3d619b
@@ -39,7 +39,12 @@ __vector unsigned long long  __builtin_pack_vector (unsigned long __a,
3d619b
 	return __v;
3d619b
 }
3d619b
 
3d619b
-#ifndef vec_xxpermdi
3d619b
+/*
3d619b
+ * Clang 7 changed the behavior of vec_xxpermdi in order to provide the same
3d619b
+ * behavior of GCC. That means code adapted to Clang >= 7 does not work on
3d619b
+ * Clang <= 6.  So, fallback to __builtin_unpack_vector() on Clang <= 6.
3d619b
+ */
3d619b
+#if !defined vec_xxpermdi || __clang_major__ <= 6
3d619b
 
3d619b
 static inline
3d619b
 unsigned long __builtin_unpack_vector (__vector unsigned long long __v,
3d619b
@@ -62,9 +67,9 @@ static inline
3d619b
 unsigned long __builtin_unpack_vector_0 (__vector unsigned long long __v)
3d619b
 {
3d619b
 	#if defined(__BIG_ENDIAN__)
3d619b
-	return vec_xxpermdi(__v, __v, 0x0)[1];
3d619b
-	#else
3d619b
 	return vec_xxpermdi(__v, __v, 0x0)[0];
3d619b
+	#else
3d619b
+	return vec_xxpermdi(__v, __v, 0x3)[0];
3d619b
 	#endif
3d619b
 }
3d619b
 
3d619b
@@ -72,9 +77,9 @@ static inline
3d619b
 unsigned long __builtin_unpack_vector_1 (__vector unsigned long long __v)
3d619b
 {
3d619b
 	#if defined(__BIG_ENDIAN__)
3d619b
-	return vec_xxpermdi(__v, __v, 0x3)[1];
3d619b
-	#else
3d619b
 	return vec_xxpermdi(__v, __v, 0x3)[0];
3d619b
+	#else
3d619b
+	return vec_xxpermdi(__v, __v, 0x0)[0];
3d619b
 	#endif
3d619b
 }
3d619b
 #endif /* vec_xxpermdi */
3d619b
-- 
3d619b
2.39.1
3d619b