bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/3] fix message fields alignment for 64 bit


From: Samuel Thibault
Subject: Re: [PATCH 1/3] fix message fields alignment for 64 bit
Date: Sat, 27 Aug 2022 23:52:24 +0200
User-agent: NeoMutt/20170609 (1.8.3)

Luca Dariz, le mar. 28 juin 2022 11:49:25 +0200, a ecrit:
> On x86_64 alignment of structures is different, as the pointer size is 
> different.
> For simplicity we keep the same 4-byte alignment as used on
> 32-bit. This simplifies the support for 32-bit rpc on 64-bit kernels,
> and also it seems not worth as an optimization, as we would need to
> add more code in the ipc_kmsg* routines.
> 
> * routine.c: align both short and long descriptors
> * utils.c: use a fixed alignment for data fields in structures
>   representing messages.
> 
> Signed-off-by: Luca Dariz <luca@orpolo.org>

Applied, thanks!

> ---
>  routine.c | 3 +--
>  utils.c   | 2 ++
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/routine.c b/routine.c
> index 0edc6b9..e6e18c3 100644
> --- a/routine.c
> +++ b/routine.c
> @@ -321,9 +321,8 @@ rtFindSize(const argument_t *args, u_int mask)
>       {
>           ipc_type_t *it = arg->argType;
>  
> +         size = (size + word_size-1) & ~(word_size-1);
>           if (arg->argLongForm) {
> -             /* might need proper alignment on 64bit archies */
> -             size = (size + word_size-1) & ~(word_size-1);
>               size += sizeof_mach_msg_type_long_t;
>           } else {
>               size += sizeof_mach_msg_type_t;
> diff --git a/utils.c b/utils.c
> index bdc39b7..a8ebc6b 100644
> --- a/utils.c
> +++ b/utils.c
> @@ -338,10 +338,12 @@ void
>  WriteStructDecl(FILE *file, const argument_t *args, write_list_fn_t *func,
>               u_int mask, const char *name)
>  {
> +    fprintf(file, "#pragma pack(push,%d)\n", word_size);
>      fprintf(file, "\ttypedef struct {\n");
>      fprintf(file, "\t\tmach_msg_header_t Head;\n");
>      WriteList(file, args, func, mask, "\n", "\n");
>      fprintf(file, "\t} %s;\n", name);
> +    fprintf(file, "#pragma pack(pop)\n");
>      fprintf(file, "\n");
>  }
>  
> -- 
> 2.30.2
> 
> 

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]