]> Savannah Git Hosting - gnulib.git/log
gnulib.git
20 months agowcsstr: Relicense under LGPLv2+.
Bruno Haible [Mon, 21 Aug 2023 13:59:34 +0000 (15:59 +0200)]
wcsstr: Relicense under LGPLv2+.

* modules/wcsstr (License): Change to LGPLv2+.

20 months agowcsstr-simple: Relicense under LGPLv2+.
Bruno Haible [Mon, 21 Aug 2023 13:58:16 +0000 (15:58 +0200)]
wcsstr-simple: Relicense under LGPLv2+.

* modules/wcsstr-simple (License): Change to LGPLv2+.
* lib/wcsstr.c: Update license notice.
* lib/wcsstr-impl.h: Update license notice. The code added here on
2023-03-27 was under LGPLv2+.

20 months agowmemcmp: Relicense under LGPLv2+.
Bruno Haible [Mon, 21 Aug 2023 13:50:35 +0000 (15:50 +0200)]
wmemcmp: Relicense under LGPLv2+.

* modules/wmemcmp (License): Change to LGPLv2+.
* lib/wmemcmp.c: Update license notice.
* lib/wmemcmp-impl.h: Likewise.

20 months agowcschr: Relicense under LGPLv2+.
Bruno Haible [Mon, 21 Aug 2023 13:46:02 +0000 (15:46 +0200)]
wcschr: Relicense under LGPLv2+.

* modules/wcschr (License): Change to LGPLv2+.
* lib/wcschr.c: Update license notice.
* lib/wcschr-impl.h: Likewise.

20 months agounistr/u32-strlen: Complete license change from 2023-07-23.
Bruno Haible [Mon, 21 Aug 2023 13:30:22 +0000 (15:30 +0200)]
unistr/u32-strlen: Complete license change from 2023-07-23.

* lib/unistr/u-strlen.h: Update license notice.

20 months agoisnanl: Relicense under LGPLv2+.
Bruno Haible [Mon, 21 Aug 2023 13:08:54 +0000 (15:08 +0200)]
isnanl: Relicense under LGPLv2+.

* modules/isnanl (License): Change to LGPLv2+.

20 months agoldexp: port to non-two’s complement
Paul Eggert [Mon, 21 Aug 2023 00:55:03 +0000 (17:55 -0700)]
ldexp: port to non-two’s complement

* lib/ldexp.c (FUNC): Don’t assume two’s-complement.

20 months agoreadutmp, boot-time: Fix the result on runit and s6 init systems.
Bruno Haible [Sun, 20 Aug 2023 20:34:39 +0000 (22:34 +0200)]
readutmp, boot-time: Fix the result on runit and s6 init systems.

* lib/boot-time-aux.h (get_linux_boot_time_fallback): Try also
/var/lib/urandom/random-seed. Try /var/run/utmp last.

20 months agoldexp: fix INT_MIN infloop
Paul Eggert [Sun, 20 Aug 2023 20:23:11 +0000 (13:23 -0700)]
ldexp: fix INT_MIN infloop

* lib/ldexp.c (FUNC): Instead of converting EXP to unsigned,
work on it directly.  This simplifies the code and avoids
an infinite loop when EXP == INT_MIN.
* modules/ldexp, modules/ldexpl: Depend on stdbool.
* tests/test-ldexp.h: Include <limits.h> for INT_MIN.
(test_function): Test for infloop.

20 months agomake -C doc INSTALL INSTALL.ISO INSTALL.UTF-8
Paul Eggert [Sun, 20 Aug 2023 19:41:58 +0000 (12:41 -0700)]
make -C doc INSTALL INSTALL.ISO INSTALL.UTF-8

20 months agoldexp: Fix compilation error in C++ mode.
Bruno Haible [Sun, 20 Aug 2023 13:01:25 +0000 (15:01 +0200)]
ldexp: Fix compilation error in C++ mode.

* lib/math.in.h (ldexp): Use _GL_CXXALIASWARN1, not _GL_CXXALIASWARN.

20 months agoldexp: Work around OpenBSD/mips64 bug.
Bruno Haible [Sun, 20 Aug 2023 00:43:01 +0000 (02:43 +0200)]
ldexp: Work around OpenBSD/mips64 bug.

* lib/math.in.h (ldexp): New declaration.
* lib/ldexp.c: New file, based on lib/ldexpl.c.
* lib/ldexpl.c: Moved the implementation to lib/ldexp.c. Just include
it.
* m4/math_h.m4 (gl_MATH_H_REQUIRE_DEFAULTS): Initialize GNULIB_LDEXP.
(gl_MATH_H_DEFAULTS): Initialize REPLACE_LDEXP.
* m4/ldexp.m4 (gl_FUNC_LDEXP): Require gl_MATH_H_DEFAULTS and
gl_FUNC_ISNAND. Invoke gl_FUNC_LDEXP_WORKS. Set REPLACE_LDEXP. Consider
it when setting LDEXP_LIBM.
(gl_FUNC_LDEXP_WORKS): New macro.
* modules/math (Makefile.am): Substitute GNULIB_LDEXP, REPLACE_LDEXP.
* modules/ldexp (Files): Add lib/ldexp.c.
(Depends-on): Add math, isnand.
(configure.ac): Set GL_COND_OBJ_LDEXP. Invoke gl_MATH_MODULE_INDICATOR.
(Makefile.am): Conditionally compile ldexp.c.
* modules/ldexpl (Files): Add lib/ldexp.c.
* doc/posix-functions/ldexp.texi: Mention the OpenBSD bug.

20 months agoldexpl: Relicense under LGPLv2+.
Bruno Haible [Sun, 20 Aug 2023 01:10:00 +0000 (03:10 +0200)]
ldexpl: Relicense under LGPLv2+.

* modules/ldexpl (License): Change to LGPLv2+.
* lib/ldexpl.c: Update license notice.

20 months agoisnand: Relicense under LGPLv2+.
Bruno Haible [Sun, 20 Aug 2023 00:19:04 +0000 (02:19 +0200)]
isnand: Relicense under LGPLv2+.

* modules/isnand (License): Change to LGPLv2+.

20 months agoldexpl: Avoid possible -Wshadow warning.
Bruno Haible [Sat, 19 Aug 2023 23:44:26 +0000 (01:44 +0200)]
ldexpl: Avoid possible -Wshadow warning.

* lib/ldexpl.c (exp): Locally rename to 'exponent'.

20 months agoldexpl: Fix signed integer overflow.
Bruno Haible [Sat, 19 Aug 2023 23:41:56 +0000 (01:41 +0200)]
ldexpl: Fix signed integer overflow.

