Skip to content

Commit

Permalink
pthread_yield() is depricated now, so use sched_yield() if possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
sanja-byelkin committed Oct 26, 2021
1 parent 1fb4537 commit 1f70e4b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions include/my_pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,16 +289,18 @@ void my_pthread_attr_getstacksize(pthread_attr_t *attrib, size_t *size);
int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
#endif

#if !defined(HAVE_PTHREAD_YIELD_ZERO_ARG)
/* no pthread_yield() available */
#ifdef HAVE_SCHED_YIELD
#define pthread_yield() sched_yield()
#elif defined(HAVE_PTHREAD_YIELD_NP) /* can be Mac OS X */
#else
#if !defined(HAVE_PTHREAD_YIELD_ZERO_ARG)
/* no pthread_yield() available */
#if defined(HAVE_PTHREAD_YIELD_NP) /* can be Mac OS X */
#define pthread_yield() pthread_yield_np()
#elif defined(HAVE_THR_YIELD)
#define pthread_yield() thr_yield()
#endif
#endif
#endif //defined(HAVE_PTHREAD_YIELD_NP)
#endif //!defined(HAVE_PTHREAD_YIELD_ZERO_ARG)
#endif //HAVE_SCHED_YIELD

/*
The defines set_timespec and set_timespec_nsec should be used
Expand Down

0 comments on commit 1f70e4b

Please sign in to comment.