summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@quicinc.com>2018-01-15 23:28:29 -0800
committerGerrit - the friendly Code Review server <code-review@localhost>2018-01-15 23:28:28 -0800
commit438abebca035fe4f956e7e6232a1b98074e4c673 (patch)
tree6529e2b31c0a89ef7f1249f4ce54690b4cc1da41
parente30133876747f185d9aa739c58f1ca064630086e (diff)
parent52f5cfe9d7d9a6c4a2c7f047bd01cd85ed25d2d9 (diff)
downloadgps-438abebca035fe4f956e7e6232a1b98074e4c673.tar.gz
Merge "init condition with attr CLOCK_MONOTONIC"
-rw-r--r--gnss/GnssAdapter.cpp13
-rw-r--r--utils/loc_log.cpp13
-rw-r--r--utils/platform_lib_abstractions/loc_pla/include/platform_lib_macros.h7
-rw-r--r--utils/platform_lib_abstractions/loc_pla/src/platform_lib_log_util.cpp7
4 files changed, 25 insertions, 15 deletions
diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp
index c2a353f..bda75e9 100644
--- a/gnss/GnssAdapter.cpp
+++ b/gnss/GnssAdapter.cpp
@@ -81,6 +81,13 @@ GnssAdapter::GnssAdapter() :
LOC_LOGD("%s]: Constructor %p", __func__, this);
mUlpPositionMode.mode = LOC_POSITION_MODE_INVALID;
+ pthread_condattr_t condAttr;
+ pthread_condattr_init(&condAttr);
+ pthread_condattr_setclock(&condAttr, CLOCK_MONOTONIC);
+ pthread_cond_init(&mNiData.session.tCond, &condAttr);
+ pthread_cond_init(&mNiData.sessionEs.tCond, &condAttr);
+ pthread_condattr_destroy(&condAttr);
+
/* Set ATL open/close callbacks */
AgpsAtlOpenStatusCb atlOpenStatusCb =
[this](int handle, int isSuccess, char* apn,
@@ -2274,9 +2281,9 @@ GnssAdapter::reportNmea(const char* nmea, size_t length)
GnssNmeaNotification nmeaNotification = {};
nmeaNotification.size = sizeof(GnssNmeaNotification);
- struct timespec tv;
- clock_gettime(CLOCK_MONOTONIC, &tv);
- int64_t now = tv.tv_sec * 1000LL + tv.tv_nsec / 1000000LL;
+ struct timeval tv;
+ gettimeofday(&tv, (struct timezone *) NULL);
+ int64_t now = tv.tv_sec * 1000LL + tv.tv_usec / 1000;
nmeaNotification.timestamp = now;
nmeaNotification.nmea = nmea;
nmeaNotification.length = length;
diff --git a/utils/loc_log.cpp b/utils/loc_log.cpp
index ca78f15..9fad9e6 100644
--- a/utils/loc_log.cpp
+++ b/utils/loc_log.cpp
@@ -165,15 +165,15 @@ RETURN VALUE
===========================================================================*/
char *loc_get_time(char *time_string, size_t buf_size)
{
- struct timespec now; /* sec and usec */
+ struct timeval now; /* sec and usec */
struct tm now_tm; /* broken-down time */
char hms_string[80]; /* HH:MM:SS */
- clock_gettime(CLOCK_MONOTONIC, &now);
+ gettimeofday(&now, NULL);
localtime_r(&now.tv_sec, &now_tm);
strftime(hms_string, sizeof hms_string, "%H:%M:%S", &now_tm);
- snprintf(time_string, buf_size, "%s.%03d", hms_string, (int) (now.tv_nsec / 1000000LL));
+ snprintf(time_string, buf_size, "%s.%03d", hms_string, (int) (now.tv_usec / 1000));
return time_string;
}
@@ -224,13 +224,14 @@ SIDE EFFECTS
===========================================================================*/
char * get_timestamp(char *str, unsigned long buf_size)
{
- struct timespec tv;
+ struct timeval tv;
+ struct timezone tz;
int hh, mm, ss;
- clock_gettime(CLOCK_MONOTONIC, &tv);
+ gettimeofday(&tv, &tz);
hh = tv.tv_sec/3600%24;
mm = (tv.tv_sec%3600)/60;
ss = tv.tv_sec%60;
- snprintf(str, buf_size, "%02d:%02d:%02d.%06ld", hh, mm, ss, tv.tv_nsec / 1000);
+ snprintf(str, buf_size, "%02d:%02d:%02d.%06ld", hh, mm, ss, tv.tv_usec);
return str;
}
diff --git a/utils/platform_lib_abstractions/loc_pla/include/platform_lib_macros.h b/utils/platform_lib_abstractions/loc_pla/include/platform_lib_macros.h
index 39e33dc..9a806bf 100644
--- a/utils/platform_lib_abstractions/loc_pla/include/platform_lib_macros.h
+++ b/utils/platform_lib_abstractions/loc_pla/include/platform_lib_macros.h
@@ -52,13 +52,14 @@ extern "C" {
// LE targets with no logcat support
#define TS_PRINTF(format, x...) \
{ \
- struct timespec tv; \
+ struct timeval tv; \
+ struct timezone tz; \
int hh, mm, ss; \
- clock_gettime(CLOCK_MONOTONIC, &tv); \
+ gettimeofday(&tv, &tz); \
hh = tv.tv_sec/3600%24; \
mm = (tv.tv_sec%3600)/60; \
ss = tv.tv_sec%60; \
- fprintf(stdout,"%02d:%02d:%02d.%06ld]" format "\n", hh, mm, ss, tv.tv_nsec/1000, ##x); \
+ fprintf(stdout,"%02d:%02d:%02d.%06ld]" format "\n", hh, mm, ss, tv.tv_usec, ##x); \
}
#define ALOGE(format, x...) TS_PRINTF("E/%s (%d): " format , LOG_TAG, getpid(), ##x)
diff --git a/utils/platform_lib_abstractions/loc_pla/src/platform_lib_log_util.cpp b/utils/platform_lib_abstractions/loc_pla/src/platform_lib_log_util.cpp
index fb4f2fe..3cb51a3 100644
--- a/utils/platform_lib_abstractions/loc_pla/src/platform_lib_log_util.cpp
+++ b/utils/platform_lib_abstractions/loc_pla/src/platform_lib_log_util.cpp
@@ -30,13 +30,14 @@
char * get_timestamp(char *str, unsigned long buf_size)
{
- struct timespec tv;
+ struct timeval tv;
+ struct timezone tz;
int hh, mm, ss;
- clock_gettime(CLOCK_MONOTONIC, &tv);
+ gettimeofday(&tv, &tz);
hh = tv.tv_sec/3600%24;
mm = (tv.tv_sec%3600)/60;
ss = tv.tv_sec%60;
- snprintf(str, buf_size, "%02d:%02d:%02d.%06ld", hh, mm, ss, tv.tv_nsec / 1000);
+ snprintf(str, buf_size, "%02d:%02d:%02d.%06ld", hh, mm, ss, tv.tv_usec);
return str;
}