* lib/ldexpl.c (ldexpl): Use an 'unsigned int' variable to represent the
absolute value of exp without overflow.

20 months agologbl: Work around endless loop on OpenBSD 7.3/mips64.
Bruno Haible [Sat, 19 Aug 2023 22:45:05 +0000 (00:45 +0200)]
logbl: Work around endless loop on OpenBSD 7.3/mips64.

* m4/logbl.m4 (gl_FUNC_LOGBL_WORKS): Terminate the test program if it
takes longer than 5 seconds.
* doc/posix-functions/logbl.texi: Mention the OpenBSD bug.

20 months agoautoupdate
Karl Berry [Sat, 19 Aug 2023 15:24:52 +0000 (08:24 -0700)]
autoupdate

20 months agothrd: Work around thrd_join bug on AIX 7.3.1.
Bruno Haible [Fri, 18 Aug 2023 20:38:04 +0000 (22:38 +0200)]
thrd: Work around thrd_join bug on AIX 7.3.1.

* m4/threads_h.m4 (gl_THREADS_H): Test against AIX 7 thrd_join bug. Set
BROKEN_THRD_JOIN.
(gl_THREADS_H_DEFAULTS): Initialize BROKEN_THRD_JOIN.
* m4/thrd.m4 (gl_FUNC_THRD_JOIN): Set REPLACE_THRD_* to 1 also if
BROKEN_THRD_JOIN is 1. Define BROKEN_THRD_START_T_OR_JOIN instead of
BROKEN_THRD_START_T.
* modules/threads-h (Makefile.am): Substitute BROKEN_THRD_JOIN.
* lib/threads.in.h (rpl_thrd_t, thrd_t): Define also if BROKEN_THRD_JOIN
is 1.
* lib/thrd.c: Test BROKEN_THRD_START_T_OR_JOIN instead of
BROKEN_THRD_START_T.
* doc/posix-functions/thrd_join.texi: Update.
* doc/posix-functions/thrd_exit.texi: Likewise.

20 months agothrd: Refactor.
Bruno Haible [Fri, 18 Aug 2023 19:14:40 +0000 (21:14 +0200)]
thrd: Refactor.

* m4/thrd.m4 (gl_FUNC_THRD_JOIN): Define BROKEN_THRD_JOIN_NULL, not
BROKEN_THRD_JOIN. Rename gl_cv_func_thrd_join_works to
gl_cv_func_thrd_join_null_works.
* lib/thrd.c: Test BROKEN_THRD_JOIN_NULL instead of BROKEN_THRD_JOIN.

20 months agothrd tests: Add unit test for thrd_exit.
Bruno Haible [Fri, 18 Aug 2023 17:39:03 +0000 (19:39 +0200)]
thrd tests: Add unit test for thrd_exit.

* tests/test-thrd_exit.c: New file, based on tests/test-thrd_create.c.
* modules/thrd-tests (Files): Add it.
(Makefile.am): Compile and run it.

20 months agothrd: On AIX 7.1 and 7.2, override also thrd_exit.
Bruno Haible [Fri, 18 Aug 2023 18:52:08 +0000 (20:52 +0200)]
thrd: On AIX 7.1 and 7.2, override also thrd_exit.

* lib/threads.in.h (thrd_exit): Consider REPLACE_THRD_EXIT.
* lib/thrd.c (rpl_thrd_exit): New function.
* m4/threads_h.m4 (gl_THREADS_H_DEFAULTS): Initialize REPLACE_THRD_EXIT.
* m4/thrd.m4 (gl_FUNC_THRD_JOIN): Set also REPLACE_THRD_EXIT and adjust
LIBSTDTHREAD.
* modules/threads-h (Makefile.am): Substitute REPLACE_THRD_EXIT.
* doc/posix-functions/thrd_exit.texi: Mention the AIX thrd_join problem
also here.

20 months agoaligned_alloc: Fix test failure on AIX 7.3 with ibm-clang.
Bruno Haible [Fri, 18 Aug 2023 16:54:28 +0000 (18:54 +0200)]
aligned_alloc: Fix test failure on AIX 7.3 with ibm-clang.

* m4/aligned_alloc.m4 (gl_FUNC_ALIGNED_ALLOC): Use 'volatile', to
disable optimization of ibm-clang -O2.
* doc/posix-functions/aligned_alloc.texi: Update version info.

20 months agosys_socket: Fix compilation errors in C++ mode on AIX 7.3 with gcc.
Bruno Haible [Fri, 18 Aug 2023 15:25:26 +0000 (17:25 +0200)]
sys_socket: Fix compilation errors in C++ mode on AIX 7.3 with gcc.

* lib/sys_socket.in.h (accept, getpeername, getsockname, recvfrom):
Disable _GL_CXXALIASWARN invocation on non-glibc systems.

20 months agostddef: Don't unnecessarily override max_align_t on AIX 7.3 with gcc.
Bruno Haible [Fri, 18 Aug 2023 11:46:15 +0000 (13:46 +0200)]
stddef: Don't unnecessarily override max_align_t on AIX 7.3 with gcc.

* lib/stddef.in.h (max_align_t, GNULIB_defined_max_align_t): Don't
define or override if HAVE_MAX_ALIGN_T is 1.

20 months agouptime: Deprecate.
Bruno Haible [Fri, 18 Aug 2023 11:18:04 +0000 (13:18 +0200)]
uptime: Deprecate.

Suggested by Paul Eggert in
<https://lists.gnu.org/archive/html/bug-coreutils/2023-08/msg00070.html>.

* modules/uptime (Status, Notice): New sections.

20 months agoRecognize the *-*-windows* config triplets introduced on 2023-06-26.
Bruno Haible [Thu, 17 Aug 2023 13:04:43 +0000 (15:04 +0200)]
Recognize the *-*-windows* config triplets introduced on 2023-06-26.

