From 3480b1832d3581c708868117c0eb21ba291df165 Mon Sep 17 00:00:00 2001 From: Yu Ning Date: Thu, 31 Mar 2016 21:49:59 +0800 Subject: [PATCH] reference-ril: Stop using pthread_cond_timedwait_relative_np() pthread_cond_timedwait_relative_np() is deprecated, and is only available in the 32-bit ABI (see bionic/libc/include/pthread.h). It is still used by the 32-bit version of reference-ril. Thanks to a recent bugfix for 64-bit [1], it is now safe to replace the deprecated function with the standard pthread_cond_timedwait(). Doing so also simplifies the code, as there is now a unified logic for 32 and 64-bit targets. [1] https://android-review.googlesource.com/210301 Change-Id: I0895bbf65ddb71965018d6945dfb8baa786d5d89 Signed-off-by: Yu Ning --- reference-ril/atchannel.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/reference-ril/atchannel.c b/reference-ril/atchannel.c index a034cf7..315d4f9 100644 --- a/reference-ril/atchannel.c +++ b/reference-ril/atchannel.c @@ -35,10 +35,6 @@ #include "misc.h" -#ifdef HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE -#define USE_NP 1 -#endif /* HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE */ - #define NUM_ELEMS(x) (sizeof(x)/sizeof(x[0])) @@ -85,7 +81,6 @@ static void onReaderClosed(); static int writeCtrlZ (const char *s); static int writeline (const char *s); -#ifndef USE_NP #define NS_PER_S 1000000000 static void setTimespecRelative(struct timespec *p_ts, long long msec) { @@ -93,9 +88,6 @@ static void setTimespecRelative(struct timespec *p_ts, long long msec) gettimeofday(&tv, (struct timezone *) NULL); - /* what's really funny about this is that I know - pthread_cond_timedwait just turns around and makes this - a relative time again */ p_ts->tv_sec = tv.tv_sec + (msec / 1000); p_ts->tv_nsec = (tv.tv_usec + (msec % 1000) * 1000L ) * 1000L; /* assuming tv.tv_usec < 10^6 */ @@ -104,7 +96,6 @@ static void setTimespecRelative(struct timespec *p_ts, long long msec) p_ts->tv_nsec -= NS_PER_S; } } -#endif /*USE_NP*/ static void sleepMsec(long long msec) { @@ -677,9 +668,7 @@ static int at_send_command_full_nolock (const char *command, ATCommandType type, long long timeoutMsec, ATResponse **pp_outResponse) { int err = 0; -#ifndef USE_NP struct timespec ts; -#endif /*USE_NP*/ if(sp_response != NULL) { err = AT_ERROR_COMMAND_PENDING; @@ -697,19 +686,13 @@ static int at_send_command_full_nolock (const char *command, ATCommandType type, s_smsPDU = smspdu; sp_response = at_response_new(); -#ifndef USE_NP if (timeoutMsec != 0) { setTimespecRelative(&ts, timeoutMsec); } -#endif /*USE_NP*/ while (sp_response->finalResponse == NULL && s_readerClosed == 0) { if (timeoutMsec != 0) { -#ifdef USE_NP - err = pthread_cond_timeout_np(&s_commandcond, &s_commandmutex, timeoutMsec); -#else err = pthread_cond_timedwait(&s_commandcond, &s_commandmutex, &ts); -#endif /*USE_NP*/ } else { err = pthread_cond_wait(&s_commandcond, &s_commandmutex); } -- 2.11.0