On Fri, Jan 17, 2020 at 9:50 PM Aleksandar Markovic <aleksandar.m.mail@xxxxxxxxx> wrote: > Alexandre (and Arnd too, or any other person knowledgeable in the area), > > I just need to clarify a couple of details with you, please. > > Firstly, here is what man page rtc(4) says: > > "The /dev/rtc (or /dev/rtc0, /dev/rtc1, etc.) device can be opened > only once (until it is closed) and it is read-only. On read(2) and > select(2) the calling process is blocked until the next interrupt from > that RTC is received. Following the interrupt, the process can read a > long integer, of which the least significant byte contains a bit mask > encoding the types of interrupt that occurred, while the remaining 3 > bytes contain the number of interrupts since the last read(2)." > > So, it looks read() will always return only 4 bytes of useful info > (regardless of host being 32-bit/64-bit). It says "long integer", which is 64-bit on a 64-bit machine. > My questions are: > > - Is the description in man page genuinely accurate? Starting with linux-2.6.18, there is another possibility: If an application asks for exactly four bytes on a 64-bit kernel, it gets the lower four bytes, as it would on a 32-bit kernel. This is a hack that was introduced for running 32-bit compat tasks. For any other size less than sizeof(long), the kernel reports an EINVAL error, and for anything larger or equal to sizeof(long) it attempts to output a long word. > - To me (but I am really an outsider to using RTC in applications), > this feature (blocking read()/select()) even looks very nice and > convenient, in all fairness. But I would like to ask you: Is this > feature used rarely or frequently by other libraries/tools/etc.? In > other words, is the feature "obscure" or "crucial" part of RTC kernel > support? Or, something in between? > - Does MC146818 support this feature? No idea, I'll leave these for Alexandre or someone else to answer. Arnd