https://learn.microsoft.com/en-us/cpp/intrinsics/assume?view=msvc-170

Signed-off-by: Antonin Décimo <anto...@tarides.com>
---

Compared to v1, this patch introduces an UNREACHABLE() macro that
expands to builtins for GCC, clang(-cl), and MSVC.

 mingw-w64-libraries/winpthreads/src/misc.h  | 6 ++++++
 mingw-w64-libraries/winpthreads/src/mutex.c | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/mingw-w64-libraries/winpthreads/src/misc.h 
b/mingw-w64-libraries/winpthreads/src/misc.h
index 83d4b3128..97a65e877 100644
--- a/mingw-w64-libraries/winpthreads/src/misc.h
+++ b/mingw-w64-libraries/winpthreads/src/misc.h
@@ -119,4 +119,10 @@ unsigned long _pthread_wait_for_multiple_objects (unsigned 
long count, void **ha
 #define unlikely(cond) (cond)
 #endif
 
+#if defined(__GNUC__) || defined(__clang__)
+#define UNREACHABLE() __builtin_unreachable()
+#elif defined(_MSC_VER)
+#define UNREACHABLE() __assume(0)
+#endif
+
 #endif
diff --git a/mingw-w64-libraries/winpthreads/src/mutex.c 
b/mingw-w64-libraries/winpthreads/src/mutex.c
index fc29341ac..514219821 100644
--- a/mingw-w64-libraries/winpthreads/src/mutex.c
+++ b/mingw-w64-libraries/winpthreads/src/mutex.c
@@ -99,7 +99,7 @@ mutex_impl(pthread_mutex_t *m)
   } else {
     /* mi cannot be null here; avoid a test in the fast path. */
     if (mi == NULL)
-      __builtin_unreachable();
+      UNREACHABLE();
     return mi;
   }
 }
-- 
2.43.0



_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to