
21 Aug
2019
21 Aug
'19
3:24 p.m.
On Wednesday, 14 August 2019 16:33:22 CEST Michal Privoznik wrote:
+int +virHostGetBootTime(unsigned long long *when ATTRIBUTE_UNUSED) +{ +#if defined(__linux__) || defined(__FreeBSD__) + struct utmpx id = {.ut_type = BOOT_TIME}; + struct utmpx *res = NULL; + + if (!(res = getutxid(&id))) { + int theerrno = errno; + endutxent(); + return -theerrno; + } + + *when = res->ut_tv.tv_sec; + endutxent(); + return 0; +#else + /* Unfortunately, mingw lacks utmp */ + errno = ENOSYS; + return -errno; +#endif
In addition to what Jirka said, IMHO it would be better to do a configure detection of the non-POSIX function, rather than assuming on which platforms/OSes it is available. -- Pino Toscano