diff --git a/src/system/libroot/posix/malloc/heap.h b/src/system/libroot/posix/malloc/heap.h index b2a9ed6ba3..f42962e2f2 100644 --- a/src/system/libroot/posix/malloc/heap.h +++ b/src/system/libroot/posix/malloc/heap.h @@ -74,8 +74,12 @@ class hoardHeap { # error "Undefined size class base." #endif - // Every object is aligned so that it can always hold a double. + // Every object is aligned so that it can always hold any type. +#ifdef __x86_64__ + enum { ALIGNMENT = 16 }; +#else enum { ALIGNMENT = sizeof(double) }; +#endif // ANDing with this rounds to ALIGNMENT. enum { ALIGNMENT_MASK = ALIGNMENT - 1 }; diff --git a/src/tests/system/libroot/posix/Jamfile b/src/tests/system/libroot/posix/Jamfile index 511752c30c..56396e89a1 100644 --- a/src/tests/system/libroot/posix/Jamfile +++ b/src/tests/system/libroot/posix/Jamfile @@ -16,7 +16,7 @@ SimpleTest flock_test : flock_test.cpp ; SimpleTest fseek_test : fseek_test.cpp ; SimpleTest getsubopt_test : getsubopt_test.cpp ; SimpleTest locale_test : locale_test.cpp ; -SimpleTest memalign_test : memalign_test.cpp ; +SimpleTest memalign_test : memalign_test.cpp : $(TARGET_LIBSUPC++) ; SimpleTest mprotect_test : mprotect_test.cpp ; SimpleTest pthread_signal_test : pthread_signal_test.cpp ; SimpleTest realtime_sem_test1 : realtime_sem_test1.cpp ; diff --git a/src/tests/system/libroot/posix/memalign_test.cpp b/src/tests/system/libroot/posix/memalign_test.cpp index 02b60bf99c..3908e05f24 100644 --- a/src/tests/system/libroot/posix/memalign_test.cpp +++ b/src/tests/system/libroot/posix/memalign_test.cpp @@ -53,7 +53,13 @@ allocate_random_no_alignment(int32 count, size_t maxSize) printf("allocation of %lu bytes failed\n", sizes[i]); exit(1); } - +#ifdef __x86_64__ + if (((addr_t)allocations[i] & 0xf) != 0) { + printf("allocation %p not aligned failed\n", + allocations[i]); + exit(1); + } +#endif write_test_pattern(allocations[i], sizes[i]); }