Signed-off-by: Antonin Décimo <anto...@tarides.com> --- Compared to v1, this patch doesn't provide a definition of likely/unlikely for compilers other that GCC, clang(-cl), or MSVC.
mingw-w64-libraries/winpthreads/src/misc.h | 8 ++++++++ mingw-w64-libraries/winpthreads/src/mutex.c | 3 --- mingw-w64-libraries/winpthreads/src/spinlock.c | 3 --- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/mingw-w64-libraries/winpthreads/src/misc.h b/mingw-w64-libraries/winpthreads/src/misc.h index cdb242689..83d4b3128 100644 --- a/mingw-w64-libraries/winpthreads/src/misc.h +++ b/mingw-w64-libraries/winpthreads/src/misc.h @@ -111,4 +111,12 @@ unsigned long long _pthread_rel_time_in_ms(const struct timespec *ts); unsigned long _pthread_wait_for_single_object (void *handle, unsigned long timeout); unsigned long _pthread_wait_for_multiple_objects (unsigned long count, void **handles, unsigned int all, unsigned long timeout); +#if defined(__GNUC__) || defined(__clang__) +#define likely(cond) __builtin_expect((cond) != 0, 1) +#define unlikely(cond) __builtin_expect((cond) != 0, 0) +#elif defined(_MSC_VER) +#define likely(cond) (cond) +#define unlikely(cond) (cond) +#endif + #endif diff --git a/mingw-w64-libraries/winpthreads/src/mutex.c b/mingw-w64-libraries/winpthreads/src/mutex.c index c6f261394..fc29341ac 100644 --- a/mingw-w64-libraries/winpthreads/src/mutex.c +++ b/mingw-w64-libraries/winpthreads/src/mutex.c @@ -88,9 +88,6 @@ mutex_impl_init(pthread_mutex_t *m, mutex_impl_t *mi) } } -#define likely(cond) __builtin_expect((cond) != 0, 1) -#define unlikely(cond) __builtin_expect((cond) != 0, 0) - /* Return the implementation part of a mutex, creating it if necessary. Return NULL on out-of-memory error. */ static inline mutex_impl_t * diff --git a/mingw-w64-libraries/winpthreads/src/spinlock.c b/mingw-w64-libraries/winpthreads/src/spinlock.c index 2032d602a..4c1ea3afc 100644 --- a/mingw-w64-libraries/winpthreads/src/spinlock.c +++ b/mingw-w64-libraries/winpthreads/src/spinlock.c @@ -23,9 +23,6 @@ #include "pthread.h" -#define likely(cond) __builtin_expect((cond) != 0, 1) -#define unlikely(cond) __builtin_expect((cond) != 0, 0) - /* We use the pthread_spinlock_t itself as a lock: -1 is free, 0 is locked. (This is dictated by PTHREAD_SPINLOCK_INITIALIZER, which we can't change -- 2.43.0 _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public