diff options
author | Nick Mathewson <nickm@torproject.org> | 2016-09-24 13:33:09 -0700 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-09-24 13:33:09 -0700 |
commit | a633baf6320291b6f3de15557438682ed7fe2eaa (patch) | |
tree | a0c8e27dd5eb626a208d5a7f57ce14faff65c800 /src | |
parent | 9db7bd08f0a04133fcf4ee976d1b8f9a321de5a9 (diff) | |
parent | 39f51dfae312d67f4a97366db4b476d520ed0c0f (diff) | |
download | tor-a633baf6320291b6f3de15557438682ed7fe2eaa.tar.gz tor-a633baf6320291b6f3de15557438682ed7fe2eaa.zip |
Merge branch 'osx_sierra_028'
Diffstat (limited to 'src')
-rw-r--r-- | src/common/compat_pthreads.c | 19 | ||||
-rw-r--r-- | src/common/crypto.c | 3 |
2 files changed, 16 insertions, 6 deletions
diff --git a/src/common/compat_pthreads.c b/src/common/compat_pthreads.c index 79f5cec43a..c1ae66c1d2 100644 --- a/src/common/compat_pthreads.c +++ b/src/common/compat_pthreads.c @@ -200,14 +200,21 @@ tor_cond_init(tor_cond_t *cond) return -1; } -#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) \ - && defined(HAVE_PTHREAD_CONDATTR_SETCLOCK) +#if defined(HAVE_CLOCK_GETTIME) +#if defined(CLOCK_MONOTONIC) && defined(HAVE_PTHREAD_CONDATTR_SETCLOCK) /* Use monotonic time so when we timedwait() on it, any clock adjustment * won't affect the timeout value. */ if (pthread_condattr_setclock(&condattr, CLOCK_MONOTONIC)) { return -1; } -#endif +#define USE_COND_CLOCK CLOCK_MONOTONIC +#else /* !defined HAVE_PTHREAD_CONDATTR_SETCLOCK */ + /* On OSX Sierra, there is no pthread_condattr_setclock, so we are stuck + * with the realtime clock. + */ +#define USE_COND_CLOCK CLOCK_REALTIME +#endif /* which clock to use */ +#endif /* HAVE_CLOCK_GETTIME */ if (pthread_cond_init(&cond->cond, &condattr)) { return -1; } @@ -252,12 +259,12 @@ tor_cond_wait(tor_cond_t *cond, tor_mutex_t *mutex, const struct timeval *tv) struct timeval tvnow, tvsum; struct timespec ts; while (1) { -#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) - if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) { +#if defined(HAVE_CLOCK_GETTIME) && defined(USE_COND_CLOCK) + if (clock_gettime(USE_COND_CLOCK, &ts) < 0) { return -1; } tvnow.tv_sec = ts.tv_sec; - tvnow.tv_usec = ts.tv_nsec / 1000; + tvnow.tv_usec = (int)(ts.tv_nsec / 1000); timeradd(tv, &tvnow, &tvsum); #else if (gettimeofday(&tvnow, NULL) < 0) diff --git a/src/common/crypto.c b/src/common/crypto.c index 72c1c45983..56409b47e2 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -67,6 +67,9 @@ ENABLE_GCC_WARNING(redundant-decls) #ifdef HAVE_SYS_SYSCALL_H #include <sys/syscall.h> #endif +#ifdef HAVE_SYS_RANDOM_H +#include <sys/random.h> +#endif #include "torlog.h" #include "torint.h" |