Date: Fri, 19 Apr 2024 14:55:44 GMT From: Stefan =?utf-8?Q?E=C3=9Fer?= <se@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 6b13e4cb3da2 - main - ldconfig: small optimization Message-ID: <202404191455.43JEtipf014181@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by se: URL: https://cgit.FreeBSD.org/src/commit/?id=6b13e4cb3da28be82f9d3b8bd98e229ae107c73a commit 6b13e4cb3da28be82f9d3b8bd98e229ae107c73a Author: Stefan Eßer <se@FreeBSD.org> AuthorDate: 2024-04-19 14:29:12 +0000 Commit: Stefan Eßer <se@FreeBSD.org> CommitDate: 2024-04-19 14:47:19 +0000 ldconfig: small optimization Swap which side of a comparison is byte-swapped by be32toh() on little-endian architectures. The be32toh() macro just returns the operand and big-endian architectures and returns it byte-swapped on little-endian architectures. When operating on a constant argument, the compiler can perform the swap operation at build time instead of swapping the data read from the hints file at run time. Reviewed by: kib Tested by: tuexen MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D44734 --- sbin/ldconfig/elfhints.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/ldconfig/elfhints.c b/sbin/ldconfig/elfhints.c index d6ee5e0918d6..64b3f916ba8d 100644 --- a/sbin/ldconfig/elfhints.c +++ b/sbin/ldconfig/elfhints.c @@ -220,7 +220,7 @@ read_elf_hints(const char *hintsfile, bool must_exist, bool force_be) close(fd); hdr = (struct elfhints_hdr *)mapbase; - is_be = be32toh(hdr->magic) == ELFHINTS_MAGIC; + is_be = hdr->magic == htobe32(ELFHINTS_MAGIC); if (COND_SWAP(hdr->magic) != ELFHINTS_MAGIC) errx(1, "\"%s\": invalid file format", hintsfile); if (force_be && !is_be)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202404191455.43JEtipf014181>