public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/arm/morello/main] cheri: malloc: use uintptr_t in alloc_buffer
@ 2022-08-05 19:35 Szabolcs Nagy
0 siblings, 0 replies; 2+ messages in thread
From: Szabolcs Nagy @ 2022-08-05 19:35 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=84068c087ba210a694aa656f6c873f4d7daa84d0
commit 84068c087ba210a694aa656f6c873f4d7daa84d0
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date: Wed Mar 16 12:09:15 2022 +0000
cheri: malloc: use uintptr_t in alloc_buffer
This is the right type as the values hold pointers.
Diff:
---
include/alloc_buffer.h | 11 ++++++-----
malloc/alloc_buffer_alloc_array.c | 6 +++---
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/include/alloc_buffer.h b/include/alloc_buffer.h
index be33e8b68c..b0d50289f0 100644
--- a/include/alloc_buffer.h
+++ b/include/alloc_buffer.h
@@ -82,6 +82,7 @@
#include <stddef.h>
#include <stdlib.h>
#include <sys/param.h>
+#include <libc-pointer-arith.h>
/* struct alloc_buffer objects refer to a region of bytes in memory of a
fixed size. The functions below can be used to allocate single
@@ -248,9 +249,9 @@ __alloc_buffer_alloc (struct alloc_buffer *buf, size_t size, size_t align)
if (size == 1 && align == 1)
return alloc_buffer_alloc_bytes (buf, size);
- size_t current = buf->__alloc_buffer_current;
- size_t aligned = roundup (current, align);
- size_t new_current = aligned + size;
+ uintptr_t current = buf->__alloc_buffer_current;
+ uintptr_t aligned = roundup (current, align);
+ uintptr_t new_current = aligned + size;
if (aligned >= current /* No overflow in align step. */
&& new_current >= size /* No overflow in size computation. */
&& new_current <= buf->__alloc_buffer_end) /* Room in buffer. */
@@ -282,8 +283,8 @@ __alloc_buffer_next (struct alloc_buffer *buf, size_t align)
if (align == 1)
return (const void *) buf->__alloc_buffer_current;
- size_t current = buf->__alloc_buffer_current;
- size_t aligned = roundup (current, align);
+ uintptr_t current = buf->__alloc_buffer_current;
+ uintptr_t aligned = roundup (current, align);
if (aligned >= current /* No overflow in align step. */
&& aligned <= buf->__alloc_buffer_end) /* Room in buffer. */
{
diff --git a/malloc/alloc_buffer_alloc_array.c b/malloc/alloc_buffer_alloc_array.c
index d8c08d03ea..b5f32bb630 100644
--- a/malloc/alloc_buffer_alloc_array.c
+++ b/malloc/alloc_buffer_alloc_array.c
@@ -23,12 +23,12 @@ void *
__libc_alloc_buffer_alloc_array (struct alloc_buffer *buf, size_t element_size,
size_t align, size_t count)
{
- size_t current = buf->__alloc_buffer_current;
+ uintptr_t current = buf->__alloc_buffer_current;
/* The caller asserts that align is a power of two. */
- size_t aligned = ALIGN_UP (current, align);
+ uintptr_t aligned = ALIGN_UP (current, align);
size_t size;
bool overflow = __builtin_mul_overflow (element_size, count, &size);
- size_t new_current = aligned + size;
+ uintptr_t new_current = aligned + size;
if (!overflow /* Multiplication did not overflow. */
&& aligned >= current /* No overflow in align step. */
&& new_current >= size /* No overflow in size computation. */
^ permalink raw reply [flat|nested] 2+ messages in thread
* [glibc/arm/morello/main] cheri: malloc: use uintptr_t in alloc_buffer
@ 2022-10-26 15:11 Szabolcs Nagy
0 siblings, 0 replies; 2+ messages in thread
From: Szabolcs Nagy @ 2022-10-26 15:11 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5a25980484b50497567c2842034a6015f7b55222
commit 5a25980484b50497567c2842034a6015f7b55222
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date: Wed Mar 16 12:09:15 2022 +0000
cheri: malloc: use uintptr_t in alloc_buffer
This is the right type as the values hold pointers.
Diff:
---
include/alloc_buffer.h | 11 ++++++-----
malloc/alloc_buffer_alloc_array.c | 6 +++---
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/include/alloc_buffer.h b/include/alloc_buffer.h
index be33e8b68c..b0d50289f0 100644
--- a/include/alloc_buffer.h
+++ b/include/alloc_buffer.h
@@ -82,6 +82,7 @@
#include <stddef.h>
#include <stdlib.h>
#include <sys/param.h>
+#include <libc-pointer-arith.h>
/* struct alloc_buffer objects refer to a region of bytes in memory of a
fixed size. The functions below can be used to allocate single
@@ -248,9 +249,9 @@ __alloc_buffer_alloc (struct alloc_buffer *buf, size_t size, size_t align)
if (size == 1 && align == 1)
return alloc_buffer_alloc_bytes (buf, size);
- size_t current = buf->__alloc_buffer_current;
- size_t aligned = roundup (current, align);
- size_t new_current = aligned + size;
+ uintptr_t current = buf->__alloc_buffer_current;
+ uintptr_t aligned = roundup (current, align);
+ uintptr_t new_current = aligned + size;
if (aligned >= current /* No overflow in align step. */
&& new_current >= size /* No overflow in size computation. */
&& new_current <= buf->__alloc_buffer_end) /* Room in buffer. */
@@ -282,8 +283,8 @@ __alloc_buffer_next (struct alloc_buffer *buf, size_t align)
if (align == 1)
return (const void *) buf->__alloc_buffer_current;
- size_t current = buf->__alloc_buffer_current;
- size_t aligned = roundup (current, align);
+ uintptr_t current = buf->__alloc_buffer_current;
+ uintptr_t aligned = roundup (current, align);
if (aligned >= current /* No overflow in align step. */
&& aligned <= buf->__alloc_buffer_end) /* Room in buffer. */
{
diff --git a/malloc/alloc_buffer_alloc_array.c b/malloc/alloc_buffer_alloc_array.c
index d8c08d03ea..b5f32bb630 100644
--- a/malloc/alloc_buffer_alloc_array.c
+++ b/malloc/alloc_buffer_alloc_array.c
@@ -23,12 +23,12 @@ void *
__libc_alloc_buffer_alloc_array (struct alloc_buffer *buf, size_t element_size,
size_t align, size_t count)
{
- size_t current = buf->__alloc_buffer_current;
+ uintptr_t current = buf->__alloc_buffer_current;
/* The caller asserts that align is a power of two. */
- size_t aligned = ALIGN_UP (current, align);
+ uintptr_t aligned = ALIGN_UP (current, align);
size_t size;
bool overflow = __builtin_mul_overflow (element_size, count, &size);
- size_t new_current = aligned + size;
+ uintptr_t new_current = aligned + size;
if (!overflow /* Multiplication did not overflow. */
&& aligned >= current /* No overflow in align step. */
&& new_current >= size /* No overflow in size computation. */
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-26 15:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-05 19:35 [glibc/arm/morello/main] cheri: malloc: use uintptr_t in alloc_buffer Szabolcs Nagy
2022-10-26 15:11 Szabolcs Nagy
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).