Loading liblog/include/log/log_time.h +28 −29 Original line number Diff line number Diff line Loading @@ -37,9 +37,7 @@ struct log_time { uint32_t tv_sec = 0; /* good to Feb 5 2106 */ uint32_t tv_nsec = 0; static const uint32_t tv_sec_max = 0xFFFFFFFFUL; static const uint32_t tv_nsec_max = 999999999UL; static const timespec EPOCH; static constexpr timespec EPOCH = {0, 0}; log_time() {} explicit log_time(const timespec& T) Loading @@ -55,16 +53,6 @@ struct log_time { tv_nsec = static_cast<uint32_t>(T.tv_nsec); } #endif explicit log_time(const char* T) { const uint8_t* c = reinterpret_cast<const uint8_t*>(T); tv_sec = c[0] | (static_cast<uint32_t>(c[1]) << 8) | (static_cast<uint32_t>(c[2]) << 16) | (static_cast<uint32_t>(c[3]) << 24); tv_nsec = c[4] | (static_cast<uint32_t>(c[5]) << 8) | (static_cast<uint32_t>(c[6]) << 16) | (static_cast<uint32_t>(c[7]) << 24); } /* timespec */ bool operator==(const timespec& T) const { return (tv_sec == static_cast<uint32_t>(T.tv_sec)) && Loading @@ -90,17 +78,6 @@ struct log_time { return !(*this > T); } log_time operator-=(const timespec& T); log_time operator-(const timespec& T) const { log_time local(*this); return local -= T; } log_time operator+=(const timespec& T); log_time operator+(const timespec& T) const { log_time local(*this); return local += T; } /* log_time */ bool operator==(const log_time& T) const { return (tv_sec == T.tv_sec) && (tv_nsec == T.tv_nsec); Loading @@ -123,12 +100,36 @@ struct log_time { return !(*this > T); } log_time operator-=(const log_time& T); log_time operator-=(const log_time& T) { // No concept of negative time, clamp to EPOCH if (*this <= T) { return *this = log_time(EPOCH); } if (this->tv_nsec < T.tv_nsec) { --this->tv_sec; this->tv_nsec = NS_PER_SEC + this->tv_nsec - T.tv_nsec; } else { this->tv_nsec -= T.tv_nsec; } this->tv_sec -= T.tv_sec; return *this; } log_time operator-(const log_time& T) const { log_time local(*this); return local -= T; } log_time operator+=(const log_time& T); log_time operator+=(const log_time& T) { this->tv_nsec += T.tv_nsec; if (this->tv_nsec >= NS_PER_SEC) { this->tv_nsec -= NS_PER_SEC; ++this->tv_sec; } this->tv_sec += T.tv_sec; return *this; } log_time operator+(const log_time& T) const { log_time local(*this); return local += T; Loading @@ -146,10 +147,8 @@ struct log_time { tv_nsec / (NS_PER_SEC / MS_PER_SEC); } static const char default_format[]; /* Add %#q for the fraction of a second to the standard library functions */ char* strptime(const char* s, const char* format = default_format); char* strptime(const char* s, const char* format); } __attribute__((__packed__)); } Loading liblog/log_time.cpp +0 −60 Original line number Diff line number Diff line Loading @@ -21,11 +21,7 @@ #include <private/android_logger.h> const char log_time::default_format[] = "%m-%d %H:%M:%S.%q"; const timespec log_time::EPOCH = {0, 0}; // Add %#q for fractional seconds to standard strptime function char* log_time::strptime(const char* s, const char* format) { time_t now; #ifdef __linux__ Loading Loading @@ -131,59 +127,3 @@ char* log_time::strptime(const char* s, const char* format) { #endif return ret; } log_time log_time::operator-=(const timespec& T) { // No concept of negative time, clamp to EPOCH if (*this <= T) { return *this = log_time(EPOCH); } if (this->tv_nsec < (unsigned long int)T.tv_nsec) { --this->tv_sec; this->tv_nsec = NS_PER_SEC + this->tv_nsec - T.tv_nsec; } else { this->tv_nsec -= T.tv_nsec; } this->tv_sec -= T.tv_sec; return *this; } log_time log_time::operator+=(const timespec& T) { this->tv_nsec += (unsigned long int)T.tv_nsec; if (this->tv_nsec >= NS_PER_SEC) { this->tv_nsec -= NS_PER_SEC; ++this->tv_sec; } this->tv_sec += T.tv_sec; return *this; } log_time log_time::operator-=(const log_time& T) { // No concept of negative time, clamp to EPOCH if (*this <= T) { return *this = log_time(EPOCH); } if (this->tv_nsec < T.tv_nsec) { --this->tv_sec; this->tv_nsec = NS_PER_SEC + this->tv_nsec - T.tv_nsec; } else { this->tv_nsec -= T.tv_nsec; } this->tv_sec -= T.tv_sec; return *this; } log_time log_time::operator+=(const log_time& T) { this->tv_nsec += T.tv_nsec; if (this->tv_nsec >= NS_PER_SEC) { this->tv_nsec -= NS_PER_SEC; ++this->tv_sec; } this->tv_sec += T.tv_sec; return *this; } liblog/tests/liblog_benchmark.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -684,8 +684,8 @@ static void BM_log_latency(benchmark::State& state) { if (!eventData || (eventData[4] != EVENT_TYPE_LONG)) { continue; } log_time tx(eventData + 4 + 1); if (ts != tx) { log_time* tx = reinterpret_cast<log_time*>(eventData + 4 + 1); if (ts != *tx) { if (0xDEADBEEFA55A5AA5ULL == caught_convert(eventData + 4 + 1)) { state.SkipWithError("signal"); break; Loading Loading @@ -757,8 +757,8 @@ static void BM_log_delay(benchmark::State& state) { if (!eventData || (eventData[4] != EVENT_TYPE_LONG)) { continue; } log_time tx(eventData + 4 + 1); if (ts != tx) { log_time* tx = reinterpret_cast<log_time*>(eventData + 4 + 1); if (ts != *tx) { if (0xDEADBEEFA55A5AA6ULL == caught_convert(eventData + 4 + 1)) { state.SkipWithError("signal"); break; Loading liblog/tests/liblog_test.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -270,10 +270,10 @@ TEST(liblog, __android_log_btwrite__android_logger_list_read) { return; } log_time tx(reinterpret_cast<char*>(&eventData->payload.data)); if (ts == tx) { log_time* tx = reinterpret_cast<log_time*>(&eventData->payload.data); if (ts == *tx) { ++count; } else if (ts1 == tx) { } else if (ts1 == *tx) { ++second_count; } Loading logcat/tests/logcat_test.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -475,8 +475,8 @@ TEST(logcat, End_to_End) { continue; } log_time tx((const char*)&t); if (ts == tx) { log_time* tx = reinterpret_cast<log_time*>(&t); if (ts == *tx) { ++count; } } Loading Loading @@ -521,8 +521,8 @@ TEST(logcat, End_to_End_multitude) { continue; } log_time tx((const char*)&t); if (ts == tx) { log_time* tx = reinterpret_cast<log_time*>(&t); if (ts == *tx) { ++count; } } Loading Loading
liblog/include/log/log_time.h +28 −29 Original line number Diff line number Diff line Loading @@ -37,9 +37,7 @@ struct log_time { uint32_t tv_sec = 0; /* good to Feb 5 2106 */ uint32_t tv_nsec = 0; static const uint32_t tv_sec_max = 0xFFFFFFFFUL; static const uint32_t tv_nsec_max = 999999999UL; static const timespec EPOCH; static constexpr timespec EPOCH = {0, 0}; log_time() {} explicit log_time(const timespec& T) Loading @@ -55,16 +53,6 @@ struct log_time { tv_nsec = static_cast<uint32_t>(T.tv_nsec); } #endif explicit log_time(const char* T) { const uint8_t* c = reinterpret_cast<const uint8_t*>(T); tv_sec = c[0] | (static_cast<uint32_t>(c[1]) << 8) | (static_cast<uint32_t>(c[2]) << 16) | (static_cast<uint32_t>(c[3]) << 24); tv_nsec = c[4] | (static_cast<uint32_t>(c[5]) << 8) | (static_cast<uint32_t>(c[6]) << 16) | (static_cast<uint32_t>(c[7]) << 24); } /* timespec */ bool operator==(const timespec& T) const { return (tv_sec == static_cast<uint32_t>(T.tv_sec)) && Loading @@ -90,17 +78,6 @@ struct log_time { return !(*this > T); } log_time operator-=(const timespec& T); log_time operator-(const timespec& T) const { log_time local(*this); return local -= T; } log_time operator+=(const timespec& T); log_time operator+(const timespec& T) const { log_time local(*this); return local += T; } /* log_time */ bool operator==(const log_time& T) const { return (tv_sec == T.tv_sec) && (tv_nsec == T.tv_nsec); Loading @@ -123,12 +100,36 @@ struct log_time { return !(*this > T); } log_time operator-=(const log_time& T); log_time operator-=(const log_time& T) { // No concept of negative time, clamp to EPOCH if (*this <= T) { return *this = log_time(EPOCH); } if (this->tv_nsec < T.tv_nsec) { --this->tv_sec; this->tv_nsec = NS_PER_SEC + this->tv_nsec - T.tv_nsec; } else { this->tv_nsec -= T.tv_nsec; } this->tv_sec -= T.tv_sec; return *this; } log_time operator-(const log_time& T) const { log_time local(*this); return local -= T; } log_time operator+=(const log_time& T); log_time operator+=(const log_time& T) { this->tv_nsec += T.tv_nsec; if (this->tv_nsec >= NS_PER_SEC) { this->tv_nsec -= NS_PER_SEC; ++this->tv_sec; } this->tv_sec += T.tv_sec; return *this; } log_time operator+(const log_time& T) const { log_time local(*this); return local += T; Loading @@ -146,10 +147,8 @@ struct log_time { tv_nsec / (NS_PER_SEC / MS_PER_SEC); } static const char default_format[]; /* Add %#q for the fraction of a second to the standard library functions */ char* strptime(const char* s, const char* format = default_format); char* strptime(const char* s, const char* format); } __attribute__((__packed__)); } Loading
liblog/log_time.cpp +0 −60 Original line number Diff line number Diff line Loading @@ -21,11 +21,7 @@ #include <private/android_logger.h> const char log_time::default_format[] = "%m-%d %H:%M:%S.%q"; const timespec log_time::EPOCH = {0, 0}; // Add %#q for fractional seconds to standard strptime function char* log_time::strptime(const char* s, const char* format) { time_t now; #ifdef __linux__ Loading Loading @@ -131,59 +127,3 @@ char* log_time::strptime(const char* s, const char* format) { #endif return ret; } log_time log_time::operator-=(const timespec& T) { // No concept of negative time, clamp to EPOCH if (*this <= T) { return *this = log_time(EPOCH); } if (this->tv_nsec < (unsigned long int)T.tv_nsec) { --this->tv_sec; this->tv_nsec = NS_PER_SEC + this->tv_nsec - T.tv_nsec; } else { this->tv_nsec -= T.tv_nsec; } this->tv_sec -= T.tv_sec; return *this; } log_time log_time::operator+=(const timespec& T) { this->tv_nsec += (unsigned long int)T.tv_nsec; if (this->tv_nsec >= NS_PER_SEC) { this->tv_nsec -= NS_PER_SEC; ++this->tv_sec; } this->tv_sec += T.tv_sec; return *this; } log_time log_time::operator-=(const log_time& T) { // No concept of negative time, clamp to EPOCH if (*this <= T) { return *this = log_time(EPOCH); } if (this->tv_nsec < T.tv_nsec) { --this->tv_sec; this->tv_nsec = NS_PER_SEC + this->tv_nsec - T.tv_nsec; } else { this->tv_nsec -= T.tv_nsec; } this->tv_sec -= T.tv_sec; return *this; } log_time log_time::operator+=(const log_time& T) { this->tv_nsec += T.tv_nsec; if (this->tv_nsec >= NS_PER_SEC) { this->tv_nsec -= NS_PER_SEC; ++this->tv_sec; } this->tv_sec += T.tv_sec; return *this; }
liblog/tests/liblog_benchmark.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -684,8 +684,8 @@ static void BM_log_latency(benchmark::State& state) { if (!eventData || (eventData[4] != EVENT_TYPE_LONG)) { continue; } log_time tx(eventData + 4 + 1); if (ts != tx) { log_time* tx = reinterpret_cast<log_time*>(eventData + 4 + 1); if (ts != *tx) { if (0xDEADBEEFA55A5AA5ULL == caught_convert(eventData + 4 + 1)) { state.SkipWithError("signal"); break; Loading Loading @@ -757,8 +757,8 @@ static void BM_log_delay(benchmark::State& state) { if (!eventData || (eventData[4] != EVENT_TYPE_LONG)) { continue; } log_time tx(eventData + 4 + 1); if (ts != tx) { log_time* tx = reinterpret_cast<log_time*>(eventData + 4 + 1); if (ts != *tx) { if (0xDEADBEEFA55A5AA6ULL == caught_convert(eventData + 4 + 1)) { state.SkipWithError("signal"); break; Loading
liblog/tests/liblog_test.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -270,10 +270,10 @@ TEST(liblog, __android_log_btwrite__android_logger_list_read) { return; } log_time tx(reinterpret_cast<char*>(&eventData->payload.data)); if (ts == tx) { log_time* tx = reinterpret_cast<log_time*>(&eventData->payload.data); if (ts == *tx) { ++count; } else if (ts1 == tx) { } else if (ts1 == *tx) { ++second_count; } Loading
logcat/tests/logcat_test.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -475,8 +475,8 @@ TEST(logcat, End_to_End) { continue; } log_time tx((const char*)&t); if (ts == tx) { log_time* tx = reinterpret_cast<log_time*>(&t); if (ts == *tx) { ++count; } } Loading Loading @@ -521,8 +521,8 @@ TEST(logcat, End_to_End_multitude) { continue; } log_time tx((const char*)&t); if (ts == tx) { log_time* tx = reinterpret_cast<log_time*>(&t); if (ts == *tx) { ++count; } } Loading