Le mer. 29 nov. 2023 à 12:34, Martin Storsjö <mar...@martin.st> a écrit :
>
> 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 <anto...@tarides.com>
> > ---
> > 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() ...?

Sounds fine to me, it could go into the winpthreads-compat.h file, but
as this is internal I suppose it'll be better placed in src/misc.h.


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

Reply via email to