void jent_get_nstime(__u64 *out) { struct timespec ts; __u64 tmp = 0; tmp = random_get_entropy(); /* * If random_get_entropy does not return a value (which is possible on, * for example, MIPS), invoke __getnstimeofday * hoping that there are timers we can work with. * * The list of available timers can be obtained from * /sys/devices/system/clocksource/clocksource0/available_clocksource * and are registered with clocksource_register() */ if ((0 == tmp) && (0 == __getnstimeofday(&ts))) { tmp = ts.tv_sec; tmp = tmp << 32; tmp = tmp | ts.tv_nsec; } *out = tmp; }
static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz) { char *hdr; struct timespec timestamp; size_t len; /* Report zeroed timestamp if called before timekeeping has resumed. */ if (__getnstimeofday(×tamp)) { timestamp.tv_sec = 0; timestamp.tv_nsec = 0; } hdr = kasprintf(GFP_ATOMIC, RAMOOPS_KERNMSG_HDR "%lu.%lu\n", (long)timestamp.tv_sec, (long)(timestamp.tv_nsec / 1000)); WARN_ON_ONCE(!hdr); len = hdr ? strlen(hdr) : 0; persistent_ram_write(prz, hdr, len); kfree(hdr); return len; }
void jent_get_nstime(__u64 *out) { struct timespec ts; __u64 tmp = 0; tmp = random_get_entropy(); /* * If random_get_entropy does not return a value (which is possible on, * for example, MIPS), invoke __getnstimeofday * hoping that there are timers we can work with. */ if ((0 == tmp) && (0 == __getnstimeofday(&ts))) { tmp = ts.tv_sec; tmp = tmp << 32; tmp = tmp | ts.tv_nsec; } *out = tmp; }