diff options
author | Colin Cross <ccross@android.com> | 2010-04-13 19:35:09 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2010-04-13 22:52:10 -0700 |
commit | 504bc5175a8fe5a2f2552903afee761a86283cf4 (patch) | |
tree | be6367244c16c66fac5967fa79fba45dad2bb39f /init | |
parent | d11beb2b1516144327c3f730f75e6b4bc65f1374 (diff) | |
download | core-504bc5175a8fe5a2f2552903afee761a86283cf4.tar.gz core-504bc5175a8fe5a2f2552903afee761a86283cf4.tar.bz2 core-504bc5175a8fe5a2f2552903afee761a86283cf4.zip |
init: Move gettime() to util.c
Change-Id: I1df96964763f8baedbc1cea6875d3dfc5e48c065
Diffstat (limited to 'init')
-rwxr-xr-x | init/init.c | 19 | ||||
-rw-r--r-- | init/init.h | 1 | ||||
-rw-r--r-- | init/util.c | 19 |
3 files changed, 20 insertions, 19 deletions
diff --git a/init/init.c b/init/init.c index ba2c0d3ab..008c5134e 100755 --- a/init/init.c +++ b/init/init.c @@ -25,7 +25,6 @@ #include <sys/mount.h> #include <sys/stat.h> #include <sys/poll.h> -#include <time.h> #include <errno.h> #include <stdarg.h> #include <mtd/mtd-user.h> @@ -119,24 +118,6 @@ static void open_console() close(fd); } -/* - * gettime() - returns the time in seconds of the system's monotonic clock or - * zero on error. - */ -static 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; - } - - return ts.tv_sec; -} - static void publish_socket(const char *name, int fd) { char key[64] = ANDROID_SOCKET_ENV_PREFIX; diff --git a/init/init.h b/init/init.h index 2d18b9e2c..8210238b0 100644 --- a/init/init.h +++ b/init/init.h @@ -25,6 +25,7 @@ int create_socket(const char *name, int type, mode_t perm, uid_t uid, gid_t gid); void *read_file(const char *fn, unsigned *_sz); +time_t gettime(void); void log_init(void); void log_set_level(int level); diff --git a/init/util.c b/init/util.c index 48f8d54cc..6f9a12e9e 100644 --- a/init/util.c +++ b/init/util.c @@ -21,6 +21,7 @@ #include <fcntl.h> #include <ctype.h> #include <errno.h> +#include <time.h> #include <sys/stat.h> #include <sys/types.h> @@ -280,3 +281,21 @@ 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; + } + + return ts.tv_sec; +} |