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

Commit d01c257f authored by Mark Salyzyn's avatar Mark Salyzyn Committed by Android Git Automerger
Browse files

am 8f632327: am bb0fbdbe: Merge "logd: liblog: 64-bit issues"

* commit '8f632327':
  logd: liblog: 64-bit issues
parents e4980725 8f632327
Loading
Loading
Loading
Loading
+55 −4
Original line number Diff line number Diff line
@@ -19,21 +19,38 @@

#include <time.h>

/* struct log_time is a wire-format variant of struct timespec */
#define NS_PER_SEC 1000000000ULL
#ifdef __cplusplus
struct log_time : public timespec {
struct log_time {
public:
    uint32_t tv_sec; // good to Feb 5 2106
    uint32_t tv_nsec;

    log_time(const timespec &T)
    {
        tv_sec = T.tv_sec;
        tv_nsec = T.tv_nsec;
    }
    log_time(const log_time &T)
    {
        tv_sec = T.tv_sec;
        tv_nsec = T.tv_nsec;
    }
    log_time(uint32_t sec, uint32_t nsec)
    {
        tv_sec = sec;
        tv_nsec = nsec;
    }
    log_time()
    {
    }
    log_time(clockid_t id)
    {
        clock_gettime(id, (timespec *) this);
        timespec T;
        clock_gettime(id, &T);
        tv_sec = T.tv_sec;
        tv_nsec = T.tv_nsec;
    }
    log_time(const char *T)
    {
@@ -41,6 +58,8 @@ public:
        tv_sec = c[0] | (c[1] << 8) | (c[2] << 16) | (c[3] << 24);
        tv_nsec = c[4] | (c[5] << 8) | (c[6] << 16) | (c[7] << 24);
    }

    // timespec
    bool operator== (const timespec &T) const
    {
        return (tv_sec == T.tv_sec) && (tv_nsec == T.tv_nsec);
@@ -67,13 +86,45 @@ public:
    {
        return !(*this > T);
    }

    // log_time
    bool operator== (const log_time &T) const
    {
        return (tv_sec == T.tv_sec) && (tv_nsec == T.tv_nsec);
    }
    bool operator!= (const log_time &T) const
    {
        return !(*this == T);
    }
    bool operator< (const log_time &T) const
    {
        return (tv_sec < T.tv_sec)
            || ((tv_sec == T.tv_sec) && (tv_nsec < T.tv_nsec));
    }
    bool operator>= (const log_time &T) const
    {
        return !(*this < T);
    }
    bool operator> (const log_time &T) const
    {
        return (tv_sec > T.tv_sec)
            || ((tv_sec == T.tv_sec) && (tv_nsec > T.tv_nsec));
    }
    bool operator<= (const log_time &T) const
    {
        return !(*this > T);
    }

    uint64_t nsec() const
    {
        return static_cast<uint64_t>(tv_sec) * NS_PER_SEC + tv_nsec;
    }
};
} __attribute__((__packed__));
#else
typedef struct timespec log_time;
typedef struct log_time {
    uint32_t tv_sec;
    uint32_t tv_nsec;
} __attribute__((__packed__)) log_time;
#endif

#endif /* define _LIBS_LOG_LOG_READ_H */
+4 −4
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ struct logger_entry {
    int32_t     sec;    /* seconds since Epoch */
    int32_t     nsec;   /* nanoseconds */
    char        msg[0]; /* the entry's payload */
};
} __attribute__((__packed__));

/*
 * The userspace structure for version 2 of the logger_entry ABI.
@@ -46,18 +46,18 @@ struct logger_entry_v2 {
    int32_t     nsec;      /* nanoseconds */
    uint32_t    euid;      /* effective UID of logger */
    char        msg[0];    /* the entry's payload */
};
} __attribute__((__packed__));

struct logger_entry_v3 {
    uint16_t    len;       /* length of the payload */
    uint16_t    hdr_size;  /* sizeof(struct logger_entry_v2) */
    uint16_t    hdr_size;  /* sizeof(struct logger_entry_v3) */
    int32_t     pid;       /* generating process's pid */
    int32_t     tid;       /* generating process's tid */
    int32_t     sec;       /* seconds since Epoch */
    int32_t     nsec;      /* nanoseconds */
    uint32_t    lid;       /* log id of the payload */
    char        msg[0];    /* the entry's payload */
};
} __attribute__((__packed__));

/*
 * The maximum size of the log entry payload that can be
+4 −1
Original line number Diff line number Diff line
@@ -117,8 +117,11 @@ static int __write_to_log_kernel(log_id_t log_id, struct iovec *vec, size_t nr)
    newVec[0].iov_base   = (unsigned char *) &log_id_buf;
    newVec[0].iov_len    = sizeof_log_id_t;

    struct timespec ts;
    clock_gettime(CLOCK_REALTIME, &ts);
    log_time realtime_ts;
    clock_gettime(CLOCK_REALTIME, &realtime_ts);
    realtime_ts.tv_sec = ts.tv_sec;
    realtime_ts.tv_nsec = ts.tv_nsec;

    newVec[1].iov_base   = (unsigned char *) &realtime_ts;
    newVec[1].iov_len    = sizeof(log_time);
+1 −1
Original line number Diff line number Diff line
@@ -143,7 +143,7 @@ static void BM_log_latency(int iters) {
    for (int j = 0, i = 0; i < iters && j < 10*iters; ++i, ++j) {
        log_time ts;
        LOG_FAILURE_RETRY((
            clock_gettime(CLOCK_REALTIME, &ts),
            ts = log_time(CLOCK_REALTIME),
            android_btWriteLog(0, EVENT_TYPE_LONG, &ts, sizeof(ts))));

        for (;;) {
+1 −1
Original line number Diff line number Diff line
@@ -171,7 +171,7 @@ static void caught_blocking(int signum)

    ++signaled;
    if ((signal_time.tv_sec == 0) && (signal_time.tv_nsec == 0)) {
        clock_gettime(CLOCK_MONOTONIC, &signal_time);
        signal_time = log_time(CLOCK_MONOTONIC);
        signal_time.tv_sec += 2;
    }

Loading