]> Savannah Git Hosting - gnulib.git/log
gnulib.git
20 months agothreads-h tests: Fix gcc -Wold-style-declaration warning.
Bruno Haible [Mon, 4 Sep 2023 14:39:07 +0000 (16:39 +0200)]
threads-h tests: Fix gcc -Wold-style-declaration warning.

* tests/test-thread_local.c (value0, value1, value2, value3): Put the
'thread_local' storage class specifier before the type.

20 months agoieee754-h tests: Fix some gcc -Wmissing-field-initializers warnings.
Bruno Haible [Mon, 4 Sep 2023 14:23:39 +0000 (16:23 +0200)]
ieee754-h tests: Fix some gcc -Wmissing-field-initializers warnings.

* tests/test-ieee754-h.c (float_tests): Use float literals.
(double_tests): Use double literals. Initialize frac_lo.

20 months agostring-buffer tests: Fix a gcc -Wformat warning.
Bruno Haible [Mon, 4 Sep 2023 14:02:36 +0000 (16:02 +0200)]
string-buffer tests: Fix a gcc -Wformat warning.

* tests/test-string-buffer.c: Don't assume that wint_t has the same size
as 'int'.

20 months agocrypto/* tests: Fix some gcc -Wdiscarded-qualifiers warnings.
Bruno Haible [Mon, 4 Sep 2023 13:46:39 +0000 (15:46 +0200)]
crypto/* tests: Fix some gcc -Wdiscarded-qualifiers warnings.

* tests/test-gc-hmac-md5.c (main): Change type of variables with a
string literal initializer to 'const char *'.
* tests/test-gc-hmac-sha1.c (main): Likewise.
* tests/test-gc-hmac-sha256.c (main): Likewise.
* tests/test-gc-hmac-sha512.c (main): Likewise.
* tests/test-gc-md2.c (main): Likewise.
* tests/test-gc-md5.c (main): Likewise.
* tests/test-gc-sha1.c (main): Likewise.
* tests/test-gc-sha256.c (main): Likewise.
* tests/test-gc-sha512.c (main): Likewise.
* tests/test-hmac-md5.c (main): Likewise.
* tests/test-hmac-sha1.c (main): Likewise.
* tests/test-hmac-sha256.c (main): Likewise.
* tests/test-hmac-sha512.c (main): Likewise.

20 months agofile-has-acl: Avoid gcc warning.
Bruno Haible [Mon, 4 Sep 2023 13:20:59 +0000 (15:20 +0200)]
file-has-acl: Avoid gcc warning.

* lib/acl-internal.h (MIN): Remove definition.

20 months agosame-inode, stat-size: support pointers too
Paul Eggert [Mon, 4 Sep 2023 01:14:53 +0000 (18:14 -0700)]
same-inode, stat-size: support pointers too

Add functions and macros so that we can test pointers to struct
stat as well as plain struct stat.  This lets coreutils deal with
structs that are only partly initialized, without relying on
undefined behavior.
* NEWS: Mention this.
* doc/posix-headers/sys_stat.texi, doc/stat-size.texi:
Mention this and modernize.
* lib/at-func2.c (at_func2):
* lib/fts.c (same_fd):
* lib/rename.c (rpl_rename) [RENAME_HARD_LINK_BUG]:
* lib/same-inode.c: New file.
* lib/same.c (same_nameat):
* lib/term-style-control.c (activate_term_style_controller):
Prefer psame_inode (a, b) to SAME_INODE (*a, *b).
* lib/hash-triple-simple.c (triple_compare_ino_str):
* lib/hash-triple.c (triple_compare):
Prefer PSAME_INODE (a, b) to SAME_INODE (*a, *b).
psame_inode is not suitable since the args are not struct stat *.
* lib/same-inode.h: Check that config.h is included first.
(SAME_INODE_INLINE, PSAME_INODE): New macros.
(SAME_INODE): Reimplement in terms of PSAME_INODE.
(psame_inode): New function.
* lib/stat-size.h (STP_BLKSIZE, STP_NBLOCKS): New macros.
(ST_BLKSIZE, ST_NBLOCKS): Use them.
* lib/term-style-control.c (log_signal_handler_called):
Always define as a function, to pacify -Wunused*.
* modules/canonicalize-lgpl-tests (Files): Add m4/musl.m4.
(Depends-on): Call gl_MUSL_LIBC.
* modules/same-inode (Files): Add same-inode.c.
(Depends-on): Add extern-inline, stdbool.
(lib_SOURCES): New macro.
* tests/test-binary-io.c, tests/test-canonicalize-lgpl.c:
* tests/test-canonicalize.c, tests/test-cloexec.c:
* tests/test-dup-safer.c, tests/test-dup2.c, tests/test-error.c:
* tests/test-fcntl.c, tests/test-fdopendir.c, tests/test-fgetc.c:
* tests/test-fputc.c, tests/test-fread.c, tests/test-fstat.c:
* tests/test-fstatat.c, tests/test-ftruncate.c:
* tests/test-fwrite.c, tests/test-getcwd.c:
* tests/test-getdtablesize.c, tests/test-isblank.c:
* tests/test-linkat.c, tests/test-lock.c, tests/test-lstat.h:
* tests/test-malloc-gnu.c, tests/test-openat.c:
* tests/test-pthread-thread.c, tests/test-pthread_sigmask1.c:
* tests/test-pthread_sigmask2.c, tests/test-ptsname.c:
* tests/test-ptsname_r.c, tests/test-raise.c:
* tests/test-realloc-gnu.c, tests/test-rwlock1.c:
* tests/test-sigprocmask.c, tests/test-snprintf.c:
* tests/test-stat.h, tests/test-term-style-control-hello.c:
* tests/test-term-style-control-yes.c, tests/test-thread_create.c:
* tests/test-unlinkat.c, tests/test-vasnprintf.c:
* tests/test-xalloc-die.c:
Adjust to these changes, and fix some warnings elicited by
-Wall -Wextra that I ran into while testing.
* top/maint.mk (sc_prohibit_stat_st_blocks): Mention STP_NBLOCKS.

20 months agoWarn about Bug#65599 with CIFS chmod/chown
Paul Eggert [Sat, 2 Sep 2023 20:43:34 +0000 (13:43 -0700)]
Warn about Bug#65599 with CIFS chmod/chown

20 months agoalignalloc: Fix license header.
Bruno Haible [Sat, 2 Sep 2023 12:56:31 +0000 (14:56 +0200)]
alignalloc: Fix license header.

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

* lib/alignalloc.h: Make license header consistent with module
description.
* lib/alignalloc.c: Likewise.

20 months agocrypto/{sha*,md5}-buffer: Add comment.
Bruno Haible [Fri, 1 Sep 2023 13:04:38 +0000 (15:04 +0200)]
crypto/{sha*,md5}-buffer: Add comment.

* m4/gl-openssl.m4 (gl_CRYPTO_CHECK): Add comment regarding license.

20 months agocrypto/{sha*,md5,sm3}-buffer: Fix --with-openssl (regr. 2023-08-26).
Bruno Haible [Fri, 1 Sep 2023 10:55:30 +0000 (12:55 +0200)]
crypto/{sha*,md5,sm3}-buffer: Fix --with-openssl (regr. 2023-08-26).

Reported by Agostino Sarubbo via Sam James <sam@gentoo.org> in
<https://lists.gnu.org/archive/html/bug-gnulib/2023-09/msg00000.html>.

* lib/sha1.h: Test the OpenSSL major version before attempting to
include <openssl/configuration.h>.
* lib/sha256.h: Likewise.
* lib/sha512.h: Likewise.
* lib/md5.h: Likewise.
* lib/sm3.h: Likewise.

20 months agoreadutmp: Fix memory leak introduced by last commit.
Bruno Haible [Thu, 31 Aug 2023 09:31:11 +0000 (11:31 +0200)]
readutmp: Fix memory leak introduced by last commit.

* lib/readutmp.c (read_utmp_from_systemd): If num_sessions == 0 and
sessions != NULL, do call free (sessions).

20 months agoreadutmp: fix core dump if --enable-systemd
Paul Eggert [Thu, 31 Aug 2023 01:26:52 +0000 (18:26 -0700)]
readutmp: fix core dump if --enable-systemd

Problem reported by Thorsten Kukuk <https://bugs.gnu.org/65617>.
* lib/readutmp.c (read_utmp_from_systemd):
Don’t assume session_ptr != NULL if num_sessions == 0.
In practice it can be null, and the man page OKs this behavior.

20 months agodoc: Mention the module 'wchar-single'.
Bruno Haible [Wed, 30 Aug 2023 19:10:20 +0000 (21:10 +0200)]
doc: Mention the module 'wchar-single'.

* doc/multithread.texi: Mention the module 'wchar-single'.

20 months agowchar-single: fix module broken since 2021
Paul Eggert [Wed, 30 Aug 2023 17:15:09 +0000 (10:15 -0700)]
wchar-single: fix module broken since 2021

Adjust to 2021-03-07 change “Rename GNULIB_WCHAR_SINGLE to
GNULIB_WCHAR_SINGLE_LOCALE”.  Apparently nobody noticed that
the module was broken.  Perhaps we should obsolete the module?
* modules/wchar-single (GNULIB_WCHAR_SINGLE_LOCALE): Define.

20 months agowctype: Rely on module iswpunct.
Bruno Haible [Wed, 30 Aug 2023 00:19:01 +0000 (02:19 +0200)]
wctype: Rely on module iswpunct.

* m4/wctype.m4 (gl_FUNC_WCTYPE): Also test whether the "punct" class
works.
* modules/wctype (Depends-on): Add iswpunct.
* tests/test-iswctype.c (main): Add more tests of the "punct" class.
* doc/posix-functions/wctype.texi: Mention the Android problem.

20 months agoc32ispunct: Rely on module iswpunct.
Bruno Haible [Wed, 30 Aug 2023 00:18:40 +0000 (02:18 +0200)]
c32ispunct: Rely on module iswpunct.

* modules/c32ispunct (Depends-on): Add iswpunct.
* tests/test-c32ispunct.c (main): Add a few more tests in the "C"
locale.

20 months agoiswpunct: Add tests.
Bruno Haible [Wed, 30 Aug 2023 00:18:26 +0000 (02:18 +0200)]
iswpunct: Add tests.

* tests/test-iswpunct.c: New file, based on tests/test-iswdigit.c and
tests/test-c32ispunct.c.
* tests/test-iswpunct.sh: New file, based on tests/test-iswdigit.sh.
* modules/iswpunct-tests: New file.

20 months agoiswpunct: New module.
Bruno Haible [Wed, 30 Aug 2023 00:18:06 +0000 (02:18 +0200)]
iswpunct: New module.

* lib/wctype.in.h (iswpunct): New declaration.
* lib/iswpunct.c: New file.
* m4/iswpunct.m4: New file.
* m4/wctype_h.m4 (gl_WCTYPE_H_REQUIRE_DEFAULTS): Initialize
GNULIB_ISWPUNCT.
(gl_WCTYPE_H_DEFAULTS): Initialize REPLACE_ISWPUNCT.
* modules/wctype-h (Makefile.am): Substitute GNULIB_ISWPUNCT,
REPLACE_ISWPUNCT.
* modules/iswpunct: New file.
* doc/posix-functions/iswpunct.texi: Mention the new module.

20 months agowctype-h tests: Add more tests.
Bruno Haible [Wed, 30 Aug 2023 00:18:00 +0000 (02:18 +0200)]
wctype-h tests: Add more tests.

* tests/test-wctype-h.c (main): Add a sanity check of iswpunct.

20 months agoiswdigit, iswxdigit: Fix documentation.
Bruno Haible [Tue, 29 Aug 2023 23:38:59 +0000 (01:38 +0200)]
iswdigit, iswxdigit: Fix documentation.

* doc/posix-functions/iswdigit.texi: Mention the module 'iswdigit'.
* doc/posix-functions/iswxdigit.texi: Mention the module 'iswxdigit'.

20 months agobootstrap: Try to prevent the user from setting GNULIB_URL to a wrong value.
Bruno Haible [Tue, 29 Aug 2023 21:34:34 +0000 (23:34 +0200)]
bootstrap: Try to prevent the user from setting GNULIB_URL to a wrong value.

* top/bootstrap-funclib.sh: Explain GNULIB_URL better.
* top/bootstrap: Likewise.
* build-aux/bootstrap: Likewise.

20 months agomaint: don’t say “clonable” either
Paul Eggert [Tue, 29 Aug 2023 20:06:41 +0000 (13:06 -0700)]
maint: don’t say “clonable” either

The spelling is controversial, and the word adds little of use here.

20 months agowctype: Fix documentation (mistake 2023-07-26).
Bruno Haible [Tue, 29 Aug 2023 17:49:15 +0000 (19:49 +0200)]
wctype: Fix documentation (mistake 2023-07-26).

* doc/posix-functions/wctype.texi: The "blank" argument problem on mingw
is now worked around by Gnulib.

20 months agorename: fix m4 comment
Paul Eggert [Tue, 29 Aug 2023 14:59:57 +0000 (07:59 -0700)]
rename: fix m4 comment

* m4/rename.m4: Fix comment to match code.

20 months agospelling fix: cloneable -> clonable
Paul Eggert [Mon, 28 Aug 2023 19:21:23 +0000 (12:21 -0700)]
spelling fix: cloneable -> clonable

* build-aux/bootstrap, top/bootstrap, top/bootstrap-funclib.sh:
Spell it “clonable”, the more common English way, instead of
“cloneable”, the Java way.  Found while doing spelling check
of Coreutils.

20 months agotrim: do not over-allocate result
Paul Eggert [Sun, 27 Aug 2023 06:19:12 +0000 (23:19 -0700)]
trim: do not over-allocate result

* lib/trim.c: Include mbuiterf.h, not mbiterf.h, since we no
longer compute strlen at first.
(trim2): Do not over-allocate result and then trim the parts we
don’t want.  Instead, skip unwanted input before allocating,
so that the result is just the right size.  Use mempcpy
instead of memmove.  Simplify.
* modules/trim (Depends-on): Remove mbiterf, memmove, strdup, xalloc.
Add mbuiterf, mempcpy, xalloc-die.

20 months agopropername: tune single-byte code
Paul Eggert [Sun, 27 Aug 2023 06:19:11 +0000 (23:19 -0700)]
propername: tune single-byte code

* lib/propername.c (mbsstr_trimmed_wordbounded): Cache MB_CUR_MAX.
Simplify word boundary detection in single-byte code.

20 months agoTune single-byte code involving tolower
Paul Eggert [Sun, 27 Aug 2023 06:19:10 +0000 (23:19 -0700)]
Tune single-byte code involving tolower

* lib/mbmemcasecmp.c (mbmemcasecmp):
* lib/mbscasecmp.c (mbscasecmp):
* lib/mbscasestr.c (mbscasestr):
* lib/mbsncasecmp.c (mbsncasecmp):
* lib/mbspcasecmp.c (mbspcasecmp):
Avoid some unnecessary calls to tolower.  For example, if the two
single-byte characters are equal before downcasing there is no
need to call tolower on either character.

20 months agoc32width tests: Avoid failure on FreeBSD 12.
Bruno Haible [Sat, 26 Aug 2023 23:53:57 +0000 (01:53 +0200)]
c32width tests: Avoid failure on FreeBSD 12.

* tests/test-c32width.c (main): Skip two tests on FreeBSD < 13.

20 months agocrypto/{sha*,md5,sm3}-buffer: Ignore too old OpenSSL versions.
Bruno Haible [Sat, 26 Aug 2023 20:45:17 +0000 (22:45 +0200)]
crypto/{sha*,md5,sm3}-buffer: Ignore too old OpenSSL versions.

* lib/sha1.h: If <openssl/macros.h> would give a compile-time error,
undefine HAVE_OPENSSL_SHA1.
* lib/sha256.h: If <openssl/macros.h> would give a compile-time error,
undefine HAVE_OPENSSL_SHA256.
* lib/sha512.h: If <openssl/macros.h> would give a compile-time error,
undefine HAVE_OPENSSL_SHA512.
* lib/md5.h: If <openssl/macros.h> would give a compile-time error,
undefine HAVE_OPENSSL_MD5.
* lib/sm3.h: If <openssl/macros.h> would give a compile-time error,
undefine HAVE_OPENSSL_SM3.

20 months agoselinux-h: Add a comment.
Bruno Haible [Sat, 26 Aug 2023 18:41:31 +0000 (20:41 +0200)]
selinux-h: Add a comment.

* lib/se-selinux.in.h: Clarify which #endif belongs to the
double-inclusion guard.

20 months agosys_utsname: Make double-inclusion guard more robust.
Bruno Haible [Sat, 26 Aug 2023 18:39:04 +0000 (20:39 +0200)]
sys_utsname: Make double-inclusion guard more robust.

* lib/sys_utsname.in.h: Test the guard symbol a second time.

20 months agosys_times: Make double-inclusion guard more robust.
Bruno Haible [Sat, 26 Aug 2023 18:38:51 +0000 (20:38 +0200)]
sys_times: Make double-inclusion guard more robust.

* lib/sys_times.in.h: Test the guard symbol a second time.

20 months agouchar: Make #include_next work right.
Bruno Haible [Sat, 26 Aug 2023 18:33:39 +0000 (20:33 +0200)]
uchar: Make #include_next work right.

* lib/uchar.in.h: Use a split double-inclusion guard.

20 months agoutimens: update FIXME date
Paul Eggert [Sat, 26 Aug 2023 16:10:25 +0000 (09:10 -0700)]
utimens: update FIXME date

* lib/utimens.c (fdutimens): Change FIXME date to agree with
similar FIXME in utimensat.c.

20 months agoexclude: refactor for more-modern style
Paul Eggert [Thu, 24 Aug 2023 15:50:00 +0000 (09:50 -0600)]
exclude: refactor for more-modern style

* lib/exclude.c: Sort include directives.
(fnmatch_pattern_has_wildcards, file_name_matches):
Prefer ‘true’ to ‘1’.
(string_hasher, string_compare, string_compare_ci):
Avoid unnecessary locals.
(string_free): Remove.  All callers changed to just use ‘free’.
(new_exclude_segment): Prefer xmalloc to xzalloc when it’s
clearer to initialize ourselves.
(new_exclude_segment, exclude_patopts, add_exclude_fp):
Prefer nullptr to NULL.
(free_exclude_segment, file_pattern_matches):
Avoid unnecessary nesting.
(free_exclude, fnmatch_no_wildcards, exclude_fnmatch)
(excluded_file_name, add_exclude, add_exclude_fp):
Assume C99 decl syntax.
(fnmatch_no_wildcards): Prefer idx_t to size_t.
(exclude_fnmatch, add_exclude_fp): Prefer ‘f (x)’ to ‘(*f) (x)’.
(add_exclude): Help compiler by refactoring search for
trailing slashes.  Avoid unnecessary cast to char *.
* modules/exclude (Depends-on): Add nullptr.

20 months agounlocked-io: fix getc_unlocked typo
Paul Eggert [Tue, 22 Aug 2023 05:08:46 +0000 (22:08 -0700)]
unlocked-io: fix getc_unlocked typo

* lib/unlocked-io.h (getc): Fix misspelling of ‘getc_unlocked’.

20 months agoalignasof, stdalign: Fix a compilation error in C++ mode on FreeBSD 12.
Bruno Haible [Mon, 21 Aug 2023 15:23:41 +0000 (17:23 +0200)]
alignasof, stdalign: Fix a compilation error in C++ mode on FreeBSD 12.

* m4/stdalign.m4 (gl_ALIGNASOF): In C++ mode, prefer __builtin_offsetof
over offsetof when possible, since __builtin_offsetof works also when
<stddef.h> has not been fully included yet.

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.