On Wed, 29 Nov 2023, Antonin Décimo wrote:

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

Signed-off-by: Antonin Décimo <[email protected]>
---
mingw-w64-libraries/winpthreads/src/mutex.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/mingw-w64-libraries/winpthreads/src/mutex.c 
b/mingw-w64-libraries/winpthreads/src/mutex.c
index fc29341ac..2c1e891bf 100644
--- a/mingw-w64-libraries/winpthreads/src/mutex.c
+++ b/mingw-w64-libraries/winpthreads/src/mutex.c
@@ -99,7 +99,11 @@ mutex_impl(pthread_mutex_t *m)
  } else {
    /* mi cannot be null here; avoid a test in the fast path. */
    if (mi == NULL)
+#if defined(_MSC_VER)
+      __assume(0);
+#else
      __builtin_unreachable();
+#endif
    return mi;
  }

Can we abstract this out to a macro out of the actual function? (One could consider doing #define __builtin_unreachable() __assume(0) for MSVC, but it's kinda ugly to define things in the __builtin namespace.) Admittedly, it is used only one in this one single instance, but I'd still prefer having the compatibility handling out of line. Perhaps just a #define UNREACHABLE() ...?

// Martin

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to