Thread #108622965
HomeIndexCatalogAll ThreadsNew ThreadReply
H
previous: >>108613877

#define __NR_adjtimex                159
#define __NR_clock_adjtime 305

https://man7.org/linux/man-pages/man2/adjtimex.2.html

tl;dr:
clock algorithm wizardry

that's all you're getting for the description, too. it's just algorithm stuff. important, sure, but really complicated and outside of my area of expertise

relevant resources:
man man

man syscalls

https://man7.org/linux/man-pages/
https://linux.die.net/man/
https://elixir.bootlin.com/linux/
https://elixir.bootlin.com/musl/
https://elixir.bootlin.com/glibc/
+Showing all 8 replies.
>>
This is used to implement adjtime(3), which tries to change the time by slightly speeding up or slowing down the clock until the time is correct. This is meant to avoid confusing programs that use CLOCK_REALTIME because the clock jumped a huge amount of time in an instant. https://man7.org/linux/man-pages/man3/adjtime.3.html
>>
>>108623490
Actually I guess its not just programs that use CLOCK_REALTIME, but also programs like make that care about file timestamps
>>
I guess this is the thread to ask this in: does anyone know what the deal with leap seconds is? I know Unix time is supposed to ignore them, so is Unix time 22 seconds (or however much) off from real time or what? I've implemented my own C time library because the stdlib one sucks, and the results from that are identical to coreutils tools, which are identical to what the NIST atomic clock calculates, so where do the leap seconds factor in?
>>
Bumped just in time.
>>
>>108625104
yay
>>
I guess nobody cares about this one. Or maybe it's just Friday.
>>
>>108626677
I'm busy sperging out at retarded compiler devs.
>>
>>108623903
unix timestamp is miserable underspecified in this sense.
time(NULL) and clock_gettime(CLOCK_REALTIME) already returns time modified by leap seconds. this is Linux behavior, some systems might behave differently. it's just not specified.
the fucked up thing is that during leap second, you just get the same time for window of two seconds. although the nice side effect is that the conversion from seconds to calendar is always correct (but for leap seconds you have two possible answers, you always get the 59s instead of 60s).
conversion to struct tm with GM timezone is just formatting, doesn't care about leap seconds being or not being included.
there is a file in /etc with leap seconds, any program that cares needs to process it on its own.

actually I'm not sure how OS handles the addition of leap seconds. I think you have to update the table file (some OS core package, maybe main distro release) and reboot??? does Linux kernel accesses this file? how and when? idk

god I fucking have leap seconds and UTC so fucking much. If I had a time machine I would kill that faggot who used it as time base for NTP.

Reply to Thread #108622965


Supported: JPG, PNG, GIF, WebP, WebM, MP4, MP3 (max 4MB)