public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@gnu.org>
To: Flavio Cruz <flaviocruz@gmail.com>
Cc: bug-hurd@gnu.org, libc-alpha@sourceware.org
Subject: Re: [PATCH] Make __mach_msg_destroy portable for x86_64
Date: Mon, 1 May 2023 00:54:27 +0200	[thread overview]
Message-ID: <20230430225427.afe726obse5p2sxd@begin> (raw)
In-Reply-To: <ZE3aPH7uCEDti47H@jupiter.tail36e24.ts.net>

Applied, thanks!

Flavio Cruz, le sam. 29 avril 2023 23:02:20 -0400, a ecrit:
> We need to align on uintptr_t to make this work for x86_64, 
> otherwise things will go wrong when RPCs return errors.
> ---
>  mach/msg-destroy.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/mach/msg-destroy.c b/mach/msg-destroy.c
> index 7429ecbc2d..0a8b46c895 100644
> --- a/mach/msg-destroy.c
> +++ b/mach/msg-destroy.c
> @@ -38,6 +38,7 @@
>   *
>   */
>  
> +#include <libc-pointer-arith.h>
>  #if 1
>  #include <mach.h>
>  #else
> @@ -162,9 +163,10 @@ __mach_msg_destroy (mach_msg_header_t *msg)
>  		    saddr += sizeof(mach_msg_type_t);
>  	    }
>  
> -	    /* calculate length of data in bytes, rounding up */
> -	    length = (((((number * size) + 7) >> 3) + sizeof (int) - 1)
> -		      &~ (sizeof (int) - 1));
> +	    /* Calculate length of data in bytes... */
> +	    length = ((number * size) + 7) >> 3;
> +	    /* ... and round up using uintptr_t alignment */
> +	    length = ALIGN_UP (length, __alignof__ (uintptr_t));
>  
>  	    addr = is_inline ? saddr : * (vm_offset_t *) saddr;
>  
> @@ -177,7 +179,6 @@ __mach_msg_destroy (mach_msg_header_t *msg)
>  	    }
>  
>  	    if (is_inline) {
> -		/* inline data sizes round up to int boundaries */
>  		saddr += length;
>  	    } else {
>  		mach_msg_destroy_memory(addr, length);
> -- 
> 2.39.2
> 

-- 
Samuel
---
Pour une évaluation indépendante, transparente et rigoureuse !
Je soutiens la Commission d'Évaluation de l'Inria.

      reply	other threads:[~2023-04-30 22:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-30  3:02 Flavio Cruz
2023-04-30 22:54 ` Samuel Thibault [this message]

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=20230430225427.afe726obse5p2sxd@begin \
    --to=samuel.thibault@gnu.org \
    --cc=bug-hurd@gnu.org \
    --cc=flaviocruz@gmail.com \
    --cc=libc-alpha@sourceware.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).