[vlc-devel] [PATCH] clock_nanosleep() is optional
Rafaël Carré
rafael.carre at gmail.com
Wed Aug 31 07:15:50 CEST 2011
Its presence depends on _POSIX_CLOCK_SELECTION
Note: "If the symbolic constant _POSIX_CLOCK_SELECTION is defined, then the symbolic constant _POSIX_TIMERS shall also be defined by the implementation to have the value 200112L."
So perhaps we could change the check to _POSIX_TIMERS to _POSIX_CLOCK_SELECTION
---
src/posix/thread.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/posix/thread.c b/src/posix/thread.c
index 9064563..4d356be 100644
--- a/src/posix/thread.c
+++ b/src/posix/thread.c
@@ -80,7 +80,7 @@
# define _POSIX_MONOTONIC_CLOCK (-1)
#endif
-#if (_POSIX_TIMERS > 0)
+#if (_POSIX_TIMERS > 0) && (_POSIX_CLOCK_SELECTION > 0)
static unsigned vlc_clock_prec;
# if (_POSIX_MONOTONIC_CLOCK > 0)
@@ -117,7 +117,7 @@ static pthread_once_t vlc_clock_once = PTHREAD_ONCE_INIT;
# define vlc_clock_setup() \
pthread_once(&vlc_clock_once, vlc_clock_setup_once)
-#else /* _POSIX_TIMERS */
+#else /* _POSIX_TIMERS && _POSIX_CLOCK_SELECTION */
# include <sys/time.h> /* gettimeofday() */
# if defined (HAVE_DECL_NANOSLEEP) && !HAVE_DECL_NANOSLEEP
@@ -126,7 +126,7 @@ int nanosleep (struct timespec *, struct timespec *);
# define vlc_clock_setup() (void)0
# warning Monotonic clock not available. Expect timing issues.
-#endif /* _POSIX_TIMERS */
+#endif /* _POSIX_TIMERS && _POSIX_CLOCK_SELECTION */
static struct timespec mtime_to_ts (mtime_t date)
{
@@ -942,7 +942,7 @@ void vlc_control_cancel (int cmd, ...)
*/
mtime_t mdate (void)
{
-#if (_POSIX_TIMERS > 0)
+#if (_POSIX_TIMERS > 0) && (_POSIX_CLOCK_SELECTION > 0)
struct timespec ts;
vlc_clock_setup ();
@@ -968,7 +968,7 @@ mtime_t mdate (void)
*/
void mwait (mtime_t deadline)
{
-#if (_POSIX_TIMERS > 0)
+#if (_POSIX_TIMERS > 0) && (_POSIX_CLOCK_SELECTION > 0)
vlc_clock_setup ();
/* If the deadline is already elapsed, or within the clock precision,
* do not even bother the system timer. */
@@ -996,7 +996,7 @@ void msleep (mtime_t delay)
struct timespec ts = mtime_to_ts (delay);
vlc_clock_setup ();
-#if (_POSIX_TIMERS > 0)
+#if (_POSIX_TIMERS > 0) && (_POSIX_CLOCK_SELECTION > 0)
while (clock_nanosleep (vlc_clock_id, 0, &ts, &ts) == EINTR);
#else
--
1.7.5.4
More information about the vlc-devel
mailing list