Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 504bc517 authored by Colin Cross's avatar Colin Cross
Browse files

init: Move gettime() to util.c

Change-Id: I1df96964763f8baedbc1cea6875d3dfc5e48c065
parent d11beb2b
Loading
Loading
Loading
Loading
+0 −19
Original line number Original line Diff line number Diff line
@@ -25,7 +25,6 @@
#include <sys/mount.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <sys/poll.h>
#include <sys/poll.h>
#include <time.h>
#include <errno.h>
#include <errno.h>
#include <stdarg.h>
#include <stdarg.h>
#include <mtd/mtd-user.h>
#include <mtd/mtd-user.h>
@@ -119,24 +118,6 @@ static void open_console()
    close(fd);
    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)
static void publish_socket(const char *name, int fd)
{
{
    char key[64] = ANDROID_SOCKET_ENV_PREFIX;
    char key[64] = ANDROID_SOCKET_ENV_PREFIX;
+1 −0
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@ int create_socket(const char *name, int type, mode_t perm,
                  uid_t uid, gid_t gid);
                  uid_t uid, gid_t gid);


void *read_file(const char *fn, unsigned *_sz);
void *read_file(const char *fn, unsigned *_sz);
time_t gettime(void);


void log_init(void);
void log_init(void);
void log_set_level(int level);
void log_set_level(int level);
+19 −0
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@
#include <fcntl.h>
#include <fcntl.h>
#include <ctype.h>
#include <ctype.h>
#include <errno.h>
#include <errno.h>
#include <time.h>


#include <sys/stat.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/types.h>
@@ -280,3 +281,21 @@ int mtd_name_to_number(const char *name)
    }
    }
    return -1;
    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;
}