* m4/*.m4: Treat windows* as equivalent to mingw*.
* modules/*: Likewise.

20 months agomake -C doc INSTALL INSTALL.ISO INSTALL.UTF-8
Paul Eggert [Wed, 16 Aug 2023 22:33:27 +0000 (15:33 -0700)]
make -C doc INSTALL INSTALL.ISO INSTALL.UTF-8

20 months agombrtoc32-regular: Make it work as expected on glibc 2.12.
Bruno Haible [Wed, 16 Aug 2023 21:44:57 +0000 (23:44 +0200)]
mbrtoc32-regular: Make it work as expected on glibc 2.12.

* lib/mbrtoc32.c (mbrtoc32): If necessary, clear the mbstate_t after
mbrtowc() returned.

20 months agofnmatch: Override fnmatch from glibc versions < 2.22.
Bruno Haible [Wed, 16 Aug 2023 19:47:26 +0000 (21:47 +0200)]
fnmatch: Override fnmatch from glibc versions < 2.22.

* m4/fnmatch.m4 (gl_FUNC_FNMATCH_POSIX): Force REPLACE_FNMATCH=1 in
glibc versions < 2.22.

20 months agotests: Avoid some test failures on Slackware 13.37.
Bruno Haible [Wed, 16 Aug 2023 19:42:46 +0000 (21:42 +0200)]
tests: Avoid some test failures on Slackware 13.37.

Make last commit actually work.

20 months agotests: Avoid some test failures on Slackware 13.37.
Bruno Haible [Wed, 16 Aug 2023 15:45:26 +0000 (17:45 +0200)]
tests: Avoid some test failures on Slackware 13.37.

* tests/test-c32isalnum.c (main): Disable GB18030 tests on
glibc 2.13..2.15.
* tests/test-c32isalpha.c (main): Likewise.
* tests/test-c32isblank.c (main): Likewise.
* tests/test-c32iscntrl.c (main): Likewise.
* tests/test-c32isdigit.c (main): Likewise.
* tests/test-c32isgraph.c (main): Likewise.
* tests/test-c32islower.c (main): Likewise.
* tests/test-c32isprint.c (main): Likewise.
* tests/test-c32ispunct.c (main): Likewise.
* tests/test-c32isspace.c (main): Likewise.
* tests/test-c32isupper.c (main): Likewise.
* tests/test-c32isxdigit.c (main): Likewise.
* tests/test-c32rtomb.c (main): Likewise.
* tests/test-c32snrtombs.c (main): Likewise.
* tests/test-c32srtombs.c (main): Likewise.
* tests/test-c32stombs.c (main): Likewise.
* tests/test-c32tolower.c (main): Likewise.
* tests/test-c32toupper.c (main): Likewise.
* tests/test-fnmatch.c (main): Likewise.
* tests/test-mbrtoc16.c (main): Likewise.
* tests/test-mbrtoc32.c (main): Likewise.
* tests/test-mbsnrtoc32s.c (main): Likewise.
* tests/test-mbsrtoc32s.c (main): Likewise.
* tests/test-mbstoc32s.c (main): Likewise.

20 months agoautoupdate
Karl Berry [Wed, 16 Aug 2023 14:14:19 +0000 (07:14 -0700)]
autoupdate

20 months agoreadutmp tests: Add test against today's bug.
Bruno Haible [Tue, 15 Aug 2023 21:32:27 +0000 (23:32 +0200)]
readutmp tests: Add test against today's bug.

* tests/test-readutmp.c (main): Verify that there is exactly one
BOOT_TIME entry.

20 months agoreadutmp: Fix for platforms without ut_type (regression 2023-08-08).
Bruno Haible [Tue, 15 Aug 2023 10:58:14 +0000 (12:58 +0200)]
readutmp: Fix for platforms without ut_type (regression 2023-08-08).

* lib/readutmp.h (UT_TYPE_BOOT_TIME, UT_TYPE_USER_PROCESS): Don't use
UT_TYPE_EQ macro.
(IS_USER_PROCESS): Don't use UT_USER, UT_TYPE_NOT_DEFINED macros.
* lib/readutmp.c (IS_USER_PROCESS): Don't override.

20 months agoreadutmp, boot-time: Don't use __UT_* symbols (regression 2023-08-11).
Bruno Haible [Mon, 14 Aug 2023 13:47:41 +0000 (15:47 +0200)]
readutmp, boot-time: Don't use __UT_* symbols (regression 2023-08-11).

* lib/readutmp.h (_GL_UT_USER_SIZE, _GL_UT_ID_SIZE, _GL_UT_LINE_SIZE,
_GL_UT_HOST_SIZE): New macros.
(struct utmpx32): Use them.

20 months agoreadutmp, boot-time: Fix build on 32-bit glibc (regression 2023-08-11).
Bruno Haible [Mon, 14 Aug 2023 10:14:38 +0000 (12:14 +0200)]
readutmp, boot-time: Fix build on 32-bit glibc (regression 2023-08-11).

Reported by Andreas Schwab <schwab@suse.de> in
<https://lists.gnu.org/archive/html/bug-gnulib/2023-08/msg00125.html>.

* lib/readutmp.h (struct utmpx32): Reference __UT_NAMESIZE, not
__UT_USERSIZE.

20 months agostdint: Fix configure test result with gcc 4.7 or 4.8.
Bruno Haible [Mon, 14 Aug 2023 00:51:01 +0000 (02:51 +0200)]
stdint: Fix configure test result with gcc 4.7 or 4.8.

* m4/stdint.m4 (gl_STDINT_H): Don't assume that _Generic works with
GCC versions < 4.9 with -std=gnu11.

20 months agoFix some test module descriptions.
Bruno Haible [Mon, 14 Aug 2023 00:02:31 +0000 (02:02 +0200)]
Fix some test module descriptions.

* modules/boot-time-tests (Files): Add tests/macros.h.
* modules/dprintf-gnu-tests (Files): Likewise.
* modules/fclose-tests (Files): Likewise.
* modules/getcwd-tests (Files): Likewise.
* modules/lock-tests (Files): Likewise.
* modules/nullptr-c++-tests (Files): Likewise.
* modules/posix_spawn-tests (Files): Likewise.
* modules/posix_spawnp-tests (Files): Likewise.
* modules/readutmp-tests (Files): Likewise.
* modules/sh-quote-tests (Files): Likewise.
* modules/unigbrk/u16-grapheme-breaks-tests (Files): Likewise.
* modules/unigbrk/u16-grapheme-next-tests (Files): Likewise.
* modules/unigbrk/u16-grapheme-prev-tests (Files): Likewise.
* modules/unigbrk/u32-grapheme-breaks-tests (Files): Likewise.
* modules/unigbrk/u32-grapheme-next-tests (Files): Likewise.
* modules/unigbrk/u32-grapheme-prev-tests (Files): Likewise.
* modules/unigbrk/u8-grapheme-breaks-tests (Files): Likewise.
* modules/unigbrk/u8-grapheme-next-tests (Files): Likewise.
* modules/unigbrk/u8-grapheme-prev-tests (Files): Likewise.
* modules/unigbrk/uc-grapheme-breaks-tests (Files): Likewise.

20 months agonproc, physmem: Use sysctl() as a fallback on GNU/kFreeBSD.
Bruno Haible [Sun, 13 Aug 2023 23:04:36 +0000 (01:04 +0200)]
nproc, physmem: Use sysctl() as a fallback on GNU/kFreeBSD.

* lib/nproc.c: Do include <sys/sysctl.h> on GNU/kFreeBSD.
(num_processors_ignoring_omp): Call sysctl on GNU/kFreeBSD.
* lib/physmem.c: Do include <sys/sysctl.h> on GNU/kFreeBSD.
(physmem_total, physmem_available): Call sysctl on GNU/kFreeBSD.

20 months agophysmem: Add tests.
Bruno Haible [Sun, 13 Aug 2023 22:49:25 +0000 (00:49 +0200)]
physmem: Add tests.

* tests/test-physmem.c: New file.
* modules/physmem-tests: New file.

20 months agoreadutmp, boot-time: Fix warning on glibc 2.30..2.31 on Linux.
Bruno Haible [Sun, 13 Aug 2023 22:13:13 +0000 (00:13 +0200)]
readutmp, boot-time: Fix warning on glibc 2.30..2.31 on Linux.

Reported by Pádraig Brady in
<https://lists.gnu.org/archive/html/bug-gnulib/2023-08/msg00110.html>.

* lib/readutmp.c: Don't include <sys/sysctl.h> on glibc/Linux.
* lib/boot-time.c: Likewise.

20 months agofts: improve memory-allocation errno handling
Paul Eggert [Sun, 13 Aug 2023 16:46:47 +0000 (09:46 -0700)]
fts: improve memory-allocation errno handling

* lib/fts.c (fts_read, fts_build): When enter_dir or setup_dir
fails, report its errno value back to the user.
(internal_function): Preserve errno.
* modules/fts (Depends-on): Add calloc-posix, free-posix,
malloc-posix, and realloc-posix, for better errno handling
on allocation failures.

20 months agohash: set errno on failure
Paul Eggert [Sun, 13 Aug 2023 15:34:44 +0000 (08:34 -0700)]
hash: set errno on failure

* lib/hash.c: Include errno.h.
(compute_bucket_size, hash_initialize, hash_rehash)
(hash_insert_if_absent): Set errno reliably on failure.
(hash_free): Preserve errno, like plain 'free'.
* modules/hash (Depends-on): Depend on calloc-posix,
free-posix, malloc-posix, so that errno is set reliably.

20 months agoreadutmp, boot-time: Fix compilation error on old Android.
Bruno Haible [Sun, 13 Aug 2023 14:33:28 +0000 (16:33 +0200)]
readutmp, boot-time: Fix compilation error on old Android.

Reported by Po Lu in
<https://lists.gnu.org/archive/html/bug-gnulib/2023-08/msg00108.html>.

* lib/readutmp.h (BOOT_TIME): Add fallback.

20 months agoreadutmp, boot-time: Fix compilation error on Android API 8.
Bruno Haible [Sun, 13 Aug 2023 14:08:33 +0000 (16:08 +0200)]
readutmp, boot-time: Fix compilation error on Android API 8.

Reported by Po Lu in
<https://lists.gnu.org/archive/html/bug-gnulib/2023-08/msg00108.html>.

* m4/readutmp.m4 (gl_PREREQ_READUTMP_H): Test whether sysinfo is
declared.
* lib/boot-time-aux.h (get_linux_uptime): Invoke sysinfo only if it is
declared.
* doc/glibc-functions/sysinfo.texi: Mention the Android problem.

20 months agoreadutmp, boot-time: Fix compilation error on old Android.
Bruno Haible [Sun, 13 Aug 2023 13:39:09 +0000 (15:39 +0200)]
readutmp, boot-time: Fix compilation error on old Android.

Reported by Po Lu in
<https://lists.gnu.org/archive/html/bug-gnulib/2023-08/msg00108.html>.

* lib/readutmp.c (endutent): New fallback declaration, for Android.
(getutent): Remove Ultrix workaround from 2000-04-05.
* lib/boot-time.c: Likewise.
* m4/readutmp.m4 (gl_PREREQ_READUTMP_H): Test whether endutent is
declared, not getutent.
* doc/glibc-functions/endutent.texi: Mention the Android bug.

20 months agoboot-time,readutmp: do not depend on c-strtod
Paul Eggert [Sat, 12 Aug 2023 23:54:51 +0000 (16:54 -0700)]
boot-time,readutmp: do not depend on c-strtod

* lib/boot-time-aux.h (get_linux_uptime): Compute struct timespec
using integer arithmetic rather than double.
* lib/boot-time.c, lib/readutmp.c: Don’t include c-strtod.h.
* modules/boot-time, modules/readutmp (Depends-on): Remove c-strtod.

20 months agoboot-time,readutmp: remove -lrt usage
Paul Eggert [Sat, 12 Aug 2023 23:45:30 +0000 (16:45 -0700)]
boot-time,readutmp: remove -lrt usage

This code uses clock-relevant functions only on platforms
that do not need -lrt.
* m4/readutmp.m4 (gl_READUTMP): Do not require gl_CLOCK_TIME
or add CLOCK_TIME_LIB to READUTMP_LIB.
* modules/boot-time (Link): No need to link with CLOCK_TIME_LIB.

20 months agoboot-time,readutmp: do not depend on fopen-gnu
Paul Eggert [Sat, 12 Aug 2023 23:05:22 +0000 (16:05 -0700)]
boot-time,readutmp: do not depend on fopen-gnu

These modules should work well enough even if fopen is not fixed
to conform to fopen-gnu standards.  The only gotcha I can see is
older fopen implementations that lack support for "e", and
a potential O_CLOEXEC leak is not worth worrying about.
* modules/boot-time (Depends-on):
* modules/readutmp (Depends-on):
Remove fopen-gnu.

20 months agoreadutmp: do not depend on timespec_get
Paul Eggert [Sat, 12 Aug 2023 22:57:35 +0000 (15:57 -0700)]
readutmp: do not depend on timespec_get

boot-time code no longer needs it.
* modules/readutmp (Depends-on): Remove timespec_get.

20 months agoboot-time: do not depend on timespec_get
Paul Eggert [Sat, 12 Aug 2023 22:46:43 +0000 (15:46 -0700)]
boot-time: do not depend on timespec_get

This is for Emacs, which does not use timespec_get now
and which likes to minimize dependencies.
Also, treat musl libc like recent glibc,
and fix a timespec_get return value typo.
* lib/boot-time-aux.h (get_linux_uptime):
Assume musl libc supports CLOCK_BOOTTIME.
(get_linux_boot_time_final_fallback):
Likewise for musl libc and CLOCK_REALTIME.
Do not rely on the timespec_get module, to break the dependency.
Consider 0 to be a failure return from timespec_get.
Fall back on gettimeofday if timespec_get does not exist.
* modules/boot-time (Depends-on): Remove timespec_get.

20 months agoreadutmp, boot-time: Fix parsing of /proc/uptime.
Bruno Haible [Sat, 12 Aug 2023 22:09:06 +0000 (00:09 +0200)]
readutmp, boot-time: Fix parsing of /proc/uptime.

* lib/boot-time-aux.h (get_linux_uptime): Use c_strtod, not strtod.
* lib/readutmp.c: Include c-strtod.h.
* lib/boot-time.c: Likewise.
* modules/readutmp (Depends-on): Add c-strtod.
* modules/boot-time (Depends-on): Likewise.

20 months agoreadutmp: On Linux, don't fail if /var/run/utmp is not accessible.
Bruno Haible [Sat, 12 Aug 2023 21:44:23 +0000 (23:44 +0200)]
readutmp: On Linux, don't fail if /var/run/utmp is not accessible.

* lib/boot-time-aux.h (get_linux_boot_time_final_fallback): Don't test
NEED_BOOT_TIME_FINAL_FALLBACK.
* lib/boot-time.c (NEED_BOOT_TIME_FINAL_FALLBACK): Remove macro.
* lib/readutmp.c (NEED_BOOT_TIME_FINAL_FALLBACK): Remove macro.
(read_utmp_from_file): As a fallback on Linux, invoke
get_linux_boot_time_final_fallback.
(get_boot_time_uncached): Don't do it here.
* m4/readutmp.m4 (gl_READUTMP): Add $CLOCK_TIME_LIB to READUTMP_LIB.

20 months agoreadutmp, boot-time: On Haiku, return the boot time.
Bruno Haible [Sat, 12 Aug 2023 17:40:28 +0000 (19:40 +0200)]
readutmp, boot-time: On Haiku, return the boot time.

* m4/readutmp.m4 (gl_PREREQ_READUTMP_H): Test whether <OS.h> exists.
* lib/boot-time-aux.h (get_haiku_boot_time,
get_haiku_boot_time_final_fallback): New functions.
* lib/readutmp.c: Include <OS.h>.
(read_utmp_from_file): If opening UTMP_FILE fails, continue processing
instead of failing. Invoke get_haiku_boot_time and
get_haiku_boot_time_final_fallback.
* lib/boot-time.c: Include <OS.h>.
(get_boot_time_uncached): Invoke get_haiku_boot_time and
get_haiku_boot_time_final_fallback.

20 months agoreadutmp: Reduce code duplication.
Bruno Haible [Sat, 12 Aug 2023 17:01:56 +0000 (19:01 +0200)]
readutmp: Reduce code duplication.

* lib/readutmp.c (have_boot_time): New function.
(read_utmp_from_file): Invoke it, instead of duplicating the same loop.

20 months agoc-file-type: new module
Paul Eggert [Sat, 12 Aug 2023 16:54:08 +0000 (09:54 -0700)]
c-file-type: new module

* lib/c-file-type.c: New file, containing all of the
old file-type except for the gettext call.
* lib/file-type.c (_): Remove; no longer used.
(file_type): Call c_file_type for most of the work.
* modules/c-file-type: New module.
* modules/file-type (Depends-on): Add c-file-type.

20 months agoreadutmp, boot-time: Use the BSD sysctl as fallback.
Bruno Haible [Sat, 12 Aug 2023 13:09:50 +0000 (15:09 +0200)]
readutmp, boot-time: Use the BSD sysctl as fallback.

* m4/readutmp.m4 (gl_PREREQ_READUTMP_H): Test for <sys/param.h>,
<sys/sysctl.h>, sysctl.
* lib/boot-time-aux.h (get_bsd_boot_time_final_fallback): New function.
* lib/readutmp.c: Include <sys/param.h> and <sys/sysctl.h>.
(read_utmp_from_file): Invoke get_bsd_boot_time_final_fallback as a
fallback.
* lib/boot-time.c: Include <sys/param.h> and <sys/sysctl.h>.
(get_boot_time_uncached): Invoke get_bsd_boot_time_final_fallback as a
fallback.

20 months agoreadutmp: Fix compilation error on OpenBSD (regression 2023-08-11).
Bruno Haible [Sat, 12 Aug 2023 12:13:21 +0000 (14:13 +0200)]
readutmp: Fix compilation error on OpenBSD (regression 2023-08-11).

* lib/readutmp.c (read_utmp_from_file): Remove extraneous 'break'
statement.

20 months agoboot-time: Add comment about multithread-safety.
Bruno Haible [Fri, 11 Aug 2023 21:31:37 +0000 (23:31 +0200)]
boot-time: Add comment about multithread-safety.

* lib/boot-time.h (get_boot_time): Add comment, same as in readutmp.h.

20 months agoboot-time: Simplify execution.
Bruno Haible [Fri, 11 Aug 2023 21:30:01 +0000 (23:30 +0200)]
boot-time: Simplify execution.

* lib/boot-time.c: Include <stdio.h>, <string.h>, <sys/types.h>,
<sys/stat.h>, <sys/sysinfo.h>, <time.h>, stat-time.h, unlocked-io.h,
boot-time-aux.h.
(UT_USER): New macro, from lib/readutmp.c.
(getutent): New declaration.
(get_boot_time_uncached): New function, containing a simplified code
from lib/readutmp.c.
(get_boot_time): Don't invoke read_utmp. Instead, invoke
get_boot_time_uncached and cache the result.
* modules/boot-time (Files): Add lib/boot-time-aux.h, lib/readutmp.h,
m4/readutmp.m4.
(Depends-on): Remove readutmp. Add extensions, fopen-gnu, stat-time,
stdbool, time-h, timespec_get, unlocked-io-internal.
(configure.ac): Invoke gl_PREREQ_READUTMP_H.
(Link): Remove $(READUTMP_LIB). Add $(CLOCK_TIME_LIB).
* modules/boot-time-tests (Makefile.am): Link test-boot-time with
$(CLOCK_TIME_LIB), not with $(READUTMP_LIB).

20 months agoreadutmp: Refactor boot time determination code.
Bruno Haible [Fri, 11 Aug 2023 21:20:44 +0000 (23:20 +0200)]
readutmp: Refactor boot time determination code.

* lib/boot-time-aux.h: New file, extracted from lib/readutmp.c.
* lib/readutmp.c: On Linux, include <sys/sysinfo.h> even if
!READUTMP_USE_SYSTEMD.
Include boot-time-aux.h.
(SIZEOF): Remove macro, moved to boot-time-aux.h.
(get_linux_uptime): Remove function, moved to boot-time-aux.h.
(read_utmp_from_file): Invoke get_linux_boot_time_fallback,
get_android_boot_time, get_openbsd_boot_time, get_windows_boot_time.
Code moved to boot-time-aux.h.
(get_boot_time_uncached: Invoke get_linux_boot_time_final_fallback.
Code moved to boot-time-aux.h.
* m4/readutmp.m4 (gl_PREREQ_READUTMP_H): New macro, extracted from
gl_READUTMP.
(gl_READUTMP): Invoke it.
* modules/readutmp (Files): Add lib/boot-time-aux.h.

20 months agoreadutmp: Make 'struct utmpx32' usable by other code.
Bruno Haible [Fri, 11 Aug 2023 14:09:22 +0000 (16:09 +0200)]
readutmp: Make 'struct utmpx32' usable by other code.

* lib/readutmp.h (struct utmpx32): Moved to here from lib/readutmp.c.
(UTMP_STRUCT_NAME): Define as utmpx32 if needed.
* lib/readutmp.c (read_utmp_from_file): Simply use UTMP_STRUCT_NAME.

20 months agoreadutmp tests: Fix link error.
Bruno Haible [Fri, 11 Aug 2023 20:02:02 +0000 (22:02 +0200)]
readutmp tests: Fix link error.

* modules/readutmp-tests (Makefile.am): Link test-readutmp with
$(LIBINTL).

20 months agoreadutmp: Fix the boot time returned on Minix.
Bruno Haible [Fri, 11 Aug 2023 13:22:43 +0000 (15:22 +0200)]
readutmp: Fix the boot time returned on Minix.

* lib/readutmp.c (read_utmp_from_file): [__minix] When the time of the
BOOT_TIME entry is very close to the Epoch, replace it with the time
from the "run-level m" entry.

20 months agoreadutmp: On Cygwin and Windows, return the boot time.
Bruno Haible [Fri, 11 Aug 2023 12:29:32 +0000 (14:29 +0200)]
readutmp: On Cygwin and Windows, return the boot time.

* lib/readutmp.h (READ_UTMP_SUPPORTED): Define also on native Windows.
* lib/readutmp.c (desirable_utmp_entry): Ignore READ_UTMP_CHECK_PIDS on
Windows.
(read_utmp_from_file): Add a BOOT_TIME entry on Windows.

20 months agoclock-time: On mingw, avoid buggy clock_gettime from libwinpthread.
Bruno Haible [Fri, 11 Aug 2023 08:24:46 +0000 (10:24 +0200)]
clock-time: On mingw, avoid buggy clock_gettime from libwinpthread.

* m4/clock_time.m4 (gl_CLOCK_TIME): Require AC_CANONICAL_HOST. On
native Windows, avoid using clock_getres clock_gettime clock_settime
from mingw's libwinpthread.
* doc/posix-functions/clock_gettime.texi: Mention the mingw bug.

20 months agoreadutmp: Make the header file includable from C++.
Bruno Haible [Fri, 11 Aug 2023 00:39:56 +0000 (02:39 +0200)]
readutmp: Make the header file includable from C++.

* lib/readutmp.h: Add extern "C" block.

20 months agoreadutmp: Tweak the Android specific addition.
Bruno Haible [Fri, 11 Aug 2023 00:31:30 +0000 (02:31 +0200)]
readutmp: Tweak the Android specific addition.

* lib/readutmp.c (read_utmp_from_file) [__ANDROID__]: Don't fake a
BOOT_TIME entry if the options request to omit it or if a BOOT_TIME
entry is already present.

20 months agoreadutmp: Fix the boot time returned on Raspbian.
Bruno Haible [Thu, 10 Aug 2023 15:23:56 +0000 (17:23 +0200)]
readutmp: Fix the boot time returned on Raspbian.

* lib/readutmp.c (read_utmp_from_file): When the time of the BOOT_TIME
entry is very close to the Epoch, replace it with the time from the
"runlevel"/"~" entry.

20 months agoboot-time: Add tests.
Bruno Haible [Thu, 10 Aug 2023 11:08:48 +0000 (13:08 +0200)]
boot-time: Add tests.

* tests/test-boot-time.c: New file.
* modules/boot-time-tests: New file.

20 months agoboot-time: New module.
Bruno Haible [Thu, 10 Aug 2023 11:08:19 +0000 (13:08 +0200)]
boot-time: New module.

* lib/boot-time.h: New file.
* lib/boot-time.c: New file.
* modules/boot-time: New file.

20 months agoreadutmp: Return a boot time also on Android.
Bruno Haible [Thu, 10 Aug 2023 05:59:19 +0000 (07:59 +0200)]
readutmp: Return a boot time also on Android.

* lib/readutmp.c (get_linux_uptime): New function, extracted from
get_boot_time_uncached.
(read_utmp_from_file): Don't look for file time stamps on Android.
Instead, use get_linux_uptime.
(get_boot_time_uncached): Use get_linux_uptime.

20 months agoreadutmp: Fix a mistake (regression 2023-08-08).
Bruno Haible [Wed, 9 Aug 2023 23:55:33 +0000 (01:55 +0200)]
readutmp: Fix a mistake (regression 2023-08-08).

* lib/readutmp.c (UT_TYPE_EQ, UT_TYPE_NOT_DEFINED): Fix a typo.

20 months agoreadutmp: Return a boot time also on OpenBSD.
Bruno Haible [Wed, 9 Aug 2023 20:52:22 +0000 (22:52 +0200)]
readutmp: Return a boot time also on OpenBSD.

* lib/readutmp.h (BOOT_TIME, USER_PROCESS): Provide fallback
definitions.
* lib/readutmp.c (read_utmp_from_file) [__OpenBSD__]: Fake a BOOT_TIME
entry by looking at the time stamp of a specific file.

20 months agoreadutmp: Return a boot time also on Alpine Linux.
Bruno Haible [Wed, 9 Aug 2023 20:27:16 +0000 (22:27 +0200)]
readutmp: Return a boot time also on Alpine Linux.

* lib/readutmp.c: Include stat-time.h.
(SIZEOF): New macro.
(read_utmp_from_file) [__linux__]: Fake a BOOT_TIME entry by looking
at the time stamp of a specific file.
* modules/readutmp (Depends-on): Add stat-time.

20 months agoreadutmp: Fix boot time in VMs after sleep state and date update.
Bruno Haible [Wed, 9 Aug 2023 19:12:40 +0000 (21:12 +0200)]
readutmp: Fix boot time in VMs after sleep state and date update.

* lib/readutmp.c (read_utmp_from_file): New function, extracted from
read_utmp.
(get_boot_time_uncached): Before all other approaches, try to find the
boot time in the /var/run/utmp file.
(read_utmp): Invoke read_utmp_from_file.

20 months agoreadutmp: Make it easier to filter for/against the boot-time entry.
Bruno Haible [Wed, 9 Aug 2023 16:49:22 +0000 (18:49 +0200)]
readutmp: Make it easier to filter for/against the boot-time entry.

* lib/readutmp.h (READ_UTMP_BOOT_TIME, READ_UTMP_NO_BOOT_TIME): New
enum items.
* lib/readutmp.c (desirable_utmp_entry, read_utmp_from_systemd):
Implement them.
(read_utmp): If no entries can match the given options, return
immediately.

20 months agoreadutmp: omit pragma
Paul Eggert [Wed, 9 Aug 2023 02:29:55 +0000 (19:29 -0700)]
readutmp: omit pragma

* lib/readutmp.c: Omit -Sstringop-overread pragma.
It’s no longer needed now that extract_trimmed_name
no longer calls strnlen.

20 months agoreadutmp: Use classical implementation for files != /var/run/utmp.
Bruno Haible [Tue, 8 Aug 2023 21:27:38 +0000 (23:27 +0200)]
readutmp: Use classical implementation for files != /var/run/utmp.

* lib/readutmp.c (read_utmp_from_systemd): Renamed from read_utmp
[READUTMP_USE_SYSTEMD]. Remove file argument.
(read_utmp): Call it when the file argument is "/var/run/utmp".

20 months agoreadutmp: Get the boot time with higher precision.
Bruno Haible [Tue, 8 Aug 2023 19:28:46 +0000 (21:28 +0200)]
readutmp: Get the boot time with higher precision.

Suggested by Thorsten Kukuk <kukuk@suse.com> in
<https://github.com/thkukuk/utmpx/blob/main/utmp-to-logind.md#determine-boot-time>.

* lib/readutmp.c (get_boot_time_uncached): Try clock_gettime first.

20 months agoreadutmp: Add comment about multithread-safety.
Bruno Haible [Tue, 8 Aug 2023 18:27:31 +0000 (20:27 +0200)]
readutmp: Add comment about multithread-safety.

* lib/readutmp.h (read_utmp): Add comment.

20 months agoreadutmp: Return entries with unbounded strings on all platforms.
Bruno Haible [Tue, 8 Aug 2023 15:36:10 +0000 (17:36 +0200)]
readutmp: Return entries with unbounded strings on all platforms.

Suggested  by Paul Eggert in
<https://lists.gnu.org/archive/html/bug-gnulib/2023-07/msg00165.html>.

* m4/readutmp.m4 (gl_READUTMP): Test also whether struct utmp has an
ut_tv member, and whether struct utmp and struct utmpx have an
ut_session member.
* lib/readutmp.h (struct gl_utmp): Define always. Add ut_exit field.
(HAVE_GL_UTMP): Remove macro.
(UT_USER, UT_TIME_MEMBER, UT_PID, UT_TYPE_EQ, UT_TYPE_NOT_DEFINED,
UT_EXIT_E_TERMINATION, UT_EXIT_E_EXIT, STRUCT_UTMP): Define w.r.t.
struct gl_utmp.
(UT_USER_SIZE, UT_ID_SIZE, UT_LINE_SIZE, UT_HOST_SIZE): Define to -1
always.
(getutent): Remove declaration.
(HAVE_STRUCT_XTMP_UT_EXIT): Remove unused macro.
(HAVE_STRUCT_XTMP_UT_ID, HAVE_STRUCT_XTMP_UT_PID,
HAVE_STRUCT_XTMP_UT_HOST): Change to match the way coreutils uses these
macros.
* lib/readutmp.c (UT_USER, UT_TIME_MEMBER, UT_PID, UT_TYPE_EQ,
UT_TYPE_NOT_DEFINED, IS_USER_PROCESS, UT_EXIT_E_TERMINATION,
UT_EXIT_E_EXIT, UT_USER_SIZE, UT_ID_SIZE, UT_LINE_SIZE, UT_HOST_SIZE):
Define w.r.t. struct utmpx or struct utmp.
(extract_trimmed_name): Don't use UT_USER or UT_USER_SIZE here.
(desirable_utmp_entry): Don't use UT_TIME_MEMBER or UT_USER here.
(struct utmp_alloc): Define always.
(add_utmp): Likewise. Add user_len, id_len, line_len, host_len,
termination, exit arguments. Don't require that user, id, line, host are
NUL-terminated. Assume user and host are non-NULL.
(finish_utmp): New function, extracted from read_utmp.
(read_utmp) [READUTMP_USE_SYSTEMD]: Update add_utmp invocations. Pass a
non-NULL user and a non-NULL host. Call finish_utmp.
(getutent): Move declaration from readutmp.h to here.
(copy_utmp_entry): Remove function.
(read_utmp) [UTMP_NAME_FUNCTION]: Replace variables n_read, n_alloc,
utmp with a 'struct utmp_alloc'. Use 'struct utmpx32' from
copy_utmp_entry here. Invoke add_utmp and finish_utmp.
(read_utmp) [!UTMP_NAME_FUNCTION]: Replace variables n_read, n_alloc,
utmp with a 'struct utmp_alloc'. Invoke add_utmp and finish_utmp.
* NEWS: Mention the API change.

20 months agoreadutmp: Fix compilation error on OpenBSD and AIX (regr. 2023-08-03).
Bruno Haible [Tue, 8 Aug 2023 15:17:42 +0000 (17:17 +0200)]
readutmp: Fix compilation error on OpenBSD and AIX (regr. 2023-08-03).

* lib/readutmp.h (UT_TIME_MEMBER) [HAVE_UTMP_H]: Revert last change.

20 months agoreadutmp: Fix compilation error on OpenBSD (regr. 2023-08-02).
Bruno Haible [Tue, 8 Aug 2023 15:23:24 +0000 (17:23 +0200)]
readutmp: Fix compilation error on OpenBSD (regr. 2023-08-02).

* lib/readutmp.h (UT_ID_SIZE): Define to a dummy if there is no ut_id
field.

20 months agoAdd ChangeLog entries for the last 3 commits.
Paul Eggert [Tue, 8 Aug 2023 12:16:57 +0000 (14:16 +0200)]
Add ChangeLog entries for the last 3 commits.

20 months agoquotearg: fix obsolete comment
Paul Eggert [Mon, 7 Aug 2023 16:10:21 +0000 (09:10 -0700)]
quotearg: fix obsolete comment

* lib/quotearg.h: Fix comment to match behavior.
This fixes a commentary bug introduced in
commit 1a43a982c927eaf26bbc2701a872009d9be4b33b
"quotearg: do not use grave accent for left quote"
dated 2011-12-18 15:44:17+01, where the comment
was not updated to match the changed behavior.

21 months agoreadutmp: fix comment bug ID
Paul Eggert [Sun, 6 Aug 2023 19:43:05 +0000 (12:43 -0700)]
readutmp: fix comment bug ID

* lib/readutmp.c: Fix comment (thanks to Bruno Haible).

21 months agoDocument Android, OpenBSD printf "%n" lack
Paul Eggert [Sun, 6 Aug 2023 19:19:36 +0000 (12:19 -0700)]
Document Android, OpenBSD printf "%n" lack

In doc/posix/functions/*printf*.texi,
document that the POSIX-specified printf functions
do not support the %n format on Android and OpenBSD.
This lack of support is deliberate, as %n is
a common target of attacks on security.

21 months agoreadutmp: anticipate Y2038 hack for utmp
Paul Eggert [Sat, 5 Aug 2023 18:16:12 +0000 (11:16 -0700)]
readutmp: anticipate Y2038 hack for utmp

* lib/readutmp.c (struct utmpx32): Use unsigned int for tv_sec,
not int, as that is more likely to work after 2038.
Suggested by Andreas Schwab in:
https://sourceware.org/pipermail/libc-alpha/2023-August/150661.html

21 months agodiffseq: simplify lint removal
Paul Eggert [Sat, 5 Aug 2023 17:04:41 +0000 (10:04 -0700)]
diffseq: simplify lint removal

* lib/diffseq.h (IF_LINT): Remove.
Instead, always ignore the diagnostic, as that’s simpler
now that we have the pragma change installed in May.
This removes the last IF_LINT from diffutils, though not
the last use of GCC_LINT.

21 months agounistr/{u8-mbtouc,u8-mbsnlen}: Fix test failures (regr. 2023-07-25).
Bruno Haible [Sat, 5 Aug 2023 00:40:03 +0000 (02:40 +0200)]
unistr/{u8-mbtouc,u8-mbsnlen}: Fix test failures (regr. 2023-07-25).

* modules/unistr/u8-mbtouc (configure.ac): Compile this code if the
preinstalled libunistring version is >= 0.9.4, < 1.2.
* modules/unistr/u8-mbsnlen (configure.ac): Likewise.

21 months agounistr/*-pcpy: Fix compilation errors (regression 2023-07-21).
Bruno Haible [Fri, 4 Aug 2023 21:44:27 +0000 (23:44 +0200)]
unistr/*-pcpy: Fix compilation errors (regression 2023-07-21).

* modules/unistr/base (configure.ac): Generate unistr.h if the
preinstalled libunistring version is >= 0.9.11, < 1.2.

21 months agoreadutmp: In systemd mode, fix the ut_host contents (regr. yesterday).
Bruno Haible [Fri, 4 Aug 2023 13:26:37 +0000 (15:26 +0200)]
readutmp: In systemd mode, fix the ut_host contents (regr. yesterday).

* lib/readutmp.c (add_utmp): Fix ut_host contents.
* tests/test-readutmp.c (main): Show also the contents of the ut_host
field.

21 months agoreadutmp: Ensure multithread-safety.
Bruno Haible [Fri, 4 Aug 2023 12:50:04 +0000 (14:50 +0200)]
readutmp: Ensure multithread-safety.

* lib/readutmp.c (get_boot_time): Initialize 'cached' after 'boot_time',
not before. Also declare both as volatile.

21 months agoreadutmp tests: Fix gcc warning (regression from yesterday).
Bruno Haible [Fri, 4 Aug 2023 11:28:27 +0000 (13:28 +0200)]
readutmp tests: Fix gcc warning (regression from yesterday).

* tests/test-readutmp.c: Include idx.h.
(main): Use idx_t instead of size_t.

21 months ago* m4/systemd.m4: Fix --help lineup.
Paul Eggert [Fri, 4 Aug 2023 01:41:52 +0000 (18:41 -0700)]
* m4/systemd.m4: Fix --help lineup.

21 months agoreadutmp: fix comments
Paul Eggert [Fri, 4 Aug 2023 01:27:35 +0000 (18:27 -0700)]
readutmp: fix comments

21 months agoreadutmp: systemd supports only UTMP_FILE
Paul Eggert [Thu, 3 Aug 2023 23:01:52 +0000 (16:01 -0700)]
readutmp: systemd supports only UTMP_FILE

* lib/readutmp.c (read_utmp): Fail if not UTMP_FILE.
* m4/systemd.m4 (gl_SYSTEMD_CHOICE): Default to no for now,
since yes means "who /var/log/wtmp" stops working.

21 months agoreadutmp: switch new struct to struct timespec
Paul Eggert [Thu, 3 Aug 2023 23:01:50 +0000 (16:01 -0700)]
readutmp: switch new struct to struct timespec

* lib/readutmp.c (get_boot_time_uncached, get_boot_time)
(add_utmp, read_utmp):
Use struct timespec, not struct timeval.
* lib/readutmp.h: Always include <time.h>, for struct timespec.
Simplify when utmp.h and utmpx.h are included.
(struct gl_utmp): Use the same struct for both the
systemd and the dummy version.  Reorder members, and
use proper pid_t type for ut_session.  Rename ut_tv to ut_ts
and make it a struct timespec.  All uses changed.
(HAVE_GL_UTMP): New macro.  Use it where appropriate, instead
of READUTMP_USE_SYSTEMD.
(UT_USER, HAVE_STRUCT_XTMP_UT_EXIT, HAVE_STRUCT_XTMP_UT_ID)
(HAVE_STRUCT_XTMP_UT_PID, HAVE_STRUCT_XTMP_UT_HOST):
Simplify.
* modules/readutmp (Depends-on): Add time-h, timespec_get.
Remove sys_type.  Sort.