tools/thermal/lib/uptimeofday.c
Source file repositories/reference/linux-study-clean/tools/thermal/lib/uptimeofday.c
File Facts
- System
- Linux kernel
- Corpus path
tools/thermal/lib/uptimeofday.c- Extension
.c- Size
- 735 bytes
- Lines
- 41
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdio.hsys/time.hlinux/sysinfo.hthermal-tools.h
Detected Declarations
function uptimeofday_initfunction getuptimeofday_msfunction msec_to_timespec
Annotated Snippet
// SPDX-License-Identifier: LGPL-2.1+
// Copyright (C) 2022, Linaro Ltd - Daniel Lezcano <daniel.lezcano@linaro.org>
#include <stdio.h>
#include <sys/time.h>
#include <linux/sysinfo.h>
#include "thermal-tools.h"
static unsigned long __offset;
static struct timeval __tv;
int uptimeofday_init(void)
{
struct sysinfo info;
if (sysinfo(&info))
return -1;
gettimeofday(&__tv, NULL);
__offset = __tv.tv_sec - info.uptime;
return 0;
}
unsigned long getuptimeofday_ms(void)
{
gettimeofday(&__tv, NULL);
return ((__tv.tv_sec - __offset) * 1000) + (__tv.tv_usec / 1000);
}
struct timespec msec_to_timespec(int msec)
{
struct timespec tv = {
.tv_sec = (msec / 1000),
.tv_nsec = (msec % 1000) * 1000000,
};
return tv;
}
Annotation
- Immediate include surface: `stdio.h`, `sys/time.h`, `linux/sysinfo.h`, `thermal-tools.h`.
- Detected declarations: `function uptimeofday_init`, `function getuptimeofday_ms`, `function msec_to_timespec`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.