[rtems-libbsd commit] rtembsd: Fix alignment of allocations for 64bit
Joel Sherrill
joel at rtems.org
Wed Mar 10 14:58:05 UTC 2021
Module: rtems-libbsd
Branch: 6-freebsd-12
Commit: 0c60fe524eef22ce8443c507c4feccd9f02dc550
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=0c60fe524eef22ce8443c507c4feccd9f02dc550
Author: Kinsey Moore <kinsey.moore at oarcorp.com>
Date: Mon Feb 1 10:04:59 2021 -0600
rtembsd: Fix alignment of allocations for 64bit
Alignment on 64bit hardware is strict in comparison to running in an
emulator. This resolves an alignment exception when allocating memory on
real hardware.
---
rtemsbsd/rtems/rtems-program.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/rtemsbsd/rtems/rtems-program.c b/rtemsbsd/rtems/rtems-program.c
index 204ed24..370609d 100644
--- a/rtemsbsd/rtems/rtems-program.c
+++ b/rtemsbsd/rtems/rtems-program.c
@@ -479,12 +479,13 @@ rtems_bsd_program_alloc(size_t size, void *org_ptr)
void *ptr = NULL;
size_t size_with_list;
size_t size_alligned;
+ size_t alignment = sizeof(void*);
if (prog_ctrl != NULL) {
/* align the end to the next word address */
size_alligned = size;
- if ((size_alligned & 0x3) != 0) {
- size_alligned = (size_alligned | 0x03) + 1;
+ if ((size_alligned & (alignment - 1)) != 0) {
+ size_alligned = (size_alligned | (alignment - 1)) + 1;
}
size_with_list = size_alligned +
sizeof(struct program_allocmem_item);
More information about the vc
mailing list