From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1792) id 031D83858C66; Sun, 30 Apr 2023 22:54:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 031D83858C66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1682895264; bh=Icj9NlumZrHXVav4frnU9RuOv14FD2fCLbOU20yEJiQ=; h=From:To:Subject:Date:From; b=AarH34eDIX7NBJX4REUfCkXp5S0InGoLffb6KjLpfQ5FtjGyFabAlhav1iANwoc+v RXH5OAqpQiLhl2OSa4M7bR/n2vtWythF0kvAeklDa2oxWk1tY9k/LtPR5cetrCi3Rn cH6oug3m1koz18knsA/IEO4NgXufEo4qVuX0Z1PI= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Samuel Thibault To: glibc-cvs@sourceware.org Subject: [glibc] Make __mach_msg_destroy portable for x86_64 X-Act-Checkin: glibc X-Git-Author: Flavio Cruz X-Git-Refname: refs/heads/master X-Git-Oldrev: 6639cc10029e24e06b34e169712b21c31b8cf213 X-Git-Newrev: 6b25b6ca4e30a114c5af4086ed04e2f2de7077e5 Message-Id: <20230430225424.031D83858C66@sourceware.org> Date: Sun, 30 Apr 2023 22:54:24 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=6b25b6ca4e30a114c5af4086ed04e2f2de7077e5 commit 6b25b6ca4e30a114c5af4086ed04e2f2de7077e5 Author: Flavio Cruz Date: Sat Apr 29 23:02:20 2023 -0400 Make __mach_msg_destroy portable for x86_64 We need to align on uintptr_t to make this work for x86_64, otherwise things will go wrong when RPCs return errors. Message-Id: Diff: --- 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 #if 1 #include #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);