Fix chromium roll
- NaCL doesn't seem to have aligned_malloc()
- Fuchsia seems to have it but return null.
- So use posix_memalign() everywhere % Windows.
- Then fix a ssize_t in Windows by including utils.h
Failed roll: https://chromium-review.googlesource.com/c/chromium/src/+/3270903/
Bug: 205302474
Change-Id: Ib0461fb3251839e0cbf7528fd7ee3747b2913d79
diff --git a/src/base/utils.cc b/src/base/utils.cc
index 0138198..c080388 100644
--- a/src/base/utils.cc
+++ b/src/base/utils.cc
@@ -245,16 +245,14 @@
void* AlignedAlloc(size_t alignment, size_t size) {
void* res = nullptr;
alignment = AlignUp<sizeof(void*)>(alignment); // At least pointer size.
-#if PERFETTO_BUILDFLAG(PERFETTO_OS_LINUX) || \
- PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID)
- // aligned_alloc has been introduced in Android only in API 28.
- ignore_result(posix_memalign(&res, alignment, size));
-#elif PERFETTO_BUILDFLAG(PERFETTO_OS_WIN)
+#if PERFETTO_BUILDFLAG(PERFETTO_OS_WIN)
// Window's _aligned_malloc() has a nearly identically signature to Unix's
// aligned_alloc() but its arguments are obviously swapped.
res = _aligned_malloc(size, alignment);
#else
- res = aligned_alloc(alignment, size);
+ // aligned_alloc() has been introduced in Android only in API 28.
+ // Also NaCl and Fuchsia seems to have only posix_memalign().
+ ignore_result(posix_memalign(&res, alignment, size));
#endif
PERFETTO_CHECK(res);
return res;