summaryrefslogtreecommitdiffstats
path: root/init/util.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-03-27 23:20:44 -0700
committerElliott Hughes <enh@google.com>2015-03-28 00:25:22 -0700
commitda40c00137f75543a69972f1be506e2d14a41845 (patch)
treed24df4f9a94411205786227c26cd2a1a664420bc /init/util.cpp
parente29744d94df787fa83307572d90a954b1592f69b (diff)
downloadcore-da40c00137f75543a69972f1be506e2d14a41845.tar.gz
core-da40c00137f75543a69972f1be506e2d14a41845.tar.bz2
core-da40c00137f75543a69972f1be506e2d14a41845.zip
Log more timing information from init.
Also make important events in init's life NOTICE rather than INFO, and ensure that NOTICE events actually make it to the kernel log. Also fix the logging so that if you have a printf format string error, the compiler now catches it. Also give messages from init, ueventd, and watchdogd distinct tags. (Previously they'd all call themselves "init", and dmesg doesn't include pids, so you couldn't untangle them.) Also include the tag in SELinux messages. Bug: 19544788 Change-Id: Ica6daea065bfdb80155c52c0b06f346a7df208fe
Diffstat (limited to 'init/util.cpp')
-rw-r--r--init/util.cpp24
1 files changed, 9 insertions, 15 deletions
diff --git a/init/util.cpp b/init/util.cpp
index 8b238d47b..3b49b30d3 100644
--- a/init/util.cpp
+++ b/init/util.cpp
@@ -258,22 +258,16 @@ int mtd_name_to_number(const char *name)
return -1;
}
-/*
- * gettime() - returns the time in seconds of the system's monotonic clock or
- * zero on error.
- */
-time_t gettime(void)
-{
- struct timespec ts;
- int ret;
-
- ret = clock_gettime(CLOCK_MONOTONIC, &ts);
- if (ret < 0) {
- ERROR("clock_gettime(CLOCK_MONOTONIC) failed: %s\n", strerror(errno));
- return 0;
- }
+time_t gettime() {
+ timespec now;
+ clock_gettime(CLOCK_MONOTONIC, &now);
+ return now.tv_sec;
+}
- return ts.tv_sec;
+uint64_t gettime_ns() {
+ timespec now;
+ clock_gettime(CLOCK_MONOTONIC, &now);
+ return static_cast<uint64_t>(now.tv_sec) * UINT64_C(1000000000) + now.tv_nsec;
}
int mkdir_recursive(const char *pathname, mode_t mode)