TODR(9)
π TODR(9) π
okay bestie, welcome to the Kernel Developer's Manual page for TODR(9) β we're talking time-of-day clock support, and it's lowkey giving main character energy π°οΈβ¨.
πΈ NAME πΈ
todr_attach,todr_gettime,todr_settime,clock_ymdhms_to_secs,clock_secs_to_ymdhmsβ time-of-day clock support π
β¨ SYNOPSIS β¨
here's the exact incantation, no cap:
#include <dev/clock_subr.h>
void
todr_attach(todr_chip_handle_t);
int
todr_gettime(todr_chip_handle_t, struct timeval *);
int
todr_settime(todr_chip_handle_t, struct timeval *);
int
clock_secs_to_ymdhms(time_t, struct clock_ymdhms *);
time_t
clock_ymdhms_to_secs(struct clock_ymdhms *);
π« DESCRIPTION π«
so the todr_*() functions are your interface to read, set and control βtime-of-dayβ devices. A driver for a βtime-of-dayβ device registers its todr_chip_handle_t with machine-dependent code using the todr_attach() function. Alternatively, a machine-dependent front-end to a βtime-of-dayβ device driver may obtain the todr_chip_handle_t directly. periodt. π«Ά
todr_gettime() retrieves the current data and time from the TODR device and returns it in the struct timeval storage provided by the caller. todr_settime() sets the date and time in the TODR device represented by todr_chip_handle_t according to the struct timeval argument. slay. π
The utilities clock_secs_to_ymdhms() and clock_ymdhms_to_secs() are provided to convert a time value in seconds to and from a structure representing the date and time as a β¨year,month,day,weekday,hour,minute,secondsβ© tuple. This structure is defined as follows, bestie:
struct clock_ymdhms {
uint64_t dt_year; /* Year */
u_char dt_mon; /* Month (1-12) */
u_char dt_day; /* Day (1-31) */
u_char dt_wday; /* Day of week (0-6) */
u_char dt_hour; /* Hour (0-23) */
u_char dt_min; /* Minute (0-59) */
u_char dt_sec; /* Second (0-59) */
};
Note: leap years are recognised by these conversion routines. literally iconic behavior ποΈπ
π RETURN VALUES π
todr_*()β return0if the requested operation was successful; otherwise an error code from<sys/errno.h>shall be returned. zero is the vibe check, anything else means check your errno πclock_ymdhms_to_secs()β returns-1if the time in seconds would be less that zero or too large to fit in atime_t.clock_secs_to_ymdhms()β returns0on success orEINVALif the time passed is negative.
β οΈ However, behaviour is undefined if an invalid todr_chip_handle_t is passed to any of these functions. no cap, do not do this π
π¦ SEE ALSO π¦
go read these next, bestie β I'm obsessed:
xoxo, Debian β September 10, 2014 β TODR(9) out π
π«Άβ¨
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2000, 2003 The NetBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms