public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] Make __mach_msg_destroy portable for x86_64
@ 2023-04-30 22:54 Samuel Thibault
0 siblings, 0 replies; only message in thread
From: Samuel Thibault @ 2023-04-30 22:54 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=6b25b6ca4e30a114c5af4086ed04e2f2de7077e5
commit 6b25b6ca4e30a114c5af4086ed04e2f2de7077e5
Author: Flavio Cruz <flaviocruz@gmail.com>
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: <ZE3aPH7uCEDti47H@jupiter.tail36e24.ts.net>
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 <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);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-04-30 22:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-30 22:54 [glibc] Make __mach_msg_destroy portable for x86_64 Samuel Thibault
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).