Hello,

Is it really worth making the code a bit obscure? The mapping RPC will
be way more expensive than branch misprediction...

Samuel

Sergey Bugaev, le lun. 24 avril 2023 00:55:25 +0300, a ecrit:
> Signed-off-by: Sergey Bugaev <buga...@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

Reply via email to