From: Sergey Bugaev <bugaevc@gmail.com>
To: libc-alpha@sourceware.org
Cc: bug-hurd@gnu.org, Samuel Thibault <samuel.thibault@gnu.org>
Subject: [PATCH 3/4] hurd: Microoptimize mmap ()
Date: Mon, 24 Apr 2023 00:55:25 +0300 [thread overview]
Message-ID: <20230423215526.346009-3-bugaevc@gmail.com> (raw)
In-Reply-To: <20230423215526.346009-1-bugaevc@gmail.com>
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
---
sysdeps/mach/hurd/mmap.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/sysdeps/mach/hurd/mmap.c b/sysdeps/mach/hurd/mmap.c
index 790eb238..d570be24 100644
--- a/sysdeps/mach/hurd/mmap.c
+++ b/sysdeps/mach/hurd/mmap.c
@@ -42,7 +42,8 @@ __mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset)
mapaddr = (vm_address_t) addr;
/* ADDR and OFFSET must be page-aligned. */
- if ((mapaddr & (__vm_page_size - 1)) || (offset & (__vm_page_size - 1)))
+ if (__glibc_unlikely ((mapaddr & (__vm_page_size - 1))
+ || (offset & (__vm_page_size - 1))))
return (void *) (long int) __hurd_fail (EINVAL);
vmprot = VM_PROT_NONE;
@@ -73,7 +74,8 @@ __mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset)
mach_port_t robj, wobj;
if (err = HURD_DPORT_USE (fd, __io_map (port, &robj, &wobj)))
{
- if (err == MIG_BAD_ID || err == EOPNOTSUPP || err == ENOSYS)
+ if (__glibc_unlikely (err == MIG_BAD_ID || err == EOPNOTSUPP
+ || err == ENOSYS))
err = ENODEV; /* File descriptor doesn't support mmap. */
return (void *) (long int) __hurd_dfail (fd, err);
}
@@ -173,7 +175,7 @@ __mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset)
if (err == KERN_PROTECTION_FAILURE)
err = EACCES;
- if (err)
+ if (__glibc_unlikely (err))
return (void *) (long int) __hurd_fail (err);
return (void *) mapaddr;
--
2.40.0
next prev parent reply other threads:[~2023-04-23 21:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-23 21:55 [PATCH 1/4] hurd: Implement MAP_32BIT Sergey Bugaev
2023-04-23 21:55 ` [PATCH 2/4] hurd: Don't attempt to deallocate MACH_PORT_DEAD Sergey Bugaev
2023-04-24 20:44 ` Samuel Thibault
2023-04-23 21:55 ` Sergey Bugaev [this message]
2023-04-24 20:46 ` [PATCH 3/4] hurd: Microoptimize mmap () Samuel Thibault
2023-04-24 21:09 ` Sergey Bugaev
2023-04-24 21:25 ` Samuel Thibault
2023-04-23 21:55 ` [RFC PATCH 4/4] hurd: Implement prefer_map_32bit_exec tunable Sergey Bugaev
2023-04-24 20:48 ` Samuel Thibault
2023-04-24 20:42 ` [PATCH 1/4] hurd: Implement MAP_32BIT Samuel Thibault
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230423215526.346009-3-bugaevc@gmail.com \
--to=bugaevc@gmail.com \
--cc=bug-hurd@gnu.org \
--cc=libc-alpha@sourceware.org \
--cc=samuel.thibault@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).